use of com.collabnet.subversion.merge.UndoMergeOperation in project subclipse by subclipse.
the class UndoMergeAction method run.
public void run(IAction action) {
DialogWizard dialogWizard = new DialogWizard(DialogWizard.UNDO_MERGE_WARNING);
MergeWizardDialog dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard, true);
if (dialog.open() == MergeWizardDialog.CANCEL)
return;
final ArrayList resources = new ArrayList();
ArrayList mergeOutputs = new ArrayList();
Iterator iter = fSelection.iterator();
while (iter.hasNext()) {
Object object = iter.next();
if (object instanceof MergeOutput) {
MergeOutput mergeOutput = (MergeOutput) object;
mergeOutputs.add(mergeOutput);
IResource resource = mergeOutput.getResource();
resources.add(resource);
}
}
final IResource[] resourceArray = new IResource[resources.size()];
resources.toArray(resourceArray);
UndoMergeOperation undoMergeOperation = new UndoMergeOperation(MergeResultsView.getView(), resourceArray);
try {
undoMergeOperation.run();
} catch (Exception e) {
Activator.handleError(Messages.UndoMergeAction_error, e);
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.UndoMergeAction_title, e.getMessage());
return;
}
iter = mergeOutputs.iterator();
while (iter.hasNext()) {
MergeOutput mergeOutput = (MergeOutput) iter.next();
mergeOutput.delete();
}
MergeResultsView.getView().refresh();
dialogWizard = new DialogWizard(DialogWizard.UNDO_MERGE_COMPLETED);
dialog = new MergeWizardDialog(Display.getDefault().getActiveShell(), dialogWizard, true);
if (dialog.open() == MergeWizardDialog.CANCEL)
return;
RevertAction revertAction = new RevertAction();
revertAction.setShowNothingToRevertMessage(false);
IStructuredSelection selection = new IStructuredSelection() {
public Object getFirstElement() {
return resourceArray[0];
}
public Iterator iterator() {
return toList().iterator();
}
public int size() {
return resourceArray.length;
}
public Object[] toArray() {
return resourceArray;
}
public List toList() {
return resources;
}
public boolean isEmpty() {
return resources.isEmpty();
}
};
revertAction.selectionChanged(null, selection);
revertAction.run(null);
}
Aggregations