Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.MenuItem


        for (final CoolBarItem toolItem : toolItems) {
          if (!visibleItems.contains(toolItem) || toolItem == CoolBarItem.SEPARATOR || toolItem == CoolBarItem.SPACER) {

            /* Divide Groups by Separators */
            if (currentGroup >= 0 && currentGroup != toolItem.getGroup())
              new MenuItem(fAddMenu, SWT.SEPARATOR);

            /* Create Menu Item */
            MenuItem item = new MenuItem(fAddMenu, SWT.PUSH);
            if (StringUtils.isSet(toolItem.getTooltip()))
              item.setText(toolItem.getTooltip());
            else
              item.setText(toolItem.getName());
            if (toolItem.getImg() != null)
              item.setImage(fResources.createImage(toolItem.getImg()));

            item.addSelectionListener(new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {

                /* Add Item */
                onAdd(toolItem);
View Full Code Here


      public Menu getMenu(Control parent) {
        Menu menu = new Menu(parent);

        /* Search on: Subject */
        final MenuItem searchHeadline = new MenuItem(menu, SWT.RADIO);
        searchHeadline.setText(NewsFilter.SearchTarget.HEADLINE.getName());
        searchHeadline.setSelection(NewsFilter.SearchTarget.HEADLINE == filter.getSearchTarget());
        searchHeadline.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (searchHeadline.getSelection() && filter.getSearchTarget() != NewsFilter.SearchTarget.HEADLINE)
              doSearch(NewsFilter.SearchTarget.HEADLINE);
          }
        });

        /* Search on: Entire News */
        final MenuItem searchEntireNews = new MenuItem(menu, SWT.RADIO);
        searchEntireNews.setText(NewsFilter.SearchTarget.ALL.getName());
        searchEntireNews.setSelection(NewsFilter.SearchTarget.ALL == filter.getSearchTarget());
        searchEntireNews.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (searchEntireNews.getSelection() && filter.getSearchTarget() != NewsFilter.SearchTarget.ALL)
              doSearch(NewsFilter.SearchTarget.ALL);
          }
        });

        new MenuItem(menu, SWT.SEPARATOR);

        /* Search on: Author */
        final MenuItem searchAuthor = new MenuItem(menu, SWT.RADIO);
        searchAuthor.setText(NewsFilter.SearchTarget.AUTHOR.getName());
        searchAuthor.setSelection(NewsFilter.SearchTarget.AUTHOR == filter.getSearchTarget());
        searchAuthor.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (searchAuthor.getSelection() && filter.getSearchTarget() != NewsFilter.SearchTarget.AUTHOR)
              doSearch(NewsFilter.SearchTarget.AUTHOR);
          }
        });

        /* Search on: Category */
        final MenuItem searchCategory = new MenuItem(menu, SWT.RADIO);
        searchCategory.setText(NewsFilter.SearchTarget.CATEGORY.getName());
        searchCategory.setSelection(NewsFilter.SearchTarget.CATEGORY == filter.getSearchTarget());
        searchCategory.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (searchCategory.getSelection() && filter.getSearchTarget() != NewsFilter.SearchTarget.CATEGORY)
              doSearch(NewsFilter.SearchTarget.CATEGORY);
          }
        });

        /* Search on: Source */
        final MenuItem searchSource = new MenuItem(menu, SWT.RADIO);
        searchSource.setText(NewsFilter.SearchTarget.SOURCE.getName());
        searchSource.setSelection(NewsFilter.SearchTarget.SOURCE == filter.getSearchTarget());
        searchSource.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (searchSource.getSelection() && filter.getSearchTarget() != NewsFilter.SearchTarget.SOURCE)
              doSearch(NewsFilter.SearchTarget.SOURCE);
          }
        });

        /* Search on: Attachments */
        final MenuItem searchAttachments = new MenuItem(menu, SWT.RADIO);
        searchAttachments.setText(NewsFilter.SearchTarget.ATTACHMENTS.getName());
        searchAttachments.setSelection(NewsFilter.SearchTarget.ATTACHMENTS == filter.getSearchTarget());
        searchAttachments.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (searchAttachments.getSelection() && filter.getSearchTarget() != NewsFilter.SearchTarget.ATTACHMENTS)
              doSearch(NewsFilter.SearchTarget.ATTACHMENTS);
          }
        });

        return menu;
