Search in sources :

Example 1 with MergeOperation

use of org.tigris.subversion.subclipse.ui.operations.MergeOperation in project subclipse by subclipse.

the class SVNHistoryPage method getRevertChangesAction.

// get revert changes action (context menu)
private IAction getRevertChangesAction() {
    revisionRanges = getRevisionRanges();
    if (revertChangesAction == null) {
        revertChangesAction = new Action() {

            public void run() {
                ISelection selection = getSelection();
                if (!(selection instanceof IStructuredSelection))
                    return;
                final IStructuredSelection ss = (IStructuredSelection) selection;
                if (ss.size() == 1) {
                    if (!MessageDialog.openConfirm(getSite().getShell(), Policy.bind("HistoryView.revertRevision"), Policy.bind("HistoryView.confirmRevertRevision", // $NON-NLS-1$
                    resource.getFullPath().toString())))
                        return;
                } else {
                    if (!MessageDialog.openConfirm(getSite().getShell(), Policy.bind("HistoryView.revertRevisions"), Policy.bind("HistoryView.confirmRevertRevisions", // $NON-NLS-1$
                    resource.getFullPath().toString())))
                        return;
                }
                BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                    public void run() {
                        ILogEntry firstElement = getFirstElement();
                        ILogEntry lastElement = getLastElement();
                        final IResource[] resources = { resource };
                        try {
                            final SVNUrl path1 = new SVNUrl(firstElement.getResource().getUrl() + "@HEAD");
                            final SVNUrl path2 = new SVNUrl(lastElement.getResource().getUrl() + "@HEAD");
                            for (int i = 0; i < revisionRanges.length; i++) {
                                final SVNRevision revision1 = revisionRanges[i].getFromRevision();
                                final SVNRevision revision2 = new SVNRevision.Number(((SVNRevision.Number) revisionRanges[i].getToRevision()).getNumber() - 1);
                                WorkspaceAction mergeAction = new WorkspaceAction() {

                                    protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
                                        new MergeOperation(getSite().getPage().getActivePart(), resources, path1, revision1, path2, revision2).run();
                                    }
                                };
                                mergeAction.run(null);
                            }
                        } catch (Exception e) {
                            MessageDialog.openError(getSite().getShell(), revertChangesAction.getText(), e.getMessage());
                        }
                    }
                });
            }
        };
    }
    ISelection selection = getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) selection;
        if (ss.size() == 1) {
            ILogEntry currentSelection = getLogEntry(ss);
            revertChangesAction.setText(Policy.bind("HistoryView.revertChangesFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
            "" + currentSelection.getRevision().getNumber()));
        }
        if (ss.size() > 1) {
            revertChangesAction.setText(// $NON-NLS-1$
            Policy.bind("HistoryView.revertChangesFromRevisions"));
        }
    }
    revertChangesAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_MARKMERGED));
    revertChangesAction.setEnabled(revertEnabled);
    return revertChangesAction;
}
Also used : CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) ExportRemoteFolderAction(org.tigris.subversion.subclipse.ui.actions.ExportRemoteFolderAction) ShowDifferencesAsUnifiedDiffAction(org.tigris.subversion.subclipse.ui.actions.ShowDifferencesAsUnifiedDiffAction) TextViewerAction(org.tigris.subversion.subclipse.ui.console.TextViewerAction) ShowAnnotationAction(org.tigris.subversion.subclipse.ui.actions.ShowAnnotationAction) ShowHistoryAction(org.tigris.subversion.subclipse.ui.actions.ShowHistoryAction) WorkspaceAction(org.tigris.subversion.subclipse.ui.actions.WorkspaceAction) IAction(org.eclipse.jface.action.IAction) OpenRemoteFileAction(org.tigris.subversion.subclipse.ui.actions.OpenRemoteFileAction) GenerateChangeLogAction(org.tigris.subversion.subclipse.ui.actions.GenerateChangeLogAction) Action(org.eclipse.jface.action.Action) MergeOperation(org.tigris.subversion.subclipse.ui.operations.MergeOperation) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) IAction(org.eclipse.jface.action.IAction) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ParseException(java.text.ParseException) WorkspaceAction(org.tigris.subversion.subclipse.ui.actions.WorkspaceAction) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ISelection(org.eclipse.jface.viewers.ISelection) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource)

Example 2 with MergeOperation

use of org.tigris.subversion.subclipse.ui.operations.MergeOperation in project subclipse by subclipse.

the class MergeAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    if (action != null && !action.isEnabled()) {
        action.setEnabled(true);
    } else {
        IResource[] resources = getSelectedResources();
        for (int i = 0; i < resources.length; i++) {
            MergeDialog dialog = new MergeDialog(getShell(), resources[i]);
            if (dialog.open() == MergeDialog.CANCEL)
                break;
            SVNUrl svnUrl1 = dialog.getFromUrl();
            SVNRevision svnRevision1 = dialog.getFromRevision();
            SVNUrl svnUrl2 = dialog.getToUrl();
            SVNRevision svnRevision2 = dialog.getToRevision();
            MergeOperation mergeOperation = new MergeOperation(getTargetPart(), getSelectedResources(), svnUrl1, svnRevision1, svnUrl2, svnRevision2);
            mergeOperation.setForce(dialog.isForce());
            mergeOperation.setIgnoreAncestry(dialog.isIgnoreAncestry());
            mergeOperation.run();
        }
    }
}
Also used : MergeOperation(org.tigris.subversion.subclipse.ui.operations.MergeOperation) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) MergeDialog(org.tigris.subversion.subclipse.ui.dialogs.MergeDialog) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource)

Aggregations

IResource (org.eclipse.core.resources.IResource)2 MergeOperation (org.tigris.subversion.subclipse.ui.operations.MergeOperation)2 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)2 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ParseException (java.text.ParseException)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 CoreException (org.eclipse.core.runtime.CoreException)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TeamException (org.eclipse.team.core.TeamException)1 PartInitException (org.eclipse.ui.PartInitException)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)1 CompareRemoteResourcesAction (org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction)1 ExportRemoteFolderAction (org.tigris.subversion.subclipse.ui.actions.ExportRemoteFolderAction)1 GenerateChangeLogAction (org.tigris.subversion.subclipse.ui.actions.GenerateChangeLogAction)1 OpenRemoteFileAction (org.tigris.subversion.subclipse.ui.actions.OpenRemoteFileAction)1