public void buildMenu(IMenuManager manager) {
      if (getSelectedObject(myWorkbenchPart) instanceof GraphicalEditPart) {
        manager.removeAll();
        GraphicalEditPart selected = (GraphicalEditPart) getSelectedObject(myWorkbenchPart);

        org.eclipse.uml2.uml.Package package_ =
            (org.eclipse.uml2.uml.Package) selected.getNotationView().getElement();
        loadProfilesFromUML2Registry(package_);

        List<Profile> profiles = getProfiles(package_);
        for (Profile profile : profiles) {
          // no much sense to cache dynamic target specific actions
          ApplyProfileAction action = new ApplyProfileAction(getWorkbenchPage(), package_, profile);
          action.init();
          manager.add(action);
        }

        Collection<ProfileInfo> profilesFromRegistry = getProfilesFromRegistry(package_);
        List<String> loadedProfileUris = new ArrayList<String>(profiles.size());
        for (Profile profile : profiles) {
          loadedProfileUris.add(EcoreUtil.getURI(profile).toString());
        }
        for (ProfileInfo profileInfo : profilesFromRegistry) {
          // filter profiles, that have already been loaded
          if (loadedProfileUris.contains(profileInfo.uri)) {
            continue;
          }
          ApplyProfileInfoAction action =
              new ApplyProfileInfoAction(getWorkbenchPage(), package_, profileInfo);
          action.init();
          manager.add(action);
        }
      }
    }
 @Override
 public void fillContextMenu(IMenuManager menu) {
   IMenuManager buildPathMenu = (IMenuManager) menu.find(BUILD_PATH_MENU_ID);
   if (buildPathMenu != null) {
     buildPathMenu.addMenuListener(
         new IMenuListener() {
           @Override
           public void menuAboutToShow(IMenuManager manager) {
             ISelection selection = selectionProvider.getSelection();
             if (selection instanceof IStructuredSelection) {
               IStructuredSelection structuredSelection = (IStructuredSelection) selection;
               if (structuredSelection.size() == 1) {
                 Object firstElement = structuredSelection.getFirstElement();
                 if (firstElement instanceof IPackageFragment) {
                   IPackageFragment packageFragment = (IPackageFragment) firstElement;
                   IProject project = packageFragment.getJavaProject().getProject();
                   if (isCeylonProject(project)) {
                     Module module = getModule(project, packageFragment.getElementName());
                     if (module != null) {
                       manager.add(new AddCeylonTestImportAction(project, module));
                     }
                   }
                 }
               }
             }
           }
         });
   }
 }
  /** Adds a submenu to the given menu with the name "New Component". */
  @Override
  public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
      return;
    }

    // ADD msjian TDQ-10444: fix get error when click on the exchange node
    if (isExchangeNode()) {
      return;
    }
    // TDQ-10444~

    Object obj = ((TreeSelection) this.getContext().getSelection()).getFirstElement();
    if (obj instanceof RepositoryNode) {
      RepositoryNode node = (RepositoryNode) obj;
      // RepositoryNode parent = node.getParent();
      // if (!(parent instanceof ReportSubFolderRepNode)) {
      if (shouldShowDeleteMenu(node)) {
        // menu.add(new DeleteObjectsAction());
        menu.add(new DQDeleteAction());
        if (shouldShowRenameFolderMenu(node)) {
          Object type = node.getProperties(EProperties.CONTENT_TYPE);
          if (ERepositoryObjectType.TDQ_JRAXML_ELEMENT.equals(type)) {
            menu.add(new RenameJrxmlFolderAction(node));
          } else {
            menu.add(new RenameTdqFolderAction(node));
          }
        }
      }
      // }
    }
  }
  /**
   * The <code>PropertySheet</code> implementation of this <code>IWorkbenchPart</code> method
   * creates a <code>PageBook</code> control with its default page showing.
   */
  public void createPartControl(Composite parent) {
    super.createPartControl(parent);

    pinPropertySheetAction.addPropertyChangeListener(
        new IPropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent event) {
            if (IAction.CHECKED.equals(event.getProperty())) {
              updateContentDescription();
            }
          }
        });
    IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
    menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    menuManager.add(pinPropertySheetAction);

    IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
    menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    toolBarManager.add(pinPropertySheetAction);

    getSite()
        .getPage()
        .getWorkbenchWindow()
        .getWorkbench()
        .getHelpSystem()
        .setHelp(getPageBook(), IPropertiesHelpContextIds.PROPERTY_SHEET_VIEW);
  }
  /** Place the actions in the ui. */
  private void placeActions() {
    IActionBars actionBars = getViewSite().getActionBars();

    // first in the menu
    IMenuManager menuManager = actionBars.getMenuManager();
    menuManager.add(mCreateFilterAction);
    menuManager.add(mEditFilterAction);
    menuManager.add(mDeleteFilterAction);
    menuManager.add(new Separator());
    menuManager.add(mClearAction);
    menuManager.add(new Separator());
    menuManager.add(mExportAction);
    menuManager.add(mGotoMethodDeclarationAction);
    menuManager.add(mGotoErrorLineAction);

    // and then in the toolbar
    IToolBarManager toolBarManager = actionBars.getToolBarManager();
    for (CommonAction a : mLogLevelActions) {
      toolBarManager.add(a);
    }
    toolBarManager.add(new Separator());
    toolBarManager.add(mCreateFilterAction);
    toolBarManager.add(mEditFilterAction);
    toolBarManager.add(mDeleteFilterAction);
    toolBarManager.add(new Separator());
    toolBarManager.add(mClearAction);
  }
 public void testEditorContextMenuAboutToShow() {
   IMenuManager menu = new MenuManager();
   fEditor.editorContextMenuAboutToShow(menu);
   assertTrue("Unable to prepare for context menu about to show", true);
   menu.dispose();
   menu = null;
 }
 protected void rulerContextMenuAboutToShow(IMenuManager menu) {
   menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
   menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
   addAction(menu, IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT);
   addAction(menu, IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT);
   addAction(menu, IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES);
 }
