Search in sources :

Example 1 with GlobalActionDisablementHandler

use of com.archimatetool.editor.ui.components.GlobalActionDisablementHandler in project archi by archimatetool.

the class AbstractDiagramEditorActionBarContributor method contributeToToolBar.

@Override
public void contributeToToolBar(IToolBarManager toolBarManager) {
    // Add the Zoom Manager Combo
    fZoomCombo = new ZoomComboContributionItem(getPage()) {

        // Hook into the Combo so we can disable global edit action handlers when it gets the focus
        private GlobalActionDisablementHandler globalActionHandler;

        @Override
        protected Control createControl(Composite parent) {
            Combo combo = (Combo) super.createControl(parent);
            combo.addFocusListener(new FocusListener() {

                @Override
                public void focusGained(FocusEvent e) {
                    globalActionHandler = new GlobalActionDisablementHandler(getActionBars());
                    globalActionHandler.clearGlobalActions();
                }

                @Override
                public void focusLost(FocusEvent e) {
                    if (globalActionHandler != null) {
                        globalActionHandler.restoreGlobalActions();
                    }
                }
            });
            return combo;
        }

        @Override
        protected int computeWidth(Control control) {
            // On Linux GTK this can get too wide
            return Math.min(super.computeWidth(control), 100);
        }
    };
    toolBarManager.add(fZoomCombo);
    toolBarManager.add(new Separator());
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_LEFT));
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_CENTER));
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_RIGHT));
    toolBarManager.add(new Separator());
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_TOP));
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_MIDDLE));
    toolBarManager.add(getAction(GEFActionConstants.ALIGN_BOTTOM));
    toolBarManager.add(new Separator());
    toolBarManager.add(getAction(GEFActionConstants.MATCH_WIDTH));
    toolBarManager.add(getAction(GEFActionConstants.MATCH_HEIGHT));
    toolBarManager.add(getAction(GEFActionConstants.MATCH_SIZE));
    toolBarManager.add(new Separator());
    toolBarManager.add(getAction(DefaultEditPartSizeAction.ID));
    toolBarManager.add(getAction(ResetAspectRatioAction.ID));
    toolBarManager.add(new GroupMarker(GROUP_TOOLBAR_END));
}
Also used : Control(org.eclipse.swt.widgets.Control) GlobalActionDisablementHandler(com.archimatetool.editor.ui.components.GlobalActionDisablementHandler) Composite(org.eclipse.swt.widgets.Composite) Combo(org.eclipse.swt.widgets.Combo) GroupMarker(org.eclipse.jface.action.GroupMarker) ZoomComboContributionItem(org.eclipse.gef.ui.actions.ZoomComboContributionItem) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent) Separator(org.eclipse.jface.action.Separator)

Example 2 with GlobalActionDisablementHandler

use of com.archimatetool.editor.ui.components.GlobalActionDisablementHandler in project archi by archimatetool.

the class AbstractDirectEditManager method initCellEditor.

@Override
protected void initCellEditor() {
    // Hook into the global Action Handlers and null them
    fGlobalActionHandler = new GlobalActionDisablementHandler();
    fGlobalActionHandler.clearGlobalActions();
    // Filter out any illegal xml characters
    UIUtils.applyInvalidCharacterFilter(getTextControl());
}
Also used : GlobalActionDisablementHandler(com.archimatetool.editor.ui.components.GlobalActionDisablementHandler)

Example 3 with GlobalActionDisablementHandler

use of com.archimatetool.editor.ui.components.GlobalActionDisablementHandler in project archi by archimatetool.

the class UserPropertiesSection method hookCellEditorGlobalActionHandler.

/**
 * Set some editing global Action Handlers to null when the cell editor is activated
 * And restore them when the cell editor is deactivated.
 */
private void hookCellEditorGlobalActionHandler(CellEditor cellEditor) {
    Listener listener = new Listener() {

        // We have to disable the action handlers of the the active Editor/View site *and* the Properties View Site
        GlobalActionDisablementHandler propertiesViewGlobalActionHandler, globalActionHandler;

        @Override
        public void handleEvent(Event event) {
            switch(event.type) {
                case SWT.Activate:
                    // The Properties View site action bars
                    IActionBars actionBars = fPage.getSite().getActionBars();
                    propertiesViewGlobalActionHandler = new GlobalActionDisablementHandler(actionBars);
                    propertiesViewGlobalActionHandler.clearGlobalActions();
                    // The active View or Editor site's action bars also have to be updated
                    globalActionHandler = new GlobalActionDisablementHandler();
                    globalActionHandler.update();
                    break;
                case SWT.Deactivate:
                    if (propertiesViewGlobalActionHandler != null) {
                        propertiesViewGlobalActionHandler.restoreGlobalActions();
                        globalActionHandler.update();
                    }
                    break;
                default:
                    break;
            }
        }
    };
    cellEditor.getControl().addListener(SWT.Activate, listener);
    cellEditor.getControl().addListener(SWT.Deactivate, listener);
}
Also used : Listener(org.eclipse.swt.widgets.Listener) IMenuListener(org.eclipse.jface.action.IMenuListener) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) KeyListener(org.eclipse.swt.events.KeyListener) GlobalActionDisablementHandler(com.archimatetool.editor.ui.components.GlobalActionDisablementHandler) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Event(org.eclipse.swt.widgets.Event) ColumnViewerEditorActivationEvent(org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IActionBars(org.eclipse.ui.IActionBars)

Aggregations

GlobalActionDisablementHandler (com.archimatetool.editor.ui.components.GlobalActionDisablementHandler)3 ZoomComboContributionItem (org.eclipse.gef.ui.actions.ZoomComboContributionItem)1 GroupMarker (org.eclipse.jface.action.GroupMarker)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 Separator (org.eclipse.jface.action.Separator)1 ColumnViewerEditorActivationEvent (org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent)1 DragSourceEvent (org.eclipse.swt.dnd.DragSourceEvent)1 DragSourceListener (org.eclipse.swt.dnd.DragSourceListener)1 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)1 DropTargetListener (org.eclipse.swt.dnd.DropTargetListener)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 KeyListener (org.eclipse.swt.events.KeyListener)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Combo (org.eclipse.swt.widgets.Combo)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 IActionBars (org.eclipse.ui.IActionBars)1