Package org.eclipse.jface.action

Examples of org.eclipse.jface.action.IMenuManager


    formatProposal = new RetargetTextEditorAction(bundle, "ContentFormatProposal.");
  }

  public void contributeToMenu(IMenuManager mm) {
    super.contributeToMenu(mm);
    IMenuManager editMenu = mm.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
    if (editMenu != null) {
      editMenu.add(new Separator());
      editMenu.add(formatProposal);
    }
  }
View Full Code Here


    ((GridData) fSearchBarContainer.getLayoutData()).exclude = !visible;
    fSearchBarContainer.getParent().layout();
  }

  private void hookViewMenu() {
    IMenuManager menuManager = fViewSite.getActionBars().getMenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {

        /* Manage Bookmark Sets */
        IAction manageSets = new Action("Manage Bookmark-Sets...") {
          @Override
          public void run() {
            ManageSetsDialog instance = ManageSetsDialog.getVisibleInstance();
            if (instance == null) {
              ManageSetsDialog dialog = new ManageSetsDialog(fViewSite.getShell(), fSelectedBookMarkSet);
              dialog.open();
            } else {
              instance.getShell().forceActive();
            }
          }
        };
        manager.add(manageSets);

        /* Available Bookmark Sets */
        manager.add(new Separator());
        for (final IFolder rootFolder : fRootFolders) {
          IAction selectBookMarkSet = new Action(rootFolder.getName(), IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (!fSelectedBookMarkSet.equals(rootFolder) && isChecked())
                changeSet(rootFolder);
            }
          };
          selectBookMarkSet.setImageDescriptor(OwlUI.BOOKMARK_SET); //$NON-NLS-1$

          if (fSelectedBookMarkSet.equals(rootFolder))
            selectBookMarkSet.setChecked(true);

          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
          public void run() {
            fSortByName = !fSortByName;
            if (fSortByName)
              fBookMarkComparator.setType(BookMarkSorter.Type.SORT_BY_NAME);
            else
              fBookMarkComparator.setType(BookMarkSorter.Type.DEFAULT_SORTING);
            fViewer.refresh(false);

            /* Save directly to global scope */
            fGlobalPreferences.putBoolean(DefaultPreferences.BE_SORT_BY_NAME, fSortByName);
          }
        };
        sortByName.setImageDescriptor(OwlUI.getImageDescriptor("icons/elcl16/sort_alpha.gif")); //$NON-NLS-1$
        sortByName.setChecked(fSortByName);
        manager.add(sortByName);

        IAction linkFeedView = new Action("Link with Feed-View", IAction.AS_CHECK_BOX) {
          @Override
          public void run() {
            fLinkingEnabled = isChecked();

            /* Link if enabled */
            if (fLinkingEnabled) {
              IEditorPart editor = fViewSite.getPage().getActiveEditor();
              if (editor != null)
                editorActivated(editor);
            }
          }
        };
        linkFeedView.setChecked(fLinkingEnabled);
        linkFeedView.setImageDescriptor(OwlUI.getImageDescriptor("icons/etool16/synced.gif"));
        manager.add(linkFeedView);

        /* Allow Contributions */
        manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
      }
    });

    /* Dummy Entry to show Menu in View */
    menuManager.add(new Action("") {}); //$NON-NLS-1$
  }
