本文整理汇总了Java中org.eclipse.che.ide.api.action.Presentation.isVisible方法的典型用法代码示例。如果您正苦于以下问题:Java Presentation.isVisible方法的具体用法?Java Presentation.isVisible怎么用?Java Presentation.isVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.che.ide.api.action.Presentation
的用法示例。
在下文中一共展示了Presentation.isVisible方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performAction
import org.eclipse.che.ide.api.action.Presentation; //导入方法依赖的package包/类
@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, parameters);
action.update(actionEvent);
if (presentation.isEnabled() && presentation.isVisible()) {
action.actionPerformed(actionEvent);
}
}
}
示例2: render
import org.eclipse.che.ide.api.action.Presentation; //导入方法依赖的package包/类
@Override
public void render(Element itemElement, Action itemData) {
TableCellElement icon = Elements.createTDElement(css.proposalIcon());
TableCellElement label = Elements.createTDElement(css.proposalLabel());
TableCellElement group = Elements.createTDElement(css.proposalGroup());
Presentation presentation = presentationFactory.getPresentation(itemData);
itemData.update(new ActionEvent(presentation, actionManager));
if (presentation.getImageElement() != null) {
ElementWidget image = new ElementWidget(presentation.getImageElement());
image.getElement().setAttribute("class", toolbarResources.toolbar().iconButtonIcon());
image.getElement().getStyle().setMargin(0, Style.Unit.PX);
icon.appendChild((Node) image.getElement());
} else if (presentation.getHTMLResource() != null) {
icon.setInnerHTML(presentation.getHTMLResource());
}
String hotKey =
KeyMapUtil.getShortcutText(
keyBindingAgent.getKeyBinding(actionManager.getId(itemData)));
if (hotKey == null) {
hotKey = " ";
} else {
hotKey = "<nobr> [" + hotKey + "] </nobr>";
}
label.setInnerHTML(presentation.getText() + hotKey);
if (!presentation.isEnabled() || !presentation.isVisible()) {
itemElement.getStyle().setProperty("opacity", "0.6");
}
String groupName = actions.get(itemData);
if (groupName != null) {
group.setInnerHTML(groupName);
}
itemElement.appendChild(icon);
itemElement.appendChild(label);
itemElement.appendChild(group);
}
示例3: expandActionGroup
import org.eclipse.che.ide.api.action.Presentation; //导入方法依赖的package包/类
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);
action.update(e);
if (presentation.isVisible()) { // add only visible items
newVisibleActions.add(action);
}
if (action2barItem.containsKey(action)) {
action2barItem.get(action).update();
}
}
}
示例4: hasVisibleChildren
import org.eclipse.che.ide.api.action.Presentation; //导入方法依赖的package包/类
/**
* Returns true if action group has visible children.
*
* @param group action group
* @param factory presentation factory
* @param actionManager action manager
* @return boolean
*/
public static boolean hasVisibleChildren(
ActionGroup group, PresentationFactory factory, ActionManager actionManager) {
ActionEvent event = new ActionEvent(factory.getPresentation(group), actionManager);
for (Action anAction : group.getChildren(event)) {
if (anAction == null) {
Log.error(
Utils.class,
"Null action found in group " + group + ", " + factory.getPresentation(group));
continue;
}
if (anAction instanceof Separator) {
continue;
}
final Presentation presentation = factory.getPresentation(anAction);
anAction.update(new ActionEvent(presentation, actionManager));
if (anAction instanceof ActionGroup) {
ActionGroup childGroup = (ActionGroup) anAction;
// popup menu must be visible itself
if (childGroup.isPopup()) {
if (!presentation.isVisible()) {
continue;
}
}
if (hasVisibleChildren(childGroup, factory, actionManager)) {
return true;
}
} else if (presentation.isVisible()) {
return true;
}
}
return false;
}
示例5: renderActionGroup
import org.eclipse.che.ide.api.action.Presentation; //导入方法依赖的package包/类
/**
* Returns the list of visible action group.
*
* @param group action group
* @param presentationFactory presentation factory
* @param actionManager action manager
* @return list of visible action group
*/
public static List<VisibleActionGroup> renderActionGroup(
@NotNull ActionGroup group,
PresentationFactory presentationFactory,
ActionManager actionManager) {
Presentation presentation = presentationFactory.getPresentation(group);
ActionEvent event = new ActionEvent(presentation, actionManager);
if (!presentation.isVisible()) { // don't process invisible groups
return null;
}
Action[] children = group.getChildren(event);
List<VisibleActionGroup> currentVisibleActionGroupList = new ArrayList<>();
List<Action> currentActionList = new ArrayList<>();
String currentGroupId = actionManager.getId(group);
for (Action child : children) {
if (child == null) {
Log.error(Utils.class, "action is null: group=" + group + " group id=" + currentGroupId);
continue;
}
presentation = presentationFactory.getPresentation(child);
child.update(new ActionEvent(presentation, actionManager));
if (!presentation.isVisible()) { // don't create invisible items in the menu
continue;
}
if (child instanceof ActionGroup) {
ActionGroup actionGroup = (ActionGroup) child;
if (actionGroup.isPopup()) { // popup menu has its own presentation
if (actionGroup.disableIfNoVisibleChildren()) {
final boolean visibleChildren =
hasVisibleChildren(actionGroup, presentationFactory, actionManager);
if (actionGroup.hideIfNoVisibleChildren() && !visibleChildren) {
continue;
}
presentation.setEnabled(actionGroup.canBePerformed() || visibleChildren);
}
currentActionList.add(child);
} else {
List<VisibleActionGroup> newVisibleActionGroupList =
renderActionGroup((ActionGroup) child, presentationFactory, actionManager);
currentVisibleActionGroupList.addAll(newVisibleActionGroupList);
}
} else if (child instanceof Separator) {
if ((((Separator) child).getText() != null)
|| (!currentActionList.isEmpty()
&& !(currentActionList.get(currentActionList.size() - 1) instanceof Separator))) {
currentActionList.add(child);
}
} else {
currentActionList.add(child);
}
}
currentVisibleActionGroupList.add(0, new VisibleActionGroup(currentGroupId, currentActionList));
return currentVisibleActionGroupList;
}