Search in sources :

Example 1 with LogEntry

use of org.tigris.subversion.subclipse.core.history.LogEntry 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;
}
Also used : ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ProjectProperties(org.tigris.subversion.subclipse.ui.settings.ProjectProperties) SVNException(org.tigris.subversion.subclipse.core.SVNException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ChangeCommitPropertiesCommand(org.tigris.subversion.subclipse.core.commands.ChangeCommitPropertiesCommand) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) SetCommitPropertiesDialog(org.tigris.subversion.subclipse.ui.dialogs.SetCommitPropertiesDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ISelection(org.eclipse.jface.viewers.ISelection) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) LogEntry(org.tigris.subversion.subclipse.core.history.LogEntry)

Example 2 with LogEntry

use of org.tigris.subversion.subclipse.core.history.LogEntry in project subclipse by subclipse.

the class SVNHistoryPage method updatePanels.

void updatePanels(ISelection selection) {
    if (selection == null || !(selection instanceof IStructuredSelection)) {
        // $NON-NLS-1$
        textViewer.setDocument(new Document(""));
        changePathsViewer.setInput(null);
        return;
    }
    IStructuredSelection ss = (IStructuredSelection) selection;
    if (ss.size() != 1) {
        // $NON-NLS-1$
        textViewer.setDocument(new Document(""));
        changePathsViewer.setInput(null);
        return;
    }
    LogEntry entry = (LogEntry) ss.getFirstElement();
    textViewer.setDocument(new Document(entry.getComment()));
    StyledText text = textViewer.getTextWidget();
    // TODO move this logic into the hyperlink detector created in createText()
    if (projectProperties == null) {
        linkList = ProjectProperties.getUrls(entry.getComment());
    } else {
        linkList = projectProperties.getLinkList(entry.getComment());
    }
    if (linkList != null) {
        int[][] linkRanges = linkList.getLinkRanges();
        // String[] urls = linkList.getUrls();
        for (int i = 0; i < linkRanges.length; i++) {
            text.setStyleRange(new StyleRange(linkRanges[i][0], linkRanges[i][1], JFaceColors.getHyperlinkText(Display.getCurrent()), null));
        }
    }
    if (changePathsViewer instanceof ChangePathsTreeViewer) {
        ((ChangePathsTreeViewer) changePathsViewer).setCurrentLogEntry(entry);
    }
    if (changePathsViewer instanceof ChangePathsFlatViewer) {
        ((ChangePathsFlatViewer) changePathsViewer).setCurrentLogEntry(entry);
    }
    if (changePathsViewer instanceof ChangePathsTableProvider) {
        ((ChangePathsTableProvider) changePathsViewer).setCurrentLogEntry(entry);
    }
    changePathsViewer.setInput(entry);
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) StyleRange(org.eclipse.swt.custom.StyleRange) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Document(org.eclipse.jface.text.Document) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) LogEntry(org.tigris.subversion.subclipse.core.history.LogEntry)

Example 3 with LogEntry

use of org.tigris.subversion.subclipse.core.history.LogEntry in project subclipse by subclipse.

