Search in sources :

Example 11 with IUpdatableAction

use of org.whole.lang.ui.actions.IUpdatableAction in project whole by wholeplatform.

the class ActionRegistry method registerKeyActions.

public void registerKeyActions(AbstractKeyHandler keyHandler) {
    keyHandler.put(KeySequence.getInstance(KeyStroke.getInstance(SWT.F2)), true, actionFactory.createDirectEditAction());
    for (IEditorKit editorKit : ReflectionFactory.getEditorKits()) {
        for (ILanguageKit lk : ReflectionFactory.getLanguageKits(false)) {
            if (!editorKit.canApply(lk))
                continue;
            for (Object[] textAction : E4Utils.textActionsFor(lk, ((IGEFEditorKit) editorKit).getActionFactory().textActions())) {
                KeySequence keySequence = (KeySequence) textAction[0];
                Class<IUpdatableAction> actionClass = (Class<IUpdatableAction>) textAction[2];
                try {
                    IUpdatableAction action = actionClass.getConstructor(IEclipseContext.class).newInstance(context);
                    keyHandler.put(editorKit, keySequence, true, action);
                } catch (Exception e) {
                }
            }
        }
    }
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) IEditorKit(org.whole.lang.reflect.IEditorKit) IUpdatableAction(org.whole.lang.ui.actions.IUpdatableAction) KeySequence(org.eclipse.jface.bindings.keys.KeySequence) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 12 with IUpdatableAction

use of org.whole.lang.ui.actions.IUpdatableAction in project whole by wholeplatform.

the class ActionRegistry method getSelectNotationAction.

public IUpdatableAction getSelectNotationAction(IEditorKit editorKit) {
    String editorKitId = editorKit.getId();
    IUpdatableAction action = selectNotationActions.get(editorKitId);
    if (action == null) {
        String label = editorKit.getName();
        Map<String, Object> parameters = Collections.singletonMap(EDITORKIT_ID_PARAMETER_ID, editorKitId);
        selectNotationActions.put(editorKitId, action = actionFactory.createE4ActionAdapter(label, null, SELECT_NOTATION_COMMAND_ID, parameters, IAction.AS_RADIO_BUTTON));
    }
    return action;
}
Also used : IUpdatableAction(org.whole.lang.ui.actions.IUpdatableAction)

Aggregations

IUpdatableAction (org.whole.lang.ui.actions.IUpdatableAction)12 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 IAction (org.eclipse.jface.action.IAction)3 IBindingManager (org.whole.lang.bindings.IBindingManager)3 IEntity (org.whole.lang.model.IEntity)3 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)2 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)2 IContributionItem (org.eclipse.jface.action.IContributionItem)2 IEditorKit (org.whole.lang.reflect.IEditorKit)2 IGEFEditorKit (org.whole.lang.ui.editor.IGEFEditorKit)2 MalformedURLException (java.net.MalformedURLException)1 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 KeySequence (org.eclipse.jface.bindings.keys.KeySequence)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 Action (org.whole.lang.actions.model.Action)1 CustomAction (org.whole.lang.actions.model.CustomAction)1 GroupAction (org.whole.lang.actions.model.GroupAction)1 GuardedAction (org.whole.lang.actions.model.GuardedAction)1