View Full Code Here

      public Menu getMenu(Control parent) {
        Menu menu = new Menu(parent);

        /* Filter: None */
        final MenuItem showAll = new MenuItem(menu, SWT.RADIO);
        showAll.setText(NewsFilter.Type.SHOW_ALL.getName());
        showAll.setSelection(NewsFilter.Type.SHOW_ALL == filter.getType());
        showAll.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showAll.getSelection() && filter.getType() != NewsFilter.Type.SHOW_ALL)
              doFilter(NewsFilter.Type.SHOW_ALL, true, true);
          }
        });
        menu.setDefaultItem(showAll);

        /* Separator */
        new MenuItem(menu, SWT.SEPARATOR);

        /* Filter: New */
        final MenuItem showNew = new MenuItem(menu, SWT.RADIO);
        showNew.setText(NewsFilter.Type.SHOW_NEW.getName());
        showNew.setSelection(NewsFilter.Type.SHOW_NEW == filter.getType());
        showNew.addSelectionListener(new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showNew.getSelection() && filter.getType() != NewsFilter.Type.SHOW_NEW)
              doFilter(NewsFilter.Type.SHOW_NEW, true, true);
          }
        });

        /* Filter: Unread */
        final MenuItem showUnread = new MenuItem(menu, SWT.RADIO);
        showUnread.setText(NewsFilter.Type.SHOW_UNREAD.getName());
        showUnread.setSelection(NewsFilter.Type.SHOW_UNREAD == filter.getType());
        showUnread.addSelectionListener(new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showUnread.getSelection() && filter.getType() != NewsFilter.Type.SHOW_UNREAD)
              doFilter(NewsFilter.Type.SHOW_UNREAD, true, true);
          }
        });

        /* Separator */
        new MenuItem(menu, SWT.SEPARATOR);

        /* Filter: Recent News */
        final MenuItem showRecent = new MenuItem(menu, SWT.RADIO);
        showRecent.setText(NewsFilter.Type.SHOW_RECENT.getName());
        showRecent.setSelection(NewsFilter.Type.SHOW_RECENT == filter.getType());
        showRecent.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showRecent.getSelection() && filter.getType() != NewsFilter.Type.SHOW_RECENT)
              doFilter(NewsFilter.Type.SHOW_RECENT, true, true);
          }
        });

        /* Filter: Sticky */
        final MenuItem showSticky = new MenuItem(menu, SWT.RADIO);
        showSticky.setText(NewsFilter.Type.SHOW_STICKY.getName());
        showSticky.setSelection(NewsFilter.Type.SHOW_STICKY == filter.getType());
        showSticky.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showSticky.getSelection() && filter.getType() != NewsFilter.Type.SHOW_STICKY)
              doFilter(NewsFilter.Type.SHOW_STICKY, true, true);
          }
        });

        return menu;
