Search in sources :

Example 11 with ActionEvent

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

the class Utils method hasVisibleChildren.

/**
     * Returns true if action group has visible children.
     *
     * @param group
     *         action group
     * @param factory
     *         presentation factory
     * @param actionManager
     *         action manager
     * @param perspectiveManager
     *         perspective manager
     * @return boolean
     */
public static boolean hasVisibleChildren(ActionGroup group, PresentationFactory factory, ActionManager actionManager, PerspectiveManager perspectiveManager) {
    ActionEvent event = new ActionEvent(factory.getPresentation(group), actionManager, perspectiveManager);
    for (Action anAction : group.getChildren(event)) {
        if (anAction == null) {
            Log.error(Utils.class, "Null action found in group " + group + ", " + factory.getPresentation(group));
            continue;
        }
        if (anAction instanceof Separator) {
            continue;
        }
        final Presentation presentation = factory.getPresentation(anAction);
        anAction.update(new ActionEvent(presentation, actionManager, perspectiveManager));
        if (anAction instanceof ActionGroup) {
            ActionGroup childGroup = (ActionGroup) anAction;
            // popup menu must be visible itself
            if (childGroup.isPopup()) {
                if (!presentation.isVisible()) {
                    continue;
                }
            }
            if (hasVisibleChildren(childGroup, factory, actionManager, perspectiveManager)) {
                return true;
            }
        } else if (presentation.isVisible()) {
            return true;
        }
    }
    return false;
}
Also used : Action(org.eclipse.che.ide.api.action.Action) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Presentation(org.eclipse.che.ide.api.action.Presentation) Separator(org.eclipse.che.ide.api.action.Separator)

Example 12 with ActionEvent

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

the class Utils method renderActionGroup.

/**
     * Returns the list of visible action group.
     *
     * @param group
     *         action group
     * @param presentationFactory
     *         presentation factory
     * @param actionManager
     *         action manager
     * @param perspectiveManager
     *         perspective manager
     * @return list of visible action group
     */
public static List<VisibleActionGroup> renderActionGroup(@NotNull ActionGroup group, PresentationFactory presentationFactory, ActionManager actionManager, PerspectiveManager perspectiveManager) {
    Presentation presentation = presentationFactory.getPresentation(group);
    ActionEvent event = new ActionEvent(presentation, actionManager, perspectiveManager);
    if (!presentation.isVisible()) {
        // don't process invisible groups
        return null;
    }
    Action[] children = group.getChildren(event);
    List<VisibleActionGroup> currentVisibleActionGroupList = new ArrayList<>();
    List<Action> currentActionList = new ArrayList<>();
    String currentGroupId = actionManager.getId(group);
    for (Action child : children) {
        if (child == null) {
            Log.error(Utils.class, "action is null: group=" + group + " group id=" + currentGroupId);
            continue;
        }
        presentation = presentationFactory.getPresentation(child);
        child.update(new ActionEvent(presentation, actionManager, perspectiveManager));
        if (!presentation.isVisible()) {
            // don't create invisible items in the menu
            continue;
        }
        if (child instanceof ActionGroup) {
            ActionGroup actionGroup = (ActionGroup) child;
            if (actionGroup.isPopup()) {
                // popup menu has its own presentation
                if (actionGroup.disableIfNoVisibleChildren()) {
                    final boolean visibleChildren = hasVisibleChildren(actionGroup, presentationFactory, actionManager, perspectiveManager);
                    if (actionGroup.hideIfNoVisibleChildren() && !visibleChildren) {
                        continue;
                    }
                    presentation.setEnabled(actionGroup.canBePerformed() || visibleChildren);
                }
                currentActionList.add(child);
            } else {
                List<VisibleActionGroup> newVisibleActionGroupList = renderActionGroup((ActionGroup) child, presentationFactory, actionManager, perspectiveManager);
                currentVisibleActionGroupList.addAll(newVisibleActionGroupList);
            }
        } else if (child instanceof Separator) {
            if ((((Separator) child).getText() != null) || (!currentActionList.isEmpty() && !(currentActionList.get(currentActionList.size() - 1) instanceof Separator))) {
                currentActionList.add(child);
            }
        } else {
            currentActionList.add(child);
        }
    }
    currentVisibleActionGroupList.add(0, new VisibleActionGroup(currentGroupId, currentActionList));
    return currentVisibleActionGroupList;
}
Also used : Action(org.eclipse.che.ide.api.action.Action) ActionGroup(org.eclipse.che.ide.api.action.ActionGroup) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) ArrayList(java.util.ArrayList) Presentation(org.eclipse.che.ide.api.action.Presentation) Separator(org.eclipse.che.ide.api.action.Separator)

