use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class MergeDialog method showLog.
private void showLog(Text text) {
ISVNRemoteResource remoteResource = null;
if (text == fromRevisionText) {
try {
fromUrl = new SVNUrl(fromUrlCombo.getText());
remoteResource = svnResource.getRepository().getRemoteFile(fromUrl);
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
e.toString());
return;
}
if (remoteResource == null) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
fromUrlCombo.getText());
return;
}
}
if (text == toRevisionText) {
try {
toUrl = new SVNUrl(toUrlCombo.getText());
remoteResource = svnResource.getRepository().getRemoteFile(toUrl);
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
e.toString());
return;
}
if (remoteResource == null) {
MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
toUrlCombo.getText());
return;
}
}
HistoryDialog dialog = null;
if ((text == fromRevisionText) || (text == toRevisionText))
dialog = new HistoryDialog(getShell(), remoteResource);
else
dialog = new HistoryDialog(getShell(), resource);
if (dialog.open() == HistoryDialog.CANCEL)
return;
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0)
return;
if ((text != null) && useFromUrlButton.getSelection()) {
fromRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber() - 1));
fromHeadButton.setSelection(false);
toRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
toHeadButton.setSelection(false);
fromRevisionText.setEnabled(true);
toRevisionText.setEnabled(true);
return;
}
if ((text == fromRevisionText) || ((text == null) && (fromRevisionText.getText().trim().length() == 0))) {
fromRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
fromHeadButton.setSelection(false);
fromRevisionText.setEnabled(true);
}
if (text == toRevisionText) {
toRevisionText.setText(Long.toString(selectedEntries[0].getRevision().getNumber()));
toHeadButton.setSelection(false);
toRevisionText.setEnabled(true);
}
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class ShowAnnotationOperation method createRevisionInformation.
private RevisionInformation createRevisionInformation(final AnnotateBlocks annotateBlocks, IProgressMonitor monitor) {
Map logEntriesByRevision = new HashMap();
GetLogsCommand logCommand = new GetLogsCommand(this.remoteFile, SVNRevision.HEAD, this.fromRevision, this.toRevision, false, 0, null, false);
try {
logCommand.run(monitor);
ILogEntry[] logEntries = logCommand.getLogEntries();
for (int i = 0; i < logEntries.length; i++) {
ILogEntry logEntry = logEntries[i];
logEntriesByRevision.put(new Long(logEntry.getRevision().getNumber()), logEntry);
}
} catch (SVNException e) {
SVNUIPlugin.log(e);
}
RevisionInformation info = new RevisionInformation();
try {
// Have to use reflection for compatibility with Eclipse 3.2 API
// info.setHoverControlCreator(new AnnotationControlCreator("Press F2 for focus."));
// info.setInformationPresenterControlCreator(new AnnotationControlCreator(null));
String tooltipAffordance = "Press F2 for focus.";
try {
// Will either set an affordance, or null if the tooltip affordance turned is off
tooltipAffordance = (String) EditorsUI.class.getMethod("getTooltipAffordanceString", null).invoke(null, null);
} catch (Exception e) {
// ignore
}
Class infoClass = info.getClass();
Class[] paramTypes = { IInformationControlCreator.class };
Method setHoverControlCreator = infoClass.getMethod("setHoverControlCreator", paramTypes);
Method setInformationPresenterControlCreator = infoClass.getMethod("setInformationPresenterControlCreator", paramTypes);
final class AnnotationControlCreator implements IInformationControlCreator {
private final String statusFieldText;
public AnnotationControlCreator(String statusFieldText) {
this.statusFieldText = statusFieldText;
}
public IInformationControl createInformationControl(Shell parent) {
return new SourceViewerInformationControl(parent, SWT.TOOL, SWT.NONE, JFaceResources.DEFAULT_FONT, statusFieldText);
}
}
setHoverControlCreator.invoke(info, new Object[] { new AnnotationControlCreator(tooltipAffordance) });
setInformationPresenterControlCreator.invoke(info, new Object[] { new AnnotationControlCreator(null) });
} catch (Exception e) {
// ignore
}
final CommitterColors colors = CommitterColors.getDefault();
HashMap sets = new HashMap();
for (Iterator blocks = annotateBlocks.getAnnotateBlocks().iterator(); blocks.hasNext(); ) {
final AnnotateBlock block = (AnnotateBlock) blocks.next();
final String revisionString = Long.toString(block.getRevision());
LogEntry logEntry = (LogEntry) logEntriesByRevision.get(new Long(block.getRevision()));
final String logMessage;
if (logEntry == null) {
logMessage = getSingleEntry(remoteFile, new Long(block.getRevision()));
} else {
logMessage = logEntry.getComment();
}
Revision revision = (Revision) sets.get(revisionString);
if (revision == null) {
revision = new Revision() {
public Object getHoverInfo() {
return block.getUser() + " " + revisionString + " " + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(block.getDate()) + "\n\n" + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
(// $NON-NLS-1$
logMessage != null ? logMessage : "");
}
public String getAuthor() {
return block.getUser();
}
public String getId() {
return revisionString;
}
public Date getDate() {
return block.getDate();
}
public RGB getColor() {
return colors.getCommitterRGB(getAuthor());
}
};
sets.put(revisionString, revision);
info.addRevision(revision);
}
revision.addRange(new LineRange(block.getStartLine(), block.getEndLine() - block.getStartLine() + 1));
}
return info;
}
use of org.tigris.subversion.subclipse.core.history.ILogEntry in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffDialogWC method showLog.
private void showLog(Object sourceButton) {
try {
SVNUrl url = new SVNUrl(toUrlText.getText().trim());
ISVNRemoteResource remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().getRemoteFile(url);
HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
if (dialog.open() == HistoryDialog.CANCEL)
return;
ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
if (selectedEntries.length == 0)
return;
toRevisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), // $NON-NLS-1$
e.getMessage());
}
setOkButtonStatus();
}
Aggregations