View Full Code Here

      public Menu getMenu(Control parent) {
        Menu menu = new Menu(parent);

        /* Group: None */
        final MenuItem noGrouping = new MenuItem(menu, SWT.RADIO);
        noGrouping.setText(NewsGrouping.Type.NO_GROUPING.getName());
        noGrouping.setSelection(grouping.getType() == NewsGrouping.Type.NO_GROUPING);
        noGrouping.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (noGrouping.getSelection() && grouping.getType() != NewsGrouping.Type.NO_GROUPING)
              doGrouping(NewsGrouping.Type.NO_GROUPING, true, true);
          }
        });
        menu.setDefaultItem(noGrouping);

        /* Separator */
        new MenuItem(menu, SWT.SEPARATOR);

        /* Group: By Date */
        final MenuItem groupByDate = new MenuItem(menu, SWT.RADIO);
        groupByDate.setText(NewsGrouping.Type.GROUP_BY_DATE.getName());
        groupByDate.setSelection(grouping.getType() == NewsGrouping.Type.GROUP_BY_DATE);
        groupByDate.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByDate.getSelection() && grouping.getType() != NewsGrouping.Type.GROUP_BY_DATE)
              doGrouping(NewsGrouping.Type.GROUP_BY_DATE, true, true);
          }
        });

        /* Group: By Author */
        final MenuItem groupByAuthor = new MenuItem(menu, SWT.RADIO);
        groupByAuthor.setText(NewsGrouping.Type.GROUP_BY_AUTHOR.getName());
        groupByAuthor.setSelection(grouping.getType() == NewsGrouping.Type.GROUP_BY_AUTHOR);
        groupByAuthor.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByAuthor.getSelection() && grouping.getType() != NewsGrouping.Type.GROUP_BY_AUTHOR)
              doGrouping(NewsGrouping.Type.GROUP_BY_AUTHOR, true, true);
          }
        });

        /* Group: By Category */
        final MenuItem groupByCategory = new MenuItem(menu, SWT.RADIO);
        groupByCategory.setText(NewsGrouping.Type.GROUP_BY_CATEGORY.getName());
        groupByCategory.setSelection(grouping.getType() == NewsGrouping.Type.GROUP_BY_CATEGORY);
        groupByCategory.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByCategory.getSelection() && grouping.getType() != NewsGrouping.Type.GROUP_BY_CATEGORY)
              doGrouping(NewsGrouping.Type.GROUP_BY_CATEGORY, true, true);
          }
        });

        /* Group: By Topic */
        final MenuItem groupByTopic = new MenuItem(menu, SWT.RADIO);
        groupByTopic.setText(NewsGrouping.Type.GROUP_BY_TOPIC.getName());
        groupByTopic.setSelection(grouping.getType() == NewsGrouping.Type.GROUP_BY_TOPIC);
        groupByTopic.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByTopic.getSelection() && grouping.getType() != NewsGrouping.Type.GROUP_BY_TOPIC)
              doGrouping(NewsGrouping.Type.GROUP_BY_TOPIC, true, true);
          }
        });

        /* Separator */
        new MenuItem(menu, SWT.SEPARATOR);

        /* Group: By Other */
        final MenuItem groupByOther = new MenuItem(menu, SWT.CASCADE);
        groupByOther.setText("Other");
        Menu otherMenu = new Menu(groupByOther);
        groupByOther.setMenu(otherMenu);

        /* Group: By State */
        final MenuItem groupByState = new MenuItem(otherMenu, SWT.RADIO);
        groupByState.setText(NewsGrouping.Type.GROUP_BY_STATE.getName());
        groupByState.setSelection(grouping.getType() == NewsGrouping.Type.GROUP_BY_STATE);
        groupByState.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByState.getSelection() && grouping.getType() != NewsGrouping.Type.GROUP_BY_STATE)
              doGrouping(NewsGrouping.Type.GROUP_BY_STATE, true, true);
          }
        });

        /* Group: By Stickyness */
        final MenuItem groupByStickyness = new MenuItem(otherMenu, SWT.RADIO);
        groupByStickyness.setText(NewsGrouping.Type.GROUP_BY_STICKY.getName());
        groupByStickyness.setSelection(grouping.getType() == NewsGrouping.Type.GROUP_BY_STICKY);
        groupByStickyness.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByStickyness.getSelection() && grouping.getType() != NewsGrouping.Type.GROUP_BY_STICKY)
              doGrouping(NewsGrouping.Type.GROUP_BY_STICKY, true, true);
          }
        });

        /* Separator */
        new MenuItem(otherMenu, SWT.SEPARATOR);

        /* Group: By Label */
        final MenuItem groupByLabel = new MenuItem(otherMenu, SWT.RADIO);
        groupByLabel.setText(NewsGrouping.Type.GROUP_BY_LABEL.getName());
        groupByLabel.setSelection(grouping.getType() == NewsGrouping.Type.GROUP_BY_LABEL);
        groupByLabel.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByLabel.getSelection() && grouping.getType() != NewsGrouping.Type.GROUP_BY_LABEL)
              doGrouping(NewsGrouping.Type.GROUP_BY_LABEL, true, true);
          }
        });

        /* Group: By Rating */
        final MenuItem groupByRating = new MenuItem(otherMenu, SWT.RADIO);
        groupByRating.setText(NewsGrouping.Type.GROUP_BY_RATING.getName());
        groupByRating.setSelection(grouping.getType() == NewsGrouping.Type.GROUP_BY_RATING);
        groupByRating.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByRating.getSelection() && grouping.getType() != NewsGrouping.Type.GROUP_BY_RATING)
              doGrouping(NewsGrouping.Type.GROUP_BY_RATING, true, true);
          }
        });

        /* Separator */
        new MenuItem(otherMenu, SWT.SEPARATOR);

        /* Group: By Feed */
        final MenuItem groupByFeed = new MenuItem(otherMenu, SWT.RADIO);
        groupByFeed.setText(NewsGrouping.Type.GROUP_BY_FEED.getName());
        groupByFeed.setSelection(grouping.getType() == NewsGrouping.Type.GROUP_BY_FEED);
        groupByFeed.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByFeed.getSelection() && grouping.getType() != NewsGrouping.Type.GROUP_BY_FEED)
              doGrouping(NewsGrouping.Type.GROUP_BY_FEED, true, true);
          }
        });

        return menu;