Beispiel #8
0
 private void fillContextMenu(IMenuManager manager) {
   manager.add(connection);
   manager.add(new Separator());
   // drillDownAdapter.addNavigationActions(manager);
   // Other plug-ins can contribute there actions here
   // manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
 }
 /** called to create the context menu of the outline */
 protected void contextMenuAboutToShow(IMenuManager menu) {
   if (OpenIncludeAction.canActionBeAdded(getSelection())) {
     menu.add(fOpenIncludeAction);
   }
   menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
   menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); // $NON-NLS-1$
 }
 private void fillContextMenu(IMenuManager manager) {
   manager.add(action1);
   manager.add(action2);
   manager.add(new Separator());
   drillDownAdapter.addNavigationActions(manager);
   manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
 }
  protected void fillMenuBar(IMenuManager menuBar) {
    MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
    MenuManager actionsMenu = new MenuManager("&Actions");
    MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);

    menuBar.add(fileMenu);
    // Add a group marker indicating where action set menus will appear.
    menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    menuBar.add(actionsMenu);
    menuBar.add(helpMenu);

    // File
    fileMenu.add(newWindowAction);
    fileMenu.add(new Separator());
    // fileMenu.add(messagePopupAction);

    fileMenu.add(new Separator());
    fileMenu.add(exitAction);

    actionsMenu.add(openDbConnectionViewAction);
    actionsMenu.add(openRepositoriesViewAction);
    actionsMenu.add(openSoftwareInstalledViewAction);

    // Help
    helpMenu.add(aboutAction);
  }
 private int fillViewSubMenu(IMenuManager source) {
   int added = 0;
   source.add(new Separator(GROUP_COMMENT));
   //    added += addAction(source, fAddJavaDocStub);
   source.add(new Separator(GROUP_EDIT));
   added += addAction(source, fFormatAll);
   source.add(new Separator(GROUP_IMPORT));
   //    added += addAction(source, fSortMembers);
   //    added += addAction(source, fCleanUp);
   //    if (IUIConstants.SUPPORT_REFACTORING) {
   //      source.add(new Separator(GROUP_GENERATE));
   //      added += addAction(source, fOverrideMethods);
   //      added += addAction(source, fAddGetterSetter);
   //      added += addAction(source, fAddDelegateMethods);
   //      // added+= addAction(source, fHashCodeEquals);
   //      added += addAction(source, fGenerateConstructorUsingFields);
   //      // added+= addAction(source, fAddUnimplementedConstructors);
   //    }
   source.add(new Separator(GROUP_CODE));
   source.add(new Separator(GROUP_EXTERNALIZE));
   //    if (IUIConstants.SUPPORT_REFACTORING) {
   //      added += addAction(source, fExternalizeStrings);
   //      added += addAction(source, fFindNLSProblems);
   //    }
   return added;
 }
  private int fillEditorSubMenu(IMenuManager source) {
    int added = 0;
    source.add(new Separator(GROUP_COMMENT));
    added += addEditorAction(source, "ToggleComment"); // $NON-NLS-1$
    added += addEditorAction(source, "AddBlockComment"); // $NON-NLS-1$
    added += addEditorAction(source, "RemoveBlockComment"); // $NON-NLS-1$
    //    added += addAction(source, fAddJavaDocStub);
    source.add(new Separator(GROUP_EDIT));
    added += addEditorAction(source, "Indent"); // $NON-NLS-1$
    added += addEditorAction(source, "Format"); // $NON-NLS-1$
    source.add(new Separator(GROUP_IMPORT));
    //    added += addAction(source, fSortMembers);
    //    added += addAction(source, fCleanUp);

    //    if (IUIConstants.SUPPORT_REFACTORING) {
    //      source.add(new Separator(GROUP_GENERATE));
    //      added += addAction(source, fOverrideMethods);
    //      added += addAction(source, fAddGetterSetter);
    //      added += addAction(source, fAddDelegateMethods);
    //      // added+= addAction(source, fHashCodeEquals);
    //      added += addAction(source, fGenerateConstructorUsingFields);
    //    }
    // added+= addAction(source, fAddUnimplementedConstructors);
    source.add(new Separator(GROUP_CODE));
    source.add(new Separator(GROUP_EXTERNALIZE));
    //    if (IUIConstants.SUPPORT_REFACTORING)
    //      added += addAction(source, fExternalizeStrings);
    return added;
  }
  @Override
  public void fillContextMenu(IMenuManager menu) {
    boolean onlyEnvironmentsSelected = true;
    StructuredSelection selection =
        (StructuredSelection) getActionSite().getStructuredViewer().getSelection();
    Iterator iterator = selection.iterator();
    List<EnvironmentDescription> environments = new ArrayList<EnvironmentDescription>();
    while (iterator.hasNext()) {
      Object obj = iterator.next();
      if (obj instanceof EnvironmentDescription) {
        environments.add((EnvironmentDescription) obj);
      } else {
        onlyEnvironmentsSelected = false;
      }
    }

    if (onlyEnvironmentsSelected) {
      if (environments.size() == 1) {
        menu.add(new OpenEnvironmentEditorAction(environments.get(0)));
        menu.add(new Separator());
      }

      menu.add(new TerminateEnvironmentsAction(environments));
    }
  }