Example 13 with ActionEvent

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

the class StandardComponentInitializer method initialize.

public void initialize() {
    messageLoaderResources.Css().ensureInjected();
    editorResources.editorCss().ensureInjected();
    popupResources.popupStyle().ensureInjected();
    fileTypeRegistry.registerFileType(xmlFile);
    fileTypeRegistry.registerFileType(txtFile);
    fileTypeRegistry.registerFileType(jsonFile);
    fileTypeRegistry.registerFileType(mdFile);
    fileTypeRegistry.registerFileType(pngFile);
    editorRegistry.registerDefaultEditor(pngFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(bmpFile);
    editorRegistry.registerDefaultEditor(bmpFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(gifFile);
    editorRegistry.registerDefaultEditor(gifFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(iconFile);
    editorRegistry.registerDefaultEditor(iconFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(svgFile);
    editorRegistry.registerDefaultEditor(svgFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(jpeFile);
    editorRegistry.registerDefaultEditor(jpeFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(jpegFile);
    editorRegistry.registerDefaultEditor(jpegFile, imageViewerProvider);
    fileTypeRegistry.registerFileType(jpgFile);
    editorRegistry.registerDefaultEditor(jpgFile, imageViewerProvider);
    // Workspace (New Menu)
    DefaultActionGroup workspaceGroup = (DefaultActionGroup) actionManager.getAction(GROUP_WORKSPACE);
    actionManager.registerAction(IMPORT_PROJECT, importProjectAction);
    workspaceGroup.add(importProjectAction);
    actionManager.registerAction(CREATE_PROJECT, createProjectAction);
    workspaceGroup.add(createProjectAction);
    actionManager.registerAction("downloadWsAsZipAction", downloadWsAction);
    workspaceGroup.add(downloadWsAction);
    workspaceGroup.addSeparator();
    // Project (New Menu)
    DefaultActionGroup projectGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PROJECT);
    DefaultActionGroup newGroup = new DefaultActionGroup("New", true, actionManager);
    newGroup.getTemplatePresentation().setDescription("Create...");
    newGroup.getTemplatePresentation().setSVGResource(resources.newResource());
    actionManager.registerAction(GROUP_FILE_NEW, newGroup);
    projectGroup.add(newGroup);
    newGroup.addSeparator();
    actionManager.registerAction(NEW_FILE, newFileAction);
    newGroup.addAction(newFileAction);
    actionManager.registerAction("newFolder", newFolderAction);
    newGroup.addAction(newFolderAction);
    newGroup.addSeparator();
    actionManager.registerAction("newXmlFile", newXmlFileAction);
    newXmlFileAction.getTemplatePresentation().setSVGResource(xmlFile.getImage());
    newGroup.addAction(newXmlFileAction);
    actionManager.registerAction("uploadFile", uploadFileAction);
    projectGroup.add(uploadFileAction);
    actionManager.registerAction("uploadFolder", uploadFolderAction);
    projectGroup.add(uploadFolderAction);
    actionManager.registerAction("convertFolderToProject", convertFolderToProjectAction);
    projectGroup.add(convertFolderToProjectAction);
    actionManager.registerAction("downloadAsZipAction", downloadProjectAction);
    projectGroup.add(downloadProjectAction);
    actionManager.registerAction("showHideHiddenFiles", showHiddenFilesAction);
    projectGroup.add(showHiddenFilesAction);
    projectGroup.addSeparator();
    actionManager.registerAction("projectConfiguration", projectConfigurationAction);
    projectGroup.add(projectConfigurationAction);
    // Edit (New Menu)
    DefaultActionGroup editGroup = (DefaultActionGroup) actionManager.getAction(GROUP_EDIT);
    DefaultActionGroup recentGroup = new DefaultActionGroup(RECENT_GROUP_ID, true, actionManager);
    actionManager.registerAction(GROUP_RECENT_FILES, recentGroup);
    actionManager.registerAction("clearRecentList", clearRecentFilesAction);
    recentGroup.addSeparator();
    recentGroup.add(clearRecentFilesAction, LAST);
    editGroup.add(recentGroup);
    actionManager.registerAction(OPEN_RECENT_FILES, openRecentFilesAction);
    editGroup.add(openRecentFilesAction);
    editGroup.addSeparator();
    actionManager.registerAction(CLOSE_ACTIVE_EDITOR, closeActiveEditorAction);
    editGroup.add(closeActiveEditorAction);
    actionManager.registerAction(FORMAT, formatterAction);
    editGroup.add(formatterAction);
    actionManager.registerAction("undo", undoAction);
    editGroup.add(undoAction);
    actionManager.registerAction("redo", redoAction);
    editGroup.add(redoAction);
    actionManager.registerAction(CUT, cutResourceAction);
    editGroup.add(cutResourceAction);
    actionManager.registerAction(COPY, copyResourceAction);
    editGroup.add(copyResourceAction);
    actionManager.registerAction(PASTE, pasteResourceAction);
    editGroup.add(pasteResourceAction);
    actionManager.registerAction(RENAME, renameItemAction);
    editGroup.add(renameItemAction);
    actionManager.registerAction(DELETE_ITEM, deleteResourceAction);
    editGroup.add(deleteResourceAction);
    actionManager.registerAction(FULL_TEXT_SEARCH, fullTextSearchAction);
    editGroup.add(fullTextSearchAction);
    editGroup.addSeparator();
    editGroup.add(switchPreviousEditorAction);
    editGroup.add(switchNextEditorAction);
    editGroup.addSeparator();
    editGroup.add(revealResourceAction);
    // Assistant (New Menu)
    DefaultActionGroup assistantGroup = (DefaultActionGroup) actionManager.getAction(GROUP_ASSISTANT);
    actionManager.registerAction(FIND_ACTION, findActionAction);
    assistantGroup.add(findActionAction);
    actionManager.registerAction("hotKeysList", hotKeysListAction);
    assistantGroup.add(hotKeysListAction);
    assistantGroup.addSeparator();
    actionManager.registerAction("callCompletion", completeAction);
    assistantGroup.add(completeAction);
    actionManager.registerAction("downloadItemAction", downloadResourceAction);
    actionManager.registerAction(NAVIGATE_TO_FILE, navigateToFileAction);
    assistantGroup.add(navigateToFileAction);
    // Compose Save group
    DefaultActionGroup saveGroup = new DefaultActionGroup(actionManager);
    actionManager.registerAction("saveGroup", saveGroup);
    actionManager.registerAction("save", saveAction);
    actionManager.registerAction("saveAll", saveAllAction);
    saveGroup.addSeparator();
    saveGroup.add(saveAction);
    saveGroup.add(saveAllAction);
    //Compose Profile menu
    DefaultActionGroup profileGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PROFILE);
    actionManager.registerAction("showPreferences", showPreferencesAction);
    profileGroup.add(showPreferencesAction);
    // Compose Help menu
    DefaultActionGroup helpGroup = (DefaultActionGroup) actionManager.getAction(GROUP_HELP);
    helpGroup.addSeparator();
    // Compose main context menu
    DefaultActionGroup resourceOperation = new DefaultActionGroup(actionManager);
    actionManager.registerAction("resourceOperation", resourceOperation);
    actionManager.registerAction("refreshPathAction", refreshPathAction);
    actionManager.registerAction("linkWithEditor", linkWithEditorAction);
    resourceOperation.addSeparator();
    resourceOperation.add(showReferenceAction);
    resourceOperation.add(goIntoAction);
    resourceOperation.add(editFileAction);
    resourceOperation.add(cutResourceAction);
    resourceOperation.add(copyResourceAction);
    resourceOperation.add(pasteResourceAction);
    resourceOperation.add(renameItemAction);
    resourceOperation.add(deleteResourceAction);
    resourceOperation.addSeparator();
    resourceOperation.add(downloadResourceAction);
    resourceOperation.add(refreshPathAction);
    resourceOperation.add(linkWithEditorAction);
    resourceOperation.addSeparator();
    resourceOperation.add(convertFolderToProjectAction);
    resourceOperation.addSeparator();
    DefaultActionGroup mainContextMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_CONTEXT_MENU);
    mainContextMenuGroup.add(newGroup, Constraints.FIRST);
    mainContextMenuGroup.addSeparator();
    mainContextMenuGroup.add(resourceOperation);
    DefaultActionGroup partMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_PART_MENU);
    partMenuGroup.add(maximizePartAction);
    partMenuGroup.add(minimizePartAction);
    partMenuGroup.add(restorePartAction);
    actionManager.registerAction("expandEditor", expandEditorAction);
    DefaultActionGroup rightMenuGroup = (DefaultActionGroup) actionManager.getAction(GROUP_RIGHT_MAIN_MENU);
    rightMenuGroup.add(expandEditorAction, FIRST);
    // Compose main toolbar
    DefaultActionGroup changeResourceGroup = new DefaultActionGroup(actionManager);
    actionManager.registerAction("changeResourceGroup", changeResourceGroup);
    actionManager.registerAction("editFile", editFileAction);
    actionManager.registerAction("goInto", goIntoAction);
    actionManager.registerAction(SHOW_REFERENCE, showReferenceAction);
    actionManager.registerAction("collapseAll", collapseAllAction);
    actionManager.registerAction("openFile", openFileAction);
    actionManager.registerAction(SWITCH_LEFT_TAB, switchPreviousEditorAction);
    actionManager.registerAction(SWITCH_RIGHT_TAB, switchNextEditorAction);
    actionManager.registerAction("scrollFromSource", revealResourceAction);
    changeResourceGroup.add(cutResourceAction);
    changeResourceGroup.add(copyResourceAction);
    changeResourceGroup.add(pasteResourceAction);
    changeResourceGroup.add(deleteResourceAction);
    DefaultActionGroup mainToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_TOOLBAR);
    mainToolbarGroup.add(newGroup);
    mainToolbarGroup.add(changeResourceGroup);
    toolbarPresenter.bindMainGroup(mainToolbarGroup);
    DefaultActionGroup centerToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_CENTER_TOOLBAR);
    toolbarPresenter.bindCenterGroup(centerToolbarGroup);
    DefaultActionGroup rightToolbarGroup = (DefaultActionGroup) actionManager.getAction(GROUP_RIGHT_TOOLBAR);
    toolbarPresenter.bindRightGroup(rightToolbarGroup);
    //Editor context menu group
    DefaultActionGroup editorTabContextMenu = (DefaultActionGroup) actionManager.getAction(GROUP_EDITOR_TAB_CONTEXT_MENU);
    editorTabContextMenu.add(closeAction);
    actionManager.registerAction(CLOSE, closeAction);
    editorTabContextMenu.add(closeAllAction);
    actionManager.registerAction(CLOSE_ALL, closeAllAction);
    editorTabContextMenu.add(closeOtherAction);
    actionManager.registerAction(CLOSE_OTHER, closeOtherAction);
    editorTabContextMenu.add(closeAllExceptPinnedAction);
    actionManager.registerAction(CLOSE_ALL_EXCEPT_PINNED, closeAllExceptPinnedAction);
    editorTabContextMenu.addSeparator();
    editorTabContextMenu.add(reopenClosedFileAction);
    actionManager.registerAction(REOPEN_CLOSED, reopenClosedFileAction);
    editorTabContextMenu.add(pinEditorTabAction);
    actionManager.registerAction(PIN_TAB, pinEditorTabAction);
    editorTabContextMenu.addSeparator();
    actionManager.registerAction(SPLIT_HORIZONTALLY, splitHorizontallyAction);
    editorTabContextMenu.add(splitHorizontallyAction);
    actionManager.registerAction(SPLIT_VERTICALLY, splitVerticallyAction);
    editorTabContextMenu.add(splitVerticallyAction);
    actionManager.registerAction(SIGNATURE_HELP, signatureHelpAction);
    DefaultActionGroup editorContextMenuGroup = new DefaultActionGroup(actionManager);
    actionManager.registerAction(GROUP_EDITOR_CONTEXT_MENU, editorContextMenuGroup);
    editorContextMenuGroup.add(undoAction);
    editorContextMenuGroup.add(redoAction);
    editorContextMenuGroup.addSeparator();
    editorContextMenuGroup.add(formatterAction);
    editorContextMenuGroup.addSeparator();
    editorContextMenuGroup.add(fullTextSearchAction);
    editorContextMenuGroup.add(closeActiveEditorAction);
    // Define hot-keys
    keyBinding.getGlobal().addKey(new KeyBuilder().action().alt().charCode('n').build(), NAVIGATE_TO_FILE);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('F').build(), FULL_TEXT_SEARCH);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('A').build(), FIND_ACTION);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('L').build(), FORMAT);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('c').build(), COPY);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('x').build(), CUT);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('v').build(), PASTE);
    keyBinding.getGlobal().addKey(new KeyBuilder().shift().charCode(KeyCodeMap.F6).build(), RENAME);
    keyBinding.getGlobal().addKey(new KeyBuilder().shift().charCode(KeyCodeMap.F7).build(), SHOW_REFERENCE);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.ARROW_LEFT).build(), SWITCH_LEFT_TAB);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.ARROW_RIGHT).build(), SWITCH_RIGHT_TAB);
    keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('e').build(), OPEN_RECENT_FILES);
    keyBinding.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.DELETE).build(), DELETE_ITEM);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('N').build(), NEW_FILE);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('x').build(), CREATE_PROJECT);
    keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('A').build(), IMPORT_PROJECT);
    if (UserAgent.isMac()) {
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('w').build(), CLOSE_ACTIVE_EDITOR);
        keyBinding.getGlobal().addKey(new KeyBuilder().control().charCode('p').build(), SIGNATURE_HELP);
    } else {
        keyBinding.getGlobal().addKey(new KeyBuilder().alt().charCode('w').build(), CLOSE_ACTIVE_EDITOR);
        keyBinding.getGlobal().addKey(new KeyBuilder().action().charCode('p').build(), SIGNATURE_HELP);
    }
    final Map<String, Perspective> perspectives = perspectiveManager.getPerspectives();
    if (perspectives.size() > 1) {
        //if registered perspectives will be more then 2 Main Menu -> Window
        // will appears and contains all of them as sub-menu
        final DefaultActionGroup windowMenu = new DefaultActionGroup("Window", true, actionManager);
        actionManager.registerAction("Window", windowMenu);
        final DefaultActionGroup mainMenu = (DefaultActionGroup) actionManager.getAction(GROUP_MAIN_MENU);
        mainMenu.add(windowMenu);
        for (Perspective perspective : perspectives.values()) {
            final Action action = new Action(perspective.getPerspectiveName()) {

                @Override
                public void actionPerformed(ActionEvent e) {
                    perspectiveManager.setPerspectiveId(perspective.getPerspectiveId());
                }
            };
            actionManager.registerAction(perspective.getPerspectiveId(), action);
            windowMenu.add(action);
        }
    }
}
Also used : KeyBuilder(org.eclipse.che.ide.api.keybinding.KeyBuilder) Perspective(org.eclipse.che.ide.api.parts.Perspective) FullTextSearchAction(org.eclipse.che.ide.actions.FullTextSearchAction) UndoAction(org.eclipse.che.ide.actions.UndoAction) LinkWithEditorAction(org.eclipse.che.ide.actions.LinkWithEditorAction) MinimizePartAction(org.eclipse.che.ide.actions.common.MinimizePartAction) ConvertFolderToProjectAction(org.eclipse.che.ide.actions.ConvertFolderToProjectAction) NavigateToFileAction(org.eclipse.che.ide.actions.NavigateToFileAction) UploadFolderAction(org.eclipse.che.ide.actions.UploadFolderAction) RestorePartAction(org.eclipse.che.ide.actions.common.RestorePartAction) CloseAllAction(org.eclipse.che.ide.part.editor.actions.CloseAllAction) RenameItemAction(org.eclipse.che.ide.actions.RenameItemAction) SaveAction(org.eclipse.che.ide.actions.SaveAction) ShowHiddenFilesAction(org.eclipse.che.ide.actions.ShowHiddenFilesAction) CutResourceAction(org.eclipse.che.ide.resources.action.CutResourceAction) SplitVerticallyAction(org.eclipse.che.ide.part.editor.actions.SplitVerticallyAction) DownloadWsAction(org.eclipse.che.ide.actions.DownloadWsAction) DownloadResourceAction(org.eclipse.che.ide.actions.DownloadResourceAction) PinEditorTabAction(org.eclipse.che.ide.part.editor.actions.PinEditorTabAction) RevealResourceAction(org.eclipse.che.ide.resources.action.RevealResourceAction) SwitchNextEditorAction(org.eclipse.che.ide.part.editor.actions.SwitchNextEditorAction) ImportProjectAction(org.eclipse.che.ide.actions.ImportProjectAction) NewXmlFileAction(org.eclipse.che.ide.xml.NewXmlFileAction) SaveAllAction(org.eclipse.che.ide.actions.SaveAllAction) CloseAction(org.eclipse.che.ide.part.editor.actions.CloseAction) CloseOtherAction(org.eclipse.che.ide.part.editor.actions.CloseOtherAction) GoIntoAction(org.eclipse.che.ide.actions.GoIntoAction) EditFileAction(org.eclipse.che.ide.actions.EditFileAction) HotKeysListAction(org.eclipse.che.ide.actions.HotKeysListAction) ProjectConfigurationAction(org.eclipse.che.ide.actions.ProjectConfigurationAction) RedoAction(org.eclipse.che.ide.actions.RedoAction) NewFileAction(org.eclipse.che.ide.newresource.NewFileAction) FormatterAction(org.eclipse.che.ide.actions.FormatterAction) OpenFileAction(org.eclipse.che.ide.actions.OpenFileAction) ReopenClosedFileAction(org.eclipse.che.ide.part.editor.actions.ReopenClosedFileAction) FindActionAction(org.eclipse.che.ide.actions.find.FindActionAction) ShowPreferencesAction(org.eclipse.che.ide.actions.ShowPreferencesAction) ClearRecentListAction(org.eclipse.che.ide.part.editor.recent.ClearRecentListAction) NewFolderAction(org.eclipse.che.ide.newresource.NewFolderAction) PasteResourceAction(org.eclipse.che.ide.resources.action.PasteResourceAction) CollapseAllAction(org.eclipse.che.ide.actions.CollapseAllAction) OpenRecentFilesAction(org.eclipse.che.ide.part.editor.recent.OpenRecentFilesAction) CreateProjectAction(org.eclipse.che.ide.actions.CreateProjectAction) CompleteAction(org.eclipse.che.ide.actions.CompleteAction) ExpandEditorAction(org.eclipse.che.ide.actions.ExpandEditorAction) DownloadProjectAction(org.eclipse.che.ide.actions.DownloadProjectAction) MaximizePartAction(org.eclipse.che.ide.actions.common.MaximizePartAction) ShowReferenceAction(org.eclipse.che.ide.actions.ShowReferenceAction) DeleteResourceAction(org.eclipse.che.ide.actions.DeleteResourceAction) CloseAllExceptPinnedAction(org.eclipse.che.ide.part.editor.actions.CloseAllExceptPinnedAction) SplitHorizontallyAction(org.eclipse.che.ide.part.editor.actions.SplitHorizontallyAction) CopyResourceAction(org.eclipse.che.ide.resources.action.CopyResourceAction) SwitchPreviousEditorAction(org.eclipse.che.ide.part.editor.actions.SwitchPreviousEditorAction) SignatureHelpAction(org.eclipse.che.ide.actions.SignatureHelpAction) Action(org.eclipse.che.ide.api.action.Action) UploadFileAction(org.eclipse.che.ide.actions.UploadFileAction) CloseActiveEditorAction(org.eclipse.che.ide.actions.CloseActiveEditorAction) RefreshPathAction(org.eclipse.che.ide.actions.RefreshPathAction) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) DefaultActionGroup(org.eclipse.che.ide.api.action.DefaultActionGroup)