the class ShowRevisionsDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    if (title == null)
        // $NON-NLS-1$
        getShell().setText(Policy.bind("HistoryView.showMergedRevisions"));
    else
        getShell().setText(title);
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    GridData data = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(data);
    sashForm = new SashForm(composite, SWT.VERTICAL);
    sashForm.setLayout(new GridLayout());
    sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite historyGroup = new Composite(sashForm, SWT.NULL);
    historyGroup.setLayout(new GridLayout());
    historyGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    Tree tree = new Tree(historyGroup, SWT.BORDER | SWT.FULL_SELECTION);
    treeHistoryViewer = new TreeViewer(tree);
    data = new GridData(GridData.FILL_BOTH);
    data.widthHint = WIDTH_HINT;
    data.heightHint = LOG_HEIGHT_HINT;
    treeHistoryViewer.getTree().setLayoutData(data);
    treeHistoryViewer.getTree().setHeaderVisible(true);
    revisionColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
    revisionColumn.setResizable(true);
    // $NON-NLS-1$
    revisionColumn.setText(Policy.bind("HistoryView.revision"));
    int revisionWidth = 75;
    int tagsWidth = 225;
    int dateWidth = 100;
    int authorWidth = 100;
    int commentWidth = 300;
    try {
        revisionWidth = settings.getInt("ShowRevisionsDialog.width_revision");
        dateWidth = settings.getInt("ShowRevisionsDialog.width_date");
        authorWidth = settings.getInt("ShowRevisionsDialog.width_author");
        commentWidth = settings.getInt("ShowRevisionsDialog.width_comment");
        tagsWidth = settings.getInt("ShowRevisionsDialog.width_tag");
    } catch (Exception e) {
    }
    revisionColumn.setWidth(revisionWidth);
    if (includeTags) {
        tagsColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
        tagsColumn.setResizable(true);
        // $NON-NLS-1$
        tagsColumn.setText(Policy.bind("HistoryView.tags"));
        tagsColumn.setWidth(tagsWidth);
    }
    dateColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
    dateColumn.setResizable(true);
    // $NON-NLS-1$
    dateColumn.setText(Policy.bind("HistoryView.date"));
    dateColumn.setWidth(dateWidth);
    authorColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
    authorColumn.setResizable(true);
    // $NON-NLS-1$
    authorColumn.setText(Policy.bind("HistoryView.author"));
    authorColumn.setWidth(authorWidth);
    commentColumn = new TreeColumn(treeHistoryViewer.getTree(), SWT.NONE);
    commentColumn.setResizable(true);
    // $NON-NLS-1$
    commentColumn.setText(Policy.bind("HistoryView.comment"));
    commentColumn.setWidth(commentWidth);
    treeHistoryViewer.setLabelProvider(new ITableLabelProvider() {

        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }

        public String getColumnText(Object element, int columnIndex) {
            ILogEntry entry = (ILogEntry) element;
            int index = columnIndex;
            if (index > 0 && !includeTags)
                index++;
            switch(index) {
                case COL_REVISION:
                    String revision = entry.getRevision().toString();
                    return revision;
                case COL_TAGS:
                    return AliasManager.getAliasesAsString(entry.getTags());
                case COL_DATE:
                    Date date = entry.getDate();
                    // $NON-NLS-1$
                    if (date == null)
                        return Policy.bind("notAvailable");
                    return DateFormat.getInstance().format(date);
                case COL_AUTHOR:
                    // $NON-NLS-1$
                    if (entry.getAuthor() == null)
                        return Policy.bind("noauthor");
                    return entry.getAuthor();
                case COL_COMMENT:
                    String comment = entry.getComment();
                    // $NON-NLS-1$
                    if (comment == null)
                        return "";
                    // $NON-NLS-1$
                    int rIndex = comment.indexOf("\r");
                    // $NON-NLS-1$
                    int nIndex = comment.indexOf("\n");
                    if ((rIndex == -1) && (nIndex == -1))
                        return comment;
                    if ((rIndex == 0) || (nIndex == 0))
                        // $NON-NLS-1$
                        return Policy.bind("HistoryView.[...]_4");
                    if (rIndex != -1)
                        return Policy.bind("SVNCompareRevisionsInput.truncate", // $NON-NLS-1$
                        comment.substring(0, rIndex));
                    else
                        return Policy.bind("SVNCompareRevisionsInput.truncate", // $NON-NLS-1$
                        comment.substring(0, nIndex));
            }
            return null;
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    treeHistoryViewer.setContentProvider(new WorkbenchContentProvider() {

        public Object[] getChildren(Object element) {
            if (element instanceof ILogEntry) {
                return ((ILogEntry) element).getChildMessages();
            }
            ILogEntry[] logEntries = { logEntry };
            return logEntries;
        }

        public Object[] getElements(Object element) {
            return getChildren(element);
        }

        public boolean hasChildren(Object element) {
            if (element instanceof ILogEntry) {
                return ((ILogEntry) element).getNumberOfChildren() > 0;
            }
            return false;
        }
    });
    treeHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection == null || !(selection instanceof IStructuredSelection)) {
                // $NON-NLS-1$
                textViewer.setDocument(new Document(""));
                changePathsViewer.setInput(null);
                return;
            }
            IStructuredSelection ss = (IStructuredSelection) selection;
            if (ss.size() != 1) {
                // $NON-NLS-1$
                textViewer.setDocument(new Document(""));
                changePathsViewer.setInput(null);
                return;
            }
            LogEntry entry = (LogEntry) ss.getFirstElement();
            textViewer.setDocument(new Document(entry.getComment()));
            changePathsViewer.setInput(entry);
        }
    });
    if (resource == null)
        treeHistoryViewer.setInput(remoteResource);
    else
        treeHistoryViewer.setInput(resource);
    treeHistoryViewer.resetFilters();
    treeHistoryViewer.expandToLevel(2);
    MenuManager menuMgr = new MenuManager();
    Menu menu = menuMgr.createContextMenu(treeHistoryViewer.getTree());
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager menuMgr) {
            fillTreeMenu(menuMgr);
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    treeHistoryViewer.getTree().setMenu(menu);
    Composite commentGroup = new Composite(sashForm, SWT.NULL);
    commentGroup.setLayout(new GridLayout());
    commentGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    textViewer = new TextViewer(commentGroup, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.READ_ONLY);
    data = new GridData(GridData.FILL_BOTH);
    data.heightHint = COMMENT_HEIGHT_HINT;
    data.widthHint = WIDTH_HINT;
    textViewer.getControl().setLayoutData(data);
    Composite pathGroup = new Composite(sashForm, SWT.NULL);
    pathGroup.setLayout(new GridLayout());
    pathGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    IPreferenceStore store = SVNUIPlugin.getPlugin().getPreferenceStore();
    int mode = store.getInt(ISVNUIConstants.PREF_AFFECTED_PATHS_MODE);
    IStructuredContentProvider contentProvider = new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            if ((inputElement == null) || (!(inputElement instanceof ILogEntry))) {
                return null;
            }
            ILogEntry logEntry = (ILogEntry) inputElement;
            return logEntry.getLogEntryChangePaths();
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    };
    switch(mode) {
        case ISVNUIConstants.MODE_COMPRESSED:
            changePathsViewer = new ChangePathsTreeViewer(pathGroup, historyPage);
            break;
        case ISVNUIConstants.MODE_FLAT2:
            changePathsViewer = new ChangePathsFlatViewer(pathGroup, historyPage);
            break;
        default:
            changePathsViewer = new ChangePathsTableProvider(pathGroup, contentProvider);
            break;
    }
    try {
        int[] weights = new int[3];
        // $NON-NLS-1$
        weights[0] = settings.getInt("ShowRevisionsDialog.weights.0");
        // $NON-NLS-1$
        weights[1] = settings.getInt("ShowRevisionsDialog.weights.1");
        // $NON-NLS-1$
        weights[2] = settings.getInt("ShowRevisionsDialog.weights.2");
        sashForm.setWeights(weights);
    } catch (Exception e) {
    }
    if (selectFirst && treeHistoryViewer.getTree().getItemCount() > 0) {
        TreeItem item = treeHistoryViewer.getTree().getItem(0);
        treeHistoryViewer.getTree().setSelection(item);
        // Method not available in 3.3
        // treeHistoryViewer.getTree().select(item);
        treeHistoryViewer.setSelection(treeHistoryViewer.getSelection());
        changePathsViewer.refresh();
        if (changePathsViewer instanceof ChangePathsTreeViewer)
            ((ChangePathsTreeViewer) changePathsViewer).expandAll();
    }
    return composite;
}
Also used : ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ChangePathsTreeViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsTreeViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ChangePathsFlatViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsFlatViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ChangePathsTreeViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsTreeViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) Viewer(org.eclipse.jface.viewers.Viewer) TextViewer(org.eclipse.jface.text.TextViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) Document(org.eclipse.jface.text.Document) TextViewer(org.eclipse.jface.text.TextViewer) GridLayout(org.eclipse.swt.layout.GridLayout) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ChangePathsFlatViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsFlatViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) ISelection(org.eclipse.jface.viewers.ISelection) Tree(org.eclipse.swt.widgets.Tree) Menu(org.eclipse.swt.widgets.Menu) LogEntry(org.tigris.subversion.subclipse.core.history.LogEntry) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ChangePathsTreeViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsTreeViewer) Point(org.eclipse.swt.graphics.Point) Date(java.util.Date) IMenuListener(org.eclipse.jface.action.IMenuListener) ChangePathsTableProvider(org.tigris.subversion.subclipse.ui.history.ChangePathsTableProvider) SashForm(org.eclipse.swt.custom.SashForm) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IMenuManager(org.eclipse.jface.action.IMenuManager) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 4 with LogEntry