View Full Code Here

    ((GridData) fSearchBarContainer.getLayoutData()).exclude = !visible;
    fSearchBarContainer.getParent().layout();
  }

  private void hookViewMenu() {
    IMenuManager menuManager = fViewSite.getActionBars().getMenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {

        /* Manage Bookmark Sets */
        IAction manageSets = new Action("Manage Bookmark-Sets...") {
          @Override
          public void run() {
            ManageSetsDialog instance = ManageSetsDialog.getVisibleInstance();
            if (instance == null) {
              ManageSetsDialog dialog = new ManageSetsDialog(fViewSite.getShell(), fSelectedBookMarkSet);
              dialog.open();
            } else {
              instance.getShell().forceActive();
            }
          }
        };
        manager.add(manageSets);

        /* Available Bookmark Sets */
        manager.add(new Separator());
        for (final IFolder rootFolder : fRootFolders) {
          IAction selectBookMarkSet = new Action(rootFolder.getName(), IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (!fSelectedBookMarkSet.equals(rootFolder) && isChecked())
                changeSet(rootFolder);
            }
          };
          selectBookMarkSet.setImageDescriptor(OwlUI.BOOKMARK_SET); //$NON-NLS-1$

          if (fSelectedBookMarkSet.equals(rootFolder))
            selectBookMarkSet.setChecked(true);

          manager.add(selectBookMarkSet);
        }

        /* Search Bar */
        manager.add(new Separator());
        MenuManager searchMenu = new MenuManager("Search");
        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
          public void run() {
            fSortByName = !fSortByName;
            if (fSortByName)
              fBookMarkComparator.setType(BookMarkSorter.Type.SORT_BY_NAME);
            else
              fBookMarkComparator.setType(BookMarkSorter.Type.DEFAULT_SORTING);
            fViewer.refresh(false);

            /* Save directly to global scope */
            fGlobalPreferences.putBoolean(DefaultPreferences.BE_SORT_BY_NAME, fSortByName);
          }
        };
        sortByName.setImageDescriptor(OwlUI.getImageDescriptor("icons/elcl16/sort_alpha.gif")); //$NON-NLS-1$
        sortByName.setChecked(fSortByName);
        manager.add(sortByName);

        IAction linkFeedView = new Action("Link with Feed-View", IAction.AS_CHECK_BOX) {
          @Override
          public void run() {
            fLinkingEnabled = isChecked();

            /* Link if enabled */
            if (fLinkingEnabled) {
              IEditorPart editor = fViewSite.getPage().getActiveEditor();
              if (editor != null)
                editorActivated(editor);
            }
          }
        };
        linkFeedView.setChecked(fLinkingEnabled);
        linkFeedView.setImageDescriptor(OwlUI.getImageDescriptor("icons/etool16/synced.gif"));
        manager.add(linkFeedView);

        /* Allow Contributions */
        manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
      }
    });

    /* Dummy Entry to show Menu in View */
    menuManager.add(new Action("") {}); //$NON-NLS-1$
  }
View Full Code Here

    ((GridData) fSearchBarContainer.getLayoutData()).exclude = !visible;
    fSearchBarContainer.getParent().layout();
  }

  private void hookViewMenu() {
    IMenuManager menuManager = fViewSite.getActionBars().getMenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {

        /* Manage Bookmark Sets */
        IAction manageSets = new Action(Messages.BookMarkExplorer_MANAGE_SETS) {
          @Override
          public void run() {
            ManageSetsDialog instance = ManageSetsDialog.getVisibleInstance();
            if (instance == null) {
              ManageSetsDialog dialog = new ManageSetsDialog(fViewSite.getShell(), fSelectedBookMarkSet);
              dialog.open();
            } else {
              instance.getShell().forceActive();
            }
          }
        };
        manager.add(manageSets);

        /* Available Bookmark Sets */
        manager.add(new Separator());
        for (final IFolder rootFolder : fRootFolders) {
          IAction selectBookMarkSet = new Action(rootFolder.getName(), IAction.AS_RADIO_BUTTON) {
            @Override
            public void run() {
              if (!fSelectedBookMarkSet.equals(rootFolder) && isChecked())
                changeSet(rootFolder);
            }
          };
          selectBookMarkSet.setImageDescriptor(OwlUI.BOOKMARK_SET);

          if (fSelectedBookMarkSet.equals(rootFolder))
            selectBookMarkSet.setChecked(true);

          manager.add(selectBookMarkSet);
        }

        /* Search Bar */
        manager.add(new Separator());
        MenuManager searchMenu = new MenuManager(Messages.BookMarkExplorer_FIND);
        manager.add(searchMenu);

        /* Search Bar - Always Show Bar */
        IAction alwaysShow = new Action(Messages.BookMarkExplorer_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(Messages.BookMarkExplorer_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(Messages.BookMarkExplorer_SORT_BY_NAME, IAction.AS_CHECK_BOX) {
          @Override
          public void run() {
            fSortByName = !fSortByName;
            if (fSortByName)
              fBookMarkComparator.setType(BookMarkSorter.Type.SORT_BY_NAME);
            else
              fBookMarkComparator.setType(BookMarkSorter.Type.DEFAULT_SORTING);
            fViewer.refresh(false);

            /* Save directly to global scope */
            fGlobalPreferences.putBoolean(DefaultPreferences.BE_SORT_BY_NAME, fSortByName);
          }
        };
        sortByName.setChecked(fSortByName);
        manager.add(sortByName);

        IAction showFavicons = new Action(Messages.BookMarkExplorer_SHOW_FAVICONS, IAction.AS_CHECK_BOX) {
          @Override
          public void run() {
            fFaviconsEnabled = isChecked();

            fLabelProvider.setUseFavicons(fFaviconsEnabled);
            fViewer.getTree().setRedraw(false);
            try {
              fViewer.refresh(true);
            } finally {
              fViewer.getTree().setRedraw(true);
            }
          }
        };
        showFavicons.setChecked(fFaviconsEnabled);
        manager.add(showFavicons);

        /* Allow Contributions */
        manager.add(new Separator());

        IAction linkFeedView = new Action(Messages.BookMarkExplorer_LINKING, IAction.AS_CHECK_BOX) {
          @Override
          public void run() {
            fLinkingEnabled = isChecked();

            /* Link if enabled */
            if (fLinkingEnabled) {
              IEditorPart editor = fViewSite.getPage().getActiveEditor();
              if (editor != null)
                editorActivated(editor);
            }
          }
        };
        linkFeedView.setChecked(fLinkingEnabled);
        linkFeedView.setImageDescriptor(OwlUI.getImageDescriptor("icons/etool16/synced.gif")); //$NON-NLS-1$
        manager.add(linkFeedView);

        /* Allow Contributions */
        manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
      }
    });

    /* Dummy Entry to show Menu in View */
    menuManager.add(new Action("") {}); //$NON-NLS-1$
  }
