Java Code Examples for org.eclipse.swt.widgets.MenuItem#setEnabled()

The following examples show how to use org.eclipse.swt.widgets.MenuItem#setEnabled() . 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 tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider ungroupColumnsMenuItemProvider() {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH);
			columnStyleEditor.setText("Ungroup columns");
			columnStyleEditor.setEnabled(true);

			columnStyleEditor.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					natTable.doCommand(new UngroupColumnCommand());
				}
			});
		}
	};
}
 
Example 2
Source File: MenuItemProviders.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
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 3
Source File: StickerComposite.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private MenuItem createMenuItemAdd(Menu menu) {
	final MenuItem miAdd = new MenuItem(menu, SWT.NONE);
	miAdd.setText("Sticker hinzufügen");
	miAdd.addSelectionListener(new SelectionAdapter() {
		
		@Override
		public void widgetSelected(SelectionEvent e){
			
			AssignStickerDialog assignStickerDialog =
					new AssignStickerDialog(getShell(), actPatient);
			if (assignStickerDialog.open() == MessageDialog.OK) {
				// refresh
				setPatient(actPatient);
				getParent().getParent().layout(true);
			}
		}
		
	});
	miAdd.setEnabled(
		CoreHub.acl.request(AccessControlDefaults.KONTAKT_ETIKETTE));
	return miAdd;
}
 
Example 4
Source File: MenuItemProviders.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
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 5
Source File: MenuItemProviders.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider columnChooserMenuItemProvider(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_chooser"));
			columnChooser.setEnabled(true);

			columnChooser.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					natTable.doCommand(new DisplayColumnChooserCommand(natTable));
				}
			});
		}
	};
}
 
Example 6
Source File: MenuItemProviders.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider renameColumnMenuItemProvider(final String label) {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
			menuItem.setText(label);
			menuItem.setEnabled(true);

			menuItem.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent event) {
					natTable.doCommand(new DisplayColumnRenameDialogCommand(natTable, getNatEventData(event).getColumnPosition()));
				}
			});
		}
	};
}
 
Example 7
Source File: TextEditorContextMenuContribution.java    From git-appraise-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@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 8
Source File: MenuItemProviders.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider ungroupColumnsMenuItemProvider() {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH);
			columnStyleEditor.setText("Ungroup columns");
			columnStyleEditor.setEnabled(true);

			columnStyleEditor.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					natTable.doCommand(new UngroupColumnCommand());
				}
			});
		}
	};
}
 
Example 9
Source File: MenuItemProviders.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider autoResizeAllSelectedColumnMenuItemProvider() {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem autoResizeColumns = new MenuItem(popupMenu, SWT.PUSH);
			autoResizeColumns.setText("Auto resize all selected columns");
			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 10
Source File: MenuItemProviders.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
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 11
Source File: MenuItemProviders.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider renameColumnMenuItemProvider(final String label) {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
			menuItem.setText(label);
			menuItem.setEnabled(true);

			menuItem.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent event) {
					natTable.doCommand(new DisplayColumnRenameDialogCommand(natTable, getNatEventData(event).getColumnPosition()));
				}
			});
		}
	};
}
 
Example 12
Source File: MenuItemProviders.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
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 13
Source File: MenuItemProviders.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider autoResizeAllSelectedColumnMenuItemProvider() {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem autoResizeColumns = new MenuItem(popupMenu, SWT.PUSH);
			autoResizeColumns.setText("Auto resize all selected columns");
			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: GitRepositoriesPreferencePage.java    From MergeProcessor with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Control createContents(Composite parent) {
	final Composite fieldEditorParent = (Composite) super.createContents(parent);

	final GitRepositoryPreferencePageView view = new GitRepositoryPreferencePageView(fieldEditorParent, SWT.NONE);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(view);
	tableViewer = view.getTableViewer();
	tableViewer.setContentProvider(new ArrayContentProvider());
	view.getColumnRepository().setLabelProvider(new RepositoryColumnLabelProvider());
	view.getColumnLocalPath().setLabelProvider(new LocalPathColumnLabelProvider());
	view.getColumnMemory().setLabelProvider(new MemoryColumnLabelProvider());
	tableViewer.setInput(getGitRepositoryPaths(configuration.getGitRepositoryFolder()));

	final MenuItem item = view.getMenuItemGoToRepository();
	item.setEnabled(!tableViewer.getSelection().isEmpty());
	item.addListener(SWT.Selection, e -> openRepositoryOnSelection(tableViewer));
	tableViewer.addSelectionChangedListener(e -> item.setEnabled(!e.getSelection().isEmpty()));

	return fieldEditorParent;
}
 
Example 15
Source File: LineSeparatorLabel.java    From eclipse-encoding-plugin with Eclipse Public License 1.0 5 votes vote down vote up
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);
				}
			});
		}
	}
 
Example 16
Source File: StartSessionWithProjects.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a menu entry which indicates that no Saros enabled contacts are online. */
private MenuItem createNoProjectsMenuItem(final Menu parentMenu, final int index) {

  final MenuItem menuItem = new MenuItem(parentMenu, SWT.NONE, index);
  menuItem.setText(Messages.SessionWithProjects_no_projects_in_workspace);
  menuItem.setEnabled(false);
  return menuItem;
}
 
Example 17
Source File: StartSessionWithContacts.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a menu entry which indicates that no contacts with Saros are online. */
private MenuItem createInvalidContactsMenuItem(Menu parentMenu, int index) {
  MenuItem menuItem = new MenuItem(parentMenu, SWT.NONE, index);
  menuItem.setText(Messages.SessionWithContacts_menuItem_no_contacts_available_text);
  menuItem.setEnabled(false);
  return menuItem;
}
 
Example 18
Source File: WidgetTask.java    From Flashtool with GNU General Public License v3.0 5 votes vote down vote up
private static void setMenuEnabled(MenuItem item, boolean status) {
	if (item.getMenu()!=null) {;
	MenuItem[] mit = item.getMenu().getItems();
	for (int i=0;i<mit.length;i++)
		WidgetTask.setMenuEnabled(mit[i],status);
	}
	item.setEnabled(status);	
}
 
Example 19
Source File: SwitchThemesPulldownContributionItem.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void fill(Menu menu, int index)
{
	MenuItem menuItem = new MenuItem(menu, SWT.PUSH, index);
	menuItem.setText(branchName);
	menuItem.setEnabled(!branchName.equals(manager.getCurrentTheme().getName()));
	menuItem.addSelectionListener(new SelectionAdapter()
	{
		public void widgetSelected(SelectionEvent e)
		{
			// what to do when menu is subsequently selected.
			switchTheme(manager, branchName);
		}
	});
}
 
Example 20
Source File: GamaMenu.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
protected final void sep(final Menu m, final String s) {
	final MenuItem me = createItem(m, SWT.NONE);
	me.setText(s);
	me.setEnabled(false);
}