Java Code Examples for org.eclipse.swt.widgets.MenuItem#setMenu()
The following examples show how to use
org.eclipse.swt.widgets.MenuItem#setMenu() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextEditorContextMenuContribution.java From git-appraise-eclipse with Eclipse Public License 1.0 | 6 votes |
@Override public void fill(Menu menu, int index) { MenuItem submenuItem = new MenuItem(menu, SWT.CASCADE, index); submenuItem.setText("&Appraise Review Comments"); Menu submenu = new Menu(menu); submenuItem.setMenu(submenu); MenuItem reviewCommentMenuItem = new MenuItem(submenu, SWT.CHECK); reviewCommentMenuItem.setText("New &Review Comment..."); reviewCommentMenuItem.addSelectionListener(createReviewCommentSelectionListener()); MenuItem fileCommentMenuItem = new MenuItem(submenu, SWT.CHECK); fileCommentMenuItem.setText("New &File Comment..."); fileCommentMenuItem.addSelectionListener(createFileCommentSelectionListener()); MenuItem fileLineCommentMenuItem = new MenuItem(submenu, SWT.CHECK); fileLineCommentMenuItem.setText("New &Line Comment..."); fileLineCommentMenuItem.addSelectionListener(createFileLineCommentSelectionListener()); // Can only add Appraise comments if there is an active Appraise review task. ITask activeTask = TasksUi.getTaskActivityManager().getActiveTask(); submenuItem.setEnabled(activeTask != null && AppraiseTaskMapper.APPRAISE_REVIEW_TASK_KIND.equals(activeTask.getTaskKind())); }
Example 2
Source File: GamlReferenceMenu.java From gama with GNU General Public License v3.0 | 6 votes |
public void installSubMenuIn(final Menu menu) { final MenuItem builtInItem = new MenuItem(menu, SWT.CASCADE); builtInItem.setText(getTitle()); builtInItem.setImage(getImage()); mainMenu = new Menu(builtInItem); builtInItem.setMenu(mainMenu); mainMenu.addListener(SWT.Show, e -> { if (mainMenu.getItemCount() > 0) { for (final MenuItem item : mainMenu.getItems()) { item.dispose(); } } fillMenu(); }); }
Example 3
Source File: OutputsMenu.java From gama with GNU General Public License v3.0 | 6 votes |
public void outputSubMenu(final Menu main, final IScope scope, final IOutputManager manager, final IDisplayOutput output) { final MenuItem item = new MenuItem(main, SWT.CASCADE); item.setText(output.getOriginalName()); final Menu sub = new Menu(item); item.setMenu(sub); if (output.isOpen()) { // menuItem(sub, e -> output.close(), null, "Close"); if (output.isPaused()) menuItem(sub, e -> output.setPaused(false), null, "Resume"); else menuItem(sub, e -> output.setPaused(true), null, "Pause"); menuItem(sub, e -> output.update(), null, "Refresh"); if (output.isSynchronized()) menuItem(sub, e -> output.setSynchronized(false), null, "Unsynchronize"); else menuItem(sub, e -> output.setSynchronized(true), null, "Synchronize"); } else menuItem(sub, e -> manager.open(scope, output), null, "Reopen"); }
Example 4
Source File: EditorMenu.java From gama with GNU General Public License v3.0 | 6 votes |
/** * @param menu */ private void createOtherExperiments(final Menu menu) { final MenuItem usedIn = new MenuItem(menu, SWT.CASCADE); usedIn.setText(" Other experiments..."); usedIn.setImage(GamaIcons.create("other.experiments").image()); final Menu sub = new Menu(usedIn); usedIn.setMenu(sub); sub.addListener(SWT.Show, e -> { for (final MenuItem item : sub.getItems()) { item.dispose(); } createOtherSubMenu(sub, getEditor()); }); }
Example 5
Source File: EditorMenu.java From gama with GNU General Public License v3.0 | 6 votes |
public static Menu createOtherSubMenu(final Menu parentMenu, final GamlEditor editor) { final Map<URI, List<String>> map = grabProjectModelsAndExperiments(editor); if (map.isEmpty()) { final MenuItem nothing = new MenuItem(parentMenu, SWT.PUSH); nothing.setText("No experiments defined"); nothing.setEnabled(false); return parentMenu; } for (final URI uri : map.keySet()) { final MenuItem modelItem = new MenuItem(parentMenu, SWT.CASCADE); modelItem.setText(URI.decode(uri.lastSegment())); modelItem.setImage(GamaIcons.create(IGamaIcons.FILE_ICON).image()); final Menu expMenu = new Menu(modelItem); modelItem.setMenu(expMenu); final List<String> expNames = map.get(uri); for (final String name : expNames) { final MenuItem expItem = new MenuItem(expMenu, SWT.PUSH); expItem.setText(name); expItem.setData("uri", uri); expItem.setData("exp", name); expItem.setImage(GamaIcons.create(IGamaIcons.BUTTON_GUI).image()); expItem.addSelectionListener(OtherAdapter); } } return parentMenu; }
Example 6
Source File: AgentsMenu.java From gama with GNU General Public License v3.0 | 6 votes |
public static MenuItem cascadingAgentMenuItem(final Menu parent, final IAgent agent, final String title, final MenuAction... actions) { final MenuItem result = new MenuItem(parent, SWT.CASCADE); result.setText(title); Image image; if (agent instanceof SimulationAgent) { final SimulationAgent sim = (SimulationAgent) agent; image = GamaIcons.createTempRoundColorIcon(GamaColors.get(sim.getColor())); } else { image = GamaIcons.create(IGamaIcons.MENU_AGENT).image(); } result.setImage(image); final Menu agentMenu = new Menu(result); result.setMenu(agentMenu); createMenuForAgent(agentMenu, agent, agent instanceof ITopLevelAgent, true, actions); return result; }
Example 7
Source File: AgentsMenu.java From gama with GNU General Public License v3.0 | 6 votes |
private static MenuItem cascadingPopulationMenuItem(final Menu parent, final IAgent agent, final IPopulation<? extends IAgent> population, final Image image, final MenuAction... actions) { if (population instanceof SimulationPopulation) { fillPopulationSubMenu(parent, population, actions); return null; } final MenuItem result = new MenuItem(parent, SWT.CASCADE); // if ( population instanceof SimulationPopulation ) { // result.setText("Simulations"); // } else { result.setText("Population of " + population.getName()); // } result.setImage(image); final Menu agentsMenu = new Menu(result); result.setMenu(agentsMenu); fillPopulationSubMenu(agentsMenu, population, actions); return result; }
Example 8
Source File: EditorMenu.java From gama with GNU General Public License v3.0 | 5 votes |
/** * @param menu */ private void createUsedIn(final Menu menu) { final MenuItem usedIn = new MenuItem(menu, SWT.CASCADE); usedIn.setText(" Imported in..."); usedIn.setImage(GamaIcons.create("imported.in").image()); final Menu sub = new Menu(usedIn); usedIn.setMenu(sub); sub.addListener(SWT.Show, e -> { for (final MenuItem item : sub.getItems()) { item.dispose(); } createImportedSubMenu(sub, getEditor()); }); }
Example 9
Source File: AbstractMenuContributionItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected Menu createCascadeMenu(Menu menu, String label, Optional<Image> image) { MenuItem cascadeMenuItem = new MenuItem(menu, SWT.CASCADE); cascadeMenuItem.setText(label); image.ifPresent(cascadeMenuItem::setImage); Menu cascadeMenu = new Menu(menu); cascadeMenuItem.setMenu(cascadeMenu); return cascadeMenu; }
Example 10
Source File: AnalysisToolComposite.java From ice with Eclipse Public License 1.0 | 5 votes |
/** * Creates the Menu that stores each of the available IAnalysisViews for * each of the data sources. */ private void createViewMenu() { // Instantiate viewMenu. POP_UP menus are used for context menus and // drop-downs from ToolItems. Menu menu = new Menu(this.getShell(), SWT.POP_UP); // Create the top-level of the view menu with a button for each possible // data source. for (DataSource dataSource : DataSource.values()) { // Create a disabled MenuItem with dataSource as its text. MenuItem item = new MenuItem(menu, SWT.CASCADE); item.setText(dataSource.toString()); item.setEnabled(false); // Create the sub-menu that will show the view types for this data // source. Menu subMenu = new Menu(menu); item.setMenu(subMenu); // Put the MenuItem into a Map for quick access (it will need to be // enabled/disabled depending on whether or not there are views // available for the data source. dataSourceItems.put(dataSource, item); } // Add the view ToolItem that should make the view menu appear. final ToolItem viewItem = new ToolItem(rightToolBar, SWT.DROP_DOWN); viewItem.setText("Views"); viewItem.setToolTipText("Select the view displayed below."); // We also need to add a listener to make viewMenu appear. viewItem.addListener(SWT.Selection, new ToolItemMenuListener(viewItem, menu)); return; }
Example 11
Source File: BuildSupplyChainMenuAction.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void createItem(Menu menu, IBuildAction action) { MenuItem item = new MenuItem(menu, SWT.CASCADE); item.setText(action.getText()); Menu subMenu = new Menu(item); createSubItem(subMenu, action, DefaultProviders.IGNORE, ProcessType.UNIT_PROCESS); createSubItem(subMenu, action, DefaultProviders.IGNORE, ProcessType.LCI_RESULT); createSubItem(subMenu, action, DefaultProviders.PREFER, ProcessType.UNIT_PROCESS); createSubItem(subMenu, action, DefaultProviders.PREFER, ProcessType.LCI_RESULT); createSubItem(subMenu, action, DefaultProviders.ONLY, null); item.setMenu(subMenu); }
Example 12
Source File: GamaMenu.java From gama with GNU General Public License v3.0 | 5 votes |
public static Menu sub(final Menu parent, final String s, final String t) { final MenuItem item = createItem(parent, SWT.CASCADE); item.setText(s); if (t != null) { item.setToolTipText(t); } final Menu m = new Menu(item); item.setMenu(m); return m; }
Example 13
Source File: GroupPage.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void createMoveMenu() { Menu menu = new Menu(processViewer.getTable()); processViewer.getTable().setMenu(menu); MenuItem item = new MenuItem(menu, SWT.CASCADE); item.setText(M.Move); groupMoveMenu = new Menu(item); item.setMenu(groupMoveMenu); groupMoveMenu.addListener(SWT.Show, new MenuGroupListener()); }
Example 14
Source File: ReviewMarkerMenuContribution.java From git-appraise-eclipse with Eclipse Public License 1.0 | 5 votes |
@Override public void fill(Menu menu, int index) { MenuItem submenuItem = new MenuItem(menu, SWT.CASCADE, index); submenuItem.setText("&Appraise Review Comments"); Menu submenu = new Menu(menu); submenuItem.setMenu(submenu); for (IMarker marker : markers) { MenuItem menuItem = new MenuItem(submenu, SWT.CHECK); menuItem.setText(marker.getAttribute(IMarker.MESSAGE, "")); menuItem.addSelectionListener(createDynamicSelectionListener(marker)); } }
Example 15
Source File: GeoMapBrowser.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void createMenu(Shell shell) { Menu bar = new Menu(shell, SWT.BAR); shell.setMenuBar(bar); MenuItem fileItem = new MenuItem(bar, SWT.CASCADE); fileItem.setText("&File"); Menu submenu = new Menu(shell, SWT.DROP_DOWN); fileItem.setMenu(submenu); MenuItem item = new MenuItem(submenu, SWT.PUSH); item.addListener(SWT.Selection, e -> Runtime.getRuntime().halt(0)); item.setText("E&xit\tCtrl+W"); item.setAccelerator(SWT.MOD1 + 'W'); }
Example 16
Source File: AgentsMenu.java From gama with GNU General Public License v3.0 | 4 votes |
public static void fillPopulationSubMenu(final Menu menu, final Collection<? extends IAgent> species, final MenuAction... actions) { final boolean isSimulations = species instanceof SimulationPopulation; int subMenuSize = GamaPreferences.Interface.CORE_MENU_SIZE.getValue(); if (subMenuSize < 2) { subMenuSize = 2; } final List<IAgent> agents = new ArrayList<>(species); final int size = agents.size(); if (size > 1 && !isSimulations) { GamaMenu.separate(menu, "Actions"); } if (size > 1) { browsePopulationMenuItem(menu, species, GamaIcons.create(IGamaIcons.MENU_BROWSE).image()); } if (size > 1 && !isSimulations) { GamaMenu.separate(menu); GamaMenu.separate(menu, "Agents"); } if (size < subMenuSize) { for (final IAgent agent : agents) { cascadingAgentMenuItem(menu, agent, agent.getName(), actions); } } else { final int nb = size / subMenuSize + 1; for (int i = 0; i < nb; i++) { final int begin = i * subMenuSize; final int end = Math.min((i + 1) * subMenuSize, size); if (begin >= end) { break; } final MenuItem rangeItem = new MenuItem(menu, SWT.CASCADE); final Menu rangeMenu = new Menu(rangeItem); rangeItem.setMenu(rangeMenu); rangeItem.setText("" + begin + " to " + (end - 1)); rangeItem.setImage(GamaIcons.create(IGamaIcons.MENU_POPULATION).image()); rangeMenu.addListener(SWT.Show, e -> { if (!menu.isVisible()) { return; } final MenuItem[] items = rangeMenu.getItems(); for (final MenuItem item : items) { item.dispose(); } for (int j = begin; j < end; j++) { final IAgent ag = agents.get(j); if (ag != null && !ag.dead()) { cascadingAgentMenuItem(rangeMenu, ag, ag.getName(), actions); } } }); } } }
Example 17
Source File: ToolbarComposite.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void mouseDown(MouseEvent event) { checkWidget(); Rectangle bigArrowsBounds = new Rectangle(mArrowsBounds.x, 0, mArrowsBounds.width, CustomButton.BUTTON_HEIGHT); if (isInside(event.x, event.y, bigArrowsBounds)) { GC gc = new GC(this); Rectangle rect = new Rectangle(mArrowsBounds.x - mSettings.getToolBarLeftSpacer(), 0, mArrowsBounds.width + mSettings.getToolBarRightSpacer(), CustomButton.BUTTON_HEIGHT); mButtonPainter.paintBackground(gc, mColorManager, mSettings, rect, false, true); gc.drawImage(mArrowImage, mArrowsBounds.x, mArrowsBounds.y); gc.dispose(); Menu mainMenu = new Menu(Display.getDefault().getActiveShell(), SWT.POP_UP); List<IMenuListener> menuListeners = mButtonComposite.getMenuListeners(); for (int i = 0; i < menuListeners.size(); i++) { menuListeners.get(i).preMenuItemsCreated(mainMenu); } MenuItem menuShowMoreButtons = new MenuItem(mainMenu, SWT.PUSH); MenuItem menuShowFewerButtons = new MenuItem(mainMenu, SWT.PUSH); menuShowFewerButtons.addListener(SWT.Selection, e -> mButtonComposite.hideNextButton()); menuShowMoreButtons.addListener(SWT.Selection, e-> mButtonComposite.showNextButton()); menuShowMoreButtons.setText(mLanguage.getShowMoreButtonsText()); menuShowFewerButtons.setText(mLanguage.getShowFewerButtonsText()); new MenuItem(mainMenu, SWT.SEPARATOR); MenuItem more = new MenuItem(mainMenu, SWT.CASCADE); more.setText(mLanguage.getAddOrRemoveButtonsText()); Menu moreMenu = new Menu(more); more.setMenu(moreMenu); List<CustomButton> cbs = mButtonComposite.getItems(); for (int i = 0; i < cbs.size(); i++) { final CustomButton cb = cbs.get(i); final MenuItem temp = new MenuItem(moreMenu, SWT.CHECK); temp.setText(cb.getText()); temp.setImage(cb.getToolBarImage()); temp.setSelection(mButtonComposite.isVisible(cb)); temp.addListener(SWT.Selection, e -> { if (mButtonComposite.isVisible(cb)) { mButtonComposite.permanentlyHideButton(cb); temp.setSelection(false); } else { mButtonComposite.permanentlyShowButton(cb); temp.setSelection(true); } }); } for (int i = 0; i < menuListeners.size(); i++) { menuListeners.get(i).postMenuItemsCreated(mainMenu); } mainMenu.setVisible(true); return; } for (int i = 0; i < mToolBarItems.size(); i++) { TBItem item = mToolBarItems.get(i); if (item.getBounds() != null) { if (isInside(event.x, event.y, item.getBounds())) { mButtonComposite.selectItemAndLoad(item.getButton()); break; } } } }
Example 18
Source File: EditorMenu.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public void fill(final Menu m, final int index) { final MenuItem menuItem = new MenuItem(m, SWT.CASCADE); menuItem.setText("Model"); final Menu menu = new Menu(menuItem); if (menuItem.getMenu() != null) { menuItem.getMenu().dispose(); } menuItem.setMenu(menu); menu.addListener(SWT.Show, e -> { markPref = GamaPreferences.get("pref_editor_mark_occurrences", Boolean.class); for (final MenuItem item : menu.getItems()) { item.dispose(); } if (getEditor() != null) { GamaMenu.separate(menu, "Presentation"); GamaMenu.separate(menu); createLineToggle(menu); createFoldingToggle(menu); createMarkToggle(menu); createBoxToggle(menu); createOverviewToggle(menu); GamaMenu.separate(menu); GamaMenu.separate(menu, "Insert"); GamaMenu.separate(menu); createReferenceMenus(menu); GamaMenu.separate(menu); GamaMenu.separate(menu, "Model"); GamaMenu.separate(menu); createUsedIn(menu); createOtherExperiments(menu); GamaMenu.separate(menu); createValidate(menu); // line.setSelection(getEditor().isLineNumberRulerVisible()); // folding.setSelection(getEditor().isRangeIndicatorEnabled()); // box.setSelection(getEditor().isDecorationEnabled()); initializePreferences(); // mark.setSelection(markPref.getValue()); } createValidateAll(menu); }); }
Example 19
Source File: AbstractTableDialogEx.java From logbook with MIT License | 4 votes |
/** * Open the dialog. */ public void open() { // シェルを作成 this.shell = new Shell(this.getParent(), this.getStyle()); this.shell.setSize(this.getSize()); // ウインドウ位置を復元 LayoutLogic.applyWindowLocation(this.getClass(), this.shell); // 閉じた時にウインドウ位置を保存 this.shell.addShellListener(new SaveWindowLocationAdapter(this.getClass())); this.shell.setText(this.getTitle()); this.shell.setLayout(new FillLayout()); // メニューバー this.menubar = new Menu(this.shell, SWT.BAR); this.shell.setMenuBar(this.menubar); // メニューバーのメニュー MenuItem fileroot = new MenuItem(this.menubar, SWT.CASCADE); fileroot.setText("ファイル"); this.filemenu = new Menu(fileroot); fileroot.setMenu(this.filemenu); MenuItem savecsv = new MenuItem(this.filemenu, SWT.NONE); savecsv.setText("CSVファイルに保存(&S)\tCtrl+S"); savecsv.setAccelerator(SWT.CTRL + 'S'); savecsv.addSelectionListener(new TableToCsvSaveAdapter(this.shell, this.getTitle(), () -> this.getSelectionTable().getTable())); MenuItem operoot = new MenuItem(this.menubar, SWT.CASCADE); operoot.setText("操作"); this.opemenu = new Menu(operoot); operoot.setMenu(this.opemenu); MenuItem reload = new MenuItem(this.opemenu, SWT.NONE); reload.setText("再読み込み(&R)\tF5"); reload.setAccelerator(SWT.F5); reload.addSelectionListener(new TableReloadAdapter()); Boolean isCyclicReload = AppConfig.get().getCyclicReloadMap().get(this.getClass().getName()); MenuItem cyclicReload = new MenuItem(this.opemenu, SWT.CHECK); cyclicReload.setText("定期的に再読み込み(&A)\tCtrl+F5"); cyclicReload.setAccelerator(SWT.CTRL + SWT.F5); if ((isCyclicReload != null) && isCyclicReload.booleanValue()) { cyclicReload.setSelection(true); } CyclicReloadAdapter adapter = new CyclicReloadAdapter(cyclicReload); cyclicReload.addSelectionListener(adapter); adapter.setCyclicReload(cyclicReload); MenuItem selectVisible = new MenuItem(this.opemenu, SWT.NONE); selectVisible.setText("列の表示・非表示(&V)"); selectVisible.addSelectionListener(new SelectVisibleColumnAdapter()); new MenuItem(this.opemenu, SWT.SEPARATOR); // 閉じた時に設定を保存 this.shell.addShellListener(new ShellAdapter() { @Override public void shellClosed(ShellEvent e) { AppConfig.get().getCyclicReloadMap() .put(AbstractTableDialogEx.this.getClass().getName(), cyclicReload.getSelection()); } }); this.createContents(); this.shell.open(); this.shell.layout(); Display display = this.getParent().getDisplay(); while (!this.shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } // タスクがある場合キャンセル if (this.future != null) { this.future.cancel(false); } }
Example 20
Source File: BattleAggDialog.java From logbook with MIT License | 4 votes |
/** * Create contents of the dialog. */ private void createContents() { // シェルを作成 this.shell = new Shell(this.getParent(), this.getStyle()); this.shell.setSize(this.getSize()); // ウインドウ位置を復元 LayoutLogic.applyWindowLocation(this.getClass(), this.shell); // 閉じた時にウインドウ位置を保存 this.shell.addShellListener(new SaveWindowLocationAdapter(this.getClass())); this.shell.setText(this.getTitle()); this.shell.setLayout(new FillLayout(SWT.HORIZONTAL)); // メニューバー this.menubar = new Menu(this.shell, SWT.BAR); this.shell.setMenuBar(this.menubar); // ツリーテーブル this.tree = new Tree(this.shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.MULTI); this.tree.addKeyListener(new TreeKeyShortcutAdapter(this.header, this.tree)); this.tree.setLinesVisible(true); this.tree.setHeaderVisible(true); // メニューバーのメニュー MenuItem operoot = new MenuItem(this.menubar, SWT.CASCADE); operoot.setText("操作"); this.opemenu = new Menu(operoot); operoot.setMenu(this.opemenu); MenuItem reload = new MenuItem(this.opemenu, SWT.NONE); reload.setText("再読み込み(&R)\tF5"); reload.setAccelerator(SWT.F5); reload.addSelectionListener((SelectedListener) e -> this.reloadTable()); // テーブル右クリックメニュー this.tablemenu = new Menu(this.tree); this.tree.setMenu(this.tablemenu); MenuItem sendclipbord = new MenuItem(this.tablemenu, SWT.NONE); sendclipbord.addSelectionListener(new TreeToClipboardAdapter(this.header, this.tree)); sendclipbord.setText("クリップボードにコピー(&C)"); MenuItem reloadtable = new MenuItem(this.tablemenu, SWT.NONE); reloadtable.setText("再読み込み(&R)"); reloadtable.addSelectionListener((SelectedListener) e -> this.reloadTable()); this.setTableHeader(); this.reloadTable(); }