Search in sources :

Example 16 with SvnWizardDialog

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

the class RevertAction method confirmRevert.

/**
 * prompt revert of selected resources.
 */
protected boolean confirmRevert(IResource[] modifiedResources) {
    if (modifiedResources.length == 0) {
        if (showNothingToRevertMessage) {
            MessageDialog.openInformation(Display.getDefault().getActiveShell(), Policy.bind("RevertAction.0"), // $NON-NLS-1$ //$NON-NLS-2$
            Policy.bind("RevertAction.1"));
        }
        return false;
    }
    revertPage = new SvnWizardRevertPage(modifiedResources, url, statusMap, false);
    revertPage.setResourceRemoved(resourcesHidden);
    SvnWizard wizard = new SvnWizard(revertPage);
    SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
    boolean revert = (dialog.open() == SvnWizardDialog.OK);
    url = null;
    resourcesToRevert = revertPage.getSelectedResources();
    return revert;
}
Also used : SvnWizardRevertPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardRevertPage) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard)

Example 17 with SvnWizardDialog

use of org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog 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)

Example 18 with SvnWizardDialog

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

the class SVNHistoryPage method getCreateTagFromRevisionChangedPathAction.

private IAction getCreateTagFromRevisionChangedPathAction() {
    if (createTagFromRevisionChangedPathAction == null) {
        createTagFromRevisionChangedPathAction = new // $NON-NLS-1$
        Action() {

            public void run() {
                SVNRevision selectedRevision = null;
                ISelection selection = changePathsViewer.getSelection();
                if (!(selection instanceof IStructuredSelection))
                    return;
                IStructuredSelection sel = (IStructuredSelection) selection;
                ISVNRemoteResource remoteResource = null;
                if (sel.getFirstElement() instanceof LogEntryChangePath) {
                    try {
                        remoteResource = ((LogEntryChangePath) sel.getFirstElement()).getRemoteResource();
                        selectedRevision = remoteResource.getRevision();
                    } catch (SVNException e) {
                    }
                } else if (sel.getFirstElement() instanceof HistoryFolder) {
                    HistoryFolder historyFolder = (HistoryFolder) sel.getFirstElement();
                    Object[] children = historyFolder.getChildren();
                    if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
                        LogEntryChangePath changePath = (LogEntryChangePath) children[0];
                        try {
                            remoteResource = changePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath());
                            selectedRevision = getSelectedRevision();
                        } catch (SVNException e) {
                        }
                    }
                }
                if (remoteResource == null)
                    return;
                ISVNRemoteResource[] remoteResources = { remoteResource };
                BranchTagWizard wizard = new BranchTagWizard(remoteResources);
                wizard.setRevisionNumber(Long.parseLong(selectedRevision.toString()));
                WizardDialog dialog = new ClosableWizardDialog(getSite().getShell(), wizard);
                if (dialog.open() == WizardDialog.OK) {
                    final SVNUrl sourceUrl = wizard.getUrl();
                    final SVNUrl destinationUrl = wizard.getToUrl();
                    final String message = wizard.getComment();
                    final SVNRevision revision = wizard.getRevision();
                    final boolean makeParents = wizard.isMakeParents();
                    try {
                        BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                            public void run() {
                                ISVNClientAdapter client = null;
                                try {
                                    client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
                                    client.copy(sourceUrl, destinationUrl, message, revision, makeParents);
                                    SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
                                } catch (Exception e) {
                                    MessageDialog.openError(getSite().getShell(), Policy.bind("HistoryView.createTagFromRevision"), // $NON-NLS-1$
                                    e.getMessage());
                                } finally {
                                    SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                                }
                            }
                        });
                    } catch (Exception e) {
                        MessageDialog.openError(getSite().getShell(), Policy.bind("HistoryView.createTagFromRevision"), // $NON-NLS-1$
                        e.getMessage());
                    }
                }
            // SvnWizardBranchTagPage branchTagPage = new
            // SvnWizardBranchTagPage(remoteResource);
            // 
            // branchTagPage.setRevisionNumber(Long.parseLong(selectedRevision.toString()));
            // SvnWizard wizard = new SvnWizard(branchTagPage);
            // SvnWizardDialog dialog = new SvnWizardDialog(getSite().getShell(),
            // wizard);
            // wizard.setParentDialog(dialog);
            // if (!(dialog.open() == SvnWizardDialog.OK)) return;
            // final SVNUrl sourceUrl = branchTagPage.getUrl();
            // final SVNUrl destinationUrl = branchTagPage.getToUrl();
            // final String message = branchTagPage.getComment();
            // final SVNRevision revision = branchTagPage.getRevision();
            // final boolean makeParents = branchTagPage.isMakeParents();
            // try {
            // BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
            // public void run() {
            // try {
            // ISVNClientAdapter client =
            // SVNProviderPlugin.getPlugin().getSVNClientManager().createSVNClient();
            // client.copy(sourceUrl, destinationUrl, message, revision,
            // makeParents);
            // } catch(Exception e) {
            // MessageDialog.openError(getSite().getShell(),
            // Policy.bind("HistoryView.createTagFromRevision"), e
            // .getMessage());
            // }
            // }
            // });
            // } catch(Exception e) {
            // MessageDialog.openError(getSite().getShell(),
            // Policy.bind("HistoryView.createTagFromRevision"), e
            // .getMessage());
            // }
            }
        };
    }
    ISelection selection = changePathsViewer.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sel = (IStructuredSelection) selection;
        SVNRevision selectedRevision = null;
        if (sel.size() == 1) {
            // ISVNRemoteResource remoteResource = null;
            if (sel.getFirstElement() instanceof LogEntryChangePath && ((LogEntryChangePath) sel.getFirstElement()).getAction() != 'D') {
                // try {
                // remoteResource = ((LogEntryChangePath)sel.getFirstElement()).getRemoteResource();
                selectedRevision = ((LogEntryChangePath) sel.getFirstElement()).getRevision();
            // selectedRevision = remoteResource.getRevision();
            // } catch (SVNException e) {}
            } else if (sel.getFirstElement() instanceof HistoryFolder) {
                HistoryFolder historyFolder = (HistoryFolder) sel.getFirstElement();
                Object[] children = historyFolder.getChildren();
                if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
                    selectedRevision = getSelectedRevision();
                }
            }
            createTagFromRevisionChangedPathAction.setEnabled(selectedRevision != null);
            if (selectedRevision == null) {
                createTagFromRevisionChangedPathAction.setText(Policy.bind("HistoryView.createTagFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
                "" + ((LogEntryChangePath) sel.getFirstElement()).getRevision()));
            } else {
                createTagFromRevisionChangedPathAction.setText(Policy.bind("HistoryView.createTagFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
                "" + selectedRevision));
            }
        }
    }
    createTagFromRevisionChangedPathAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_BRANCHTAG));
    return createTagFromRevisionChangedPathAction;
}
Also used : LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) 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) BranchTagWizard(org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ISelection(org.eclipse.jface.viewers.ISelection) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

SvnWizardDialog (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog)18 SvnWizard (org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard)17 IResource (org.eclipse.core.resources.IResource)9 SVNException (org.tigris.subversion.subclipse.core.SVNException)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 CoreException (org.eclipse.core.runtime.CoreException)5 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)5 IContainer (org.eclipse.core.resources.IContainer)4 TeamException (org.eclipse.team.core.TeamException)4 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)4 Action (org.eclipse.jface.action.Action)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3 ParseException (java.text.ParseException)2 Iterator (java.util.Iterator)2 IFile (org.eclipse.core.resources.IFile)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 ISelection (org.eclipse.jface.viewers.ISelection)2 PartInitException (org.eclipse.ui.PartInitException)2