View Full Code Here

    final List<Pair<IAttachment, URI>> attachments = ModelUtils.getAttachmentLinks(selection);
    if (!attachments.isEmpty()) {
      manager.add(new Separator("attachments")); //$NON-NLS-1$

      /* 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();

      /* Offer to Download All */
      if (attachments.size() > 1) {
        int sumBytes = 0;
        for (Pair<IAttachment, URI> attachment : attachments) {
          if (attachment.getFirst().getLength() > 0) {
            sumBytes += attachment.getFirst().getLength();
          } else {
            sumBytes = 0;
            break;
          }
        }
        String sumSize = OwlUI.getSize(sumBytes);

        Action downloadAllAction = new Action(sumSize != null ? (NLS.bind(Messages.ApplicationActionBarAdvisor_DOWNLOAD_ALL_WITH_SIZE, sumSize)) : (Messages.ApplicationActionBarAdvisor_DOWNLOAD_ALL)) {
          @Override
          public void run() {
            DirectoryDialog dialog = new DirectoryDialog(shellProvider.getShell(), SWT.None);
            dialog.setText(Messages.ApplicationActionBarAdvisor_SELECT_FOLDER_FOR_DOWNLOADS);

            String downloadFolder = preferences.getString(DefaultPreferences.DOWNLOAD_FOLDER);
            if (StringUtils.isSet(downloadFolder) && new File(downloadFolder).exists())
              dialog.setFilterPath(downloadFolder);

            String folder = dialog.open();
            if (StringUtils.isSet(folder)) {
              for (Pair<IAttachment, URI> attachment : attachments) {
                Controller.getDefault().getDownloadService().download(attachment.getFirst(), attachment.getSecond(), new File(folder), true);
              }

              /* Remember Download Folder in Settings */
              preferences.putString(DefaultPreferences.DOWNLOAD_FOLDER, folder);
            }
          }
        };
        downloadAllAction.setImageDescriptor(OwlUI.getImageDescriptor("icons/elcl16/save_all.gif")); //$NON-NLS-1$
        attachmentMenu.add(downloadAllAction);
        attachmentMenu.add(new Separator());
      }

      /* Collect openable Attachments that have already been downloaded */
      List<Action> openActions = new ArrayList<Action>(1);
      Set<String> downloadLocations = getDownloadLocations();

      /* Offer Download Action for each */
      for (final Pair<IAttachment, URI> attachmentPair : attachments) {
        IAttachment attachment = attachmentPair.getFirst();
        final String fileName = URIUtils.getFile(attachmentPair.getSecond(), OwlUI.getExtensionForMime(attachment.getType()));
        String size = OwlUI.getSize(attachment.getLength());

        Action action = new Action(size != null ? (NLS.bind(Messages.ApplicationActionBarAdvisor_FILE_SIZE, fileName, size)) : (fileName)) {
          @Override
          public void run() {
            FileDialog dialog = new FileDialog(shellProvider.getShell(), SWT.SAVE);
            dialog.setText(Messages.ApplicationActionBarAdvisor_SELECT_FILE_FOR_DOWNLOAD);
            dialog.setFileName(Application.IS_WINDOWS ? CoreUtils.getSafeFileNameForWindows(fileName) : fileName);
            dialog.setOverwrite(true);

            String downloadFolder = preferences.getString(DefaultPreferences.DOWNLOAD_FOLDER);
            if (StringUtils.isSet(downloadFolder) && new File(downloadFolder).exists())
              dialog.setFilterPath(downloadFolder);

            String selectedFileName = dialog.open();
            if (StringUtils.isSet(selectedFileName)) {
              File file = new File(selectedFileName);
              Controller.getDefault().getDownloadService().download(attachmentPair.getFirst(), attachmentPair.getSecond(), file.getName(), file.getParentFile(), true);

              /* Remember Download Folder in Settings */
              preferences.putString(DefaultPreferences.DOWNLOAD_FOLDER, file.getParentFile().toString());
            }
          }
        };

        action.setImageDescriptor(OwlUI.getImageDescriptor("icons/etool16/save_as.gif")); //$NON-NLS-1$
        attachmentMenu.add(action);

        /* Check if Attachment already exists and offer Open Action then */
        String usedFileName = Application.IS_WINDOWS ? CoreUtils.getSafeFileNameForWindows(fileName) : fileName;
        if (shouldOfferOpenAction(usedFileName)) {
          for (String downloadLocation : downloadLocations) {
            final File downloadedFile = new File(downloadLocation, usedFileName);
            if (downloadedFile.exists()) {
              Action openAction = new Action(NLS.bind(Messages.ApplicationActionBarAdvisor_OPEN_FILE, fileName)) {
                @Override
                public void run() {
                  Program.launch(downloadedFile.toString());
                }
              };

              openAction.setImageDescriptor(OwlUI.getAttachmentImage(fileName, attachmentPair.getFirst().getType()));
              openActions.add(openAction);

              break;
            }
          }
        }
      }

      /* Offer Open Action for each downloaded */
      if (!openActions.isEmpty()) {
        attachmentMenu.add(new Separator());
        for (Action openAction : openActions) {
          attachmentMenu.add(openAction);
        }
      }

      /* Offer to Automize Downloading */
      attachmentMenu.add(new Separator());
      attachmentMenu.add(new AutomateFilterAction(PresetAction.DOWNLOAD, selection));
    }
  }
