Search in sources :

Example 1 with ErDiagramItemDeleteAction

use of org.talend.sqlbuilder.erdiagram.ui.actions.ErDiagramItemDeleteAction in project tdi-studio-se by Talend.

the class ErDiagramMenuProvider method buildContextMenu.

@Override
public void buildContextMenu(IMenuManager menu) {
    menu.add(new Separator(RELATION));
    menu.add(new Separator(GEFActionConstants.GROUP_EDIT));
    IAction action;
    action = getAction(ActionFactory.DELETE.getId());
    ((ErDiagramItemDeleteAction) action).update();
    if (action.isEnabled()) {
        menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    }
    CreateRelationAction createRelation;
    createRelation = new CreateRelationAction(part);
    createRelation.update();
    if (createRelation.isEnabled()) {
        menu.add(createRelation);
    }
    TableAddAction addAction = new TableAddAction(part);
    addAction.update();
    menu.add(addAction);
}
Also used : TableAddAction(org.talend.sqlbuilder.erdiagram.ui.actions.TableAddAction) IAction(org.eclipse.jface.action.IAction) ErDiagramItemDeleteAction(org.talend.sqlbuilder.erdiagram.ui.actions.ErDiagramItemDeleteAction) CreateRelationAction(org.talend.sqlbuilder.erdiagram.ui.actions.CreateRelationAction) Separator(org.eclipse.jface.action.Separator)

Example 2 with ErDiagramItemDeleteAction

use of org.talend.sqlbuilder.erdiagram.ui.actions.ErDiagramItemDeleteAction 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)

Aggregations

IAction (org.eclipse.jface.action.IAction)2 ErDiagramItemDeleteAction (org.talend.sqlbuilder.erdiagram.ui.actions.ErDiagramItemDeleteAction)2 Dimension (org.eclipse.draw2d.geometry.Dimension)1 ContextMenuProvider (org.eclipse.gef.ContextMenuProvider)1 ToggleGridAction (org.eclipse.gef.ui.actions.ToggleGridAction)1 ToggleSnapToGeometryAction (org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction)1 GraphicalViewerKeyHandler (org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler)1 ScrollingGraphicalViewer (org.eclipse.gef.ui.parts.ScrollingGraphicalViewer)1 Separator (org.eclipse.jface.action.Separator)1 CreateRelationAction (org.talend.sqlbuilder.erdiagram.ui.actions.CreateRelationAction)1 TableAddAction (org.talend.sqlbuilder.erdiagram.ui.actions.TableAddAction)1