Search in sources :

Example 1 with FreeformGraphicalRootEditPart

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

the class ERSchemaEditDomain method mouseDown.

/**
	 * the button in the para of mouseEvent, that was pressed or released; 1 for
	 * the left click, 2 for the double left-click, and 3 for the right click,
	 * etc.
	 */
public void mouseDown(MouseEvent mouseEvent, EditPartViewer viewer) {
    ERSchemaEditor erschemaEditor = (ERSchemaEditor) this.getEditorPart();
    Point location = new Point(mouseEvent.x, mouseEvent.y);
    EditPart part = erschemaEditor.getGraphicalViewer().findObjectAt(location);
    if (part != null && ((part instanceof SchemaDiagramPart) || (part instanceof FreeformGraphicalRootEditPart))) {
        if (getDefaultTool().equals(getActiveTool())) {
            setActiveTool(erDragTool);
        // when click on "FreeformGraphicalRootEditPart", its on the
        // extending space of "EXDefaultRangeModel"
        }
    }
    if (mouseEvent.button == 3 && !getDefaultTool().equals(getActiveTool())) {
        // mouseEvent.button == 3 : right click
        setActiveTool(getDefaultTool());
    }
    super.mouseDown(mouseEvent, viewer);
    if (part != null && part instanceof SchemaDiagramPart) {
        erschemaEditor.setAllFiguresOrigin();
    }
}
Also used : SchemaDiagramPart(com.cubrid.common.ui.er.part.SchemaDiagramPart) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart) EditPart(org.eclipse.gef.EditPart) Point(org.eclipse.draw2d.geometry.Point) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)

Example 2 with FreeformGraphicalRootEditPart

use of org.eclipse.gef.editparts.FreeformGraphicalRootEditPart in project dbeaver by dbeaver.

the class LockGraphicalView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    setEditDomain(new DefaultEditDomain(null));
    setGraphicalViewer(new ScrollingGraphicalViewer());
    getGraphicalViewer().createControl(parent);
    getGraphicalViewer().setRootEditPart(new FreeformGraphicalRootEditPart());
    getGraphicalViewer().setEditPartFactory(new LockGraphEditPartFactory());
    getGraphicalViewer().setContextMenu(new ContextMenuProvider(graphicalViewer) {

        @Override
        public void buildContextMenu(IMenuManager menu) {
            menu.add(viewer.getKillAction());
        }
    });
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart) IMenuManager(org.eclipse.jface.action.IMenuManager) DefaultEditDomain(org.eclipse.gef.DefaultEditDomain) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider)

Example 3 with FreeformGraphicalRootEditPart

use of org.eclipse.gef.editparts.FreeformGraphicalRootEditPart in project archi by archimatetool.

the class DiagramUtils method createViewer.

/**
 * Create a GraphicalViewerImpl to show the model. The Viewer has no Scroll Bars
 * @param model
 * @return A Graphical Viewer
 */
public static GraphicalViewerImpl createViewer(IDiagramModel model, Composite parent) {
    EditPartFactory editPartFactory = null;
    if (model instanceof IArchimateDiagramModel) {
        editPartFactory = new ArchimateDiagramEditPartFactory();
    } else if (model instanceof ISketchModel) {
        editPartFactory = new SketchEditPartFactory();
    } else {
        // Extensions
        IDiagramEditorFactory factory = DiagramEditorFactoryExtensionHandler.INSTANCE.getFactory(model);
        if (factory != null) {
            editPartFactory = factory.createEditPartFactory();
        }
    }
    if (editPartFactory == null) {
        // $NON-NLS-1$
        throw new RuntimeException("Unsupported model type");
    }
    GraphicalViewerImpl viewer = new GraphicalViewerImpl();
    viewer.createControl(parent);
    viewer.setEditPartFactory(editPartFactory);
    RootEditPart rootPart = new FreeformGraphicalRootEditPart();
    viewer.setRootEditPart(rootPart);
    viewer.setContents(model);
    viewer.flush();
    return viewer;
}
Also used : IDiagramEditorFactory(com.archimatetool.editor.diagram.IDiagramEditorFactory) ArchimateDiagramEditPartFactory(com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory) GraphicalViewerImpl(org.eclipse.gef.ui.parts.GraphicalViewerImpl) SketchEditPartFactory(com.archimatetool.editor.diagram.sketch.editparts.SketchEditPartFactory) SketchEditPartFactory(com.archimatetool.editor.diagram.sketch.editparts.SketchEditPartFactory) EditPartFactory(org.eclipse.gef.EditPartFactory) ArchimateDiagramEditPartFactory(com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart) ISketchModel(com.archimatetool.model.ISketchModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) RootEditPart(org.eclipse.gef.RootEditPart) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)