Example 14 with ActionEvent

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

the class KeyBindingManager method runActions.

/**
     * Finds and runs an action cancelling original key event
     *
     * @param actionIds
     *         list containing action ids
     * @param keyEvent
     *         original key event
     */
private void runActions(List<String> actionIds, Event keyEvent) {
    for (String actionId : actionIds) {
        Action action = actionManager.getAction(actionId);
        if (action == null) {
            continue;
        }
        ActionEvent e = new ActionEvent(presentationFactory.getPresentation(action), actionManager, perspectiveManager.get());
        action.update(e);
        if (e.getPresentation().isEnabled() && e.getPresentation().isVisible()) {
            /** Stop handling the key event */
            keyEvent.preventDefault();
            keyEvent.stopPropagation();
            /** Perform the action */
            action.actionPerformed(e);
        }
    }
}
Also used : Action(org.eclipse.che.ide.api.action.Action) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent)

Example 15 with ActionEvent

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

the class FileStructureActionTest method actionShouldBePerformed.

@Test
public void actionShouldBePerformed() throws Exception {
    ActionEvent e = mock(ActionEvent.class);
    action.actionPerformed(e);
    verify(editorAgent).getActiveEditor();
    verify(fileStructurePresenter).show(editorPartPresenter);
}
Also used : ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Test(org.junit.Test)

Aggregations

ActionEvent (org.eclipse.che.ide.api.action.ActionEvent)15 Action (org.eclipse.che.ide.api.action.Action)10 Presentation (org.eclipse.che.ide.api.action.Presentation)9 ActionGroup (org.eclipse.che.ide.api.action.ActionGroup)5 Separator (org.eclipse.che.ide.api.action.Separator)3 DefaultActionGroup (org.eclipse.che.ide.api.action.DefaultActionGroup)2 ToggleAction (org.eclipse.che.ide.api.action.ToggleAction)2 Test (org.junit.Test)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 DivElement (com.google.gwt.dom.client.DivElement)1 Image (com.google.gwt.user.client.ui.Image)1 Label (com.google.gwt.user.client.ui.Label)1 Inject (com.google.inject.Inject)1 Singleton (com.google.inject.Singleton)1 Element (elemental.dom.Element)1 Event (elemental.events.Event)1 EventListener (elemental.events.EventListener)1 LIElement (elemental.html.LIElement)1 SpanElement (elemental.html.SpanElement)1 ArrayList (java.util.ArrayList)1