View Full Code Here

        /* Restore */
        trayMenu.add(new ContributionItem() {
          @Override
          public void fill(Menu menu, int index) {
            MenuItem restoreItem = new MenuItem(menu, SWT.PUSH);
            restoreItem.setText("Restore");
            restoreItem.addSelectionListener(new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                restoreFromTray(shell);
              }
            });
View Full Code Here

      public Menu getMenu(Control parent) {
        Set<ISearchMark> searchMarks = Controller.getDefault().getCacheService().getSearchMarks();
        Menu menu = new Menu(parent);

        /* Create new Saved Search */
        MenuItem newSavedSearch = new MenuItem(menu, SWT.NONE);
        newSavedSearch.setText("New Saved Search...");
        newSavedSearch.setImage(OwlUI.getImage(fResources, "icons/etool16/add.gif"));
        newSavedSearch.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            onSave();
          }
        });

        /* Separator */
        if (searchMarks.size() > 0)
          new MenuItem(menu, SWT.SEPARATOR);

        /* Show Existing Saved Searches */
        for (final ISearchMark searchMark : searchMarks) {
          MenuItem item = new MenuItem(menu, SWT.None);
          item.setText(searchMark.getName());
          item.setImage(OwlUI.getImage(fResources, OwlUI.SEARCHMARK));
          item.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              show(searchMark);
            }
View Full Code Here

      public Menu getMenu(Control parent) {
        Menu menu = new Menu(parent);

        /* Search on: Name */
        final MenuItem searchName = new MenuItem(menu, SWT.RADIO);
        searchName.setText("Name");
        searchName.setSelection(BookMarkFilter.SearchTarget.NAME == fPatternFilter.getSearchTarget());
        searchName.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (searchName.getSelection() && fPatternFilter.getSearchTarget() != BookMarkFilter.SearchTarget.NAME)
              doSearch(BookMarkFilter.SearchTarget.NAME);
          }
        });

        /* Search on: Link */
        final MenuItem searchLink = new MenuItem(menu, SWT.RADIO);
        searchLink.setText("Link");
        searchLink.setSelection(BookMarkFilter.SearchTarget.LINK == fPatternFilter.getSearchTarget());
        searchLink.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (searchLink.getSelection() && fPatternFilter.getSearchTarget() != BookMarkFilter.SearchTarget.LINK)
              doSearch(BookMarkFilter.SearchTarget.LINK);
          }
        });

        return menu;
View Full Code Here

  private void createConditionMenu(Menu menu, SearchConditionItem item) {
    IModelFactory factory = Owl.getModelFactory();
    String news = INews.class.getName();

    MenuItem mItem = new MenuItem(menu, SWT.PUSH);
    mItem.setText("Entire News");
    hookSelectionListener(mItem, item, factory.createSearchField(IEntity.ALL_FIELDS, news));

    mItem = new MenuItem(menu, SWT.SEPARATOR);

    mItem = new MenuItem(menu, SWT.PUSH);
    mItem.setText("State");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.STATE, news));

    mItem = new MenuItem(menu, SWT.PUSH);
    mItem.setText("Location");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.LOCATION, news));

    new MenuItem(menu, SWT.SEPARATOR);

    mItem = new MenuItem(menu, SWT.PUSH);
    mItem.setText("Title");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.TITLE, news));

    mItem = new MenuItem(menu, SWT.PUSH);
    mItem.setText("Description");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.DESCRIPTION, news));

    mItem = new MenuItem(menu, SWT.PUSH);
    mItem.setText("Author");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.AUTHOR, news));

    mItem = new MenuItem(menu, SWT.PUSH);
    mItem.setText("Category");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.CATEGORIES, news));

    mItem = new MenuItem(menu, SWT.CASCADE);
    mItem.setText("Date");

    Menu dateMenu = new Menu(mItem);
    mItem.setMenu(dateMenu);

    mItem = new MenuItem(dateMenu, SWT.PUSH);
    mItem.setText("Date Modified");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.MODIFIED_DATE, news));

    mItem = new MenuItem(dateMenu, SWT.PUSH);
    mItem.setText("Date Published");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.PUBLISH_DATE, news));

    mItem = new MenuItem(dateMenu, SWT.PUSH);
    mItem.setText("Date Received");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.RECEIVE_DATE, news));

    new MenuItem(dateMenu, SWT.SEPARATOR);

    mItem = new MenuItem(dateMenu, SWT.PUSH);
    mItem.setText("Age in Days");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.AGE_IN_DAYS, news));

    mItem = new MenuItem(menu, SWT.SEPARATOR);

    mItem = new MenuItem(menu, SWT.CASCADE);
    mItem.setText("Other");

    Menu otherMenu = new Menu(mItem);
    mItem.setMenu(otherMenu);

    mItem = new MenuItem(otherMenu, SWT.PUSH);
    mItem.setText("Has Attachments");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.HAS_ATTACHMENTS, news));

    mItem = new MenuItem(otherMenu, SWT.PUSH);
    mItem.setText("Attachment");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.ATTACHMENTS_CONTENT, news));

    new MenuItem(otherMenu, SWT.SEPARATOR);

    mItem = new MenuItem(otherMenu, SWT.PUSH);
    mItem.setText("Source");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.SOURCE, news));

    mItem = new MenuItem(otherMenu, SWT.PUSH);
    mItem.setText("Link");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.LINK, news));

    mItem = new MenuItem(otherMenu, SWT.PUSH);
    mItem.setText("Is Sticky");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.IS_FLAGGED, news));

    mItem = new MenuItem(otherMenu, SWT.PUSH);
    mItem.setText("Feed");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.FEED, news));

    mItem = new MenuItem(otherMenu, SWT.PUSH);
    mItem.setText("Label");
    hookSelectionListener(mItem, item, factory.createSearchField(INews.LABEL, news));
  }
