use of org.eclipse.che.ide.api.action.Action in project che by eclipse.
the class PopupMenu method isRowEnabled.
private boolean isRowEnabled(Element tr) {
if (tr == null) {
return false;
}
String index = tr.getAttribute("item-index");
if (index == null || "".equals(index)) {
return false;
}
String enabled = tr.getAttribute("item-enabled");
if (enabled == null || "".equals(enabled) || "false".equals(enabled)) {
return false;
}
int itemIndex = Integer.parseInt(index);
Action menuItem = list.get(itemIndex);
return presentationFactory.getPresentation(menuItem).isEnabled();
}
use of org.eclipse.che.ide.api.action.Action in project che by eclipse.
the class PopupMenu method onRowHovered.
/**
* Handling MouseOver event.
*
* @param tr
* - element to be processed.
*/
protected void onRowHovered(Element tr) {
if (tr == hoveredTR) {
return;
}
setStyleNormal(hoveredTR);
if (subPopupAnchor != null) {
setStyleHovered(subPopupAnchor);
}
if (!isRowEnabled(tr)) {
hoveredTR = null;
return;
}
hoveredTR = tr;
setStyleHovered(tr);
int itemIndex = Integer.parseInt(tr.getAttribute("item-index"));
Action menuItem = list.get(itemIndex);
openSubPopupTimer.cancel();
if (menuItem instanceof ActionGroup && !(((ActionGroup) menuItem).canBePerformed() && !Utils.hasVisibleChildren((ActionGroup) menuItem, presentationFactory, actionManager, managerProvider.get()))) {
openSubPopupTimer.schedule(300);
} else {
closeSubPopupTimer.cancel();
closeSubPopupTimer.schedule(200);
}
}
use of org.eclipse.che.ide.api.action.Action 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;
}
use of org.eclipse.che.ide.api.action.Action in project che by eclipse.
the class ActionManagerImpl method getParentGroup.
public Action getParentGroup(final String groupId, final String actionName, final String pluginId) {
if (groupId == null || groupId.length() == 0) {
reportActionError(pluginId, actionName + ": attribute \"group-id\" should be defined");
return null;
}
Action parentGroup = getActionImpl(groupId, true);
if (parentGroup == null) {
reportActionError(pluginId, actionName + ": group with id \"" + groupId + "\" isn't registered; action will be added to the \"Other\" group");
parentGroup = getActionImpl(IdeActions.GROUP_OTHER_MENU, true);
}
if (!(parentGroup instanceof DefaultActionGroup)) {
reportActionError(pluginId, actionName + ": group with id \"" + groupId + "\" should be instance of " + DefaultActionGroup.class.getName() + " but was " + parentGroup.getClass());
return null;
}
return parentGroup;
}
use of org.eclipse.che.ide.api.action.Action in project che by eclipse.
the class ActionManagerImpl method unregisterAction.
@Override
public void unregisterAction(String actionId) {
if (!myId2Action.containsKey(actionId)) {
Log.debug(getClass(), "action with ID " + actionId + " wasn't registered");
return;
}
Action oldValue = (Action) myId2Action.remove(actionId);
myAction2Id.remove(oldValue);
myId2Index.remove(actionId);
for (Entry<String, Set<String>> entry : myPlugin2Id.entrySet()) {
final Set<String> pluginActions = entry.getValue();
if (pluginActions != null) {
pluginActions.remove(actionId);
}
}
}
Aggregations