Search in sources :

Example 1 with DefaultActionGroup

use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.

the class JavaExtension method prepareActions.

@Inject
private void prepareActions(NewPackageAction newPackageAction, KeyBindingAgent keyBinding, NewJavaSourceFileAction newJavaSourceFileAction, ActionManager actionManager, ProjectClasspathAction projectClasspathAction, MoveAction moveAction, CutJavaSourceAction cutAction, FileStructureAction fileStructureAction, MarkDirAsSourceAction markDirAsSourceAction, UnmarkDirAsSourceAction unmarkDirAsSourceAction, MarkDirectoryAsGroup markDirectoryAsGroup, OrganizeImportsAction organizeImportsAction, RenameRefactoringAction renameRefactoringAction, QuickDocumentationAction quickDocumentationAction, QuickFixAction quickFixAction, OpenDeclarationAction openDeclarationAction, OpenImplementationAction openImplementationAction, FindUsagesAction findUsagesAction, ParametersHintsAction parametersHintsAction) {
    DefaultActionGroup newGroup = (DefaultActionGroup) actionManager.getAction(GROUP_FILE_NEW);
    actionManager.registerAction("newJavaClass", newJavaSourceFileAction);
    newGroup.add(newJavaSourceFileAction, Constraints.FIRST);
    actionManager.registerAction("newJavaPackage", newPackageAction);
    newGroup.add(newPackageAction, new Constraints(Anchor.AFTER, "newJavaClass"));
    DefaultActionGroup refactorGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT_REFACTORING);
    if (refactorGroup == null) {
        refactorGroup = new DefaultActionGroup("Refactoring", true, actionManager);
        actionManager.registerAction(GROUP_ASSISTANT_REFACTORING, refactorGroup);
    }
    DefaultActionGroup projectGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PROJECT);
    actionManager.registerAction("projectProperties", projectClasspathAction);
    projectGroup.add(projectClasspathAction, new Constraints(Anchor.LAST, null));
    DefaultActionGroup assistantGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT);
    refactorGroup.addSeparator();
    refactorGroup.add(moveAction);
    refactorGroup.add(renameRefactoringAction);
    assistantGroup.add(refactorGroup, new Constraints(Anchor.BEFORE, "updateDependency"));
    actionManager.registerAction(SHOW_QUICK_DOC, quickDocumentationAction);
    actionManager.registerAction(OPEN_JAVA_DECLARATION, openDeclarationAction);
    actionManager.registerAction(OPEN_IMPLEMENTATION, openImplementationAction);
    actionManager.registerAction(JAVA_RENAME_REFACTORING, renameRefactoringAction);
    actionManager.registerAction(JAVA_MOVE_REFACTORING, moveAction);
    actionManager.registerAction(JAVA_CUT_REFACTORING, cutAction);
    actionManager.registerAction(JAVA_FIND_USAGES, findUsagesAction);
    actionManager.registerAction(JAVA_CLASS_STRUCTURE, fileStructureAction);
    actionManager.registerAction(ORGANIZE_IMPORTS, organizeImportsAction);
    actionManager.registerAction(PARAMETERS_INFO, parametersHintsAction);
    actionManager.registerAction(QUICK_FIX, quickFixAction);
    assistantGroup.add(quickDocumentationAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(quickFixAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(openDeclarationAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(organizeImportsAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(openImplementationAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(fileStructureAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    assistantGroup.add(findUsagesAction, new Constraints(Anchor.BEFORE, GROUP_ASSISTANT_REFACTORING));
    //Configure Build Path action group
    actionManager.registerAction("markDirectoryAsSourceGroup", markDirectoryAsGroup);
    actionManager.registerAction("markDirectoryAsSource", markDirAsSourceAction);
    actionManager.registerAction("unmarkDirectoryAsSource", unmarkDirAsSourceAction);
    markDirectoryAsGroup.add(markDirAsSourceAction);
    markDirectoryAsGroup.add(unmarkDirAsSourceAction);
    markDirectoryAsGroup.add(projectClasspathAction);
    DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup) actionManager.getAction("resourceOperation");
    mainContextMenuGroup.addSeparator();
    mainContextMenuGroup.add(markDirectoryAsGroup);
    mainContextMenuGroup.addSeparator();
    DefaultActionGroup editorContextMenuGroup = (DefaultActionGroup) actionManager.getAction(IdeActions.GROUP_EDITOR_CONTEXT_MENU);
    editorContextMenuGroup.add(quickDocumentationAction, new Constraints(Anchor.AFTER, "format"));
    editorContextMenuGroup.add(quickFixAction, new Constraints(Anchor.AFTER, SHOW_QUICK_DOC));
    editorContextMenuGroup.add(openDeclarationAction, new Constraints(Anchor.AFTER, QUICK_FIX));
    editorContextMenuGroup.add(refactorGroup, new Constraints(Anchor.AFTER, OPEN_JAVA_DECLARATION));
    editorContextMenuGroup.add(fileStructureAction, new Constraints(Anchor.AFTER, GROUP_ASSISTANT_REFACTORING));
    if (UserAgent.isMac()) {
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().control().charCode('b').build(), OPEN_IMPLEMENTATION);
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('j').build(), SHOW_QUICK_DOC);
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode(KeyCodeMap.F12).build(), JAVA_CLASS_STRUCTURE);
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().control().charCode('o').build(), ORGANIZE_IMPORTS);
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('p').build(), PARAMETERS_INFO);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode(KeyCodeMap.ENTER).build(), QUICK_FIX);
    } else {
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().action().charCode('b').build(), OPEN_IMPLEMENTATION);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('q').build(), SHOW_QUICK_DOC);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode(KeyCodeMap.F12).build(), JAVA_CLASS_STRUCTURE);
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().action().charCode('o').build(), ORGANIZE_IMPORTS);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('p').build(), PARAMETERS_INFO);
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.ENTER).build(), QUICK_FIX);
    }
    keyBinding.getGlobal().addKey(new KeyBuilder().none().charCode(KeyCodeMap.F4).build(), OPEN_JAVA_DECLARATION);
    keyBinding.getGlobal().addKey(new KeyBuilder().shift().charCode(KeyCodeMap.F6).build(), JAVA_RENAME_REFACTORING);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('x').build(), JAVA_CUT_REFACTORING);
    keyBinding.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.F6).build(), JAVA_MOVE_REFACTORING);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.F7).build(), JAVA_FIND_USAGES);
}
Also used : KeyBuilder(org.eclipse.che.ide.api.keybinding.KeyBuilder) Constraints(org.eclipse.che.ide.api.constraints.Constraints) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Inject(com.google.inject.Inject)

