protected void fillContextMenu(IMenuManager manager) {
    Action removeAction =
        new Action(PDEUIMessages.CategorySection_remove) {
          public void run() {
            doGlobalAction(ActionFactory.DELETE.getId());
          }
        };
    removeAction.setEnabled(isEditable());
    manager.add(removeAction);
    getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager);

    ISelection selection = fCategoryViewer.getSelection();
    if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
      final ISiteFeature[] features = getFeaturesFromSelection((IStructuredSelection) selection);
      if (features.length > 0) {
        manager.add(new Separator());
        Action synchronizeAction = new SynchronizePropertiesAction(features, fModel);
        manager.add(synchronizeAction);
        Action buildAction =
            new Action(PDEUIMessages.CategorySection_build) {
              public void run() {
                ((SiteEditor) getPage().getPDEEditor()).handleBuild(features);
              }
            };
        buildAction.setEnabled(isEditable());
        manager.add(buildAction);
      }
    }
  }
Beispiel #2
0
 private void fillContextMenu(IMenuManager manager) {
   manager.add(action1);
   manager.add(action2);
   manager.add(new Separator());
   drillDownAdapter.addNavigationActions(manager);
   // Other plug-ins can contribute there actions here
   manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
 }
  @Override
  public void fillContextMenu(IMenuManager manager) {
    if (manager == null || expandAllAction == null) return;

    if (manager.find(TeamUIPlugin.REMOVE_FROM_VIEW_ACTION_ID) != null)
      manager.insertBefore(TeamUIPlugin.REMOVE_FROM_VIEW_ACTION_ID, expandAllAction);
    else appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, expandAllAction);
  }
Beispiel #4
0
 /**
  * Create a menu containing the specified actions.
  *
  * @param actions a collection of actions and null-values (that represent separators)
  */
 public void createMenu(IAction... actions) {
   IMenuManager mgr = site.getActionBars().getMenuManager();
   for (IAction ac : actions) {
     if (ac == null) {
       mgr.add(new Separator());
     } else {
       mgr.add(ac);
     }
   }
 }
