Search in sources :

Example 11 with GraphicalViewer

use of org.eclipse.gef.GraphicalViewer in project cubrid-manager by CUBRID.

the class MonitorDashboardEditor method configureGraphicalViewer.

/**
	 * @see org.eclipse.gef.ui.parts.GraphicalEditor.configureGraphicalViewer
	 */
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();
    ScalableFreeformRootEditPart rootEditPart = new ScalableFreeformRootEditPart();
    viewer.setRootEditPart(rootEditPart);
    viewer.setEditPartFactory(new MonitorEditPartFacotry());
    ZoomManager manager = rootEditPart.getZoomManager();
    double[] zoomLevels = new double[] { 1.0, 1.2, 1.4, 1.6, 1.8, 2.0 };
    manager.setZoomLevels(zoomLevels);
    getActionRegistry().registerAction(new ZoomInAction(manager));
    getActionRegistry().registerAction(new ZoomOutAction(manager));
    KeyHandler keyHandler = new GefViewerKeyHandler(viewer);
    keyHandler.put(KeyStroke.getReleased('', 97, SWT.CONTROL), getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
    keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
    viewer.setKeyHandler(keyHandler);
    //initialize context menu
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        /**
			 * get menus to show.
			 * 
			 * @param manager IMenuManager
			 */
        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) getGraphicalViewer().getSelection();
            String[] ids = new String[] {};
            if (null == selection || selection.isEmpty() || selection.getFirstElement() instanceof DashboardPart) {
                manager.add(getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
                ids = new String[] { AddHostMonitorAction.ID, SEPARATOR, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof HostMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteHostMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, //HARoleChangeAction.ID, SEPARATOR,
                HostDashboardHistoryAction.ID, AddDatabaseMonitorAction.ID, AddBrokerMonitorAction.ID, SEPARATOR, HideHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof DatabaseMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteDatabaseMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, DbDashboardHistoryAction.ID, OpenApplyLogDBLogAction.ID, OpenCopyLogDBLogAction.ID, OpenDatabaseLogAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof BrokerMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteBrokerMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, ShowBrokerClientAction.ID, ShowBrokerDabaseAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof ClientMonitorPart) {
                ids = new String[] { EditAliasNameAction.ID };
            } else if (selection.getFirstElement() instanceof BrokerDBListMonitorPart) {
                ids = new String[] { EditAliasNameAction.ID };
            }
            for (String id : ids) {
                if (id.equals(SEPARATOR)) {
                    manager.add(new Separator());
                } else {
                    IAction action = ActionManager.getInstance().getAction(id);
                    ((ISelectionAction) action).setSelectionProvider(getGraphicalViewer());
                    ActionManager.addActionToManager(manager, action);
                }
            }
            manager.update(true);
        }
    });
    viewer.setContextMenu(menuManager);
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) BrokerDBListMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerDBListMonitorPart) IAction(org.eclipse.jface.action.IAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) BrokerMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart) IMenuListener(org.eclipse.jface.action.IMenuListener) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ClientMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.ClientMonitorPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart) MonitorEditPartFacotry(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.MonitorEditPartFacotry) KeyHandler(org.eclipse.gef.KeyHandler) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) Separator(org.eclipse.jface.action.Separator)

Example 12 with GraphicalViewer

use of org.eclipse.gef.GraphicalViewer in project knime-core by knime.

the class WorkflowEditor method getEditorGridX.

/*
     * ---------- end of auto-placing and auto-connecting --------------
     */
/**
 * Returns the grid horizontal spacing or the x value from the preference page, if the editor's property is not
 * set.
 *
 * @return the editors grid, or the value from the pref page (if not set in the editor)
 */
