예제 #1
0
  @Override
  public void fillContextMenu(IMenuManager menuManager) {
    menuManager.appendToGroup(
        ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(undoAction));
    menuManager.appendToGroup(
        ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(redoAction));
    menuManager.appendToGroup(ICommonMenuConstants.GROUP_EDIT, new Separator());
    menuManager.appendToGroup(
        ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(cutAction));
    menuManager.appendToGroup(
        ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(copyAction));
    menuManager.appendToGroup(
        ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(pasteAction));

    IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();

    boolean anyResourceSelected = !selection.isEmpty();
    if (anyResourceSelected) {
      removeAction.selectionChanged(selection);
      menuManager.appendToGroup(
          ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(removeAction));
    }
  }