Search in sources :

Example 6 with DeleteAction

use of org.eclipse.gef.ui.actions.DeleteAction in project dbeaver by serge-rider.

the class ERDEditorPropertyTester method test.

@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (!(receiver instanceof ERDEditorPart)) {
        return false;
    }
    ERDEditorPart erdEditor = (ERDEditorPart) receiver;
    switch(property) {
        case PROP_CAN_UNDO:
            return erdEditor.getCommandStack().canUndo();
        case PROP_CAN_REDO:
            return erdEditor.getCommandStack().canRedo();
        case PROP_EDITABLE:
            return !erdEditor.isReadOnly();
        case PROP_CAN_DELETE:
            DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) erdEditor);
            deleteAction.update();
            return deleteAction.isEnabled();
    }
    return false;
}
Also used : ERDEditorPart(org.jkiss.dbeaver.erd.ui.editor.ERDEditorPart) DeleteAction(org.eclipse.gef.ui.actions.DeleteAction)

Example 7 with DeleteAction

use of org.eclipse.gef.ui.actions.DeleteAction in project dbeaver by dbeaver.

the class ERDEditorPropertyTester method test.

@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (!(receiver instanceof ERDEditorPart)) {
        return false;
    }
    ERDEditorPart erdEditor = (ERDEditorPart) receiver;
    switch(property) {
        case PROP_CAN_UNDO:
            return erdEditor.getCommandStack().canUndo();
        case PROP_CAN_REDO:
            return erdEditor.getCommandStack().canRedo();
        case PROP_EDITABLE:
            return !erdEditor.isReadOnly();
        case PROP_CAN_DELETE:
            DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) erdEditor);
            deleteAction.update();
            return deleteAction.isEnabled();
    }
    return false;
}
Also used : ERDEditorPart(org.jkiss.dbeaver.erd.ui.editor.ERDEditorPart) DeleteAction(org.eclipse.gef.ui.actions.DeleteAction)

Example 8 with DeleteAction

use of org.eclipse.gef.ui.actions.DeleteAction in project dbeaver by dbeaver.

the class ERDHandlerDelete method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME);
    if (control != null) {
        ERDEditorPart editor = ERDEditorAdapter.getEditor(control);
        if (editor != null && !editor.isReadOnly()) {
            DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) editor);
            deleteAction.update();
            if (deleteAction.isEnabled()) {
                deleteAction.run();
            }
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) ERDEditorPart(org.jkiss.dbeaver.erd.ui.editor.ERDEditorPart) DeleteAction(org.eclipse.gef.ui.actions.DeleteAction)

Example 9 with DeleteAction

use of org.eclipse.gef.ui.actions.DeleteAction in project archi by archimatetool.

the class GraphicalEditor method createActions.

/**
 * Creates actions for this editor. Subclasses should override this method
 * to create and register actions with the {@link ActionRegistry}.
 */
protected void createActions() {
    ActionRegistry registry = getActionRegistry();
    IAction action;
    action = new UndoAction(this);
    registry.registerAction(action);
    getStackActions().add(action.getId());
    action = new RedoAction(this);
    registry.registerAction(action);
    getStackActions().add(action.getId());
    action = new SelectAllAction(this);
    registry.registerAction(action);
    action = new DeleteAction((IWorkbenchPart) this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new SaveAction(this);
    registry.registerAction(action);
    getPropertyActions().add(action.getId());
    registry.registerAction(new PrintAction(this));
}
Also used : SaveAction(org.eclipse.gef.ui.actions.SaveAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) PrintAction(org.eclipse.gef.ui.actions.PrintAction) SelectAllAction(org.eclipse.gef.ui.actions.SelectAllAction) RedoAction(org.eclipse.gef.ui.actions.RedoAction) DeleteAction(org.eclipse.gef.ui.actions.DeleteAction) ActionRegistry(org.eclipse.gef.ui.actions.ActionRegistry) UndoAction(org.eclipse.gef.ui.actions.UndoAction)

Example 10 with DeleteAction

use of org.eclipse.gef.ui.actions.DeleteAction in project dbeaver by serge-rider.

the class ERDHandlerDelete method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Control control = (Control) HandlerUtil.getVariable(event, ISources.ACTIVE_FOCUS_CONTROL_NAME);
    if (control != null) {
        ERDEditorPart editor = ERDEditorAdapter.getEditor(control);
        if (editor != null && !editor.isReadOnly()) {
            DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) editor);
            deleteAction.update();
            if (deleteAction.isEnabled()) {
                deleteAction.run();
            }
        }
    }
    return null;
}
Also used : Control(org.eclipse.swt.widgets.Control) ERDEditorPart(org.jkiss.dbeaver.erd.ui.editor.ERDEditorPart) DeleteAction(org.eclipse.gef.ui.actions.DeleteAction)

Aggregations

DeleteAction (org.eclipse.gef.ui.actions.DeleteAction)11 Control (org.eclipse.swt.widgets.Control)4 ERDEditorPart (org.jkiss.dbeaver.erd.ui.editor.ERDEditorPart)4 ERDEditorPart (org.jkiss.dbeaver.ext.erd.editor.ERDEditorPart)4 IAction (org.eclipse.jface.action.IAction)3 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)3 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)2 RedoAction (org.eclipse.gef.ui.actions.RedoAction)2 SaveAction (org.eclipse.gef.ui.actions.SaveAction)2 SelectAllAction (org.eclipse.gef.ui.actions.SelectAllAction)2 UndoAction (org.eclipse.gef.ui.actions.UndoAction)2 ChangeOrderAction (org.csstudio.opibuilder.actions.ChangeOrderAction)1 ChangeOrientationAction (org.csstudio.opibuilder.actions.ChangeOrientationAction)1 CopyPropertiesAction (org.csstudio.opibuilder.actions.CopyPropertiesAction)1 CopyWidgetsAction (org.csstudio.opibuilder.actions.CopyWidgetsAction)1 CutWidgetsAction (org.csstudio.opibuilder.actions.CutWidgetsAction)1 DistributeWidgetsAction (org.csstudio.opibuilder.actions.DistributeWidgetsAction)1 PastePropertiesAction (org.csstudio.opibuilder.actions.PastePropertiesAction)1 PasteWidgetsAction (org.csstudio.opibuilder.actions.PasteWidgetsAction)1 PrintDisplayAction (org.csstudio.opibuilder.actions.PrintDisplayAction)1