public int getEditorGridX() {
    GraphicalViewer viewer = getViewer();
    if (viewer == null) {
        return getPrefGridXSize();
    }
    Dimension grid = (Dimension) viewer.getProperty(SnapToGrid.PROPERTY_GRID_SPACING);
    if (grid != null) {
        return grid.width;
    }
    return getPrefGridXSize();
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 13 with GraphicalViewer

use of org.eclipse.gef.GraphicalViewer in project knime-core by knime.

the class WorkflowEditor method getEditorGridY.

/**
 * Returns the grid vertical spacing or the y value from the preference page, if the editor's property is not
 * set.
 *
 * @return the editors grid, or the value from the pref page (if not set in the editor)
 */
public int getEditorGridY() {
    GraphicalViewer viewer = getViewer();
    if (viewer == null) {
        return getPrefGridYSize();
    }
    Dimension grid = (Dimension) viewer.getProperty(SnapToGrid.PROPERTY_GRID_SPACING);
    if (grid != null) {
        return grid.height;
    }
    return getPrefGridYSize();
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 14 with GraphicalViewer

use of org.eclipse.gef.GraphicalViewer in project knime-core by knime.

the class WorkflowEditor method createGraphicalViewer.

/**
 * Creates the graphical viewer that is hosted in this editor and hooks
 * keyhandler and edit domain.
 *
 * @see org.eclipse.gef.ui.parts.GraphicalEditor
 *      #createGraphicalViewer(org.eclipse.swt.widgets.Composite)
 * @param parent The parent
 */
@Override
protected void createGraphicalViewer(final Composite parent) {
    IEditorSite editorSite = getEditorSite();
    GraphicalViewer viewer = new WorkflowGraphicalViewerCreator(editorSite, this.getActionRegistry()).createViewer(parent);
    // Add a listener to the static node provider
    NodeProvider.INSTANCE.addListener(this);
    // Configure the key handler
    GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer);
    KeyHandler parentKeyHandler = keyHandler.setParent(getCommonKeyHandler());
    viewer.setKeyHandler(parentKeyHandler);
    // hook the viewer into the EditDomain
    getEditDomain().addViewer(viewer);
    // activate the viewer as selection provider for Eclipse
    getSite().setSelectionProvider(viewer);
    // remember this viewer
    m_graphicalViewer = viewer;
    // load properties like grid- or node-connections settings (e.g. width, curved)
    // needs to be called before getGraphicalViewer().setContents(m_manager), since
    // the node connections are repainted on that setContents-call and the properties need
    // to be set by then
    loadProperties();
    // We already have the model - set it into the viewer
    getGraphicalViewer().setContents(m_manager);
    // add Help context
    WorkbenchHelpSystem.getInstance().setHelp(m_graphicalViewer.getControl(), "org.knime.workbench.help.flow_editor_context");
    updateEditorBackgroundColor();
    updateJobManagerDisplay();
    updateTempRemoteWorkflowMessage();
    RootEditPart rep = getGraphicalViewer().getRootEditPart();
    ((WorkflowRootEditPart) rep.getChildren().get(0)).createToolTipHelper(getSite().getShell());
    ZoomManager zm = this.getZoomManager();
    zm.setZoomLevels(ZOOM_LEVELS);
    m_zoomWheelListener = new ZoomWheelListener(zm, (FigureCanvas) getViewer().getControl());
}
Also used : FigureCanvas(org.eclipse.draw2d.FigureCanvas) GraphicalViewer(org.eclipse.gef.GraphicalViewer) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) KeyHandler(org.eclipse.gef.KeyHandler) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) IEditorSite(org.eclipse.ui.IEditorSite) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart)

Example 15 with GraphicalViewer

use of org.eclipse.gef.GraphicalViewer in project knime-core by knime.

the class WorkflowEditor method loadProperties.

/**
 * Sets the snap functionality and zoomlevel.
 */
private void loadProperties() {
    // Snap to Geometry property
    GraphicalViewer graphicalViewer = getGraphicalViewer();
    graphicalViewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, Boolean.TRUE);
    if (getWorkflowManagerUI() != null) {
        applyEditorSettingsFromWorkflowManager();
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer)

Aggregations

GraphicalViewer (org.eclipse.gef.GraphicalViewer)36 ArrayList (java.util.ArrayList)11 List (java.util.List)10 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)10 EditPart (org.eclipse.gef.EditPart)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)7 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)6 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)5 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)4 ZoomManager (org.eclipse.gef.editparts.ZoomManager)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 IProcess (org.talend.core.model.process.IProcess)4 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)4 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 Process (org.talend.designer.core.ui.editor.process.Process)4 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 PlatformObject (org.eclipse.core.runtime.PlatformObject)3