Package org.eclipse.jface.action

Examples of org.eclipse.jface.action.MenuManager


      /* Either as direct Menu or Submenu */
      IMenuManager attachmentMenu;
      if (directMenu)
        attachmentMenu = manager;
      else {
        attachmentMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_ATTACHMENTS, "attachments"); //$NON-NLS-1$
        manager.add(attachmentMenu);
      }

      final IPreferenceScope preferences = Owl.getPreferenceService().getGlobalScope();

View Full Code Here


    /* Either as direct Menu or Submenu */
    IMenuManager shareMenu;
    if (directMenu)
      shareMenu = manager;
    else {
      shareMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_SHARE_NEWS, OwlUI.SHARE, "sharenews"); //$NON-NLS-1$
      manager.add(shareMenu);
    }

    /* List all selected Share Providers  */
    final boolean isEnabled = !selection.isEmpty() && !OwlUI.isEntityGroupSelected(selection);
View Full Code Here

    /* Either as direct Menu or Submenu */
    IMenuManager labelMenu;
    if (directMenu)
      labelMenu = manager;
    else {
      labelMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_LABEL);
      manager.add(labelMenu);
    }

    /* Assign  Labels */
    labelMenu.add(new AssignLabelsAction(shellProvider.getShell(), selection));
View Full Code Here

    final IPreferenceScope preferences = Owl.getPreferenceService().getGlobalScope();
    Type[] allFilters = BookMarkFilter.Type.values();
    Type selectedFilter = allFilters[preferences.getInteger(DefaultPreferences.BM_MENU_FILTER)];
    List<Type> displayedFilters = Arrays.asList(new Type[] { Type.SHOW_ALL, Type.SHOW_NEW, Type.SHOW_UNREAD, Type.SHOW_STICKY });

    MenuManager optionsMenu = new MenuManager(Messages.ApplicationActionBarAdvisor_FILTER_ELEMENTS, (selectedFilter == Type.SHOW_ALL) ? OwlUI.FILTER : OwlUI.getImageDescriptor("icons/etool16/filter_active.gif"), null); //$NON-NLS-1$
    for (final Type filter : displayedFilters) {
      String name = Messages.ApplicationActionBarAdvisor_SHOW_ALL;
      switch (filter) {
        case SHOW_NEW:
          name = Messages.ApplicationActionBarAdvisor_SHOW_NEW;
          break;
        case SHOW_UNREAD:
          name = Messages.ApplicationActionBarAdvisor_SHOW_UNREAD;
          break;
        case SHOW_STICKY:
          name = Messages.ApplicationActionBarAdvisor_SHOW_STICKY;
          break;
      }

      Action action = new Action(name, IAction.AS_RADIO_BUTTON) {
        @Override
        public void run() {
          preferences.putInteger(DefaultPreferences.BM_MENU_FILTER, filter.ordinal());
        }
      };
      action.setChecked(filter == selectedFilter);
      optionsMenu.add(action);
      if (filter == Type.SHOW_ALL)
        optionsMenu.add(new Separator());
    }
    menu.add(optionsMenu);
    menu.add(new Separator());

    /* Single Bookmark Set */
    if (roots.size() == 1) {
      fillBookMarksMenu(window, menu, roots.iterator().next().getChildren(), selectedFilter);
    }

    /* More than one Bookmark Set */
    else {
      for (IFolder root : roots) {
        if (shouldShow(root, selectedFilter)) {
          MenuManager rootItem = new MenuManager(root.getName(), OwlUI.BOOKMARK_SET, null);
          menu.add(rootItem);

          fillBookMarksMenu(window, rootItem, root.getChildren(), selectedFilter);
        }
      }
View Full Code Here

      /* Folder with Children */
      else if (child instanceof IFolder) {
        final IFolder folder = (IFolder) child;

        final MenuManager folderMenu = new MenuManager(folder.getName(), getImageDescriptor(folder), null);
        parent.add(folderMenu);
        folderMenu.add(new Action("") {}); //Dummy Action //$NON-NLS-1$
        folderMenu.setRemoveAllWhenShown(true);
        folderMenu.addMenuListener(new IMenuListener() {
          public void menuAboutToShow(IMenuManager manager) {
            fillBookMarksMenu(window, folderMenu, folder.getChildren(), filter);
          }
        });
      }
View Full Code Here

    shareLink.setImageDescriptor(OwlUI.SHARE);
    shareLink.setMenuCreator(new ContextMenuCreator() {

      @Override
      public Menu createMenu(Control parent) {
        MenuManager shareMenu = new MenuManager();

        final IStructuredSelection selection = getSelectionFromBrowser();

        List<ShareProvider> providers = Controller.getDefault().getShareProviders();
        for (final ShareProvider provider : providers) {
          if (provider.isEnabled()) {
            shareMenu.add(new Action(provider.getName()) {
              @Override
              public void run() {
                if (SendLinkAction.ID.equals(provider.getId())) {
                  IActionDelegate action = new SendLinkAction();
                  action.selectionChanged(null, selection);
                  action.run(null);
                } else {
                  Object obj = selection.getFirstElement();
                  if (StringUtils.isSet((String) obj) && !URIUtils.ABOUT_BLANK.equals(obj)) {
                    String shareLink = provider.toShareUrl((String) obj, null);
                    new OpenInBrowserAction(new StructuredSelection(shareLink)).run();
                  }
                }
              };

              @Override
              public ImageDescriptor getImageDescriptor() {
                if (StringUtils.isSet(provider.getIconPath()))
                  return OwlUI.getImageDescriptor(provider.getPluginId(), provider.getIconPath());

                return super.getImageDescriptor();
              };

              @Override
              public boolean isEnabled() {
                return !selection.isEmpty();
              }

              @Override
              public String getActionDefinitionId() {
                return SendLinkAction.ID.equals(provider.getId()) ? SendLinkAction.ID : super.getActionDefinitionId();
              }

              @Override
              public String getId() {
                return SendLinkAction.ID.equals(provider.getId()) ? SendLinkAction.ID : super.getId();
              }
            });
          }
        }

        /* Configure Providers */
        shareMenu.add(new Separator());
        shareMenu.add(new Action(Messages.BrowserBar_CONFIGURE) {
          @Override
          public void run() {
            PreferencesUtil.createPreferenceDialogOn(fBrowser.getControl().getShell(), SharingPreferencesPage.ID, null, null).open();
          };
        });

        return shareMenu.createContextMenu(parent);
      }
    });

    /* Discover Feeds on Website */
    fNavigationToolBarManager.add(new Separator());
View Full Code Here

    /* Mouse-Up over Attachments-Column */
    else if (event.button == 1 && isInImageBounds(item, NewsColumn.ATTACHMENTS, p)) {
      Object data = item.getData();

      if (data instanceof ScoredNews) {
        MenuManager contextMenu = new MenuManager();
        ApplicationActionBarAdvisor.fillAttachmentsMenu(contextMenu, new StructuredSelection(((ScoredNews) data).getNews()), this, true);

        if (fAttachmentsMenu != null)
          fAttachmentsMenu.dispose();

        fAttachmentsMenu = contextMenu.createContextMenu(fResultViewer.getControl());

        Point cursorLocation = item.getDisplay().getCursorLocation();
        cursorLocation.y = cursorLocation.y + 16;
        fAttachmentsMenu.setLocation(cursorLocation);
        fAttachmentsMenu.setVisible(true);
View Full Code Here

      new OpenNewsAction(new StructuredSelection(selectedNews), getShell()).run();
    }
  }

  private void hookContextualMenu() {
    MenuManager manager = new MenuManager();
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {
        final IStructuredSelection selection = (IStructuredSelection) fResultViewer.getSelection();

        /* Open */
        {

          /* Open in FeedView */
          manager.add(new Separator("internalopen")); //$NON-NLS-1$
          if (!selection.isEmpty())
            manager.appendToGroup("internalopen", new OpenNewsAction(selection, getShell())); //$NON-NLS-1$

          manager.add(new GroupMarker("open")); //$NON-NLS-1$

          /* Show only when internal browser is used */
          if (!selection.isEmpty() && !fPreferences.getBoolean(DefaultPreferences.USE_CUSTOM_EXTERNAL_BROWSER) && !fPreferences.getBoolean(DefaultPreferences.USE_DEFAULT_EXTERNAL_BROWSER))
            manager.add(new OpenInExternalBrowserAction(selection));
        }

        /* Attachments */
        {
          ApplicationActionBarAdvisor.fillAttachmentsMenu(manager, selection, new SameShellProvider(getShell()), false);
        }

        /* Mark / Label */
        if (!selection.isEmpty()) {
          manager.add(new Separator("mark")); //$NON-NLS-1$

          /* Mark */
          MenuManager markMenu = new MenuManager(Messages.SearchNewsDialog_MARK, "mark"); //$NON-NLS-1$
          manager.add(markMenu);

          /* Mark as Read */
          IAction action = new ToggleReadStateAction(selection);
          action.setEnabled(!selection.isEmpty());
          markMenu.add(action);

          /* Sticky */
          markMenu.add(new Separator());
          action = new MakeNewsStickyAction(selection);
          action.setEnabled(!selection.isEmpty());
          markMenu.add(action);

          /* Label */
          ApplicationActionBarAdvisor.fillLabelMenu(manager, selection, new SameShellProvider(getShell()), false);
        }

        /* Move To / Copy To */
        if (!selection.isEmpty()) {
          manager.add(new Separator("movecopy")); //$NON-NLS-1$

          /* Load all news bins and sort by name */
          List<INewsBin> newsbins = new ArrayList<INewsBin>(DynamicDAO.loadAll(INewsBin.class));

          Comparator<INewsBin> comparator = new Comparator<INewsBin>() {
            public int compare(INewsBin o1, INewsBin o2) {
              return o1.getName().compareTo(o2.getName());
            };
          };

          Collections.sort(newsbins, comparator);

          /* Move To */
          MenuManager moveMenu = new MenuManager(Messages.SearchNewsDialog_MOVE, "moveto"); //$NON-NLS-1$
          manager.add(moveMenu);

          for (INewsBin bin : newsbins) {
            moveMenu.add(new MoveCopyNewsToBinAction(selection, bin, true));
          }

          moveMenu.add(new MoveCopyNewsToBinAction(selection, null, true));
          moveMenu.add(new Separator());
          moveMenu.add(new AutomateFilterAction(PresetAction.MOVE, selection));

          /* Copy To */
          MenuManager copyMenu = new MenuManager(Messages.SearchNewsDialog_COPY, "copyto"); //$NON-NLS-1$
          manager.add(copyMenu);

          for (INewsBin bin : newsbins) {
            copyMenu.add(new MoveCopyNewsToBinAction(selection, bin, false));
          }

          copyMenu.add(new MoveCopyNewsToBinAction(selection, null, false));
          copyMenu.add(new Separator());
          copyMenu.add(new AutomateFilterAction(PresetAction.COPY, selection));
        }

        /* Share */
        {
          ApplicationActionBarAdvisor.fillShareMenu(manager, selection, new SameShellProvider(getShell()), false);
View Full Code Here

    /**
     * Create the context menu for this view.
     */
    protected void createContextMenu() {
        MenuManager menuMgr = new MenuManager();
        menuMgr.setRemoveAllWhenShown(true);
        menuMgr.addMenuListener(new IMenuListener() {
            public void menuAboutToShow(IMenuManager manager) {
                fillContextMenu(manager);
            }
        });
        Control control = viewer.getControl();
        Menu menu = menuMgr.createContextMenu(control);
        control.setMenu(menu);
        getSite().registerContextMenu(menuMgr, getSite().getSelectionProvider());
    }
View Full Code Here

    /**
     * create/register context menu on text control
     */
    private void createTextContextMenu() {
        String id = "de.loskutov.bco.views.BytecodeOutlineView#ContextMenu"; //$NON-NLS-1$
        contextMenuManager = new MenuManager("#ContextMenu", id); //$NON-NLS-1$
        contextMenuManager.setRemoveAllWhenShown(true);
        contextMenuManager.addMenuListener(new IMenuListener() {

            public void menuAboutToShow(IMenuManager m) {
                contextMenuAboutToShow(m);
View Full Code Here

TOP

Related Classes of org.eclipse.jface.action.MenuManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.