Beispiel #15
0
 /**
  * Adds actions for "go back", "go home", and "go into" to a menu manager.
  *
  * @param manager is the target manager to update
  */
 public void addNavigationActions(IMenuManager manager) {
   createActions();
   manager.add(homeAction);
   manager.add(backAction);
   manager.add(forwardAction);
   updateNavigationButtons();
 }
  protected void initViewMenu() {
    IMenuManager viewMenu = commonNavigator.getViewSite().getActionBars().getMenuManager();
    viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); // $NON-NLS-1$

    updateActionBars.schedule(NavigatorPlugin.ACTION_BAR_DELAY);
  }
    @Override
    public void menuAboutToShow(IMenuManager manager) {
      manager.add(
          new Action(Messages.MenuExportChartData) {
            @Override
            public void run() {
              ScatterChartCSVExporter exporter = new ScatterChartCSVExporter(chart);
              exporter.setValueFormat(new DecimalFormat("0.##########%")); // $NON-NLS-1$
              exporter.export(getTitle() + ".csv"); // $NON-NLS-1$
            }
          });

      Set<Class<?>> exportTypes =
          new HashSet<Class<?>>(
              Arrays.asList(
                  new Class<?>[] { //
                    Client.class,
                    Security.class,
                    Portfolio.class,
                    Account.class,
                    Classification.class
                  }));

      for (DataSeries series : picker.getSelectedDataSeries()) {
        if (exportTypes.contains(series.getType())) addMenu(manager, series);
      }

      manager.add(new Separator());
      chart.exportMenuAboutToShow(manager, getTitle());
    }
 protected void fillContextMenu(IMenuManager manager) {
   manager.add(getAction("change_value"));
   manager.add(new Separator());
   drillDownAdapter.addNavigationActions(manager);
   // Other plug-ins can contribute there actions here
   manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
 }
