Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Menu


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

      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"));
View Full Code Here


        manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
      }
    });

    /* Create and Register with Workbench */
    Menu menu = manager.createContextMenu(fResultViewer.getControl());
    fResultViewer.getControl().setMenu(menu);

    /* Register with Part Site */
    IWorkbenchWindow window = OwlUI.getWindow();
    if (window != null) {
View Full Code Here

      public void run() {
        onNewFolder();
      }
    });

    Menu menu = menuManager.createContextMenu(fFolderViewer.getTree());
    fFolderViewer.getTree().setMenu(menu);

    /* Register Model Listeners */
    registerListeners();
  }
View Full Code Here

    ToolItem addButton = new ToolItem(buttonBar, SWT.DROP_DOWN);
    addButton.setImage(fAddIcon);
    addButton.setToolTipText(Messages.NewsActionList_ADD_ACTION);

    /* Add Menu */
    final Menu actionMenu = new Menu(buttonBar);
    createActionMenu(actionMenu, item);
    addButton.addListener(SWT.Selection, new Listener() {
      public void handleEvent(Event event) {
        if (event.detail == SWT.ARROW) {
          Rectangle rect = item.getBounds();
          Point pt = new Point(rect.x, rect.y + rect.height);
          pt = buttonBar.toDisplay(pt);
          actionMenu.setLocation(pt.x, pt.y);
          actionMenu.setVisible(true);
        } else
          onAdd(item);
      }
    });

    buttonBar.addDisposeListener(new DisposeListener() {
      public void widgetDisposed(DisposeEvent e) {
        actionMenu.dispose();
      }
    });

    /* Button to delete Action */
    ToolItem deleteButton = new ToolItem(buttonBar, SWT.PUSH);
View Full Code Here

    bookmarkFilter.setMenuCreator(new ContextMenuCreator() {

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

        /* Filter: None */
        final MenuItem showAll = new MenuItem(menu, SWT.RADIO);
        showAll.setText(Messages.BookMarkExplorer_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(Messages.BookMarkExplorer_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(Messages.BookMarkExplorer_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(Messages.BookMarkExplorer_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(Messages.BookMarkExplorer_SHOW_ERROR);
        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(Messages.BookMarkExplorer_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;
      }
    });

    fToolBarManager.add(bookmarkFilter);

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

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

        /* Toggle to previous */
        else if (fLastGroupType != null)
          doGrouping(fLastGroupType);

        /* Show Menu */
        else if (fToolBarManager instanceof ToolBarManager)
          OwlUI.positionDropDownMenu(this, (ToolBarManager) fToolBarManager);
      }

      @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 ContextMenuCreator() {

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

        /* Group: None */
        final MenuItem noGrouping = new MenuItem(menu, SWT.RADIO);
        noGrouping.setText(Messages.BookMarkExplorer_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);
View Full Code Here

        manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
      }
    });

    /* Create and Register with Workbench */
    Menu menu = manager.createContextMenu(fViewer.getControl());
    fViewer.getControl().setMenu(menu);
    fViewSite.registerContextMenu(manager, fViewer);
  }
View Full Code Here

    filterTargetAction.setMenuCreator(new ContextMenuCreator() {

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

        /* Search on: Name */
        final MenuItem searchName = new MenuItem(menu, SWT.RADIO);
        searchName.setText(Messages.BookMarkSearchbar_NAME);
        searchName.setSelection(BookMarkFilter.SearchTarget.NAME == fPatternFilter.getSearchTarget());
View Full Code Here

          }
        });
      }
    });

    Menu menu = manager.createContextMenu(fBrowser);
    fBrowser.setMenu(menu);
  }
View Full Code Here

    newsGroup.setMenuCreator(new ContextMenuCreator() {

      @Override
      public Menu createMenu(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)
              onGrouping(NewsGrouping.Type.NO_GROUPING);
          }
        });
        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)
              onGrouping(NewsGrouping.Type.GROUP_BY_DATE);
          }
        });

        /* 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)
              onGrouping(NewsGrouping.Type.GROUP_BY_AUTHOR);
          }
        });

        /* 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)
              onGrouping(NewsGrouping.Type.GROUP_BY_CATEGORY);
          }
        });

        /* 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)
              onGrouping(NewsGrouping.Type.GROUP_BY_TOPIC);
          }
        });

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

        /* Group: By Other */
        final MenuItem groupByOther = new MenuItem(menu, SWT.CASCADE);
        groupByOther.setText(Messages.FilterBar_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());
View Full Code Here

      existingFilters.setMenuCreator(new ContextMenuCreator() {

        @Override
        public Menu createMenu(Control parent) {
          Collection<ISearchFilter> filters = CoreUtils.loadSortedNewsFilters();
          Menu menu = new Menu(parent);

          /* Show Something if Collection is Empty */
          if (filters.isEmpty()) {
            MenuItem item = new MenuItem(menu, SWT.None);
            item.setText(Messages.NewsFilterDialog_NO_FILTER);
            item.setEnabled(false);
          }

          /* Show Existing News Filters */
          for (final ISearchFilter filter : filters) {
            MenuItem item = new MenuItem(menu, SWT.None);
            item.setText(filter.getName());
            item.setImage(OwlUI.getImage(fResources, OwlUI.FILTER));
            item.addSelectionListener(new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {

                /* Search */
                if (filter.getSearch() != null)
                  showSearch(filter.getSearch());

                /* Match All News */
                if (filter.matchAllNews()) {
                  fMatchAnyRadio.setSelection(false);
                  fMatchAllRadio.setSelection(false);
                  fMatchAllNewsRadio.setSelection(true);
                  setControlEnabled(fSearchConditionList, false);
                }

                /* Actions */
                fFilterActionList.showActions(filter.getActions());
              }
            });
          }

          return menu;
        }
      });

      dialogToolBar.add(existingFilters);
    }

    /* Existing Saved Searches */
    {
      IAction savedSearches = new Action(Messages.NewsFilterDialog_SHOW_SAVED_SEARCH, IAction.AS_DROP_DOWN_MENU) {
        @Override
        public void run() {
          OwlUI.positionDropDownMenu(this, dialogToolBar);
        }

        @Override
        public ImageDescriptor getImageDescriptor() {
          return OwlUI.SEARCHMARK;
        }

        @Override
        public String getId() {
          return SEARCHES_ACTION;
        }
      };

      savedSearches.setMenuCreator(new ContextMenuCreator() {

        @Override
        public Menu createMenu(Control parent) {
          Collection<ISearchMark> searchMarks = CoreUtils.loadSortedSearchMarks();
          Menu menu = new Menu(parent);

          /* Show Something if Collection is Empty */
          if (searchMarks.isEmpty()) {
            MenuItem item = new MenuItem(menu, SWT.None);
            item.setText(Messages.NewsFilterDialog_NO_SAVED_SEARCH);
View Full Code Here

TOP

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

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.