Search in sources :

Example 1 with EditDomain

use of org.eclipse.gef.EditDomain in project tdi-studio-se by Talend.

the class TalendPaletteContextMenuProvider method isComponentsTypePalette.

// public TalendPaletteContextMenuProvider() {
//
// }
protected boolean isComponentsTypePalette(ComponentCategory componentCategory) {
    if (componentCategory == null) {
        return false;
    }
    EditDomain editDomain = getPaletteViewer().getEditDomain();
    if (editDomain == null || !(editDomain instanceof DefaultEditDomain)) {
        return false;
    }
    IEditorPart editorPart = ((DefaultEditDomain) editDomain).getEditorPart();
    if (editorPart == null || !(editorPart instanceof AbstractTalendEditor)) {
        return false;
    }
    IProcess2 process = ((AbstractTalendEditor) editorPart).getProcess();
    if (process == null) {
        return false;
    }
    return componentCategory.getName().equals(process.getComponentsType());
}
Also used : EditDomain(org.eclipse.gef.EditDomain) DefaultEditDomain(org.eclipse.gef.DefaultEditDomain) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) IProcess2(org.talend.core.model.process.IProcess2) IEditorPart(org.eclipse.ui.IEditorPart) DefaultEditDomain(org.eclipse.gef.DefaultEditDomain)

Example 2 with EditDomain

use of org.eclipse.gef.EditDomain in project statecharts by Yakindu.

the class TransitionPriorityDecorationProvider method createDecorators.

@Override
public void createDecorators(IDecoratorTarget decoratorTarget) {
    EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class);
    if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) {
        EditDomain ed = editPart.getViewer().getEditDomain();
        if (!(ed instanceof DiagramEditDomain)) {
            return;
        }
        if (shouldInstall(((DiagramEditDomain) ed).getEditorPart()) && editPart instanceof TransitionEditPart) {
            IDecorator decorator = createStatusDecorator(decoratorTarget);
            decorators.add(decorator);
            decoratorTarget.installDecorator(getDecoratorKey(), decorator);
        }
    }
}
Also used : AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) TransitionEditPart(org.yakindu.sct.ui.editor.editparts.TransitionEditPart) DiagramEditDomain(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain) EditDomain(org.eclipse.gef.EditDomain) TransitionEditPart(org.yakindu.sct.ui.editor.editparts.TransitionEditPart) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) DiagramEditDomain(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) IDecorator(org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator)

Example 3 with EditDomain

use of org.eclipse.gef.EditDomain in project yamcs-studio by yamcs.

the class OPIRuntimeDelegate method createGUI.