Beispiel #19
0
  protected void updatePeriodActions() {
    IActionBars actionBars = getViewSite().getActionBars();

    IMenuManager menuManager = actionBars.getMenuManager();
    if (periodActions != null) {
      for (int i = 0; i < periodActions.length; i++) {
        menuManager.remove(periodActions[i]);
        periodActions[i].dispose();
      }
      periodActions = null;
    }

    createPeriodActions();

    if (periodActions != null) {
      for (int i = 0; i < periodActions.length; i++) {
        menuManager.appendToGroup("periods", periodActions[i]);
      }
    }

    TimeSpan periodTimeSpan = TimeSpan.fromString(dialogSettings.get(K_PERIOD));
    TimeSpan resolutionTimeSpan = TimeSpan.fromString(dialogSettings.get(K_RESOLUTION));
    setPeriodActionSelection(periodTimeSpan, resolutionTimeSpan);

    actionBars.updateActionBars();
  }
  public static void addActionsLibraryToMenu(IMenuManager manager) {
    if (!actionsLoaded) {
      initActions();
    }

    addMenuForAspect(
        manager, MODELING_ASPECT_LABELS.MODEL_PROJECT_MANAGEMENT, ASPECT_MODEL_PROJECT_MANAGEMENT);
    addMenuForAspect(manager, MODELING_ASPECT_LABELS.DEFINE_MODELS, ASPECT_DEFINE_MODELS);
    addMenuForAspect(manager, MODELING_ASPECT_LABELS.MANAGE_CONNECTIONS, ASPECT_MANAGE_CONNECTIONS);
    addMenuForAspect(manager, MODELING_ASPECT_LABELS.MODEL_DATA_SOURCES, ASPECT_MODEL_DATA_SOURCES);
    // addMenuForAspect(manager, MODELING_ASPECT_LABELS.CONSUME_REST_WS, ASPECT_CONSUME_REST_WS);
    //		addMenuForAspect(manager, MODELING_ASPECT_LABELS.CONSUME_SOAP_WS, ASPECT_CONSUME_SOAP_WS);
    addMenuForAspect(manager, MODELING_ASPECT_LABELS.MANAGE_VDBS, ASPECT_MANAGE_VDBS);
    addMenuForAspect(manager, MODELING_ASPECT_LABELS.TEIID_SERVER, ASPECT_TEIID_SERVER);
    addMenuForAspect(manager, MODELING_ASPECT_LABELS.TEST, ASPECT_TEST);

    if (!cheatSheetActions.isEmpty()) {
      manager.add(new Separator());
      MenuManager subManager = new MenuManager("Cheat Sheets"); // $NON-NLS-1$
      for (IAction action : cheatSheetActions) {
        subManager.add(action);
      }
      manager.add(subManager);
    }
  }
  @Override
  public void createPartControl(Composite parent) {
    super.createPartControl(parent);

    // Remove the Pin item
    IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
    menuManager.removeAll();
    //        for(IContributionItem item : menuManager.getItems()) {
    //            if(item instanceof ActionContributionItem) {
    //                if(((ActionContributionItem)item).getAction() instanceof
    // PinPropertySheetAction) {
    //                    menuManager.remove(item);
    //                    break;
    //                }
    //            }
    //        }

    IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
    toolBarManager.removeAll();
    //        for(IContributionItem item : toolBarManager.getItems()) {
    //            if(item instanceof ActionContributionItem) {
    //                if(((ActionContributionItem)item).getAction() instanceof
    // PinPropertySheetAction) {
    //                    toolBarManager.remove(item);
    //                    break;
    //                }
    //            }
    //        }
  }
  protected void fillMenuBar(IMenuManager menuBar) {
    MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
    MenuManager helpMenu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP);

    menuBar.add(fileMenu);
    // Add a group marker indicating where action set menus will appear.
    menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    menuBar.add(helpMenu);
    helpMenu.add(helpContentsAction);

    // File Menu
    /* fileMenu.add(prefAction);
    fileMenu.add(new Separator());
    fileMenu.add(exitAction); */

    // Ajout sous la forme de ActionContributionItem pour pouvoir rendre les actions ensuite
    // invisibles, car elle sont dŽjˆ prŽsentes dans le menu Pomme du mac.
    ActionContributionItem preferencesActionItem = new ActionContributionItem(prefAction);
    fileMenu.add(preferencesActionItem);
    ActionContributionItem exitActionItem = new ActionContributionItem(exitAction);
    fileMenu.add(exitActionItem);

    if (Util.isMac()) {
      preferencesActionItem.setVisible(false);
      exitActionItem.setVisible(false);
    }
  }
  protected void fillMenuBar(IMenuManager menuBar) {
    final MenuManager fileMenu = new MenuManager("&File", "org.carrot2.menus.file");
    fileMenu.add(closeAction);
    fileMenu.add(closeAllAction);
    fileMenu.add(new Separator());
    fileMenu.add(saveAsAction);
    fileMenu.add(new Separator());
    fileMenu.add(exitAction);

    final MenuManager aboutMenu = new MenuManager("&About", "org.carrot2.menus.about");
    aboutMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    aboutMenu.add(aboutAction);

    final MenuManager changePerspMenuMgr =
        new MenuManager("Open Perspective", "org.carrot2.menus.openperspective");
    changePerspMenuMgr.add(changePerspMenuItem);

    MenuManager showViewMenuMgr = new MenuManager("Show view", "org.carrot2.menus.showview");
    showViewMenuMgr.add(showViewMenu);

    final MenuManager windowMenu = new MenuManager("&Window", "org.carrot2.menus.window");
    windowMenu.add(changePerspMenuMgr);
    windowMenu.add(showViewMenuMgr);
    windowMenu.add(openPreferencesAction);

    menuBar.add(fileMenu);
    menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    menuBar.add(windowMenu);
    menuBar.add(aboutMenu);
  }
    /**
     * Creates the 'Edit' menu.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     *
     * @generated
     */
    protected IMenuManager createEditMenu(IWorkbenchWindow window) {
      IMenuManager menu =
          new MenuManager(getString("_UI_Menu_Edit_label"), IWorkbenchActionConstants.M_EDIT);
      menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START));

      addToMenuAndRegister(menu, ActionFactory.UNDO.create(window));
      addToMenuAndRegister(menu, ActionFactory.REDO.create(window));
      menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT));
      menu.add(new Separator());

      addToMenuAndRegister(menu, ActionFactory.CUT.create(window));
      addToMenuAndRegister(menu, ActionFactory.COPY.create(window));
      addToMenuAndRegister(menu, ActionFactory.PASTE.create(window));
      menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT));
      menu.add(new Separator());

      addToMenuAndRegister(menu, ActionFactory.DELETE.create(window));
      addToMenuAndRegister(menu, ActionFactory.SELECT_ALL.create(window));
      menu.add(new Separator());

      menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT));

      menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END));
      menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
      return menu;
    }
  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);
      }
    }
  }
 private void fillContextMenu(IMenuManager manager) {
   ISelection selection = viewer.getSelection();
   Object obj = ((IStructuredSelection) selection).getFirstElement();
   if (!TreeParent.class.isInstance(obj)) {
     if (TreeObject.class.isInstance(obj)) {
       TreeObject tObject = (TreeObject) obj;
       List<Capability> capabilities = tObject.getTableDefinition().getCapabilities();
       if ((capabilities != null) && !capabilities.isEmpty()) {
         if (capabilities.contains(Capability.ShowTableDefinition)) {
           manager.add(showTableDefinitionAction);
         }
         if (capabilities.contains(Capability.ViewTableContent)) {
           manager.add(viewTableContentAction);
         }
         if (capabilities.contains(Capability.ExportData)) {
           manager.add(exportDataAction);
         }
         if (!manager.isEmpty()) {
           manager.add(new Separator());
         }
         if (isOperator && capabilities.contains(Capability.Delete)) {
           manager.add(deleteAction);
         }
         if (!manager.isEmpty()) {
           manager.add(new Separator());
         }
       }
     }
   }
   manager.add(refreshViewAction);
   // Other plug-ins can contribute there actions here
   manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
 }
  /*
   * Allows the viewer to add menus and/or tools to the context menu.
   */
  public void menuAboutToShow(IMenuManager menu) {

    menu.add(new Separator("undo")); // $NON-NLS-1$
    addMenu(menu, UNDO_ID);
    addMenu(menu, REDO_ID);
    menu.add(new GroupMarker("save")); // $NON-NLS-1$
    if (fAddSaveAction) addSave(menu);
    menu.add(new Separator("file")); // $NON-NLS-1$

    menu.add(new Separator("ccp")); // $NON-NLS-1$
    addMenu(menu, CUT_ID);
    addMenu(menu, COPY_ID);
    addMenu(menu, PASTE_ID);
    addMenu(menu, DELETE_ID);
    addMenu(menu, SELECT_ALL_ID);

    menu.add(new Separator("edit")); // $NON-NLS-1$
    addMenu(menu, CHANGE_ENCODING_ID);
    menu.add(new Separator("find")); // $NON-NLS-1$
    addMenu(menu, FIND_ID);

    menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));

    menu.add(new Separator("text")); // $NON-NLS-1$
    for (Iterator iterator = textActions.iterator(); iterator.hasNext(); ) {
      IAction action = (IAction) iterator.next();
      menu.add(action);
    }

    menu.add(new Separator("rest")); // $NON-NLS-1$

    // update all actions
    // to get undo redo right
    updateActions();
  }
