Ejemplo n.º 1
0
  @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;
    //                }
    //            }
    //        }
  }
    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);
        }
      }
    }
  public void placeActions() {
    IActionBars actionBars = getViewSite().getActionBars();

    IMenuManager mm = actionBars.getMenuManager();
    mm.removeAll();
    mm.add(SaveTreeViewAction.getAction(getSite().getShell()));
    mm.add(CapturePSDAction.getAction(getSite().getShell()));
    mm.add(new Separator());
    mm.add(RefreshViewAction.getAction());
    mm.add(DisplayViewAction.getAction(getSite().getShell()));
    mm.add(new Separator());
    mm.add(InvalidateAction.getAction());
    mm.add(RequestLayoutAction.getAction());
    mm.add(DumpDisplayListAction.getAction());
    mm.add(ProfileNodesAction.getAction());

    IToolBarManager tm = actionBars.getToolBarManager();
    tm.removeAll();
    tm.add(SaveTreeViewAction.getAction(getSite().getShell()));
    tm.add(CapturePSDAction.getAction(getSite().getShell()));
    tm.add(new Separator());
    tm.add(RefreshViewAction.getAction());
    tm.add(DisplayViewAction.getAction(getSite().getShell()));
    tm.add(new Separator());
    tm.add(InvalidateAction.getAction());
    tm.add(RequestLayoutAction.getAction());
    tm.add(DumpDisplayListAction.getAction());
    tm.add(ProfileNodesAction.getAction());
  }
  /** Updates the form menu. Sub-classes can extend if needed. */
  protected void updateFormMenuManager() {
    IMenuManager menuManager = mainForm.getMenuManager();
    menuManager.removeAll();

    for (CmrRepositoryDefinition cmrRepositoryDefinition :
        cmrRepositoryManager.getCmrRepositoryDefinitions()) {
      if (!Objects.equals(cmrRepositoryDefinition, displayedCmrRepositoryDefinition)) {
        menuManager.add(new SelectCmrAction(cmrRepositoryDefinition));
      }
    }
    menuManager.update(true);
    mainForm.getHead().layout();
  }
Ejemplo n.º 5
0
  /** Fills the menu with Show In actions. */
  private void fillMenu(IMenuManager innerMgr) {
    // Remove all.
    innerMgr.removeAll();

    IWorkbenchPart sourcePart = getSourcePart();
    if (sourcePart == null) {
      return;
    }
    ShowInContext context = getContext(sourcePart);
    if (context == null) {
      return;
    }
    if (context.getInput() == null
        && (context.getSelection() == null || context.getSelection().isEmpty())) {
      return;
    }

    IViewDescriptor[] viewDescs = getViewDescriptors(sourcePart);
    if (viewDescs.length == 0) {
      return;
    }

    for (int i = 0; i < viewDescs.length; ++i) {
      IAction action = getAction(viewDescs[i]);
      if (action != null) {
        innerMgr.add(action);
      }
    }
    if (innerMgr instanceof MenuManager) {
      ISourceProviderService sps =
          (ISourceProviderService) locator.getService(ISourceProviderService.class);
      ISourceProvider sp = sps.getSourceProvider(ISources.SHOW_IN_SELECTION);
      if (sp instanceof ActivePartSourceProvider) {
        ((ActivePartSourceProvider) sp).checkActivePart();
      }
      IMenuService service = (IMenuService) locator.getService(IMenuService.class);
      service.populateContributionManager((ContributionManager) innerMgr, MenuUtil.SHOW_IN_MENU_ID);
    }
  }