View Full Code Here

   */
  public static void fillShareMenu(IMenuManager manager, final IStructuredSelection selection, final IShellProvider shellProvider, boolean directMenu) {
    manager.add(new Separator("share")); //$NON-NLS-1$

    /* 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);
    List<ShareProvider> providers = Controller.getDefault().getShareProviders();
    for (final ShareProvider provider : providers) {
      if (provider.isEnabled()) {
        shareMenu.add(new Action(provider.getName()) {
          @Override
          public void run() {

            /* Special Case "Send E-Mail" action */
            if (SendLinkAction.ID.equals(provider.getId())) {
              IActionDelegate action = new SendLinkAction();
              action.selectionChanged(null, selection);
              action.run(null);
            }

            /* Other Action */
            else {
              Object obj = selection.getFirstElement();
              if (obj != null && obj instanceof INews) {
                String shareLink = provider.toShareUrl((INews) obj);
                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 isEnabled;
          }

          @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();
          }
        });
      }
    }

    /* Allow to Configure Providers */
    shareMenu.add(new Separator());
    shareMenu.add(new Action(Messages.ApplicationActionBarAdvisor_CONFIGURE) {
      @Override
      public void run() {
        PreferencesUtil.createPreferenceDialogOn(shellProvider.getShell(), SharingPreferencesPage.ID, null, null).open();
      };
    });
