Java Code Examples for org.eclipse.swt.widgets.MenuItem#setImage()
The following examples show how to use
org.eclipse.swt.widgets.MenuItem#setImage() .
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: MenuItemProviders.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider hideColumnMenuItemProvider() { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH); menuItem.setText("Hide column"); menuItem.setImage(GUIHelper.getImage("hide_column")); menuItem.setEnabled(true); menuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { int columnPosition = getNatEventData(event).getColumnPosition(); natTable.doCommand(new ColumnHideCommand(natTable, columnPosition)); } }); } }; }
Example 2
Source File: MenuItemProviders.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider showAllColumnMenuItemProvider() { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, Menu popupMenu) { MenuItem showAllColumns = new MenuItem(popupMenu, SWT.PUSH); showAllColumns.setText("Show all columns"); showAllColumns.setImage(GUIHelper.getImage("show_column")); showAllColumns.setEnabled(true); showAllColumns.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { natTable.doCommand(new ShowAllColumnsCommand()); } }); } }; }
Example 3
Source File: MenuItemProviders.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider hideColumnMenuItemProvider() { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH); menuItem.setText("Hide column"); menuItem.setImage(GUIHelper.getImage("hide_column")); menuItem.setEnabled(true); menuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { int columnPosition = getNatEventData(event).getColumnPosition(); natTable.doCommand(new ColumnHideCommand(natTable, columnPosition)); } }); } }; }
Example 4
Source File: MenuItemProviders.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider clearAllFiltersMenuItemProvider(final String menuLabel) { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH); menuItem.setText(menuLabel); menuItem.setImage(GUIHelper.getImage("remove_filter")); menuItem.setEnabled(true); menuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { natTable.doCommand(new ClearAllFiltersCommand()); } }); } }; }
Example 5
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 6
Source File: StartSessionWithProjects.java From saros with GNU General Public License v2.0 | 6 votes |
/** Creates a menu entry which shares projects with the given Contacts. */ private MenuItem createProjectMenuItem( final Menu parentMenu, final int index, final IProject project, final List<JID> contacts) { final MenuItem menuItem = new MenuItem(parentMenu, SWT.NONE, index); menuItem.setText(workbenchLabelProvider.getText(project)); menuItem.setImage(workbenchLabelProvider.getImage(project)); menuItem.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { CollaborationUtils.startSession( Collections.<IResource>singletonList(project), contacts); } }); return menuItem; }
Example 7
Source File: MenuItemProviders.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider columnStyleEditorMenuItemProvider(final String menuLabel) { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH); columnStyleEditor.setText(menuLabel); columnStyleEditor.setImage(GUIHelper.getImage("preferences")); columnStyleEditor.setEnabled(true); columnStyleEditor.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { int rowPosition = getNatEventData(event).getRowPosition(); int columnPosition = getNatEventData(event).getColumnPosition(); natTable.doCommand(new DisplayColumnStyleEditorCommand(natTable, natTable.getConfigRegistry(), columnPosition, rowPosition)); } }); } }; }
Example 8
Source File: MenuItemProviders.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider clearToggleFilterRowMenuItemProvider(final String menuLabel) { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH); menuItem.setText(menuLabel); menuItem.setImage(GUIHelper.getImage("toggle_filter")); menuItem.setEnabled(true); menuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { natTable.doCommand(new ToggleFilterRowCommand()); } }); } }; }
Example 9
Source File: EditorMenu.java From gama with GNU General Public License v3.0 | 6 votes |
public static Menu createImportedSubMenu(final Menu parentMenu, final GamlEditor editor) { final Set<URI> importers = getImporters(editor); if (importers.isEmpty()) { final MenuItem nothing = new MenuItem(parentMenu, SWT.PUSH); nothing.setText("No importers"); nothing.setEnabled(false); return parentMenu; } for (final URI uri : importers) { final MenuItem modelItem = new MenuItem(parentMenu, SWT.CASCADE); modelItem.setText(URI.decode(uri.lastSegment())); modelItem.setImage(GamaIcons.create(IGamaIcons.FILE_ICON).image()); modelItem.setData("uri", uri); modelItem.addSelectionListener(UsedInAdapter); } return parentMenu; }
Example 10
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 11
Source File: MenuItemProviders.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider clearToggleFilterRowMenuItemProvider(final String menuLabel) { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH); menuItem.setText(menuLabel); menuItem.setImage(GUIHelper.getImage("toggle_filter")); menuItem.setEnabled(true); menuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { natTable.doCommand(new ToggleFilterRowCommand()); } }); } }; }
Example 12
Source File: MenuItemProviders.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider categoriesBasedColumnChooserMenuItemProvider(final String menuLabel) { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem columnChooser = new MenuItem(popupMenu, SWT.PUSH); columnChooser.setText(menuLabel); columnChooser.setImage(GUIHelper.getImage("column_categories_chooser")); columnChooser.setEnabled(true); columnChooser.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { natTable.doCommand(new ChooseColumnsFromCategoriesCommand(natTable)); } }); } }; }
Example 13
Source File: MenuItemProviders.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider autoResizeColumnMenuItemProvider() { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem autoResizeColumns = new MenuItem(popupMenu, SWT.PUSH); autoResizeColumns.setText("Auto resize column"); autoResizeColumns.setImage(GUIHelper.getImage("auto_resize")); autoResizeColumns.setEnabled(true); autoResizeColumns.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { int columnPosition = getNatEventData(event).getColumnPosition(); natTable.doCommand(new InitializeAutoResizeColumnsCommand(natTable, columnPosition, natTable.getConfigRegistry(), new GC(natTable))); } }); } }; }
Example 14
Source File: MenuItemProviders.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public static IMenuItemProvider autoResizeColumnMenuItemProvider() { return new IMenuItemProvider() { public void addMenuItem(final NatTable natTable, final Menu popupMenu) { MenuItem autoResizeColumns = new MenuItem(popupMenu, SWT.PUSH); autoResizeColumns.setText("Auto resize column"); autoResizeColumns.setImage(GUIHelper.getImage("auto_resize")); autoResizeColumns.setEnabled(true); autoResizeColumns.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { int columnPosition = getNatEventData(event).getColumnPosition(); natTable.doCommand(new InitializeAutoResizeColumnsCommand(natTable, columnPosition, natTable.getConfigRegistry(), new GC(natTable))); } }); } }; }
Example 15
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 16
Source File: ExpressionButton.java From birt with Eclipse Public License 1.0 | 5 votes |
public void setExpressionButtonProvider( IExpressionButtonProvider provider ) { if ( provider != null && provider != this.provider ) { this.provider = provider; provider.setInput( this ); for ( int i = 0; i < menu.getItemCount( ); i++ ) { menu.getItem( i ).dispose( ); i--; } String[] types = this.provider.getExpressionTypes( ); for ( int i = 0; i < types.length; i++ ) { MenuItem item = new MenuItem( menu, SWT.PUSH ); item.setText( this.provider.getText( types[i] ) ); item.setData( types[i] ); item.setImage( this.provider.getImage( types[i] ) ); item.addSelectionListener( listener ); } if ( menu.getItemCount( ) <= 1 ) { button.setDropDownMenu( null ); } refresh( ); } }
Example 17
Source File: AgentsMenu.java From gama with GNU General Public License v3.0 | 5 votes |
private static MenuItem actionAgentMenuItem(final Menu parent, final IAgent agent, final IStatement command, final String prefix) { final MenuItem result = new MenuItem(parent, SWT.PUSH); result.setText(prefix + " " + command.getName()); result.setImage(GamaIcons.create(IGamaIcons.MENU_RUN_ACTION).image()); result.addSelectionListener(runner); result.setData("agent", agent); result.setData("command", command); return result; }
Example 18
Source File: GamaMenu.java From gama with GNU General Public License v3.0 | 5 votes |
public static final MenuItem check(final Menu m, final String s, final boolean select, final SelectionListener listener, final Image image) { final MenuItem action = createItem(m, SWT.CHECK); action.setText(s); action.setSelection(select); action.addSelectionListener(listener); if (image != null) { action.setImage(image); } return action; }
Example 19
Source File: EditorMenu.java From gama with GNU General Public License v3.0 | 5 votes |
/** * @param menu */ private void createValidateAll(final Menu menu) { final MenuItem mark = new MenuItem(menu, SWT.PUSH); mark.setText(" Validate all"); mark.setImage(GamaIcons.create("build.all2").image()); mark.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final IWorkspace workspace = ResourcesPlugin.getWorkspace(); try { GamlResourceIndexer.eraseIndex(); workspace.build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor() { @Override public void done() { super.done(); WorkbenchHelper.getService(IRefreshHandler.class).refreshNavigator(); } }); } catch (final CoreException ex) { ex.printStackTrace(); } } }); }
Example 20
Source File: LineSeparatorLabel.java From eclipse-encoding-plugin with Eclipse Public License 1.0 | 5 votes |
private void createSelectionMenu() { final ActiveDocument doc = agent.getDocument(); boolean nonDirty = !agent.isDocumentDirty() && doc.canConvertContent(); for (final SeparatorItem separatorItem : separatorItemList) { final MenuItem menuItem = new MenuItem(popupMenu, SWT.RADIO); menuItem.setText(separatorItem.value + " " + separatorItem.desc); menuItem.setEnabled(nonDirty); // Allow change if detectedEncoding is null for english only if (prefIs(PREF_DISABLE_DISCOURAGED_OPERATION) && doc.mismatchesEncoding()) { menuItem.setEnabled(false); } if (separatorItem.value.equals(doc.getLineSeparator())) { menuItem.setSelection(true); } menuItem.setImage(Activator.getImage(separatorItem.value)); menuItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doc.setLineSeparator(separatorItem.value); } }); } }