[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [subversive-dev] How to invoke Lock operation before Commit operation using de Commit UI extension point

Hello Alexander,

Thank you for your help until tha moment, but I'm having difficulty to execute de LockOperation. I did like you tell me but lock the Eclipse IDE when execute LockOperation and Eclipse don't response never more. What I'm doing wrong? My code is exactly like your. I copy and paste and don't work.

The LockOperation need more settings? Because I think that the LockOperation don't finish your execution.

Best regards,
Rodrigo

2011/8/9 Alexander Gurov <alexander.gurov@xxxxxxxxxxxx>
Hello,

All resources that will be committed are passed down through the function input parameters. So, you don't need to collect them from the resources tree. Instead you should extract from the passed resources set only the files that could be locked. You can do it like this:

if (result == Window.OK) {
ÂÂÂ IResource []resources = (IResource [])allFilesToCommit.toArray(new IResource[allFilesToCommit.size()]);
ÂÂÂ resources = FileUtility.getResourcesRecursive(resources, IStateFilter.SF_READY_TO_LOCK, IResource.DEPTH_ZERO);

ÂÂÂ LockOperation op = new LockOperation(resources, "lock message text", false);
ÂÂÂ UIMonitorUtility.doTaskBusyDefault(op);
ÂÂÂ result = op.getStatus().getSeverity() == IStatus.OK ? Window.OK : Window.CANCEL;
}

Best regards,
Alexander.

08.08.2011 16:48, rodrigo luiz duarte ÐÐÑÐÑ:
Hello Alexander,

I did like you tell me, but de LockOperation don't work e block the eclipse IDE. I think that the LockOperation don't executed and Eclipse stay busy infinity. I tryed change method UIMonitorUtility.doTaskBusyDefault(op) to UIMonitorUtility.doTaskScheduledDefault(op) and the LockOperation don't work. It stay in zero percent of execution infinity. My code is:

if (result == Window.OK) {
LockAction lockAction = new LockAction(); IResource[] resources = lockAction.getSelectedResources(); LockOperation op = new LockOperation(resources, "lock message text", false);
UIMonitorUtility.doTaskBusyDefault(op);
result = op.getStatus().getSeverity() == IStatus.OK ? Window.OK : Window.CANCEL;
}

I used LockAction to get the resources. Is it correct? What the correct way to get de resources that ÂI want lock (the resources are the same that I want commit)?
What I'm doing wrong in the LockOperation execution?

Best regards,
Rodrigo

2011/8/5 Alexander Gurov <alexander.gurov@xxxxxxxxxxxx>
Hello,

That won't work because lock action performs real operation asynchronously. In order to avoid LockDialog and to check operation execution status you'll need to do something like this:


ÂÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âint result = Window.CANCEL;
filesToCommit = allFilesToCommit;
CustomCommitDialog dialog = new CustomCommitDialog(shell,
commentPanel);
dialog.setAllFilesToCommit(allFilesToCommit);
result = dialog.open();

if (result == Window.OK) {
LockOperation op = new LockOperation(resources, "lock message text", false /*true in order to force locks*/);
UIMonitorUtility.doTaskBusyDefault(op);
result = op.getSeverity() == IStatus.OK ? Window.OK : Window.CANCEL;
}

return result;

Also please note that there is no need of try/catch blocks because all the errors are handled by LockOperation and UIMonitorUtility classes themselves. You'll only need to check operation execution status afterwards.

Best regards,
Alexander.

04.08.2011 23:28, rodrigo luiz duarte ÐÐÑÐÑ:
Hello Alexander,

What I need is invoke Lock operation immediatly before Commit operation and if the Lock fail, to cancel Commit operation. I used this way:

ÂÂ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âint result = Window.CANCEL;
filesToCommit = allFilesToCommit;
CustomCommitDialog dialog = new CustomCommitDialog(shell,
commentPanel);
dialog.setAllFilesToCommit(allFilesToCommit);
try {
result = dialog.open();
if (result == Window.OK) {
LockAction lock = new LockAction();
IAction action = "">
lock.runImpl(acao);
}
} catch (Exception e) {
result = Window.CANCEL;
}
return result;

I used the pre-lock subversion's hook to simulate the Lock fail, but the Commit operation is not cancelled. Is it possible do this? How can I do invoke Lock operation in background without the Lock Dialog?

Best regards,Â
Rodrigo


2011/8/4 Alexander Gurov <alexander.gurov@xxxxxxxxxxxx>
Hello Rodrigo,

The API related to the commit dialog were initially created for the specific project, so it may be not the best to work with.
Regarding how to do it now - it is relatively easy. Anyway now you're implementing ICommitDialog interface. Right? In the method open() of this interface you're doing something like this:
ÂÂÂ ÂÂÂ ÂÂÂ public int open() {
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ DefaultDialog dialog = new DefaultDialog(shell, commentPanel);
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ return dialog.open();
ÂÂÂ ÂÂÂ ÂÂÂ }
So, you may as well change the code:
ÂÂÂ ÂÂÂ ÂÂÂ public int open() {
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ DefaultDialog dialog = new DefaultDialog(shell, commentPanel);
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ int retVal = dialog.open();
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ if (retVal == Window.OK) {
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ // invoke Lock here
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ }
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ return retVal;
ÂÂÂ ÂÂÂ ÂÂÂ }
The flaw of this solution is that you will run your code in the UI thread. That is not a very nice thing, but... oh well, that is why I said that API created for a single project is not the best thing to use, it misses many important points. So, if you have any ideas regarding future improvements you're welcome to share your opinion here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=327399

Best regards,
Alexander Gurov,
Subversive Team.

03.08.2011 1:58, rodrigo luiz duarte ÐÐÑÐÑ:
Hi!

I need invoke the Lock command immediatly before the Commit operation. How can i do this using deÂCommit UI extension point?

Thank you,

--
Rodrigo Luiz Duarte
rodrigo.luizduarte@xxxxxxxxx


_______________________________________________
subversive-dev mailing list
subversive-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/subversive-dev


_______________________________________________
subversive-dev mailing list
subversive-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/subversive-dev




--
Rodrigo Luiz Duarte
rodrigo.luizduarte@xxxxxxxxx


_______________________________________________
subversive-dev mailing list
subversive-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/subversive-dev


_______________________________________________
subversive-dev mailing list
subversive-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/subversive-dev




--
Rodrigo Luiz Duarte
rodrigo.luizduarte@xxxxxxxxx


_______________________________________________
subversive-dev mailing list
subversive-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/subversive-dev


_______________________________________________
subversive-dev mailing list
subversive-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/subversive-dev




--
Rodrigo Luiz Duarte
rodrigo.luizduarte@xxxxxxxxx