Beispiel #5
0
 protected void fillContextMenu(IMenuManager manager, IAction... actions) {
   manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
   for (IAction ac : actions) {
     if (ac == null) {
       manager.add(new Separator());
     } else {
       if (ac instanceof RestrictedAction) {
         ((RestrictedAction) ac).reflectRight();
       }
       manager.add(ac);
     }
   }
 }
 /*
  * (non-Javadoc) Method declared in ActionGroup
  */
 public void fillContextMenu(IMenuManager menu) {
   super.fillContextMenu(menu);
   if (!canOperateOnSelection()) return;
   String menuText = PHPUIMessages.IncludePathActionGroup_label;
   IMenuManager subMenu = new MenuManager(menuText, MENU_ID);
   subMenu.addMenuListener(
       new IMenuListener() {
         public void menuAboutToShow(IMenuManager manager) {
           fillViewSubMenu(manager);
         }
       });
   subMenu.setRemoveAllWhenShown(true);
   subMenu.add(new ConfigureBuildPathAction(fSite));
   menu.appendToGroup(fGroupName, subMenu);
 }
 private int addAction(IMenuManager menu, IAction action) {
   if (action != null && action.isEnabled()) {
     menu.add(action);
     return 1;
   }
   return 0;
 }
  /* (non-Javadoc)
   * @see org.eclipse.jface.action.IMenuManager#findUsingPath(java.lang.String)
   */
  public IContributionItem findUsingPath(String path) {
    String id = path;
    String rest = null;
    int separator = path.indexOf('/');
    if (separator != -1) {
      id = path.substring(0, separator);
      rest = path.substring(separator + 1);
    } else {
      return super.find(path);
    }

    IContributionItem item = super.find(id);
    if (item instanceof IMenuManager) {
      IMenuManager manager = (IMenuManager) item;
      return manager.findUsingPath(rest);
    }
    return null;
  }
  private void fillViewSubMenu(IMenuManager source) {
    int added = 0;
    int i = 0;
    for (Iterator iter = fActions.iterator(); iter.hasNext(); ) {
      Action action = (Action) iter.next();
      if (action instanceof IUpdate) ((IUpdate) action).update();

      if (i == 2) source.add(new Separator(GROUP_INCLUDEPATH));
      else if (i == 8) source.add(new Separator(GROUP_FILTER));
      else if (i == 10) source.add(new Separator(GROUP_CUSTOMIZE));
      added += addAction(source, action);
      i++;
    }

    if (added == 0) {
      source.add(fNoActionAvailable);
    }
  }
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#fillContextMenu(org.eclipse.jface.action.IMenuManager)
   */
  protected void fillContextMenu(IMenuManager manager) {
    IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
    if (ssel == null) return;

    Action openAction =
        new Action(PDEUIMessages.PluginSection_open) {
          public void run() {
            handleDoubleClick((IStructuredSelection) fPluginTable.getSelection());
          }
        };
    openAction.setEnabled(isEditable() && ssel.size() == 1);
    manager.add(openAction);

    manager.add(new Separator());

    Action removeAction =
        new Action(PDEUIMessages.PluginSection_remove) {
          public void run() {
            handleDelete();
          }
        };
    removeAction.setEnabled(isEditable() && ssel.size() > 0);
    manager.add(removeAction);

    Action removeAll =
        new Action(PDEUIMessages.PluginSection_removeAll) {
          public void run() {
            handleRemoveAll();
          }
        };
    removeAll.setEnabled(isEditable());
    manager.add(removeAll);

    manager.add(new Separator());

    getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager);
  }
 @Override
 protected void fillContextMenu(IMenuManager manager) {
   ISelection selection = fPackageViewer.getSelection();
   manager.add(fAddAction);
   boolean singleSelection =
       selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1;
   if (singleSelection) manager.add(fGoToAction);
   manager.add(new Separator());
   if (!selection.isEmpty()) manager.add(fRemoveAction);
   getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager);
   if (singleSelection)
     manager.add(
         new Action(PDEUIMessages.ExportPackageSection_findReferences) {
           @Override
           public void run() {
             doSearch(fPackageViewer.getSelection());
           }
         });
   if (shouldEnableProperties(((IStructuredSelection) fPackageViewer.getSelection()).toArray())) {
     manager.add(new Separator());
     manager.add(fPropertiesAction);
   }
 }
 public void contributeToMenu(IMenuManager manager) {
   IMenuManager menu = new MenuManager("Editor &Menu");
   manager.prependToGroup(IWorkbenchActionConstants.MB_ADDITIONS, menu);
   menu.add(sampleAction);
 }
  /**
   * Incrementally builds the menu from the contribution items. This method leaves out double
   * separators and separators in the first or last position.
   *
   * @param force <code>true</code> means update even if not dirty, and <code>false</code> for
   *     normal incremental updating
   * @param recursive <code>true</code> means recursively update all submenus, and <code>false
   *     </code> means just this menu
   */
  protected void update(boolean force, boolean recursive) {
    if (isDirty() || force) {
      if (menuExist()) {
        // clean contains all active items without double separators
        IContributionItem[] items = getItems();
        List clean = new ArrayList(items.length);
        IContributionItem separator = null;
        for (int i = 0; i < items.length; ++i) {
          IContributionItem ci = items[i];
          if (!isChildVisible(ci)) {
            continue;
          }
          if (ci.isSeparator()) {
            // delay creation until necessary
            // (handles both adjacent separators, and separator at end)
            separator = ci;
          } else {
            if (separator != null) {
              if (clean.size() > 0) {
                clean.add(separator);
              }
              separator = null;
            }
            clean.add(ci);
          }
        }

        // remove obsolete (removed or non active)
        Item[] mi = getMenuItems();

        for (int i = 0; i < mi.length; i++) {
          Object data = mi[i].getData();

          if (data == null || !clean.contains(data)) {
            mi[i].dispose();
          } else if (data instanceof IContributionItem
              && ((IContributionItem) data).isDynamic()
              && ((IContributionItem) data).isDirty()) {
            mi[i].dispose();
          }
        }

        // add new
        mi = getMenuItems();
        int srcIx = 0;
        int destIx = 0;

        for (Iterator e = clean.iterator(); e.hasNext(); ) {
          IContributionItem src = (IContributionItem) e.next();
          IContributionItem dest;

          // get corresponding item in SWT widget
          if (srcIx < mi.length) {
            dest = (IContributionItem) mi[srcIx].getData();
          } else {
            dest = null;
          }

          if (dest != null && src.equals(dest)) {
            srcIx++;
            destIx++;
          } else if (dest != null && dest.isSeparator() && src.isSeparator()) {
            mi[srcIx].setData(src);
            srcIx++;
            destIx++;
          } else {
            int start = getMenuItemCount();
            doItemFill(src, destIx);
            int newItems = getMenuItemCount() - start;
            for (int i = 0; i < newItems; i++) {
              Item item = getMenuItem(destIx++);
              item.setData(src);
            }
          }

          // May be we can optimize this call. If the menu has just
          // been created via the call src.fill(fMenuBar, destIx) then
          // the menu has already been updated with update(true)
          // (see MenuManager). So if force is true we do it again. But
          // we can't set force to false since then information for the
          // sub sub menus is lost.
          if (recursive) {
            IContributionItem item = src;
            if (item instanceof SubContributionItem) {
              item = ((SubContributionItem) item).getInnerItem();
            }
            if (item instanceof IMenuManager) {
              ((IMenuManager) item).updateAll(force);
            }
          }
        }

        // remove any old menu items not accounted for
        for (; srcIx < mi.length; srcIx++) {
          mi[srcIx].dispose();
        }

        setDirty(false);
      }
    } else {
      // I am not dirty. Check if I must recursivly walk down the hierarchy.
      if (recursive) {
        IContributionItem[] items = getItems();
        for (int i = 0; i < items.length; ++i) {
          IContributionItem ci = items[i];
          if (ci instanceof IMenuManager) {
            IMenuManager mm = (IMenuManager) ci;
            if (isChildVisible(mm)) {
              mm.updateAll(force);
            }
          }
        }
      }
    }
    updateMenuItem();
  }
Beispiel #14
0
 private void fillLocalPullDown(IMenuManager manager) {
   manager.add(action1);
   manager.add(new Separator());
   manager.add(action2);
 }