use of org.tigris.subversion.subclipse.ui.operations.SwitchOperation in project subclipse by subclipse.
the class SVNHistoryPage method getSwitchAction.
// get switch action (context menu)
private IAction getSwitchAction() {
if (switchAction == null) {
switchAction = new Action() {
public void run() {
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
ILogEntry currentSelection = getLogEntry(ss);
IResource[] resources = { resource };
SvnWizardSwitchPage switchPage = new SvnWizardSwitchPage(resources, currentSelection.getRevision().getNumber());
SvnWizard wizard = new SvnWizard(switchPage);
SvnWizardDialog dialog = new SvnWizardDialog(getSite().getShell(), wizard);
wizard.setParentDialog(dialog);
if (dialog.open() == SvnWizardDialog.OK) {
SVNUrl[] svnUrls = switchPage.getUrls();
SVNRevision svnRevision = switchPage.getRevision();
SwitchOperation switchOperation = new SwitchOperation(getSite().getPage().getActivePart(), resources, svnUrls, svnRevision);
switchOperation.setDepth(switchPage.getDepth());
switchOperation.setSetDepth(switchPage.isSetDepth());
switchOperation.setIgnoreExternals(switchPage.isIgnoreExternals());
switchOperation.setForce(switchPage.isForce());
switchOperation.setIgnoreAncestry(switchPage.isIgnoreAncestry());
switchOperation.setConflictResolver(switchPage.getConflictResolver());
try {
switchOperation.run();
} catch (Exception e) {
MessageDialog.openError(getSite().getShell(), switchAction.getText(), e.getMessage());
}
}
}
}
}
};
}
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() == 1) {
ILogEntry currentSelection = getLogEntry(ss);
switchAction.setText(Policy.bind("HistoryView.switchToRevision", // $NON-NLS-1$ //$NON-NLS-2$
"" + currentSelection.getRevision().getNumber()));
}
}
switchAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_SWITCH));
return switchAction;
}
use of org.tigris.subversion.subclipse.ui.operations.SwitchOperation in project subclipse by subclipse.
the class SwitchAction method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
if (action != null && !action.isEnabled()) {
action.setEnabled(true);
} else {
IResource[] resources = getSelectedResources();
// Use different wizard page name if multiple resources selected so that
// page size and location will be saved and restored separately for
// single selection switch and multiple selection switch.
String pageName;
if (resources.length > 1)
pageName = "SwitchDialogWithConflictHandling.multiple";
else
// $NON-NLS-1$
pageName = "SwitchDialogWithConflictHandling";
SvnWizardSwitchPage switchPage = new SvnWizardSwitchPage(pageName, resources);
SvnWizard wizard = new SvnWizard(switchPage);
SvnWizardDialog dialog = new SvnWizardDialog(getShell(), wizard);
wizard.setParentDialog(dialog);
if (dialog.open() == SvnWizardDialog.OK) {
SVNUrl[] svnUrls = switchPage.getUrls();
SVNRevision svnRevision = switchPage.getRevision();
SwitchOperation switchOperation = new SwitchOperation(getTargetPart(), resources, svnUrls, svnRevision);
switchOperation.setDepth(switchPage.getDepth());
switchOperation.setSetDepth(switchPage.isSetDepth());
switchOperation.setIgnoreExternals(switchPage.isIgnoreExternals());
switchOperation.setForce(switchPage.isForce());
switchOperation.setIgnoreAncestry(switchPage.isIgnoreAncestry());
switchOperation.setCanRunAsJob(canRunAsJob);
switchOperation.setConflictResolver(switchPage.getConflictResolver());
switchOperation.run();
}
}
}
use of org.tigris.subversion.subclipse.ui.operations.SwitchOperation in project subclipse by subclipse.
the class ReplaceWithBranchTagAction method execute.
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
IResource[] resources = getSelectedResources();
ReplaceWithBranchTagWizard wizard = new ReplaceWithBranchTagWizard(resources);
WizardDialog dialog = new WizardDialog(getShell(), wizard);
if (dialog.open() == WizardDialog.OK) {
ReplaceWithBranchTagWizardMainPage mainPage = wizard.getMainPage();
if (wizard.isReplaceContents()) {
SVNUrl url = mainPage.getUrl();
SVNRevision svnRevision = mainPage.getRevision();
ReplaceWithRemoteOperation replaceOperation = new ReplaceWithRemoteOperation(getTargetPart(), resources[0], url, svnRevision);
replaceOperation.run();
} else {
SvnWizardSwitchPage switchPage = wizard.getSwitchPage();
SVNUrl[] svnUrls;
SVNRevision svnRevision;
if (mainPage == null) {
svnUrls = switchPage.getUrls();
svnRevision = switchPage.getRevision();
} else {
svnUrls = new SVNUrl[] { mainPage.getUrl() };
svnRevision = mainPage.getRevision();
}
SwitchOperation switchOperation = new SwitchOperation(getTargetPart(), resources, svnUrls, svnRevision);
switchOperation.setDepth(switchPage.getDepth());
switchOperation.setSetDepth(switchPage.isSetDepth());
switchOperation.setIgnoreExternals(switchPage.isIgnoreExternals());
switchOperation.setForce(switchPage.isForce());
switchOperation.setIgnoreAncestry(switchPage.isIgnoreAncestry());
switchOperation.setCanRunAsJob(true);
switchOperation.setConflictResolver(switchPage.getConflictResolver());
switchOperation.run();
}
}
}
Aggregations