use of org.tigris.subversion.subclipse.core.history.LogEntry in project subclipse by subclipse.

the class GenerateChangeLogDialog method generateChangeLog.

private boolean generateChangeLog(final boolean preview) {
    exception = null;
    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

        public void run() {
            try {
                if (!preview && fileButton.getSelection()) {
                    File file = new File(fileText.getText().trim());
                    if (!file.exists())
                        file.createNewFile();
                    BufferedWriter writer = new BufferedWriter(new FileWriter(file));
                    for (LogEntry logEntry : logEntries) {
                        if (// $NON-NLS-2$
                        gnuButton.getSelection())
                            // $NON-NLS-2$
                            writer.write(logEntry.getGnuLog());
                        else
                            writer.write(// $NON-NLS-2$
                            logEntry.getChangeLog(svnLogAndPathsButton.getSelection()));
                    }
                    writer.close();
                } else {
                    StringBuffer changeLog = new StringBuffer();
                    for (LogEntry logEntry : logEntries) {
                        if (gnuButton.getSelection())
                            // $NON-NLS-2$
                            changeLog.append(logEntry.getGnuLog());
                        else
                            changeLog.append(logEntry.getChangeLog(// $NON-NLS-2$
                            svnLogAndPathsButton.getSelection()));
                    }
                    if (preview) {
                        changeLogPreview = changeLog.toString().trim();
                    } else {
                        TextTransfer plainTextTransfer = TextTransfer.getInstance();
                        Clipboard clipboard = new Clipboard(Display.getDefault());
                        clipboard.setContents(new String[] { changeLog.toString().trim() }, new Transfer[] { plainTextTransfer });
                        clipboard.dispose();
                    }
                }
            } catch (Exception e) {
                exception = e;
            }
        }
    });
    if (exception != null) {
        MessageDialog.openError(Display.getDefault().getActiveShell(), Policy.bind("HistoryView.generateChangeLog"), // $NON-NLS-1$
        exception.getMessage());
        return false;
    }
    if (preview && changeLogPreview != null) {
        previewText.setText(changeLogPreview);
    }
    return true;
}
Also used : FileWriter(java.io.FileWriter) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard) File(java.io.File) LogEntry(org.tigris.subversion.subclipse.core.history.LogEntry) BufferedWriter(java.io.BufferedWriter) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 5 with LogEntry