Example 2 with DefaultActionGroup

use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.

the class MyFileTypeExtension method MyFileTypeExtension.

@Inject
public void MyFileTypeExtension(final ActionManager actionManager, final CreateMyFileAction createMyFileAction, final FileTypeRegistry fileTypeRegistry, @Named("MyFileType") final FileType myFileType) {
    actionManager.registerAction("createMyFileAction", createMyFileAction);
    DefaultActionGroup mainContextMenu = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_CONTEXT_MENU);
    mainContextMenu.add(createMyFileAction);
    fileTypeRegistry.registerFileType(myFileType);
}
Also used : DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Inject(com.google.inject.Inject)

Example 3 with DefaultActionGroup

use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.

the class CommandProducerActionManager method createActionsForMachine.

/**
     * Creates actions for that {@link CommandProducer}s
     * which are applicable for the given machine's type.
     */
private void createActionsForMachine(Machine machine) {
    for (CommandProducer commandProducer : commandProducers) {
        if (commandProducer.getMachineTypes().contains(machine.getConfig().getType())) {
            CommandProducerAction machineAction = commandProducerActionFactory.create(machine.getConfig().getName(), commandProducer, machine);
            List<Action> actionList = actionsByMachines.get(machine);
            if (actionList == null) {
                actionList = new ArrayList<>();
                actionsByMachines.put(machine, actionList);
            }
            actionList.add(machineAction);
            actionManager.registerAction(machine.getConfig().getName(), machineAction);
            DefaultActionGroup actionGroup = producersToActionGroups.get(commandProducer);
            if (actionGroup != null) {
                actionGroup.add(machineAction);
                actionsToActionGroups.put(machineAction, actionGroup);
            }
        }
    }
}
Also used : CommandProducer(org.eclipse.che.ide.api.command.CommandProducer) Action(org.eclipse.che.ide.api.action.Action) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup)

