当前位置: 首页>>代码示例>>Java>>正文


Java Action.update方法代码示例

本文整理汇总了Java中org.eclipse.che.ide.api.action.Action.update方法的典型用法代码示例。如果您正苦于以下问题:Java Action.update方法的具体用法?Java Action.update怎么用?Java Action.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.che.ide.api.action.Action的用法示例。


在下文中一共展示了Action.update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runActions

import org.eclipse.che.ide.api.action.Action; //导入方法依赖的package包/类
/**
 * Finds and runs an action cancelling original key event
 *
 * @param actionIds list containing action ids
 * @param keyEvent original key event
 */
private void runActions(List<String> actionIds, Event keyEvent) {
  for (String actionId : actionIds) {
    Action action = actionManager.getAction(actionId);
    if (action == null) {
      continue;
    }
    ActionEvent e = new ActionEvent(presentationFactory.getPresentation(action), actionManager);
    action.update(e);

    if (e.getPresentation().isEnabled() && e.getPresentation().isVisible()) {
      /** Stop handling the key event */
      keyEvent.preventDefault();
      keyEvent.stopPropagation();

      /** Perform the action */
      action.actionPerformed(e);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:KeyBindingManager.java

示例2: performAction

import org.eclipse.che.ide.api.action.Action; //导入方法依赖的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);
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:ActionManagerImpl.java

示例3: onActionSelected

import org.eclipse.che.ide.api.action.Action; //导入方法依赖的package包/类
@Override
public void onActionSelected(Action action) {
  ActionEvent e = new ActionEvent(presentationFactory.getPresentation(action), actionManager);
  action.update(e);
  if (e.getPresentation().isEnabled() && e.getPresentation().isVisible()) {
    view.hide();
    action.actionPerformed(e);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:FindActionPresenter.java

示例4: render

import org.eclipse.che.ide.api.action.Action; //导入方法依赖的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 = "&nbsp;";
  } else {
    hotKey = "<nobr>&nbsp;[" + hotKey + "]&nbsp;</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);
}
 
开发者ID:eclipse,项目名称:che,代码行数:40,代码来源:FindActionViewImpl.java

示例5: expandActionGroup

import org.eclipse.che.ide.api.action.Action; //导入方法依赖的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();
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:MainMenuViewImpl.java

示例6: hasVisibleChildren

import org.eclipse.che.ide.api.action.Action; //导入方法依赖的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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:Utils.java

示例7: renderActionGroup

import org.eclipse.che.ide.api.action.Action; //导入方法依赖的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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:68,代码来源:Utils.java


注:本文中的org.eclipse.che.ide.api.action.Action.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。