use of org.tigris.subversion.subclipse.core.history.LogEntry in project subclipse by subclipse.

the class HistoryDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    if (store.getInt(ISVNUIConstants.PREF_LOG_ENTRIES_TO_FETCH) == 0) {
        getAllLogEntries();
    } else {
        getLogEntries();
    }
    if (resource == null) {
        getShell().setText(Policy.bind("HistoryDialog.title") + " - " + // $NON-NLS-1$ //$NON-NLS-2$
        remoteResource.getName());
        setIncludeBugsAndTags(remoteResource);
    } else {
        getShell().setText(Policy.bind("HistoryDialog.title") + " - " + // $NON-NLS-1$ //$NON-NLS-2$
        resource.getName());
        setIncludeBugsAndTags(resource);
    }
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    GridData data = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(data);
    sashForm = new SashForm(composite, SWT.VERTICAL);
    GridLayout sashLayout = new GridLayout();
    sashLayout.verticalSpacing = 0;
    sashLayout.marginHeight = 0;
    sashForm.setLayout(sashLayout);
    sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite historyGroup = new Composite(sashForm, SWT.NULL);
    GridLayout historyLayout = new GridLayout();
    historyLayout.verticalSpacing = 0;
    historyLayout.marginHeight = 0;
    historyLayout.marginTop = 5;
    historyGroup.setLayout(historyLayout);
    historyGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    historyTableProvider = new HistoryTableProvider(SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER, // $NON-NLS-1$
    "HistoryDialog");
    historyTableProvider.setIncludeBugs(includeBugs);
    historyTableProvider.setProjectProperties(projectProperties);
    historyTableProvider.setIncludeMergeRevisions(false);
    historyTableProvider.setIncludeTags(includeTags);
    historyTableProvider.setRemoteResource(remoteResource);
    tableHistoryViewer = historyTableProvider.createTable(historyGroup);
    data = new GridData(GridData.FILL_BOTH);
    data.widthHint = WIDTH_HINT;
    data.heightHint = LOG_HEIGHT_HINT;
    tableHistoryViewer.getTable().setLayoutData(data);
    tableHistoryViewer.setContentProvider(new IStructuredContentProvider() {

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        public Object[] getElements(Object inputElement) {
            return entries;
        }
    });
    tableHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection == null || !(selection instanceof IStructuredSelection)) {
                // $NON-NLS-1$
                textViewer.setDocument(new Document(""));
                changePathsViewer.setInput(null);
                return;
            }
            IStructuredSelection ss = (IStructuredSelection) selection;
            if (ss.size() != 1) {
                // $NON-NLS-1$
                textViewer.setDocument(new Document(""));
                changePathsViewer.setInput(null);
                return;
            }
            LogEntry entry = (LogEntry) ss.getFirstElement();
            textViewer.setDocument(new Document(entry.getComment()));
            changePathsViewer.setCurrentLogEntry(entry);
            changePathsViewer.setInput(entry);
        }
    });
    tableHistoryViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            okPressed();
        }
    });
    tableHistoryViewer.setInput(remoteResource);
    tableHistoryViewer.resetFilters();
    Composite commentGroup = new Composite(sashForm, SWT.NULL);
    GridLayout commentLayout = new GridLayout();
    commentLayout.verticalSpacing = 0;
    commentLayout.marginHeight = 0;
    commentGroup.setLayout(commentLayout);
    commentGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    textViewer = new TextViewer(commentGroup, SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.READ_ONLY);
    data = new GridData(GridData.FILL_BOTH);
    data.heightHint = COMMENT_HEIGHT_HINT;
    data.widthHint = WIDTH_HINT;
    textViewer.getControl().setLayoutData(data);
    Composite pathGroup = new Composite(sashForm, SWT.NULL);
    GridLayout pathLayout = new GridLayout();
    pathLayout.verticalSpacing = 0;
    pathLayout.marginHeight = 0;
    pathGroup.setLayout(pathLayout);
    pathGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    ChangePathsTreeContentProvider contentProvider = new ChangePathsTreeContentProvider();
    changePathsViewer = new ChangePathsTreeViewer(pathGroup, contentProvider);
    stopOnCopyButton = new Button(composite, SWT.CHECK);
    data = new GridData();
    data.verticalIndent = 5;
    data.horizontalIndent = 5;
    stopOnCopyButton.setLayoutData(data);
    stopOnCopyButton.setText(Policy.bind("HistoryView.stopOnCopy"));
    stopOnCopyButton.setSelection(store.getBoolean(ISVNUIConstants.PREF_STOP_ON_COPY));
    stopOnCopyButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            store.setValue(ISVNUIConstants.PREF_STOP_ON_COPY, stopOnCopyButton.getSelection());
            revisionStart = SVNRevision.HEAD;
            getLogEntries();
            tableHistoryViewer.refresh();
        }
    });
    try {
        int[] weights = new int[3];
        // $NON-NLS-1$
        weights[0] = settings.getInt("HistoryDialog.weights.0");
        // $NON-NLS-1$
        weights[1] = settings.getInt("HistoryDialog.weights.1");
        // $NON-NLS-1$
        weights[2] = settings.getInt("HistoryDialog.weights.2");
        sashForm.setWeights(weights);
    } catch (Exception e) {
    }
    // This is a hack to get around a problem with the initial sorting on OSx
    historyTableProvider.setSortColumn(tableHistoryViewer, 0);
    historyTableProvider.setSortColumn(tableHistoryViewer, 0);
    // set F1 help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.HISTORY_DIALOG);
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableViewer(org.eclipse.jface.viewers.TableViewer) ChangePathsTreeViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) TextViewer(org.eclipse.jface.text.TextViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Document(org.eclipse.jface.text.Document) ChangePathsTreeViewer(org.tigris.subversion.subclipse.ui.history.ChangePathsTreeViewer) SVNException(org.tigris.subversion.subclipse.core.SVNException) TeamException(org.eclipse.team.core.TeamException) HistoryTableProvider(org.tigris.subversion.subclipse.ui.history.HistoryTableProvider) TextViewer(org.eclipse.jface.text.TextViewer) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) ISelection(org.eclipse.jface.viewers.ISelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LogEntry(org.tigris.subversion.subclipse.core.history.LogEntry) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry)

Aggregations

LogEntry (org.tigris.subversion.subclipse.core.history.LogEntry)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)7 Document (org.eclipse.jface.text.Document)5 ISelection (org.eclipse.jface.viewers.ISelection)5 TextViewer (org.eclipse.jface.text.TextViewer)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)4 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 Viewer (org.eclipse.jface.viewers.Viewer)4 SashForm (org.eclipse.swt.custom.SashForm)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 IMenuListener (org.eclipse.jface.action.IMenuListener)3 IMenuManager (org.eclipse.jface.action.IMenuManager)3 MenuManager (org.eclipse.jface.action.MenuManager)3 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)3 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)3