Search in sources :

Example 1 with OpenAndLinkWithEditorHelper

use of org.eclipse.ui.OpenAndLinkWithEditorHelper in project eclipse.platform.text by eclipse.

the class AbstractTextSearchViewPage method createViewer.

private void createViewer(Composite parent, int layout) {
    if ((layout & FLAG_LAYOUT_FLAT) != 0) {
        TableViewer viewer = createTableViewer(parent);
        fViewer = viewer;
        configureTableViewer(viewer);
    } else if ((layout & FLAG_LAYOUT_TREE) != 0) {
        TreeViewer viewer = createTreeViewer(parent);
        fViewer = viewer;
        configureTreeViewer(viewer);
        fCollapseAllAction.setViewer(viewer);
        fExpandAllAction.setViewer(viewer);
    }
    fCopyToClipboardAction.setViewer(fViewer);
    fSelectAllAction.setViewer(fViewer);
    IToolBarManager tbm = getSite().getActionBars().getToolBarManager();
    tbm.removeAll();
    SearchView.createToolBarGroups(tbm);
    fillToolbar(tbm);
    tbm.update(false);
    new OpenAndLinkWithEditorHelper(fViewer) {

        @Override
        protected void activate(ISelection selection) {
            final int currentMode = OpenStrategy.getOpenMethod();
            try {
                OpenStrategy.setOpenMethod(OpenStrategy.DOUBLE_CLICK);
                handleOpen(new OpenEvent(fViewer, selection));
            } finally {
                OpenStrategy.setOpenMethod(currentMode);
            }
        }

        @Override
        protected void linkToEditor(ISelection selection) {
        // not supported by this part
        }

        @Override
        protected void open(ISelection selection, boolean activate) {
            handleOpen(new OpenEvent(fViewer, selection));
        }
    };
    fViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            fCurrentMatchIndex = -1;
            fRemoveSelectedMatches.setEnabled(canRemoveMatchesWith(event.getSelection()));
        }
    });
    fViewer.addSelectionChangedListener(fViewerAdapter);
    Menu menu = fMenu.createContextMenu(fViewer.getControl());
    fViewer.getControl().setMenu(menu);
    updateLayoutActions();
    getViewPart().updateLabel();
}
Also used : OpenAndLinkWithEditorHelper(org.eclipse.ui.OpenAndLinkWithEditorHelper) IToolBarManager(org.eclipse.jface.action.IToolBarManager) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISelection(org.eclipse.jface.viewers.ISelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Aggregations

IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 OpenEvent (org.eclipse.jface.viewers.OpenEvent)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Menu (org.eclipse.swt.widgets.Menu)1 OpenAndLinkWithEditorHelper (org.eclipse.ui.OpenAndLinkWithEditorHelper)1