Search in sources :

Example 1 with UpdateOperation

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

the class MarkMergedSynchronizeOperation method run.

protected void run(SVNTeamProvider provider, SyncInfoSet set, final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final IResource[] resources = set.getResources();
    run(new WorkspaceModifyOperation() {

        protected void execute(IProgressMonitor mon) throws CoreException, InvocationTargetException, InterruptedException {
            for (int i = 0; i < resources.length; i++) {
                File tempFile = null;
                try {
                    tempFile = copyToTempFile(resources[i]);
                } catch (Exception e) {
                    SVNUIPlugin.log(e.getMessage());
                    showErrorMessage(e);
                    return;
                }
                if (monitor.isCanceled()) {
                    if (tempFile != null)
                        tempFile.delete();
                    return;
                }
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
                if (svnResource instanceof LocalResource)
                    ((LocalResource) svnResource).revert(false);
                else
                    svnResource.revert();
                new UpdateOperation(getPart(), resources[i], SVNRevision.HEAD).run(monitor);
                if (monitor.isCanceled()) {
                    if (tempFile != null)
                        tempFile.delete();
                    return;
                }
                File file = new File(resources[i].getLocation().toString());
                try {
                    copy(tempFile, file);
                } catch (Exception e1) {
                    SVNUIPlugin.log(e1.getMessage());
                    showErrorMessage(e1);
                }
                if (tempFile != null)
                    tempFile.delete();
            }
        }
    }, true, /* cancelable */
    PROGRESS_BUSYCURSOR);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) UpdateOperation(org.tigris.subversion.subclipse.ui.operations.UpdateOperation) File(java.io.File) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) LocalResource(org.tigris.subversion.subclipse.core.resources.LocalResource)

Example 2 with UpdateOperation

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

the class UpdateAction method execute.

/*
   * @see IActionDelegate#run(IAction)
   */
public void execute(IAction action) throws InterruptedException, InvocationTargetException {
    if (action != null && !action.isEnabled()) {
        action.setEnabled(true);
    } else {
        IPreferenceStore store = SVNUIPlugin.getPlugin().getPreferenceStore();
        IResource[] resources = getSelectedResources();
        SVNConflictResolver conflictResolver = new SVNConflictResolver(resources[0], store.getInt(ISVNUIConstants.PREF_UPDATE_TO_HEAD_CONFLICT_HANDLING_TEXT_FILES), store.getInt(ISVNUIConstants.PREF_UPDATE_TO_HEAD_CONFLICT_HANDLING_BINARY_FILES), store.getInt(ISVNUIConstants.PREF_UPDATE_TO_HEAD_CONFLICT_HANDLING_PROPERTIES), store.getInt(ISVNUIConstants.PREF_UPDATE_TO_HEAD_CONFLICT_HANDLING_TREE_CONFLICTS));
        UpdateOperation updateOperation = new UpdateOperation(getTargetPart(), resources, SVNRevision.HEAD);
        updateOperation.setDepth(depth);
        updateOperation.setSetDepth(setDepth);
        updateOperation.setForce(store.getBoolean(ISVNUIConstants.PREF_UPDATE_TO_HEAD_ALLOW_UNVERSIONED_OBSTRUCTIONS));
        updateOperation.setIgnoreExternals(store.getBoolean(ISVNUIConstants.PREF_UPDATE_TO_HEAD_IGNORE_EXTERNALS));
        updateOperation.setCanRunAsJob(canRunAsJob);
        updateOperation.setConflictResolver(conflictResolver);
        updateOperation.run();
    }
}
Also used : UpdateOperation(org.tigris.subversion.subclipse.ui.operations.UpdateOperation) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IResource(org.eclipse.core.resources.IResource) SVNConflictResolver(org.tigris.subversion.subclipse.ui.conflicts.SVNConflictResolver)

Example 3 with UpdateOperation

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

the class UpdateDialogAction method execute.