Beispiel #28
0
 public static void fillVmListMenu(IMenuManager manager, List<VMTreeObject> list) {
   List<VMTreeObjectVMinGroup> vmList = new ArrayList<VMTreeObjectVMinGroup>();
   boolean isDefault = true;
   boolean isNotDefault = true;
   for (VMTreeObject o : list) {
     if (o.getParent().getName().equals(Constants.VM_GROUP_DEFAULT_NAME)) {
       isNotDefault = false;
     } else {
       isDefault = false;
     }
     vmList.add((VMTreeObjectVMinGroup) o);
   }
   if (isDefault) {
     MenuManager addtogroupMenu = new MenuManager("Ìí¼Óµ½...");
     for (VMTreeObject group : vmList.get(0).getParent().getParent().getChildren()) {
       if (!group.getName().equals(Constants.VM_GROUP_DEFAULT_NAME)) {
         addtogroupMenu.add(new AddtoGroupAction(vmList, (VMTreeObjectGroup) group));
       }
     }
     manager.add(addtogroupMenu);
     return;
   }
   if (isNotDefault) {
     manager.add(new ResetGroupAction(vmList));
   }
 }
 @Override
 public void fillContextMenu(IMenuManager aMenu) {
   IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
   if (selection.size() != 1) {
     return;
   }
   Object object = selection.getFirstElement();
   IFolder folder = Adapters.adapt(object, IFolder.class);
   if (folder == null) {
     return;
   }
   if (folder.getFile(IProjectDescription.DESCRIPTION_FILE_NAME).exists()) {
     for (IProject project : folder.getWorkspace().getRoot().getProjects()) {
       if (project.getLocation().equals(folder.getLocation())) {
         // project already in workspace
         SelectProjectForFolderAction action =
             new SelectProjectForFolderAction(project, this.viewer);
         aMenu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, action);
         return;
       }
     }
     OpenFolderAsProjectAction action = new OpenFolderAsProjectAction(folder, this.viewer);
     aMenu.prependToGroup(ICommonMenuConstants.GROUP_PORT, action);
   }
 }
  private void addOpenWithMenu(IMenuManager menu) {
    ISelection selection = getContext().getSelection();
    if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
      return;
    }
    IStructuredSelection ss = (IStructuredSelection) selection;
    if (ss.size() != 1) {
      return;
    }

    Object o = ss.getFirstElement();
    if (!(o instanceof IAdaptable)) {
      return;
    }

    IAdaptable element = (IAdaptable) o;
    Object resource = element.getAdapter(IResource.class);
    if (!(resource instanceof IFile)) {
      return;
    }

    // Create a menu.
    IMenuManager submenu = new MenuManager(ActionMessages.OpenWithMenu_label);
    submenu.add(new OpenWithMenu(fSite.getPage(), (IFile) resource));

    // Add the submenu.
    menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
  }