Search in sources :

Example 11 with ScrollingGraphicalViewer

use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project tdi-studio-se by Talend.

the class ErdiagramDiagramEditor method configureGraphicalViewer.

//$NON-NLS-1$
@SuppressWarnings("unchecked")
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
    ErDiagramRootEditPart root = new ErDiagramRootEditPart();
    IAction deleteAction = new ErDiagramItemDeleteAction(this);
    getActionRegistry().registerAction(deleteAction);
    getSelectionActions().add(deleteAction.getId());
    viewer.setRootEditPart(root);
    ErDiagramPartFactory partFactory = new ErDiagramPartFactory();
    // set the factory to use for creating EditParts for elements in the
    // model
    getGraphicalViewer().setEditPartFactory(partFactory);
    getGraphicalViewer().setKeyHandler(new GraphicalViewerKeyHandler(getGraphicalViewer()).setParent(getCommonKeyHandler()));
    /** * Management of the context menu ** */
    ContextMenuProvider cmProvider = new ErDiagramMenuProvider(this, viewer, getActionRegistry());
    viewer.setContextMenu(cmProvider);
    /** * Snap To Grid ** */
    // Grid properties
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(GRID_SIZE, GRID_SIZE));
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(true));
    // We keep grid visibility and enablement in sync
    getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(true));
    IAction showGrid = new ToggleGridAction(getGraphicalViewer());
    getActionRegistry().registerAction(showGrid);
    /** * Snap To Geometry ** */
    getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, new Boolean(false));
    IAction snapAction = new ToggleSnapToGeometryAction(getGraphicalViewer());
    getActionRegistry().registerAction(snapAction);
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) ToggleSnapToGeometryAction(org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction) IAction(org.eclipse.jface.action.IAction) ErDiagramItemDeleteAction(org.talend.sqlbuilder.erdiagram.ui.actions.ErDiagramItemDeleteAction) ToggleGridAction(org.eclipse.gef.ui.actions.ToggleGridAction) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) Dimension(org.eclipse.draw2d.geometry.Dimension) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider)

Example 12 with ScrollingGraphicalViewer

use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project knime-core by knime.

the class AbstractNodeAction method getAllObjects.

/**
 * @return all objects of the selected editor site.
 */
protected List getAllObjects() {
    ScrollingGraphicalViewer provider = (ScrollingGraphicalViewer) m_editor.getEditorSite().getSelectionProvider();
    if (provider == null) {
        return Collections.EMPTY_LIST;
    }
    // get parent of the node parts
    EditPart editorPart = (EditPart) provider.getRootEditPart().getChildren().get(0);
    return editorPart.getChildren();
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) EditPart(org.eclipse.gef.EditPart)

Example 13 with ScrollingGraphicalViewer

use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project knime-core by knime.

the class WorkflowGraphicalViewerCreator method createViewer.

/**
 * Creates the viewer control, and connect it to a root edit part Additionally the viewer gets the edit part factory
 * and a drop-listener.
 *
 * @param parent Parent composite
 * @return The viewer
 */
protected GraphicalViewer createViewer(final Composite parent) {
    ScrollingGraphicalViewer viewer = new ScrollingGraphicalViewer();
    viewer.createControl(parent);
    // configure the m_viewer
    viewer.getControl().setBackground(ColorConstants.white);
    ScalableFreeformRootEditPart part = new ConnectionSelectingScalableFreeformRootEditPart();
    viewer.setRootEditPart(part);
    viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));
    // Add drop listeners
    viewer.addDropTargetListener(new NodeDropTargetListener(viewer));
    viewer.addDropTargetListener(new MetaNodeDropTargetListener(viewer));
    viewer.addDropTargetListener(new WorkflowEditorFileDropTargetListener(viewer));
    viewer.addDropTargetListener(new WorkflowEditorSelectionDropListener(viewer));
    // DO NOT Add drag listener
    /* Don't add any drag listener here. Processing of drag events seems
         * to influence GEF events (resize, node move, create connection).
         * See bug 2844 for details (linux only) */
    MetaNodeTemplateDropTargetListener metaNodeTemplateDropListener = new MetaNodeTemplateDropTargetListener(viewer);
    viewer.addDropTargetListener(metaNodeTemplateDropListener);
    // configure context menu
    viewer.setContextMenu(new WorkflowContextMenuProvider(m_actionRegistry, viewer));
    m_editorSite.registerContextMenu(viewer.getContextMenu(), viewer, false);
    // set the factory that is able to create the edit parts to be
    // used in the viewer
    viewer.setEditPartFactory(new WorkflowEditPartFactory());
    return viewer;
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler)

