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