Search in sources :

Example 1 with ActionEvent

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

the class FindActionPresenter method onActionSelected.

@Override
public void onActionSelected(Action action) {
    ActionEvent e = new ActionEvent(presentationFactory.getPresentation(action), actionManager, perspectiveManager.get());
    action.update(e);
    if (e.getPresentation().isEnabled() && e.getPresentation().isVisible()) {
        view.hide();
        action.actionPerformed(e);
    }
}
Also used : ActionEvent(org.eclipse.che.ide.api.action.ActionEvent)

Example 2 with ActionEvent

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

the class MainMenuViewImpl method expandActionGroup.

private void expandActionGroup(List<Action> newVisibleActions, ActionManager actionManager, ActionGroup mainActionGroup) {
    final Action[] children = mainActionGroup.getChildren(null);
    for (final Action action : children) {
        final Presentation presentation = presentationFactory.getPresentation(action);
        final ActionEvent e = new ActionEvent(presentation, actionManager, managerProvider.get());
        action.update(e);
        if (presentation.isVisible()) {
            // add only visible items
            newVisibleActions.add(action);
        }
        if (action2barItem.containsKey(action)) {
            action2barItem.get(action).update();
        }
    }
}
Also used : CustomComponentAction(org.eclipse.che.ide.api.action.CustomComponentAction) Action(org.eclipse.che.ide.api.action.Action) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Presentation(org.eclipse.che.ide.api.action.Presentation)

Example 3 with ActionEvent

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

the class EmptyEditorsPanel method renderAction.

private Node renderAction(String title, final Action action) {
    final Presentation presentation = presentationFactory.getPresentation(action);
    Element divElement = Elements.createDivElement(style.listElement());
    divElement.addEventListener("click", new EventListener() {

        @Override
        public void handleEvent(Event evt) {
            ActionEvent event = new ActionEvent(presentation, actionManager, perspectiveManagerProvider.get());
            action.actionPerformed(event);
        }
    }, true);
    divElement.getStyle().setCursor("pointer");
    divElement.getStyle().setColor(Style.getOutputLinkColor());
    Element label = Elements.createDivElement(style.actionLabel());
    label.setInnerText(title);
    divElement.appendChild(label);
    String hotKey = KeyMapUtil.getShortcutText(keyBindingAgent.getKeyBinding(actionManager.getId(action)));
    if (hotKey == null) {
        hotKey = "&nbsp;";
    } else {
        hotKey = "<nobr>&nbsp;" + hotKey + "&nbsp;</nobr>";
    }
    SpanElement hotKeyElement = Elements.createSpanElement(style.hotKey());
    hotKeyElement.setInnerHTML(hotKey);
    divElement.appendChild(hotKeyElement);
    return divElement;
}
Also used : SpanElement(elemental.html.SpanElement) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Element(elemental.dom.Element) DivElement(com.google.gwt.dom.client.DivElement) LIElement(elemental.html.LIElement) SpanElement(elemental.html.SpanElement) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent) Event(elemental.events.Event) EventListener(elemental.events.EventListener) Presentation(org.eclipse.che.ide.api.action.Presentation)

Example 4 with ActionEvent

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

the class StatusPanelGroupViewImpl method expandActionGroup.

private void expandActionGroup(List<Action> newVisibleActions, ActionManager actionManager, ActionGroup mainActionGroup) {
    final Action[] children = mainActionGroup.getChildren(null);
    for (final Action action : children) {
        final Presentation presentation = presentationFactory.getPresentation(action);
        final ActionEvent e = new ActionEvent(presentation, actionManager, perspectiveManager.get());
        action.update(e);
        if (presentation.isVisible()) {
            // add only visible items
            newVisibleActions.add(action);
        }
        if (action2barItem.containsKey(action)) {
            action2barItem.get(action).update();
        }
    }
}
Also used : CustomComponentAction(org.eclipse.che.ide.api.action.CustomComponentAction) Action(org.eclipse.che.ide.api.action.Action) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Presentation(org.eclipse.che.ide.api.action.Presentation)

Example 5 with ActionEvent

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

the class DebugConfigurationActionTest method shouldBeVisibleOnUpdate.

@Test
public void shouldBeVisibleOnUpdate() {
    String confName = "test_conf";
    when(debugConfiguration.getName()).thenReturn(confName);
    DebugConfiguration configuration = mock(DebugConfiguration.class);
    Optional<DebugConfiguration> configurationOptional = mock(Optional.class);
    when(configurationOptional.isPresent()).thenReturn(Boolean.TRUE);
    when(configurationOptional.get()).thenReturn(configuration);
    when(debugConfigurationsManager.getCurrentDebugConfiguration()).thenReturn(configurationOptional);
    ActionEvent event = mock(ActionEvent.class);
    Presentation presentation = mock(Presentation.class);
    when(event.getPresentation()).thenReturn(presentation);
    action.updateInPerspective(event);
    verify(presentation).setEnabledAndVisible(true);
}
Also used : DebugConfiguration(org.eclipse.che.ide.api.debug.DebugConfiguration) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Presentation(org.eclipse.che.ide.api.action.Presentation) 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