use of org.eclipse.che.ide.api.action.Presentation in project che by eclipse.
the class MainMenuViewImpl method add.
/**
* Create and add new item in menu.
*/
private void add(Action action, PresentationFactory presentationFactory) {
Presentation presentation = presentationFactory.getPresentation(action);
if (action instanceof ActionGroup) {
ActionGroup group = (ActionGroup) action;
table.setText(0, menuBarItems.size(), presentation.getText());
Element element = table.getCellFormatter().getElement(0, menuBarItems.size());
MenuBarItem item = new MenuBarItem(group, actionManager, managerProvider, presentationFactory, element, this, keyBindingAgent, resources.menuCss());
item.onMouseOut();
menuBarItems.put(element, item);
action2barItem.put(group, item);
} else if (action instanceof CustomComponentAction) {
Widget widget = ((CustomComponentAction) action).createCustomComponent(presentation);
table.setWidget(0, menuBarItems.size(), widget);
Element element = table.getCellFormatter().getElement(0, menuBarItems.size());
menuBarItems.put(element, null);
}
}
use of org.eclipse.che.ide.api.action.Presentation 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();
}
}
}
use of org.eclipse.che.ide.api.action.Presentation 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();
}
use of org.eclipse.che.ide.api.action.Presentation in project che by eclipse.
the class SuspendAction method updateInPerspective.
@Override
public void updateInPerspective(ActionEvent event) {
final Presentation presentation = event.getPresentation();
final Debugger debugger = debuggerManager.getActiveDebugger();
if (debugger == null) {
presentation.setEnabledAndVisible(false);
return;
}
//Workaround: we don't support this action for another types of debugger
presentation.setVisible("gdb".equals(debugger.getDebuggerType()));
presentation.setEnabled(debugger.isConnected() && !debugger.isSuspended());
}
use of org.eclipse.che.ide.api.action.Presentation in project che by eclipse.
the class ToolbarViewImpl method createToolbarPart.
/**
* Creates a toolbar part widget.
*
* @return widget
*/
private Widget createToolbarPart(List<Utils.VisibleActionGroup> visibleActionGroupList) {
FlowPanel toolbarPart = new FlowPanel();
if (addSeparatorFirst) {
final Widget firstDelimiter = createDelimiter();
toolbarPart.add(firstDelimiter);
}
for (Utils.VisibleActionGroup visibleActionGroup : visibleActionGroupList) {
List<Action> actions = visibleActionGroup.getActionList();
if (actions == null || actions.size() == 0) {
continue;
}
FlowPanel actionGroupPanel = new FlowPanel();
actionGroupPanel.setStyleName(toolbarResources.toolbar().toolbarActionGroupPanel());
toolbarPart.add(actionGroupPanel);
for (Action action : actions) {
if (action instanceof Separator) {
int actionIndex = actions.indexOf(action);
if (actionIndex > 0 && actionIndex < actions.size() - 1) {
final Widget delimiter = createDelimiter();
actionGroupPanel.add(delimiter);
}
} else if (action instanceof CustomComponentAction) {
Presentation presentation = presentationFactory.getPresentation(action);
Widget customComponent = ((CustomComponentAction) action).createCustomComponent(presentation);
actionGroupPanel.add(customComponent);
} else if (action instanceof ActionGroup && ((ActionGroup) action).isPopup()) {
ActionPopupButton button = new ActionPopupButton((ActionGroup) action, actionManager, keyBindingAgent, presentationFactory, managerProvider, toolbarResources);
actionGroupPanel.add(button);
} else {
final ActionButton button = createToolbarButton(action);
actionGroupPanel.add(button);
}
}
}
return toolbarPart;
}
Aggregations