Search in sources :

Example 1 with RevertAction

use of org.tigris.subversion.subclipse.ui.actions.RevertAction 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);
}
Also used : RevertAction(org.tigris.subversion.subclipse.ui.actions.RevertAction) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) MergeOutput(com.collabnet.subversion.merge.MergeOutput) DialogWizard(com.collabnet.subversion.merge.wizards.DialogWizard) UndoMergeOperation(com.collabnet.subversion.merge.UndoMergeOperation) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MergeWizardDialog(com.collabnet.subversion.merge.wizards.MergeWizardDialog) IResource(org.eclipse.core.resources.IResource)

Example 2 with RevertAction

use of org.tigris.subversion.subclipse.ui.actions.RevertAction in project subclipse by subclipse.

the class MergeWizardBestPracticesPage method revert.

private void revert() {
    RevertAction revertAction = new RevertAction();
    revertAction.setSelectedResources(((MergeWizard) getWizard()).getResources());
    revertAction.setCanRunAsJob(false);
    revertAction.run(null);
    refreshPage(true, true);
}
Also used : RevertAction(org.tigris.subversion.subclipse.ui.actions.RevertAction)

Aggregations

RevertAction (org.tigris.subversion.subclipse.ui.actions.RevertAction)2 MergeOutput (com.collabnet.subversion.merge.MergeOutput)1 UndoMergeOperation (com.collabnet.subversion.merge.UndoMergeOperation)1 DialogWizard (com.collabnet.subversion.merge.wizards.DialogWizard)1 MergeWizardDialog (com.collabnet.subversion.merge.wizards.MergeWizardDialog)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 IResource (org.eclipse.core.resources.IResource)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1