Search in sources :

Example 16 with ConnectionLayer

use of org.eclipse.draw2d.ConnectionLayer 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)

Example 17 with ConnectionLayer

use of org.eclipse.draw2d.ConnectionLayer in project whole by wholeplatform.

the class AbstractConnectedFreeformRootPart method setConnectionRouter.

public void setConnectionRouter(ConnectionRouter router) {
    ConnectionLayer connLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    connLayer.setConnectionRouter(router);
}
Also used : ConnectionLayer(org.eclipse.draw2d.ConnectionLayer)

Example 18 with ConnectionLayer

use of org.eclipse.draw2d.ConnectionLayer in project archi by archimatetool.

the class AbstractDiagramPart method setConnectionRouter.

/**
 * Set Connection Router type for the whole diagram
 */
protected void setConnectionRouter(boolean withAnimation) {
    // Animation
    if (withAnimation && AnimationUtil.doAnimate()) {
        Animation.markBegin();
    }
    ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    switch(getModel().getConnectionRouterType()) {
        case IDiagramModel.CONNECTION_ROUTER_MANHATTAN:
            cLayer.setConnectionRouter(new ManhattanConnectionRouter());
            break;
        case IDiagramModel.CONNECTION_ROUTER_BENDPOINT:
        default:
            AutomaticRouter router = new FanRouter();
            router.setNextRouter(new BendpointConnectionRouter());
            cLayer.setConnectionRouter(router);
            break;
    }
    if (withAnimation && AnimationUtil.doAnimate()) {
        Animation.run(AnimationUtil.animationSpeed());
    }
}
Also used : AutomaticRouter(org.eclipse.draw2d.AutomaticRouter) BendpointConnectionRouter(org.eclipse.draw2d.BendpointConnectionRouter) ManhattanConnectionRouter(org.eclipse.draw2d.ManhattanConnectionRouter) FanRouter(org.eclipse.draw2d.FanRouter) ConnectionLayer(org.eclipse.draw2d.ConnectionLayer)

Example 19 with ConnectionLayer

use of org.eclipse.draw2d.ConnectionLayer in project archi by archimatetool.

the class AbstractDiagramPart method setAntiAlias.

protected void setAntiAlias() {
    ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
    // Anti-aliasing
    cLayer.setAntialias(ArchiPlugin.PREFERENCES.getBoolean(IPreferenceConstants.ANTI_ALIAS) ? SWT.ON : SWT.DEFAULT);
}
Also used : ConnectionLayer(org.eclipse.draw2d.ConnectionLayer)

Example 20 with ConnectionLayer

use of org.eclipse.draw2d.ConnectionLayer 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

ConnectionLayer (org.eclipse.draw2d.ConnectionLayer)21 FanRouter (org.eclipse.draw2d.FanRouter)5 ArrayList (java.util.ArrayList)3 BendpointConnectionRouter (org.eclipse.draw2d.BendpointConnectionRouter)3 FreeformLayer (org.eclipse.draw2d.FreeformLayer)3 FreeformLayeredPane (org.eclipse.draw2d.FreeformLayeredPane)3 ManhattanConnectionRouter (org.eclipse.draw2d.ManhattanConnectionRouter)3 ShortestPathConnectionRouter (org.eclipse.draw2d.ShortestPathConnectionRouter)3 Control (org.eclipse.swt.widgets.Control)3 WidgetEditPartFactory (org.csstudio.opibuilder.editparts.WidgetEditPartFactory)2 AutomaticRouter (org.eclipse.draw2d.AutomaticRouter)2 IFigure (org.eclipse.draw2d.IFigure)2 Layer (org.eclipse.draw2d.Layer)2 LayeredPane (org.eclipse.draw2d.LayeredPane)2 ScalableFreeformLayeredPane (org.eclipse.draw2d.ScalableFreeformLayeredPane)2 StackLayout (org.eclipse.draw2d.StackLayout)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)2 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)2 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)2