use of org.tigris.subversion.subclipse.core.commands.ChangeCommitPropertiesCommand in project subclipse by subclipse.
the class SVNHistoryPage method getSetCommitPropertiesAction.
private IAction getSetCommitPropertiesAction() {
// set Action (context menu)
if (setCommitPropertiesAction == null) {
setCommitPropertiesAction = new // $NON-NLS-1$
Action(// $NON-NLS-1$
Policy.bind("HistoryView.setCommitProperties")) {
public void run() {
try {
final ISelection selection = getSelection();
if (!(selection instanceof IStructuredSelection))
return;
final ILogEntry ourSelection = getLogEntry((IStructuredSelection) selection);
// Failing that, try the resource originally selected by the user if
// from the Team menu
// TODO: Search all paths from currentSelection and find the
// shortest path and
// get the resources for that instance (in order to get the 'best'
// "bugtraq" properties)
final ProjectProperties projectProperties = (resource != null) ? ProjectProperties.getProjectProperties(resource) : (ourSelection.getRemoteResource() != null) ? ProjectProperties.getProjectProperties(ourSelection.getRemoteResource()) : ProjectProperties.getProjectProperties(// will return null!
remoteResource);
final ISVNResource svnResource = ourSelection.getRemoteResource() != null ? ourSelection.getRemoteResource() : ourSelection.getResource();
SetCommitPropertiesDialog dialog = new SetCommitPropertiesDialog(getSite().getShell(), ourSelection.getRevision(), resource, projectProperties);
// Set previous text - the text to edit
dialog.setOldAuthor(ourSelection.getAuthor());
dialog.setOldComment(ourSelection.getComment());
boolean doCommit = (dialog.open() == Window.OK);
if (doCommit) {
final String author;
final String commitComment;
if (ourSelection.getAuthor().equals(dialog.getAuthor()))
author = null;
else
author = dialog.getAuthor();
if (ourSelection.getComment().equals(dialog.getComment()))
commitComment = null;
else
commitComment = dialog.getComment();
final ChangeCommitPropertiesCommand command = new ChangeCommitPropertiesCommand(svnResource.getRepository(), ourSelection.getRevision(), commitComment, author);
PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
command.run(monitor);
} catch (SVNException e) {
throw new InvocationTargetException(e);
} finally {
if (ourSelection instanceof LogEntry) {
LogEntry logEntry = (LogEntry) ourSelection;
if (command.isLogMessageChanged())
logEntry.setComment(commitComment);
if (command.isAuthorChanged())
logEntry.setAuthor(author);
}
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
tableHistoryViewer.refresh();
tableHistoryViewer.setSelection(selection, true);
}
});
}
}
});
}
} catch (InvocationTargetException e) {
SVNUIPlugin.openError(getSite().getShell(), null, null, e, SVNUIPlugin.LOG_NONTEAM_EXCEPTIONS);
} catch (InterruptedException e) {
// Do nothing
} catch (SVNException e) {
// TODO Auto-generated catch block
SVNUIPlugin.openError(getSite().getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
}
}
// we don't allow multiple selection
public boolean isEnabled() {
ISelection selection = getSelection();
return selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1;
}
};
}
return setCommitPropertiesAction;
}
use of org.tigris.subversion.subclipse.core.commands.ChangeCommitPropertiesCommand in project subclipse by subclipse.
the class SetCommitPropertiesAction method run.
public void run() {
try {
IResource resource = ((RevisionGraphEditorInput) editor.getEditorInput()).getResource();
ISVNRemoteResource remoteResource = ((RevisionGraphEditorInput) editor.getEditorInput()).getRemoteResource();
ISVNInfo info = ((RevisionGraphEditorInput) editor.getEditorInput()).getInfo();
final ProjectProperties projectProperties = (resource != null) ? ProjectProperties.getProjectProperties(resource) : ProjectProperties.getProjectProperties(remoteResource);
SVNRevision.Number revision = new SVNRevision.Number(node.getRevision());
SetCommitPropertiesDialog dialog = new SetCommitPropertiesDialog(Display.getDefault().getActiveShell(), revision, resource, projectProperties);
dialog.setOldAuthor(node.getAuthor());
dialog.setOldComment(node.getMessage());
if (dialog.open() == SetCommitPropertiesDialog.OK) {
final String author;
final String commitComment;
if (node.getAuthor().equals(dialog.getAuthor()))
author = null;
else
author = dialog.getAuthor();
if (node.getMessage().equals(dialog.getComment()))
commitComment = null;
else
commitComment = dialog.getComment();
ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(info.getRepository().toString());
final ChangeCommitPropertiesCommand command = new ChangeCommitPropertiesCommand(repository, revision, commitComment, author);
PlatformUI.getWorkbench().getProgressService().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
command.run(monitor);
} catch (SVNException e) {
throw new InvocationTargetException(e);
} finally {
if (command.isAuthorChanged())
node.setAuthor(author);
if (command.isLogMessageChanged())
node.setMessage(commitComment);
if (command.isAuthorChanged() || command.isLogMessageChanged()) {
nodeFigure.setToolTip(new NodeTooltipFigure(node));
}
}
}
});
}
} catch (Exception e) {
SVNUIPlugin.openError(Display.getDefault().getActiveShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
}
}
Aggregations