View Full Code Here

   * otherwise create a sub menu.
   */
  public static void fillLabelMenu(IMenuManager manager, final IStructuredSelection selection, final IShellProvider shellProvider, boolean directMenu) {

    /* 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));

    /* Organize Labels */
    labelMenu.add(new Action(Messages.ApplicationActionBarAdvisor_ORGANIZE_LABELS) {
      @Override
      public void run() {
        PreferencesUtil.createPreferenceDialogOn(shellProvider.getShell(), ManageLabelsPreferencePage.ID, null, null).open();
      }
    });

    /* Load Labels */
    final Collection<ILabel> labels = CoreUtils.loadSortedLabels();

    /* Retrieve Labels that all selected News contain */
    labelMenu.add(new Separator());
    Set<ILabel> selectedLabels = ModelUtils.getLabelsForAll(selection);
    for (final ILabel label : labels) {
      LabelAction labelAction = new LabelAction(label, selection);
      labelAction.setChecked(selectedLabels.contains(label));
      labelMenu.add(labelAction);
    }

    /* New Label */
    labelMenu.add(new Action(Messages.ApplicationActionBarAdvisor_NEW_LABEL) {
      @Override
      public void run() {
        LabelDialog dialog = new LabelDialog(shellProvider.getShell(), DialogMode.ADD, null);
        if (dialog.open() == IDialogConstants.OK_ID) {
          String name = dialog.getName();
          RGB color = dialog.getColor();

          ILabel newLabel = Owl.getModelFactory().createLabel(null, name);
          newLabel.setColor(OwlUI.toString(color));
          newLabel.setOrder(labels.size());
          DynamicDAO.save(newLabel);

          LabelAction labelAction = new LabelAction(newLabel, selection);
          labelAction.run();
        }
      }

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

    /* Remove All Labels */
    labelMenu.add(new Separator());
    LabelAction removeAllLabels = new LabelAction(null, selection);
    removeAllLabels.setId(RemoveLabelsHandler.ID);
    removeAllLabels.setActionDefinitionId(RemoveLabelsHandler.ID);
    removeAllLabels.setEnabled(!selection.isEmpty() && !labels.isEmpty());
    labelMenu.add(removeAllLabels);
  }
View Full Code Here

        // toolBarManager.appendToGroup(JadclipsePlugin.PID_JADCLIPSE, dAction);
    }

    public void contributeToMenu(IMenuManager menu) {
        super.contributeToMenu(menu);
        IMenuManager edit = menu
            .findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
        if (edit != null) {
            edit.add(refreshAction);
            edit.add(toggleRawBytecodeAction);
            edit.add(attachAction);
        }
    }
View Full Code Here

    private void createToolbarActions() {
        createTextActions();

        final IActionBars bars = getViewSite().getActionBars();
        final IToolBarManager tmanager = bars.getToolBarManager();
        final IMenuManager mmanager = bars.getMenuManager();

        selectionChangedAction = new Action() {

            public void run() {
                Point selection = textControl.getSelection();
                setSelectionInJavaEditor(selection);
            }
        };

        refreshVarsAndStackAction = new Action() {

            public void run() {
                int selectionIndex = tableControl.getSelectionIndex();
                TableItem[] items = tableControl.getSelection();
                if(items == null || items.length < 1){
                    return;
                }
                String line = items[0].getText(0);
                if(line == null || "".equals(line)){
                    return;
                }
                Integer valueOf = Integer.valueOf(line);
                if(valueOf != null){
                    updateVerifierControl4insn(valueOf.intValue());
                    tableControl.setSelection(selectionIndex);
                }
            }
        };

        linkWithEditorAction = new DefaultToggleAction(
            BCOConstants.LINK_VIEW_TO_EDITOR) {

            public void run(boolean newState) {
                setMode(BCOConstants.F_LINK_VIEW_TO_EDITOR, newState);
                if (modes.get(BCOConstants.F_LINK_VIEW_TO_EDITOR)) {
                    showSelectedOnlyAction.setEnabled(true);
                    toggleVerifierAction.setEnabled(true);
                    hideLineInfoAction.setEnabled(true);
                    hideLocalsAction.setEnabled(true);
                    toggleASMifierModeAction.setEnabled(true);
                    if (!toggleASMifierModeAction.isChecked()) {
                        setRawModeAction.setEnabled(true);
                    }
                    activateView();
                    checkOpenEditors(true);
                    inputChanged = true;
                    refreshView();
                }
            }
        };

        showSelectedOnlyAction = new DefaultToggleAction(
            BCOConstants.SHOW_ONLY_SELECTED_ELEMENT) {

            public void run(boolean newState) {
                setMode(BCOConstants.F_SHOW_ONLY_SELECTED_ELEMENT, newState);
                inputChanged = true;
                refreshView();
            }
        };

        setRawModeAction = new DefaultToggleAction(
            BCOConstants.SHOW_RAW_BYTECODE) {

            public void run(boolean newState) {
                setMode(BCOConstants.F_SHOW_RAW_BYTECODE, newState);
                inputChanged = true;
                refreshView();
            }
        };

        hideLineInfoAction = new DefaultToggleAction(
            BCOConstants.SHOW_LINE_INFO) {

            public void run(boolean newState) {
                setMode(BCOConstants.F_SHOW_LINE_INFO, newState);
                inputChanged = true;
                refreshView();
            }
        };

        hideLocalsAction = new DefaultToggleAction(BCOConstants.SHOW_VARIABLES) {

            public void run(boolean newState) {
                setMode(BCOConstants.F_SHOW_VARIABLES, newState);
                inputChanged = true;
                refreshView();
            }
        };

        hideStackMapAction = new DefaultToggleAction(BCOConstants.SHOW_STACKMAP) {

            public void run(boolean newState) {
                setMode(BCOConstants.F_SHOW_STACKMAP, newState);
                inputChanged = true;
                refreshView();
            }
        };

        expandStackMapAction = new DefaultToggleAction(
            BCOConstants.EXPAND_STACKMAP) {

            public void run(boolean newState) {
                setMode(BCOConstants.F_EXPAND_STACKMAP, newState);
                inputChanged = true;
                refreshView();
            }
        };

        showHexValuesAction = new DefaultToggleAction(
            BCOConstants.SHOW_HEX_VALUES) {

            public void run(boolean newState) {
                setMode(BCOConstants.F_SHOW_HEX_VALUES, newState);
                inputChanged = true;
                refreshView();
            }
        };

        toggleASMifierModeAction = new DefaultToggleAction(
            BCOConstants.SHOW_ASMIFIER_CODE) {

            public void run(boolean newState) {
                setMode(BCOConstants.F_SHOW_ASMIFIER_CODE, newState);
                if (newState) {
                    setMode(BCOConstants.F_SHOW_RAW_BYTECODE, true);
                    setRawModeAction.setEnabled(false);
                } else {
                    setRawModeAction.setEnabled(true);
                }
                inputChanged = true;
                refreshView();
            }
        };

        toggleVerifierAction = new DefaultToggleAction(
            BCOConstants.SHOW_ANALYZER) {

            public void run(boolean newState) {
                toggleVerifyMode(mmanager, newState);
                inputChanged = true;
                refreshView();
            }
        };

        mmanager.add(linkWithEditorAction);
        mmanager.add(showSelectedOnlyAction);
        mmanager.add(setRawModeAction);
        mmanager.add(hideLineInfoAction);
        mmanager.add(hideLocalsAction);
        mmanager.add(showHexValuesAction);
        mmanager.add(hideStackMapAction);
        mmanager.add(expandStackMapAction);
        mmanager.add(toggleASMifierModeAction);
        mmanager.add(toggleVerifierAction);

        mmanager.add(new Separator());

        toggleOrientationActions = new ToggleOrientationAction[]{
            new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
            new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL),
            new ToggleOrientationAction(this, VIEW_ORIENTATION_AUTOMATIC)};
        for (int i = 0; i < toggleOrientationActions.length; ++i) {
            mmanager.add(toggleOrientationActions[i]);
        }

        tmanager.add(linkWithEditorAction);
        tmanager.add(showSelectedOnlyAction);
        tmanager.add(setRawModeAction);
View Full Code Here

        // create actions and context menu (and register global actions)
        actionGroup = new BrowserViewActionGroup( this );
        actionGroup.fillToolBar( mainWidget.getToolBarManager() );
        actionGroup.fillMenu( mainWidget.getMenuManager() );
        actionGroup.enableGlobalActionHandlers( getViewSite().getActionBars() );
        IMenuManager contextMenuManager = mainWidget.getContextMenuManager();
        actionGroup.fillContextMenu( contextMenuManager );
        getSite().registerContextMenu( ( MenuManager ) contextMenuManager, mainWidget.getViewer() );

        // create the listener
        getSite().setSelectionProvider( mainWidget.getViewer() );
View Full Code Here

TOP

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

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.