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;
}
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();
}
}
}
Aggregations