Example 14 with ScrollingGraphicalViewer

use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project knime-core by knime.

the class AutoLayoutAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public synchronized void runOnNodes(final NodeContainerEditPart[] parts) {
    ScrollingGraphicalViewer provider = (ScrollingGraphicalViewer) getEditor().getEditorSite().getSelectionProvider();
    if (provider == null) {
        return;
    }
    ArrayList<NodeContainerUI> nodes = null;
    if (parts != null && parts.length > 0) {
        nodes = new ArrayList<NodeContainerUI>(parts.length);
        for (NodeContainerEditPart p : parts) {
            nodes.add(p.getNodeContainer());
        }
    }
    AutoLayoutCommand alc = new AutoLayoutCommand(getManager(), nodes);
    // enables undo
    getCommandStack().execute(alc);
    // update the actions
    getEditor().updateActions();
    // Give focus to the editor again. Otherwise the actions (selection)
    // is not updated correctly.
    getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AutoLayoutCommand(org.knime.workbench.ui.layout.commands.AutoLayoutCommand)

Example 15 with ScrollingGraphicalViewer

use of org.eclipse.gef.ui.parts.ScrollingGraphicalViewer in project webtools.sourceediting by eclipse.

the class RootEditPart method activate.

public void activate() {
    super.activate();
    // Set up Connection layer with a router, if it doesn't already have one
    ConnectionLayer connectionLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    if (connectionLayer != null) {
        connectionLayer.setConnectionRouter(new BendpointConnectionRouter());
    }
    Figure figure = (Figure) getLayer(LayerConstants.FEEDBACK_LAYER);
    if (figure != null) {
        if (getViewer() instanceof ScrollingGraphicalViewer) {
        // ScrollingGraphicalViewer sgv = (ScrollingGraphicalViewer)getViewer();
        // IndexFigure indexFigure = new IndexFigure(sgv);
        // figure.add(indexFigure);
        // getViewer().addPropertyChangeListener(indexFigure);
        }
    }
    refresh();
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) BendpointConnectionRouter(org.eclipse.draw2d.BendpointConnectionRouter) ConnectionLayer(org.eclipse.draw2d.ConnectionLayer) IFigure(org.eclipse.draw2d.IFigure) Figure(org.eclipse.draw2d.Figure) RectangleFigure(org.eclipse.draw2d.RectangleFigure)

Aggregations

ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)18 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)6 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)5 GraphicalViewerKeyHandler (org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler)5 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)4 Dimension (org.eclipse.draw2d.geometry.Dimension)3 ToggleGridAction (org.eclipse.gef.ui.actions.ToggleGridAction)3 ToggleSnapToGeometryAction (org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction)3 IAction (org.eclipse.jface.action.IAction)3 ArrayList (java.util.ArrayList)2 ConnectionLayer (org.eclipse.draw2d.ConnectionLayer)2 FigureCanvas (org.eclipse.draw2d.FigureCanvas)2 DefaultEditDomain (org.eclipse.gef.DefaultEditDomain)2 GraphicalViewer (org.eclipse.gef.GraphicalViewer)2 FreeformGraphicalRootEditPart (org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)2 ZoomInAction (org.eclipse.gef.ui.actions.ZoomInAction)2 ZoomOutAction (org.eclipse.gef.ui.actions.ZoomOutAction)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2