Package org.eclipse.jface.action

Examples of org.eclipse.jface.action.MenuManager


      return;
    Control focus= display.getFocusControl();
    if (focus == null || focus.isDisposed())
      return;
   
    MenuManager menu= new MenuManager();
    fillMenu(menu);
    final Menu widget= menu.createContextMenu(focus.getShell());
    Point location= computeMenuLocation(focus, widget);
    if (location == null)
      return;
    widget.setLocation(location);
    widget.setVisible(true);
View Full Code Here


    //_workingSetSelectionAction.setImageDescriptor(ImageDescriptor.createFromImage(WGADesignerPlugin.getDefault().getImageRegistry().get(WGADesignerPlugin.IMAGE_WGA_RUNTIME)));

    }
   
    private void hookContextMenu() {
        MenuManager menuMgr = new MenuManager("#PopupMenu");
        menuMgr.setRemoveAllWhenShown(true);
        menuMgr.addMenuListener(new IMenuListener() {
            public void menuAboutToShow(IMenuManager manager) {
                manager.add(_startWGARuntime);
                manager.add(_stopWGARuntime);
            }
        });
        Menu menu = menuMgr.createContextMenu(_table.getControl());
        _table.getControl().setMenu(menu);
        getSite().registerContextMenu(menuMgr, _table);
    }