public void createGUI(Composite parent) {
    viewer = new PatchedScrollingGraphicalViewer();
    if (displayModel != null) {
        displayModel.setOpiRuntime(opiRuntime);
        displayModel.setViewer(viewer);
    }
    ScalableFreeformRootEditPart root = new PatchedScalableFreeformRootEditPart() {

        // In Run mode, clicking the Display or container should de-select
        // all widgets.
        @Override
        public DragTracker getDragTracker(Request req) {
            return new DragEditPartsTracker(this);
        }

        @Override
        public boolean isSelectable() {
            return false;
        }
    };
    // 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.createControl(parent);
    viewer.setRootEditPart(root);
    viewer.setEditPartFactory(new WidgetEditPartFactory(ExecutionMode.RUN_MODE, site));
    // viewer.addDropTargetListener(new
    // ProcessVariableNameTransferDropPVTargetListener(viewer));
    // viewer.addDropTargetListener(new
    // TextTransferDropPVTargetListener(viewer));
    // Add drag listener will make click feel stagnant.
    // viewer.addDragSourceListener(new DragPVSourceListener(viewer));
    // this will make viewer as a selection provider
    EditDomain editDomain = new EditDomain() {

        @Override
        public void loadDefaultTool() {
            setActiveTool(new RuntimePatchedSelectionTool());
        }
    };
    editDomain.addViewer(viewer);
    // connect the CSS menu
    ContextMenuProvider cmProvider = new OPIRunnerContextMenuProvider(viewer, opiRuntime);
    viewer.setContextMenu(cmProvider);
    opiRuntime.getSite().registerContextMenu(cmProvider, viewer);
    if (displayModelFilled) {
        viewer.setContents(displayModel);
        displayModel.setViewer(viewer);
        displayModel.setOpiRuntime(opiRuntime);
        updateEditorTitle();
    }
    zoomManager = root.getZoomManager();
    if (zoomManager != null) {
        List<String> zoomLevels = new ArrayList<>(3);
        zoomLevels.add(Draw2dSingletonUtil.ZoomManager_FIT_ALL);
        zoomLevels.add(Draw2dSingletonUtil.ZoomManager_FIT_WIDTH);
        zoomLevels.add(Draw2dSingletonUtil.ZoomManager_FIT_HEIGHT);
        zoomManager.setZoomLevelContributions(zoomLevels);
        zoomManager.setZoomLevels(createZoomLevels());
    // IAction zoomIn = new ZoomInAction(zoomManager);
    // IAction zoomOut = new ZoomOutAction(zoomManager);
    // getActionRegistry().registerAction(zoomIn);
    // getActionRegistry().registerAction(zoomOut);
    }
    /* scroll-wheel zoom */
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    /*
         * When Figure instance which corresponds to RootEditPart is updated, calculate the frame rate and set the
         * measured rate to "frame_rate" property of the corresponding DisplayModel instance.
         *
         * By default, org.eclipse.draw2d.DeferredUpdateManager is used. This update manager queues update requests from
         * figures and others, and it repaints requested figures at once when GUI thread is ready to repaint.
         * notifyPainting() method of UpdateLister is called when it repaints. The frame rate is calculated based on the
         * timing of notifyPainting().
         *
         * Note that the update manager repaints only requested figures. It does not repaint all figures at once. For
         * example, if there are only two widgets in one display, these widgets might be repainted alternately. In that
         * case, the frame rate indicates the inverse of the time between the repainting of one widget and the
         * repainting of the other widget, which is different from our intuition. Thus, you have to be careful about the
         * meaning of "frame rate" calculated by the following code.
         */
    if (displayModelFilled && displayModel.isFreshRateEnabled()) {
        var updateManager = root.getFigure().getUpdateManager();
        updateManager.addUpdateListener(new UpdateListener() {

            // in milliseconds
            private long updateCycle = -1;

            private Date previousDate = null;

            @Override
            public void notifyPainting(Rectangle damage, @SuppressWarnings("rawtypes") Map dirtyRegions) {
                var currentDate = new Date();
                if (previousDate == null) {
                    previousDate = currentDate;
                    return;
                }
                synchronized (previousDate) {
                    updateCycle = currentDate.getTime() - previousDate.getTime();
                    displayModel.setFrameRate(1000.0 / updateCycle);
                    previousDate = currentDate;
                }
            }

            @Override
            public void notifyValidating() {
            // Do nothing
            }
        });
    }
}
Also used : EditDomain(org.eclipse.gef.EditDomain) WidgetEditPartFactory(org.csstudio.opibuilder.editparts.WidgetEditPartFactory) Request(org.eclipse.gef.Request) ArrayList(java.util.ArrayList) Rectangle(org.eclipse.draw2d.geometry.Rectangle) DragEditPartsTracker(org.eclipse.gef.tools.DragEditPartsTracker) ConnectionLayer(org.eclipse.draw2d.ConnectionLayer) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) Date(java.util.Date) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) UpdateListener(org.eclipse.draw2d.UpdateListener) Map(java.util.Map)

Example 4 with EditDomain

use of org.eclipse.gef.EditDomain in project archi by archimatetool.

the class RulerComposite method createRulerContainer.

