Search in sources :

Example 1 with ILogEntry

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

the class SVNHistoryPage method getFirstElement.

private ILogEntry getFirstElement() {
    ILogEntry firstElement = null;
    ISelection selection = getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) selection;
        Iterator iter = ss.iterator();
        while (iter.hasNext()) {
            ILogEntry element = (ILogEntry) iter.next();
            if (firstElement == null || element.getRevision().getNumber() > firstElement.getRevision().getNumber())
                firstElement = element;
        }
    }
    return firstElement;
}
Also used : ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) ISelection(org.eclipse.jface.viewers.ISelection) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with ILogEntry

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

the class SVNHistoryPage method getSwitchAction.

// get switch action (context menu)
private IAction getSwitchAction() {
    if (switchAction == null) {
        switchAction = new Action() {

            public void run() {
                if (selection instanceof IStructuredSelection) {
                    IStructuredSelection ss = (IStructuredSelection) selection;
                    if (ss.size() == 1) {
                        ILogEntry currentSelection = getLogEntry(ss);
                        IResource[] resources = { resource };
                        SvnWizardSwitchPage switchPage = new SvnWizardSwitchPage(resources, currentSelection.getRevision().getNumber());
                        SvnWizard wizard = new SvnWizard(switchPage);
                        SvnWizardDialog dialog = new SvnWizardDialog(getSite().getShell(), wizard);
                        wizard.setParentDialog(dialog);
                        if (dialog.open() == SvnWizardDialog.OK) {
                            SVNUrl[] svnUrls = switchPage.getUrls();
                            SVNRevision svnRevision = switchPage.getRevision();
                            SwitchOperation switchOperation = new SwitchOperation(getSite().getPage().getActivePart(), resources, svnUrls, svnRevision);
                            switchOperation.setDepth(switchPage.getDepth());
                            switchOperation.setSetDepth(switchPage.isSetDepth());
                            switchOperation.setIgnoreExternals(switchPage.isIgnoreExternals());
                            switchOperation.setForce(switchPage.isForce());
                            switchOperation.setIgnoreAncestry(switchPage.isIgnoreAncestry());
                            switchOperation.setConflictResolver(switchPage.getConflictResolver());
                            try {
                                switchOperation.run();
                            } catch (Exception e) {
                                MessageDialog.openError(getSite().getShell(), switchAction.getText(), e.getMessage());
                            }
                        }
                    }
                }
            }
        };
    }
    ISelection selection = getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) selection;
        if (ss.size() == 1) {
            ILogEntry currentSelection = getLogEntry(ss);
            switchAction.setText(Policy.bind("HistoryView.switchToRevision", // $NON-NLS-1$ //$NON-NLS-2$
            "" + currentSelection.getRevision().getNumber()));
        }
    }
    switchAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_SWITCH));
    return switchAction;
}
Also used : CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) ExportRemoteFolderAction(org.tigris.subversion.subclipse.ui.actions.ExportRemoteFolderAction) ShowDifferencesAsUnifiedDiffAction(org.tigris.subversion.subclipse.ui.actions.ShowDifferencesAsUnifiedDiffAction) TextViewerAction(org.tigris.subversion.subclipse.ui.console.TextViewerAction) ShowAnnotationAction(org.tigris.subversion.subclipse.ui.actions.ShowAnnotationAction) ShowHistoryAction(org.tigris.subversion.subclipse.ui.actions.ShowHistoryAction) WorkspaceAction(org.tigris.subversion.subclipse.ui.actions.WorkspaceAction) IAction(org.eclipse.jface.action.IAction) OpenRemoteFileAction(org.tigris.subversion.subclipse.ui.actions.OpenRemoteFileAction) GenerateChangeLogAction(org.tigris.subversion.subclipse.ui.actions.GenerateChangeLogAction) Action(org.eclipse.jface.action.Action) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) SvnWizard(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizard) ISelection(org.eclipse.jface.viewers.ISelection) SvnWizardSwitchPage(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardSwitchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ParseException(java.text.ParseException) SwitchOperation(org.tigris.subversion.subclipse.ui.operations.SwitchOperation)

Example 3 with ILogEntry

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

the class SVNHistoryPage method fillTableMenu.

private void fillTableMenu(IMenuManager manager) {
    // file actions go first (view file)
    manager.add(new Separator(IWorkbenchActionConstants.GROUP_FILE));
    // Add the "Add to Workspace" action if 1 revision is selected.
    ISelection sel = tableHistoryViewer.getSelection();
    if (!sel.isEmpty()) {
        if (sel instanceof IStructuredSelection) {
            if (((IStructuredSelection) sel).size() == 1) {
                if (resource != null && resource instanceof IFile) {
                    manager.add(getGetContentsAction());
                    manager.add(getUpdateToRevisionAction());
                }
                // manager.add(getShowDifferencesAsUnifiedDiffAction());
                // if (resource != null) {
                manager.add(getCreateTagFromRevisionAction());
                // }
                manager.add(getSetCommitPropertiesAction());
                manager.add(getShowRevisionPropertiesAction());
                ILogEntry logEntry = (ILogEntry) ((IStructuredSelection) sel).getFirstElement();
                if (logEntry.getNumberOfChildren() > 0)
                    manager.add(getShowRevisionsAction());
            }
            if (resource != null) {
                manager.add(getRevertChangesAction());
                if (((IStructuredSelection) sel).size() == 1)
                    manager.add(getSwitchAction());
            }
            // $NON-NLS-1$
            manager.add(new Separator("exportImportGroup"));
            getGenerateChangeLogAction().setEnabled(!store.getBoolean(ISVNUIConstants.PREF_FETCH_CHANGE_PATH_ON_DEMAND));
            manager.add(getGenerateChangeLogAction());
        }
    }
    // $NON-NLS-1$
    manager.add(new Separator("additions"));
    manager.add(getRefreshAction());
    // $NON-NLS-1$
    manager.add(new Separator("additions-end"));
}
Also used : IFile(org.eclipse.core.resources.IFile) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Separator(org.eclipse.jface.action.Separator)

Example 4 with ILogEntry

use of org.tigris.subversion.subclipse.core.history.ILogEntry 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 5 with ILogEntry

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

the class SVNHistoryPage method createTableHistory.

protected void createTableHistory(Composite parent) {
    boolean redraw = false;
    if (tableParent == null) {
        tableParent = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        tableParent.setLayout(layout);
        GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
        gridData.horizontalIndent = 0;
        gridData.verticalIndent = 0;
        tableParent.setLayoutData(gridData);
    } else {
        Control[] children = tableParent.getChildren();
        for (int i = 0; i < children.length; i++) {
            children[i].dispose();
        }
        redraw = true;
    }
    this.historyTableProvider = new HistoryTableProvider(SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION, // $NON-NLS-1$
    "SVNHistoryPage");
    this.historyTableProvider.setRemoteResource(remoteResource);
    this.historyTableProvider.setProjectProperties(this.projectProperties);
    historyTableProvider.setIncludeMergeRevisions(store.getBoolean(ISVNUIConstants.PREF_INCLUDE_MERGED_REVISIONS));
    historyTableProvider.setIncludeTags(includeTags);
    historyTableProvider.setIncludeBugs(includeBugs);
    this.tableHistoryViewer = historyTableProvider.createTable(tableParent);
    if (redraw) {
        tableParent.layout(true);
        tableParent.redraw();
    }
    this.tableHistoryViewer.getTable().addKeyListener(this);
    // set the content provider for the table
    this.tableHistoryViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            // Short-circuit to optimize
            if (entries != null)
                return entries;
            if (!(inputElement instanceof ISVNRemoteResource))
                return null;
            final ISVNRemoteResource remoteResource = (ISVNRemoteResource) inputElement;
            int entriesToFetch = store.getInt(ISVNUIConstants.PREF_LOG_ENTRIES_TO_FETCH);
            // If we are filtering by revision range, override entries to fetch.
            if (historySearchDialog != null && !historySearchDialog.getSearchAllLogs()) {
                if (historySearchDialog.getStartRevision() != null || historySearchDialog.getEndRevision() != null) {
                    if (getClearSearchAction().isEnabled())
                        entriesToFetch = 0;
                }
            }
            if (entriesToFetch > 0)
                fetchLogEntriesJob = new FetchLogEntriesJob();
            else
                fetchLogEntriesJob = new FetchAllLogEntriesJob();
            if (fetchLogEntriesJob.getState() != Job.NONE) {
                fetchLogEntriesJob.cancel();
                try {
                    fetchLogEntriesJob.join();
                } catch (InterruptedException e) {
                    SVNUIPlugin.log(new SVNException(Policy.bind("HistoryView.errorFetchingEntries", remoteResource.getName()), // $NON-NLS-1$
                    e));
                }
            }
            fetchLogEntriesJob.setRemoteFile(remoteResource);
            IWorkbenchWindow window = SVNUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow();
            if (window.getActivePage() != null && window.getActivePage().getActivePart() != null && window.getActivePage().getActivePart().getSite() != null) {
                Utils.schedule(fetchLogEntriesJob, window.getActivePage().getActivePart().getSite());
            } else {
                Utils.schedule(fetchLogEntriesJob, null);
            }
            return new Object[0];
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            entries = null;
            lastEntry = null;
            revisionStart = SVNRevision.HEAD;
        }
    });
    // set the selectionchanged listener for the table
    // updates the comments and affected paths when selection changes
    this.tableHistoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        private ILogEntry currentLogEntry;

        private int currentSelectionSize = -1;

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            ILogEntry logEntry = getLogEntry((IStructuredSelection) selection);
            if (logEntry != currentLogEntry || ((IStructuredSelection) selection).size() != currentSelectionSize) {
                this.currentLogEntry = logEntry;
                this.currentSelectionSize = ((IStructuredSelection) selection).size();
                updatePanels(selection);
            }
            SVNHistoryPage.this.selection = selection;
        }
    });
    // Double click open action
    this.tableHistoryViewer.getTable().addListener(SWT.DefaultSelection, new Listener() {

        public void handleEvent(Event e) {
            if (toggleCompareToPreviousAction.isChecked()) {
                getCompareWithPreviousAction().run();
            } else {
                getOpenRemoteFileAction().run();
            }
        }
    });
    // Contribute actions to popup menu for the table
    {
        MenuManager menuMgr = new MenuManager();
        Menu menu = menuMgr.createContextMenu(tableHistoryViewer.getTable());
        menuMgr.addMenuListener(new IMenuListener() {

            public void menuAboutToShow(IMenuManager menuMgr) {
                fillTableMenu(menuMgr);
            }
        });
        menuMgr.setRemoveAllWhenShown(true);
        tableHistoryViewer.getTable().setMenu(menu);
        getHistoryPageSite().getPart().getSite().registerContextMenu(menuMgr, tableHistoryViewer);
    }
    if (redraw) {
        parent.layout(true);
        parent.redraw();
    }
}
Also used : Listener(org.eclipse.swt.widgets.Listener) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) IResourceStateChangeListener(org.tigris.subversion.subclipse.core.IResourceStateChangeListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) KeyListener(org.eclipse.swt.events.KeyListener) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SourceViewer(org.eclipse.jface.text.source.SourceViewer) TextViewer(org.eclipse.jface.text.TextViewer) TableViewer(org.eclipse.jface.viewers.TableViewer) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) ITextViewer(org.eclipse.jface.text.ITextViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) SVNException(org.tigris.subversion.subclipse.core.SVNException) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) ISelection(org.eclipse.jface.viewers.ISelection) Menu(org.eclipse.swt.widgets.Menu) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IMenuListener(org.eclipse.jface.action.IMenuListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) IMenuManager(org.eclipse.jface.action.IMenuManager)

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