View Full Code Here

      public void update(boolean force) {
        IContributionItem[] items = getItems();
        for (IContributionItem item : items) {
          if (item instanceof MenuManager) {
            final MenuManager menu = (MenuManager) item;
            ImageHyperlink link = new ImageHyperlink(sectionClient, SWT.None);
            link.setText(menu.getMenuText());           
            if (menu.getImageDescriptor() != null) {
              link.setImage(menu.getImageDescriptor().createImage());
            }
            link.addHyperlinkListener(new HyperlinkAdapter() {
              public void linkActivated(HyperlinkEvent e) {
                IHandlerService handlerService = (IHandlerService) fEditor.getSite().getService(IHandlerService.class);
                if (handlerService != null) {
                  try {
                    handlerService.executeCommand(menu.getId(), null);
                  } catch (Exception ex) {
                    WorkbenchUtils.showErrorDialog(Plugin.getDefault(), fEditor.getSite().getShell(), "Execution of hyperlink failed", "Unable to execute hyperlink command '" + menu.getId() + "'.", ex);
                  }
                }
              }
            });   
            group.add(link);
View Full Code Here

    /* Select the input Folder and expand */
    fFolderViewer.setSelection(new StructuredSelection(fSelectedFolder));
    fFolderViewer.setExpandedState(fSelectedFolder, true);

    /* Add Menu: "New Folder" */
    MenuManager menuManager = new MenuManager();
    menuManager.add(new Action("New Folder...") {
      @Override
      public void run() {
        onNewFolder();
      }
    });

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

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

    shell.addShellListener(fTrayShellListener);

    /* Show Menu on Selection */
    fTrayItem.addListener(SWT.MenuDetect, new Listener() {
      public void handleEvent(Event event) {
        MenuManager trayMenu = new MenuManager();

        /* 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);
              }
            });
            menu.setDefaultItem(restoreItem);
          }
        });

        /* Separator */
        trayMenu.add(new Separator());

        /* Other Items */
        fActionBarAdvisor.fillTrayItem(trayMenu);

        Menu menu = trayMenu.createContextMenu(shell);
        menu.setVisible(true);
      }
    });

    /* Handle DefaultSelection */
 
View Full Code Here

    return browser;
  }

  private void hookMenu() {
    MenuManager manager = new MenuManager();
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {

        /* Back */
        manager.add(new Action("Back") {
          @Override
          public void run() {
            fBrowser.back();
          }

          @Override
          public boolean isEnabled() {
            return fBrowser.isBackEnabled();
          }

          @Override
          public ImageDescriptor getImageDescriptor() {
            return OwlUI.getImageDescriptor("icons/etool16/backward.gif");
          }
        });

        /* Forward */
        manager.add(new Action("Forward") {
          @Override
          public void run() {
            fBrowser.forward();
          }

          @Override
          public boolean isEnabled() {
            return fBrowser.isForwardEnabled();
          }

          @Override
          public ImageDescriptor getImageDescriptor() {
            return OwlUI.getImageDescriptor("icons/etool16/forward.gif");
          }
        });

        /* Reload */
        manager.add(new Separator());
        manager.add(new Action("Reload") {
          @Override
          public void run() {
            fBrowser.refresh();
          }

          @Override
          public ImageDescriptor getImageDescriptor() {
            return OwlUI.getImageDescriptor("icons/elcl16/reload.gif");
          }
        });

        /* Stop */
        manager.add(new Action("Stop") {
          @Override
          public void run() {
            fBrowser.stop();
          }

          @Override
          public ImageDescriptor getImageDescriptor() {
            return OwlUI.getImageDescriptor("icons/etool16/cancel.gif");
          }
        });
      }
    });

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

          manager.add(selectBookMarkSet);
        }

        /* Search Bar */
        manager.add(new Separator());
        MenuManager searchMenu = new MenuManager("Find");
        manager.add(searchMenu);

        /* Search Bar - Always Show Bar */
        IAction alwaysShow = new Action("Always Show", IAction.AS_CHECK_BOX) {
          @Override
          public void run() {
            fAlwaysShowSearch = !fAlwaysShowSearch;

            /* Only Update if the Filter is not Active */
            if (fSearchBar.getControl().getText().length() == 0)
              setSearchBarVisible(fAlwaysShowSearch);
          }
        };
        alwaysShow.setChecked(fAlwaysShowSearch);
        searchMenu.add(alwaysShow);

        /* Search Bar - Begin Search when Typing */
        IAction beginWhenTyping = new Action("Begin When Typing", IAction.AS_CHECK_BOX) {
          @Override
          public void run() {
            fBeginSearchOnTyping = !fBeginSearchOnTyping;
          }
        };
        beginWhenTyping.setChecked(fBeginSearchOnTyping);
        searchMenu.add(beginWhenTyping);

        /* Misc. Settings */
        manager.add(new Separator());
        IAction sortByName = new Action("Sort By Name", IAction.AS_CHECK_BOX) {
          @Override
View Full Code Here

    /* Update Image */
    fToolBarManager.find(GROUP_ACTION).update(IAction.IMAGE);
  }

  private void hookContextualMenu() {
    MenuManager manager = new MenuManager();

    /* New Menu */
    MenuManager newMenu = new MenuManager("New");
    manager.add(newMenu);

    /* New BookMark */
    newMenu.add(new Action("Bookmark...") {
      @Override
      public void run() {
        IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
        IFolder parent = getParent(selection);
        IMark position = (IMark) ((selection.getFirstElement() instanceof IMark) ? selection.getFirstElement() : null);
        new NewBookMarkAction(fViewSite.getShell(), parent, position).run(null);
      }

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

    /* New Saved Search */
    newMenu.add(new Action("Saved Search...") {
      @Override
      public void run() {
        IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
        IFolder parent = getParent(selection);
        IMark position = (IMark) ((selection.getFirstElement() instanceof IMark) ? selection.getFirstElement() : null);
        new NewSearchMarkAction(fViewSite.getShell(), parent, position).run(null);
      }

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

    /* New Folder */
    newMenu.add(new Separator());
    newMenu.add(new Action("Folder...") {
      @Override
      public void run() {
        IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
        IFolder parent = getParent(selection);
        IMark position = (IMark) ((selection.getFirstElement() instanceof IMark) ? selection.getFirstElement() : null);
View Full Code Here

    // hookDoubleClickAction();
    // contributeToActionBars();
  }

  private void hookContextMenu() {
    final MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);

    Control lControl = null;
    ISelectionProvider lProvider = null;
    if (mMediaView.getCurrentView() == MediaView.MEDIA_VIEW) {
      lControl = mMediaView.getMediaViewer().mTableViewer.getControl();
      lProvider = mMediaView.getMediaViewer().mTableViewer;
    } else {
      lControl = mMediaView.getItemViewer().mTreeViewer.getControl();
      lProvider = mMediaView.getItemViewer().mTreeViewer;
    }

    final IStructuredSelection selection = (IStructuredSelection) lProvider
        .getSelection();

    if (selection.isEmpty()) {
      // CB TODO decide what to do on an empty selection.
    }

    menuMgr.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {
        manager.add(new Separator("control"));
        menuMgr
            .appendToGroup("control",
                new MediaOpenAction(selection));
        menuMgr.appendToGroup("control", new SyncPlayAction(selection));
        MediaViewPart.this.fillContextMenu(manager);
      }
    });

    if (lControl != null && lProvider != null) {
      Menu menu = menuMgr.createContextMenu(lControl);
      lControl.setMenu(menu);
      // Register to the workbench.
      getSite().registerContextMenu(menuMgr, lProvider);
    }
  }
View Full Code Here

    return browser;
  }

  private void hookMenu() {
    MenuManager manager = new MenuManager();
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {

        /* Back */
        manager.add(new Action("Back") {
          @Override
          public void run() {
            fBrowser.back();
          }

          @Override
          public boolean isEnabled() {
            return fBrowser.isBackEnabled();
          }

          @Override
          public ImageDescriptor getImageDescriptor() {
            return OwlUI.getImageDescriptor("icons/etool16/backward.gif");
          }
        });

        /* Forward */
        manager.add(new Action("Forward") {
          @Override
          public void run() {
            fBrowser.forward();
          }

          @Override
          public boolean isEnabled() {
            return fBrowser.isForwardEnabled();
          }

          @Override
          public ImageDescriptor getImageDescriptor() {
            return OwlUI.getImageDescriptor("icons/etool16/forward.gif");
          }
        });

        /* Reload */
        manager.add(new Separator());
        manager.add(new Action("Reload") {
          @Override
          public void run() {
            fBrowser.refresh();
          }

          @Override
          public ImageDescriptor getImageDescriptor() {
            return OwlUI.getImageDescriptor("icons/elcl16/reload.gif");
          }
        });

        /* Stop */
        manager.add(new Action("Stop") {
          @Override
          public void run() {
            fBrowser.stop();
          }

          @Override
          public ImageDescriptor getImageDescriptor() {
            return OwlUI.getImageDescriptor("icons/etool16/cancel.gif");
          }
        });
      }
    });

    Menu menu = manager.createContextMenu(fBrowser);
    fBrowser.setMenu(menu);
  }
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.