private GraphicalViewer createRulerContainer(int orientation) {
    ScrollingGraphicalViewer viewer = new RulerViewer();
    final boolean isHorizontal = orientation == PositionConstants.NORTH || orientation == PositionConstants.SOUTH;
    // Finish initializing the viewer
    viewer.setRootEditPart(new RulerRootEditPart(isHorizontal));
    viewer.setEditPartFactory(new RulerEditPartFactory(diagramViewer));
    viewer.createControl(this);
    ((GraphicalEditPart) viewer.getRootEditPart()).getFigure().setBorder(new RulerBorder(isHorizontal));
    viewer.setProperty(GraphicalViewer.class.toString(), diagramViewer);
    // Configure the viewer's control
    FigureCanvas canvas = (FigureCanvas) viewer.getControl();
    canvas.setScrollBarVisibility(FigureCanvas.NEVER);
    if (font == null) {
        FontData[] data = canvas.getFont().getFontData();
        for (int i = 0; i < data.length; i++) {
            data[i].setHeight(data[i].getHeight() - 1);
        }
        font = new Font(Display.getCurrent(), data);
    }
    canvas.setFont(font);
    if (isHorizontal) {
        canvas.getViewport().setHorizontalRangeModel(editor.getViewport().getHorizontalRangeModel());
    } else {
        canvas.getViewport().setVerticalRangeModel(editor.getViewport().getVerticalRangeModel());
    }
    // Add the viewer to the rulerEditDomain
    if (rulerEditDomain == null) {
        rulerEditDomain = new EditDomain();
        rulerEditDomain.setCommandStack(diagramViewer.getEditDomain().getCommandStack());
    }
    rulerEditDomain.addViewer(viewer);
    return viewer;
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) GraphicalViewer(org.eclipse.gef.GraphicalViewer) EditDomain(org.eclipse.gef.EditDomain) FontData(org.eclipse.swt.graphics.FontData) RulerRootEditPart(org.eclipse.gef.internal.ui.rulers.RulerRootEditPart) Font(org.eclipse.swt.graphics.Font) ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) FigureCanvas(org.eclipse.draw2d.FigureCanvas) RulerEditPartFactory(org.eclipse.gef.internal.ui.rulers.RulerEditPartFactory)

Example 5 with EditDomain

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

the class SchemaDiagramPart method getEditor.

public ERSchemaEditor getEditor() {
    EditPart parentP = getParent();
    if (parentP instanceof ScalableFreeformRootEditPart) {
        ScalableFreeformRootEditPart parentEditor = (ScalableFreeformRootEditPart) parentP;
        EditPartViewer viewer = parentEditor.getViewer();
        if (viewer instanceof ValidationGraphicalViewer) {
            ValidationGraphicalViewer gViewer = (ValidationGraphicalViewer) viewer;
            EditDomain domain = gViewer.getEditDomain();
            if (domain instanceof ERSchemaEditDomain) {
                ERSchemaEditDomain erEditorDomain = (ERSchemaEditDomain) domain;
                return (ERSchemaEditor) erEditorDomain.getEditorPart();
            }
        }
    }
    return null;
}
Also used : ValidationGraphicalViewer(com.cubrid.common.ui.er.ValidationGraphicalViewer) EditDomain(org.eclipse.gef.EditDomain) ERSchemaEditDomain(com.cubrid.common.ui.er.editor.ERSchemaEditDomain) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ERSchemaEditor(com.cubrid.common.ui.er.editor.ERSchemaEditor) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) EditPart(org.eclipse.gef.EditPart) ERSchemaEditDomain(com.cubrid.common.ui.er.editor.ERSchemaEditDomain) EditPartViewer(org.eclipse.gef.EditPartViewer)

Aggregations

EditDomain (org.eclipse.gef.EditDomain)6 EditPart (org.eclipse.gef.EditPart)3 AbstractConnectionEditPart (org.eclipse.gef.editparts.AbstractConnectionEditPart)2 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)2 GraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart)2 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)2 DiagramEditDomain (org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain)2 IDecorator (org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator)2 ValidationGraphicalViewer (com.cubrid.common.ui.er.ValidationGraphicalViewer)1 ERSchemaEditDomain (com.cubrid.common.ui.er.editor.ERSchemaEditDomain)1 ERSchemaEditor (com.cubrid.common.ui.er.editor.ERSchemaEditor)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Map (java.util.Map)1 WidgetEditPartFactory (org.csstudio.opibuilder.editparts.WidgetEditPartFactory)1 ConnectionLayer (org.eclipse.draw2d.ConnectionLayer)1 FigureCanvas (org.eclipse.draw2d.FigureCanvas)1 UpdateListener (org.eclipse.draw2d.UpdateListener)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)1