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);
}
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> " + hotKey + " </nobr>";
}
SpanElement hotKeyElement = Elements.createSpanElement(style.hotKey());
hotKeyElement.setInnerHTML(hotKey);
divElement.appendChild(hotKeyElement);
return divElement;
}
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();
}
}
}
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);
}
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);
}
}
}
Aggregations