Search in sources :

Example 1 with SvnWizardLockPage

use of org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardLockPage in project subclipse by subclipse.

the class SVNFileModificationValidatorPrompt method prompt.

public boolean prompt(IFile[] lockFiles, Object context) {
    if (context == null) {
        comment = "";
        stealLock = false;
        return true;
    }
    this.files = lockFiles;
    success = false;
    SVNUIPlugin.getStandardDisplay().syncExec(new Runnable() {

        public void run() {
            SvnWizardLockPage lockPage = new SvnWizardLockPage(files);
            SvnWizard wizard = new SvnWizard(lockPage);
            SvnWizardDialog dialog = new SvnWizardDialog(Display.getCurrent().getActiveShell(), wizard);
            wizard.setParentDialog(dialog);
            if (dialog.open() == SvnWizardDialog.OK) {
                success = true;
                comment = lockPage.getComment();
                stealLock = lockPage.isStealLock();
            }
        }
    });
    return success;
}
Also used : SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SvnWizardLockPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardLockPage)

Example 2 with SvnWizardLockPage

use of org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardLockPage in project subclipse by subclipse.

the class LockAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    if (action != null && !action.isEnabled()) {
        action.setEnabled(true);
    } else {
        if (getSelectedResources() != null && getSelectedResources().length > 0) {
            final IResource[] resources = getSelectedResources();
            SvnWizardLockPage lockPage = new SvnWizardLockPage(resources);
            SvnWizard wizard = new SvnWizard(lockPage);
            SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
            wizard.setParentDialog(dialog);
            if (dialog.open() == SvnWizardDialog.OK) {
                final String comment = lockPage.getComment();
                final boolean stealLock = lockPage.isStealLock();
                run(new WorkspaceModifyOperation() {

                    protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
                        try {
                            Hashtable table = getProviderMapping(getSelectedResources());
                            Set keySet = table.keySet();
                            Iterator iterator = keySet.iterator();
                            while (iterator.hasNext()) {
                                SVNTeamProvider provider = (SVNTeamProvider) iterator.next();
                                LockResourcesCommand command = new LockResourcesCommand(provider.getSVNWorkspaceRoot(), resources, stealLock, comment);
                                command.run(Policy.subMonitorFor(monitor, 1000));
                            }
                        } catch (TeamException e) {
                            throw new InvocationTargetException(e);
                        } finally {
                            monitor.done();
                        }
                    }
                }, true, /* cancelable */
                PROGRESS_DIALOG);
            }
        }
    }
}
Also used : Set(java.util.Set) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) Hashtable(java.util.Hashtable) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) SvnWizardLockPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardLockPage) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) CoreException(org.eclipse.core.runtime.CoreException) LockResourcesCommand(org.tigris.subversion.subclipse.core.commands.LockResourcesCommand) Iterator(java.util.Iterator) IResource(org.eclipse.core.resources.IResource)

Aggregations

SvnWizard (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard)2 SvnWizardDialog (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog)2 SvnWizardLockPage (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardLockPage)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Hashtable (java.util.Hashtable)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 TeamException (org.eclipse.team.core.TeamException)1 WorkspaceModifyOperation (org.eclipse.ui.actions.WorkspaceModifyOperation)1 SVNTeamProvider (org.tigris.subversion.subclipse.core.SVNTeamProvider)1 LockResourcesCommand (org.tigris.subversion.subclipse.core.commands.LockResourcesCommand)1