Example 4 with FreeformGraphicalRootEditPart

use of org.eclipse.gef.editparts.FreeformGraphicalRootEditPart in project archi by archimatetool.

the class DiagramUtilsTests method testCreateViewer_SketchModel.

@Test
public void testCreateViewer_SketchModel() {
    IDiagramModel dm = model.getDiagramModels().get(1);
    assertTrue(dm instanceof ISketchModel);
    Shell shell = new Shell();
    GraphicalViewerImpl viewer = DiagramUtils.createViewer(dm, shell);
    assertNotNull(viewer);
    assertTrue(viewer.getEditPartFactory() instanceof SketchEditPartFactory);
    assertTrue(viewer.getRootEditPart() instanceof FreeformGraphicalRootEditPart);
    assertSame(dm, viewer.getContents().getModel());
    assertSame(shell, viewer.getControl().getShell());
    shell.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IDiagramModel(com.archimatetool.model.IDiagramModel) GraphicalViewerImpl(org.eclipse.gef.ui.parts.GraphicalViewerImpl) SketchEditPartFactory(com.archimatetool.editor.diagram.sketch.editparts.SketchEditPartFactory) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart) ISketchModel(com.archimatetool.model.ISketchModel) Test(org.junit.Test)

Example 5 with FreeformGraphicalRootEditPart

use of org.eclipse.gef.editparts.FreeformGraphicalRootEditPart in project archi by archimatetool.

the class DiagramUtilsTests method testCreateViewer_ArchimateModel.

@Test
public void testCreateViewer_ArchimateModel() {
    IDiagramModel dm = model.getDiagramModels().get(0);
    assertTrue(dm instanceof IArchimateDiagramModel);
    Shell shell = new Shell();
    GraphicalViewerImpl viewer = DiagramUtils.createViewer(dm, shell);
    assertNotNull(viewer);
    assertTrue(viewer.getEditPartFactory() instanceof ArchimateDiagramEditPartFactory);
    assertTrue(viewer.getRootEditPart() instanceof FreeformGraphicalRootEditPart);
    assertSame(dm, viewer.getContents().getModel());
    assertSame(shell, viewer.getControl().getShell());
    shell.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ArchimateDiagramEditPartFactory(com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory) IDiagramModel(com.archimatetool.model.IDiagramModel) GraphicalViewerImpl(org.eclipse.gef.ui.parts.GraphicalViewerImpl) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Aggregations

FreeformGraphicalRootEditPart (org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)6 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)3 ArchimateDiagramEditPartFactory (com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory)2 SketchEditPartFactory (com.archimatetool.editor.diagram.sketch.editparts.SketchEditPartFactory)2 IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)2 IDiagramModel (com.archimatetool.model.IDiagramModel)2 ISketchModel (com.archimatetool.model.ISketchModel)2 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)2 DefaultEditDomain (org.eclipse.gef.DefaultEditDomain)2 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 Shell (org.eclipse.swt.widgets.Shell)2 Test (org.junit.Test)2 IDiagramEditorFactory (com.archimatetool.editor.diagram.IDiagramEditorFactory)1 SchemaDiagramPart (com.cubrid.common.ui.er.part.SchemaDiagramPart)1 Point (org.eclipse.draw2d.geometry.Point)1 EditPart (org.eclipse.gef.EditPart)1 EditPartFactory (org.eclipse.gef.EditPartFactory)1 RootEditPart (org.eclipse.gef.RootEditPart)1