Search in sources :

Example 46 with ILogEntry

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);
    }
}
Also used : ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ParseException(java.text.ParseException) MalformedURLException(java.net.MalformedURLException)

Example 47 with ILogEntry

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;
}
Also used : EditorsUI(org.eclipse.ui.editors.text.EditorsUI) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) HashMap(java.util.HashMap) SVNException(org.tigris.subversion.subclipse.core.SVNException) AnnotateBlock(org.tigris.subversion.subclipse.ui.annotations.AnnotateBlock) IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) Shell(org.eclipse.swt.widgets.Shell) Iterator(java.util.Iterator) RevisionInformation(org.eclipse.jface.text.revisions.RevisionInformation) LogEntry(org.tigris.subversion.subclipse.core.history.LogEntry) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) Method(java.lang.reflect.Method) RGB(org.eclipse.swt.graphics.RGB) LineRange(org.eclipse.jface.text.source.LineRange) WorkbenchException(org.eclipse.ui.WorkbenchException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) Date(java.util.Date) Revision(org.eclipse.jface.text.revisions.Revision) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) GetLogsCommand(org.tigris.subversion.subclipse.core.commands.GetLogsCommand) Map(java.util.Map) HashMap(java.util.HashMap)

Example 48 with ILogEntry

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();
}
Also used : ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Aggregations

ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)48 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)17 SVNException (org.tigris.subversion.subclipse.core.SVNException)16 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)15 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 ISelection (org.eclipse.jface.viewers.ISelection)14 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)14 TeamException (org.eclipse.team.core.TeamException)13 HistoryDialog (org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog)13 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)10 MalformedURLException (java.net.MalformedURLException)9 ParseException (java.text.ParseException)9 Point (org.eclipse.swt.graphics.Point)7 ArrayList (java.util.ArrayList)6 Iterator (java.util.Iterator)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)6 IResource (org.eclipse.core.resources.IResource)5 GridData (org.eclipse.swt.layout.GridData)5 GridLayout (org.eclipse.swt.layout.GridLayout)5