View Full Code Here

   * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate#getMenu(org.eclipse.swt.widgets.Control)
   */
  public Menu getMenu(Control parent) {
    Menu menu = new Menu(parent);

    MenuItem newBookMark = new MenuItem(menu, SWT.PUSH);
    newBookMark.setText("Bookmark");
    newBookMark.setImage(OwlUI.getImage(fResources, OwlUI.BOOKMARK));
    newBookMark.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        try {
          addBookmark();
        } catch (Exception e1) {
          Activator.getDefault().logError(e1.getMessage(), e1);
        }
      }
    });

    MenuItem newSearchMark = new MenuItem(menu, SWT.PUSH);
    newSearchMark.setText("Saved Search");
    newSearchMark.setImage(OwlUI.getImage(fResources, OwlUI.SEARCHMARK));
    newSearchMark.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        try {
          addSearchMark();
        } catch (Exception e1) {
          Activator.getDefault().logError(e1.getMessage(), e1);
        }
      }
    });

    new MenuItem(menu, SWT.SEPARATOR);

    MenuItem newFolder = new MenuItem(menu, SWT.PUSH);
    newFolder.setText("Folder");
    newFolder.setImage(OwlUI.getImage(fResources, OwlUI.FOLDER));
    newFolder.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        try {
          addFolder();
        } catch (Exception e1) {
View Full Code Here

      public Menu getMenu(Control parent) {
        Menu menu = new Menu(parent);

        /* Filter: None */
        final MenuItem showAll = new MenuItem(menu, SWT.RADIO);
        showAll.setText("Show All");
        showAll.setSelection(BookMarkFilter.Type.SHOW_ALL == fBookMarkFilter.getType());
        menu.setDefaultItem(showAll);
        showAll.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showAll.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_ALL)
              doFilter(BookMarkFilter.Type.SHOW_ALL);
          }
        });

        /* Separator */
        new MenuItem(menu, SWT.SEPARATOR);

        /* Filter: New */
        final MenuItem showNew = new MenuItem(menu, SWT.RADIO);
        showNew.setText("Show New");
        showNew.setSelection(BookMarkFilter.Type.SHOW_NEW == fBookMarkFilter.getType());
        showNew.addSelectionListener(new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showNew.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_NEW)
              doFilter(BookMarkFilter.Type.SHOW_NEW);
          }
        });

        /* Filter: Unread */
        final MenuItem showUnread = new MenuItem(menu, SWT.RADIO);
        showUnread.setText("Show Unread");
        showUnread.setSelection(BookMarkFilter.Type.SHOW_UNREAD == fBookMarkFilter.getType());
        showUnread.addSelectionListener(new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showUnread.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_UNREAD)
              doFilter(BookMarkFilter.Type.SHOW_UNREAD);
          }
        });

        /* Filter: Sticky */
        final MenuItem showSticky = new MenuItem(menu, SWT.RADIO);
        showSticky.setText("Show Sticky");
        showSticky.setSelection(BookMarkFilter.Type.SHOW_STICKY == fBookMarkFilter.getType());
        showSticky.addSelectionListener(new SelectionAdapter() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showSticky.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_STICKY)
              doFilter(BookMarkFilter.Type.SHOW_STICKY);
          }
        });

        /* Separator */
        new MenuItem(menu, SWT.SEPARATOR);

        /* Filter: Erroneous */
        final MenuItem showErroneous = new MenuItem(menu, SWT.RADIO);
        showErroneous.setText("Show Erroneous");
        showErroneous.setSelection(BookMarkFilter.Type.SHOW_ERRONEOUS == fBookMarkFilter.getType());
        showErroneous.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showErroneous.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_ERRONEOUS)
              doFilter(BookMarkFilter.Type.SHOW_ERRONEOUS);
          }
        });

        /* Filter: Never Visited */
        final MenuItem showNeverVisited = new MenuItem(menu, SWT.RADIO);
        showNeverVisited.setText("Show Never Visited");
        showNeverVisited.setSelection(BookMarkFilter.Type.SHOW_NEVER_VISITED == fBookMarkFilter.getType());
        showNeverVisited.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (showNeverVisited.getSelection() && fBookMarkFilter.getType() != BookMarkFilter.Type.SHOW_NEVER_VISITED)
              doFilter(BookMarkFilter.Type.SHOW_NEVER_VISITED);
          }
        });

        return menu;
      }

      public Menu getMenu(Menu parent) {
        return null;
      }
    });

    fToolBarManager.add(bookmarkFilter);

    /* Bookmark Group */
    fToolBarManager.add(new Separator());
    final IAction bookmarkGroup = new Action("Group Bookmarks", IAction.AS_DROP_DOWN_MENU) {
      @Override
      public void run() {

        /* Restore Default */
        if (fBookMarkGrouping.getType() != BookMarkGrouping.Type.NO_GROUPING)
          doGrouping(BookMarkGrouping.Type.NO_GROUPING);

        /* Show Menu */
        else
          getMenuCreator().getMenu(fToolBarManager.getControl()).setVisible(true);
      }

      @Override
      public ImageDescriptor getImageDescriptor() {
        if (fBookMarkGrouping.getType() == BookMarkGrouping.Type.NO_GROUPING)
          return OwlUI.getImageDescriptor("icons/etool16/group.gif"); //$NON-NLS-1$

        return OwlUI.getImageDescriptor("icons/etool16/group_active.gif"); //$NON-NLS-1$
      }
    };
    bookmarkGroup.setId(GROUP_ACTION);

    bookmarkGroup.setMenuCreator(new IMenuCreator() {
      public void dispose() {}

      public Menu getMenu(Control parent) {
        Menu menu = new Menu(parent);

        /* Group: None */
        final MenuItem noGrouping = new MenuItem(menu, SWT.RADIO);
        noGrouping.setText("No Grouping");
        noGrouping.setSelection(BookMarkGrouping.Type.NO_GROUPING == fBookMarkGrouping.getType());
        menu.setDefaultItem(noGrouping);
        noGrouping.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (noGrouping.getSelection() && fBookMarkGrouping.getType() != BookMarkGrouping.Type.NO_GROUPING)
              doGrouping(BookMarkGrouping.Type.NO_GROUPING);
          }
        });

        /* Separator */
        new MenuItem(menu, SWT.SEPARATOR);

        /* Group: By Last Visit */
        final MenuItem groupByLastVisit = new MenuItem(menu, SWT.RADIO);
        groupByLastVisit.setText("Group by Last Visit");
        groupByLastVisit.setSelection(BookMarkGrouping.Type.GROUP_BY_LAST_VISIT == fBookMarkGrouping.getType());
        groupByLastVisit.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByLastVisit.getSelection() && fBookMarkGrouping.getType() != BookMarkGrouping.Type.GROUP_BY_LAST_VISIT)
              doGrouping(BookMarkGrouping.Type.GROUP_BY_LAST_VISIT);
          }
        });

        /* Group: By Popularity */
        final MenuItem groupByPopularity = new MenuItem(menu, SWT.RADIO);
        groupByPopularity.setText("Group by Popularity");
        groupByPopularity.setSelection(BookMarkGrouping.Type.GROUP_BY_POPULARITY == fBookMarkGrouping.getType());
        groupByPopularity.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (groupByPopularity.getSelection() && fBookMarkGrouping.getType() != BookMarkGrouping.Type.GROUP_BY_POPULARITY)
              doGrouping(BookMarkGrouping.Type.GROUP_BY_POPULARITY);
          }
        });

        return menu;
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.MenuItem

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.