public void execute(IAction action) throws InterruptedException, InvocationTargetException {
    if (action != null && !action.isEnabled()) {
        action.setEnabled(true);
    } else {
        IResource[] resources = getSelectedResources();
        String pageName;
        if (resources.length > 1)
            // $NON-NLS-1$
            pageName = "UpdateDialogWithConflictHandling.multiple";
        else
            // $NON-NLS-1$
            pageName = "UpdateDialogWithConflictHandling";
        SvnWizardUpdatePage updatePage = new SvnWizardUpdatePage(pageName, resources);
        updatePage.setDefaultRevision(revision);
        updatePage.setDepth(depth);
        updatePage.setSetDepth(setDepth);
        SvnWizard wizard = new SvnWizard(updatePage);
        SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
        wizard.setParentDialog(dialog);
        if (dialog.open() == SvnWizardDialog.OK) {
            SVNRevision svnRevision = updatePage.getRevision();
            UpdateOperation updateOperation = new UpdateOperation(getTargetPart(), resources, svnRevision);
            updateOperation.setDepth(updatePage.getDepth());
            updateOperation.setSetDepth(updatePage.isSetDepth());
            updateOperation.setForce(updatePage.isForce());
            updateOperation.setIgnoreExternals(updatePage.isIgnoreExternals());
            updateOperation.setCanRunAsJob(canRunAsJob);
            updateOperation.setConflictResolver(updatePage.getConflictResolver());
            updateOperation.run();
        }
    }
}
Also used : SvnWizardUpdatePage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardUpdatePage) UpdateOperation(org.tigris.subversion.subclipse.ui.operations.UpdateOperation) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource)

Example 4 with UpdateOperation

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

the class SVNCompareRevisionsInput method initializeActions.

/**
 * initialize the actions : - getContentsAction : get the contents for the selected revision -
 * getRevisionAction : updates to the given revision
 */
private void initializeActions() {
    getContentsAction = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Policy.bind("HistoryView.getContentsAction"), // $NON-NLS-1$
    null) {

        public void run() {
            try {
                new ProgressMonitorDialog(shell).run(false, true, new WorkspaceModifyOperation() {

                    protected void execute(IProgressMonitor monitor) throws InvocationTargetException {
                        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                        if (selection.size() != 1)
                            return;
                        VersionCompareDiffNode node = (VersionCompareDiffNode) selection.getFirstElement();
                        ResourceEditionNode right = (ResourceEditionNode) node.getRight();
                        ISVNRemoteResource edition = right.getRemoteResource();
                        // actually want to change the base.
                        try {
                            monitor.beginTask(null, 100);
                            InputStream in = ((IResourceVariant) edition).getStorage(new SubProgressMonitor(monitor, 50)).getContents();
                            resource.setContents(in, false, true, new SubProgressMonitor(monitor, 50));
                        } catch (TeamException e) {
                            throw new InvocationTargetException(e);
                        } catch (CoreException e) {
                            throw new InvocationTargetException(e);
                        } finally {
                            monitor.done();
                        }
                    }
                });
            } catch (InterruptedException e) {
                // Do nothing
                return;
            } catch (InvocationTargetException e) {
                handle(e);
            }
            // recompute the labels on the viewer
            updateCurrentEdition();
            viewer.refresh();
        }
    };
    getRevisionAction = new // $NON-NLS-1$
    Action(// $NON-NLS-1$
    Policy.bind("HistoryView.getRevisionAction"), // $NON-NLS-1$
    null) {

        public void run() {
            try {
                new ProgressMonitorDialog(shell).run(false, true, new WorkspaceModifyOperation(null) {

                    protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                        if (selection.size() != 1)
                            return;
                        VersionCompareDiffNode node = (VersionCompareDiffNode) selection.getFirstElement();
                        ResourceEditionNode right = (ResourceEditionNode) node.getRight();
                        final ISVNRemoteFile edition = (ISVNRemoteFile) right.getRemoteResource();
                        new UpdateOperation(null, resource, edition.getLastChangedRevision()).run(monitor);
                        // recompute the labels on the viewer
                        getHistoryTableProvider().setRemoteResource(edition);
                        viewer.refresh();
                    }
                });
            } catch (InterruptedException e) {
                // Do nothing
                return;
            } catch (InvocationTargetException e) {
                handle(e);
            }
        }
    };
}
Also used : WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) UpdateOperation(org.tigris.subversion.subclipse.ui.operations.UpdateOperation)

Aggregations

UpdateOperation (org.tigris.subversion.subclipse.ui.operations.UpdateOperation)4 IResource (org.eclipse.core.resources.IResource)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 InputStream (java.io.InputStream)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TeamException (org.eclipse.team.core.TeamException)1 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)1 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)1 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)1 LocalResource (org.tigris.subversion.subclipse.core.resources.LocalResource)1 SVNConflictResolver (org.tigris.subversion.subclipse.ui.conflicts.SVNConflictResolver)1 SvnWizard (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard)1