Search in sources :

Example 66 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project dbeaver by serge-rider.

the class DatabaseDebugDetailPane method display.

@Override
public void display(IStructuredSelection selection) {
    // clear status line
    IStatusLineManager statusLine = ActionBars.extractStatusLineManager(partSite);
    if (statusLine != null) {
        statusLine.setErrorMessage(null);
    }
    EDITOR editor = getEditor();
    Object input = null;
    if (selection != null && selection.size() == 1) {
        input = selection.getFirstElement();
    // update even if the same in case attributes have changed
    }
    try {
        editor.setInput(input);
    } catch (CoreException e) {
        log.log(e.getStatus());
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager)

Example 67 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project dbeaver by serge-rider.

the class BaseBrowserView method createBrowser.

private Browser createBrowser(Composite parent, final IActionBars actionBars) {
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    parent.setLayout(gridLayout);
    browser = new Browser(parent, SWT.NONE);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    browser.setLayoutData(data);
    browser.addProgressListener(new ProgressAdapter() {

        IProgressMonitor monitor = actionBars.getStatusLineManager().getProgressMonitor();

        boolean working = false;

        int workedSoFar;

        @Override
        public void changed(ProgressEvent event) {
            if (event.total == 0)
                return;
            if (!working) {
                if (event.current == event.total)
                    return;
                // $NON-NLS-1$
                monitor.beginTask("", event.total);
                workedSoFar = 0;
                working = true;
            }
            monitor.worked(event.current - workedSoFar);
            workedSoFar = event.current;
        }

        @Override
        public void completed(ProgressEvent event) {
            monitor.done();
            working = false;
        }
    });
    browser.addStatusTextListener(new StatusTextListener() {

        IStatusLineManager status = actionBars.getStatusLineManager();

        @Override
        public void changed(StatusTextEvent event) {
            status.setMessage(event.text);
        }
    });
    browser.addLocationListener(new LocationAdapter() {

        @Override
        public void changed(LocationEvent event) {
            backAction.setEnabled(browser.isBackEnabled());
            forwardAction.setEnabled(browser.isForwardEnabled());
        // if (event.top)
        // location.setText(event.location);
        }
    });
    browser.addTitleListener(new TitleListener() {

        @Override
        public void changed(TitleEvent event) {
            setPartName(event.title);
        }
    });
    /*
        browser.addOpenWindowListener(new OpenWindowListener() {
            public void open(WindowEvent event) {
                BaseBrowserView.this.openWindow(event);
            }
        });
*/
    // TODO: should handle VisibilityWindowListener.show and .hide events
    browser.addCloseWindowListener(new CloseWindowListener() {

        @Override
        public void close(WindowEvent event) {
            BaseBrowserView.this.close();
        }
    });
    /*
        location.addSelectionListener(new SelectionAdapter() {
            public void widgetDefaultSelected(SelectionEvent e) {
                browser.setUrl(location.getText());
            }
        });
*/
    // Hook the navigation actons as handlers for the retargetable actions
    // defined in BrowserActionBuilder.
    // $NON-NLS-1$
    actionBars.setGlobalActionHandler("back", backAction);
    // $NON-NLS-1$
    actionBars.setGlobalActionHandler("forward", forwardAction);
    // $NON-NLS-1$
    actionBars.setGlobalActionHandler("stop", stopAction);
    // $NON-NLS-1$
    actionBars.setGlobalActionHandler("refresh", refreshAction);
    IToolBarManager toolBarManager = actionBars.getToolBarManager();
    toolBarManager.add(backAction);
    toolBarManager.add(forwardAction);
    toolBarManager.add(stopAction);
    toolBarManager.add(refreshAction);
    backAction.setEnabled(false);
    forwardAction.setEnabled(false);
    return browser;
}
Also used : IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IToolBarManager(org.eclipse.jface.action.IToolBarManager) GridData(org.eclipse.swt.layout.GridData)

Example 68 with IStatusLineManager

use of org.eclipse.jface.action.IStatusLineManager in project yamcs-studio by yamcs.

the class OPIEditor method configureGraphicalViewer.

@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    var viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
    viewer.setEditPartFactory(new WidgetEditPartFactory(ExecutionMode.EDIT_MODE));
    ScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart() {

        @Override
        public Object getAdapter(@SuppressWarnings("rawtypes") final Class key) {
            if (key == AutoexposeHelper.class) {
                return new ViewportAutoexposeHelper(this);
            }
            return super.getAdapter(key);
        }
    };
    // set clipping strategy for connection layer of connection can be hide
    // when its source or target is not showing.
    var connectionLayer = (ConnectionLayer) root.getLayer(LayerConstants.CONNECTION_LAYER);
    connectionLayer.setClippingStrategy(new PatchedConnectionLayerClippingStrategy(connectionLayer));
    viewer.setRootEditPart(root);
    viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler()));
    ContextMenuProvider cmProvider = new OPIEditorContextMenuProvider(viewer, getActionRegistry());
    viewer.setContextMenu(cmProvider);
    getSite().registerContextMenu(cmProvider, viewer);
    // Grid Action
    IAction action = new ToggleGridAction(getGraphicalViewer()) {

        @Override
        public boolean isChecked() {
            return getDisplayModel().isShowGrid();
        }

        @Override
        public void run() {
            getCommandStack().execute(new SetWidgetPropertyCommand(displayModel, DisplayModel.PROP_SHOW_GRID, !isChecked()));
        }
    };
    getActionRegistry().registerAction(action);
    // Ruler Action
    configureRuler();
    action = new ToggleRulerVisibilityAction(getGraphicalViewer()) {

        @Override
        public boolean isChecked() {
            return getDisplayModel().isShowRuler();
        }

        @Override
        public void run() {
            getCommandStack().execute(new SetWidgetPropertyCommand(displayModel, DisplayModel.PROP_SHOW_RULER, !isChecked()));
        }
    };
    getActionRegistry().registerAction(action);
    // Snap to Geometry Action
    IAction geometryAction = new ToggleSnapToGeometryAction(getGraphicalViewer()) {

        @Override
        public boolean isChecked() {
            return getDisplayModel().isSnapToGeometry();
        }

        @Override
        public void run() {
            getCommandStack().execute(new SetWidgetPropertyCommand(displayModel, DisplayModel.PROP_SNAP_GEOMETRY, !isChecked()));
        }
    };
    getActionRegistry().registerAction(geometryAction);
    // configure zoom actions
    var zm = root.getZoomManager();
    if (zm != null) {
        List<String> zoomLevels = new ArrayList<>(3);
        zoomLevels.add(ZoomManager.FIT_ALL);
        zoomLevels.add(ZoomManager.FIT_WIDTH);
        zoomLevels.add(ZoomManager.FIT_HEIGHT);
        zm.setZoomLevelContributions(zoomLevels);
        zm.setZoomLevels(createZoomLevels());
        IAction zoomIn = new ZoomInAction(zm);
        IAction zoomOut = new ZoomOutAction(zm);
        getActionRegistry().registerAction(zoomIn);
        getActionRegistry().registerAction(zoomOut);
    }
    /* scroll-wheel zoom */
    getGraphicalViewer().setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    // status line listener
    getGraphicalViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        private IStatusLineManager statusLine = ((ActionBarContributor) getEditorSite().getActionBarContributor()).getActionBars().getStatusLineManager();

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateStatusLine(statusLine);
        }
    });
}
Also used : ToggleSnapToGeometryAction(org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction) WidgetEditPartFactory(org.csstudio.opibuilder.editparts.WidgetEditPartFactory) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ArrayList(java.util.ArrayList) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ViewportAutoexposeHelper(org.eclipse.gef.editparts.ViewportAutoexposeHelper) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) IAction(org.eclipse.jface.action.IAction) RunOPIAction(org.csstudio.opibuilder.actions.RunOPIAction) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) ToggleGridAction(org.eclipse.gef.ui.actions.ToggleGridAction) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ToggleRulerVisibilityAction(org.eclipse.gef.ui.actions.ToggleRulerVisibilityAction) ConnectionLayer(org.eclipse.draw2d.ConnectionLayer) SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) PatchedConnectionLayerClippingStrategy(org.csstudio.opibuilder.runmode.PatchedConnectionLayerClippingStrategy)

Aggregations

IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)68 IToolBarManager (org.eclipse.jface.action.IToolBarManager)33 IActionBars (org.eclipse.ui.IActionBars)33 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)32 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)31 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)31 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)30 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)30 IMenuManager (org.eclipse.jface.action.IMenuManager)30 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)30 Composite (org.eclipse.swt.widgets.Composite)30 ContentOutlinePage (org.eclipse.ui.views.contentoutline.ContentOutlinePage)30 IContentOutlinePage (org.eclipse.ui.views.contentoutline.IContentOutlinePage)30 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IContributionItem (org.eclipse.jface.action.IContributionItem)4 ArrayList (java.util.ArrayList)3 IFile (org.eclipse.core.resources.IFile)3 IAction (org.eclipse.jface.action.IAction)3 StatusLineContributionItem (org.eclipse.jface.action.StatusLineContributionItem)3