Example 4 with DefaultActionGroup

use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.

the class CommandProducerActionManager method createActionsForProducer.

/** Creates actions for the given {@link CommandProducer}. */
private void createActionsForProducer(CommandProducer producer) {
    Action action;
    if (producer.getMachineTypes().isEmpty()) {
        action = commandProducerActionFactory.create(producer.getName(), producer, appContext.getDevMachine().getDescriptor());
        actionManager.registerAction(producer.getName(), action);
    } else {
        action = new DefaultActionGroup(producer.getName(), true, actionManager);
        producersToActionGroups.put(producer, (DefaultActionGroup) action);
        actionManager.registerAction(producer.getName(), action);
        for (Machine machine : machines) {
            createActionsForMachine(machine);
        }
    }
    commandActionsPopUpGroup.add(action);
}
Also used : Action(org.eclipse.che.ide.api.action.Action) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Machine(org.eclipse.che.api.core.model.machine.Machine)

Example 5 with DefaultActionGroup

use of org.eclipse.che.ide.api.action.DefaultActionGroup in project che by eclipse.

the class EditorTabContextMenu method updateActions.

protected ActionGroup updateActions() {
    final ActionGroup mainActionGroup = (ActionGroup) actionManager.getAction(getGroupMenu());
    if (mainActionGroup == null) {
        return new DefaultActionGroup(actionManager);
    }
    final Action[] children = mainActionGroup.getChildren(null);
    for (final Action action : children) {
        final Presentation presentation = presentationFactory.getPresentation(action);
        //pass into action properties
        presentation.putClientProperty(CURRENT_FILE_PROP, editorTab.getFile());
        presentation.putClientProperty(CURRENT_TAB_PROP, editorTab);
        presentation.putClientProperty(CURRENT_PANE_PROP, editorPartStack);
    }
    return super.updateActions();
}
Also used : Action(org.eclipse.che.ide.api.action.Action) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup) Presentation(org.eclipse.che.ide.api.action.Presentation) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup)

Aggregations

DefaultActionGroup (org.eclipse.che.ide.api.action.DefaultActionGroup)26 Inject (com.google.inject.Inject)14 Action (org.eclipse.che.ide.api.action.Action)8 Icon (org.eclipse.che.ide.api.icon.Icon)5 KeyBuilder (org.eclipse.che.ide.api.keybinding.KeyBuilder)4 Machine (org.eclipse.che.api.core.model.machine.Machine)2 Constraints (org.eclipse.che.ide.api.constraints.Constraints)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 MachineConfig (org.eclipse.che.api.core.model.machine.MachineConfig)1 CloseActiveEditorAction (org.eclipse.che.ide.actions.CloseActiveEditorAction)1 CollapseAllAction (org.eclipse.che.ide.actions.CollapseAllAction)1 CompleteAction (org.eclipse.che.ide.actions.CompleteAction)1 ConvertFolderToProjectAction (org.eclipse.che.ide.actions.ConvertFolderToProjectAction)1 CreateProjectAction (org.eclipse.che.ide.actions.CreateProjectAction)1 DeleteResourceAction (org.eclipse.che.ide.actions.DeleteResourceAction)1 DownloadProjectAction (org.eclipse.che.ide.actions.DownloadProjectAction)1 DownloadResourceAction (org.eclipse.che.ide.actions.DownloadResourceAction)1