Search in sources :

Example 6 with Presentation

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

the class FullTextSearchActionTest method actionShouldBeEnabled.

@Test
public void actionShouldBeEnabled() {
    Presentation presentation = Mockito.mock(Presentation.class);
    when(actionEvent.getPresentation()).thenReturn(presentation);
    when(appContext.getRootProject()).thenReturn(project);
    fullTextSearchAction.updateInPerspective(actionEvent);
    verify(presentation).setVisible(true);
    verify(presentation).setEnabled(true);
}
Also used : Presentation(org.eclipse.che.ide.api.action.Presentation) Test(org.junit.Test)

Example 7 with Presentation

use of org.eclipse.che.ide.api.action.Presentation 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 = " ";
    } 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 8 with Presentation

use of org.eclipse.che.ide.api.action.Presentation 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 9 with Presentation

use of org.eclipse.che.ide.api.action.Presentation 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)

Example 10 with Presentation

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

the class ActionManagerImpl method performAction.

@Override
public void performAction(String actionId, Map<String, String> parameters) {
    final Action action;
    if (actionId != null && (action = getAction(actionId)) != null) {
        final Presentation presentation = presentationFactory.getPresentation(action);
        final ActionEvent actionEvent = new ActionEvent(presentation, this, managerProvider.get(), parameters);
        action.update(actionEvent);
        if (presentation.isEnabled() && presentation.isVisible()) {
            action.actionPerformed(actionEvent);
        }
    }
}
Also used : PromisableAction(org.eclipse.che.ide.api.action.PromisableAction) Action(org.eclipse.che.ide.api.action.Action) ActionEvent(org.eclipse.che.ide.api.action.ActionEvent) Presentation(org.eclipse.che.ide.api.action.Presentation)

Aggregations

Presentation (org.eclipse.che.ide.api.action.Presentation)17 Action (org.eclipse.che.ide.api.action.Action)10 ActionEvent (org.eclipse.che.ide.api.action.ActionEvent)9 ActionGroup (org.eclipse.che.ide.api.action.ActionGroup)7 CustomComponentAction (org.eclipse.che.ide.api.action.CustomComponentAction)4 Separator (org.eclipse.che.ide.api.action.Separator)4 Test (org.junit.Test)3 Widget (com.google.gwt.user.client.ui.Widget)2 DefaultActionGroup (org.eclipse.che.ide.api.action.DefaultActionGroup)2 DivElement (com.google.gwt.dom.client.DivElement)1 Element (com.google.gwt.dom.client.Element)1 RegExp (com.google.gwt.regexp.shared.RegExp)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 Image (com.google.gwt.user.client.ui.Image)1 Label (com.google.gwt.user.client.ui.Label)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