本文整理了Java中org.eclipse.swt.widgets.MenuItem
类的一些代码示例,展示了MenuItem
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem
类的具体详情如下:
包路径:org.eclipse.swt.widgets.MenuItem
类名称:MenuItem
[英]Instances of this class represent a selectable user interface object that issues notification when pressed and released. Styles: CHECK, CASCADE, PUSH, RADIO, SEPARATOR Events: Arm, Help, Selection
Note: Only one of the styles CHECK, CASCADE, PUSH, RADIO and SEPARATOR may be specified.
IMPORTANT: This class is not intended to be subclassed.
[中]此类的实例表示一个可选择的用户界面对象,当按下并释放该对象时,该对象会发出通知。样式:检查、级联、推送、广播、分隔事件:手臂、帮助、选择
注:只能指定检查、级联、推送、无线电和分离器中的一种。
重要提示:这个类不是子类。
代码示例来源:origin: caoxinyu/RedisClient
private Menu initMenuTreeServer() {
Menu menu_server = initMenuTableServer();
new MenuItem(menu_server, SWT.SEPARATOR);
MenuItem mntmRefresh_3 = new MenuItem(menu_server, SWT.NONE);
mntmRefresh_3.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] items = tree.getSelection();
serverTreeItemSelected(items[0], true);
}
});
mntmRefresh_3.setText(i18nFile.getText(I18nFile.REFRESH));
return menu_server;
}
代码示例来源:origin: caoxinyu/RedisClient
MenuItem mntmServer = new MenuItem(menu, SWT.CASCADE);
mntmServer.setText(i18nFile.getText(I18nFile.SERVER));
mntmServer.setMenu(menuServer);
MenuItem mntmNew = new MenuItem(menuServer, SWT.NONE);
mntmNew.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
mntmNew.setText(i18nFile.getText(I18nFile.ADD));
MenuItem mntmEdit = new MenuItem(menuServer, SWT.NONE);
mntmEdit.setEnabled(false);
mntmEdit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
mntmEdit.setText(i18nFile.getText(I18nFile.UPDATE));
MenuItem mntmDelete_1 = new MenuItem(menuServer, SWT.NONE);
mntmDelete_1.setEnabled(false);
mntmDelete_1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
mntmDelete_1.setText(i18nFile.getText(I18nFile.REMOVE));
MenuItem mntmProperties = new MenuItem(menuServer, SWT.NONE);
代码示例来源:origin: pentaho/pentaho-kettle
MenuItem addNewItem = new MenuItem( cMenu, SWT.PUSH );
addNewItem.setText( BaseMessages.getString( PKG, "ScriptValuesDialogMod.AddNewTab" ) );
addNewItem.setImage( imageAddScript );
addNewItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
addCtab( "", "", ADD_BLANK );
MenuItem copyItem = new MenuItem( cMenu, SWT.PUSH );
copyItem.setText( BaseMessages.getString( PKG, "ScriptValuesDialogMod.AddCopy" ) );
copyItem.setImage( imageDuplicateScript );
copyItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
CTabItem item = folder.getSelection();
new MenuItem( cMenu, SWT.SEPARATOR );
MenuItem setActiveScriptItem = new MenuItem( cMenu, SWT.PUSH );
setActiveScriptItem.setText( BaseMessages.getString( PKG, "ScriptValuesDialogMod.SetTransformScript" ) );
setActiveScriptItem.setImage( imageActiveScript );
setActiveScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
CTabItem item = folder.getSelection();
MenuItem setStartScriptItem = new MenuItem( cMenu, SWT.PUSH );
setStartScriptItem.setText( BaseMessages.getString( PKG, "ScriptValuesDialogMod.SetStartScript" ) );
setStartScriptItem.setImage( imageActiveStartScript );
setStartScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
CTabItem item = folder.getSelection();
代码示例来源:origin: pentaho/pentaho-kettle
private void buildingFolderMenu() {
MenuItem addNewItem = new MenuItem( cMenu, SWT.PUSH );
addNewItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.AddNewTab" ) );
addNewItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
addCtab( "", "", TabAddActions.ADD_BLANK );
MenuItem copyItem = new MenuItem( cMenu, SWT.PUSH );
copyItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.AddCopy" ) );
copyItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
CTabItem item = folder.getSelection();
new MenuItem( cMenu, SWT.SEPARATOR );
MenuItem setActiveScriptItem = new MenuItem( cMenu, SWT.PUSH );
setActiveScriptItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.SetTransformClass" ) );
setActiveScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
CTabItem item = folder.getSelection();
new MenuItem( cMenu, SWT.SEPARATOR );
MenuItem setRemoveScriptItem = new MenuItem( cMenu, SWT.PUSH );
setRemoveScriptItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.RemoveClassType" ) );
setRemoveScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
CTabItem item = folder.getSelection();
代码示例来源:origin: caoxinyu/RedisClient
private void addFavoriteMenuItem() {
List<Favorite> favorites = service3.listAll();
if (favorites.size() > 0) {
new MenuItem(menuFavorite, SWT.SEPARATOR);
for (Favorite favorite : favorites) {
final MenuItem menuItem = new MenuItem(menuFavorite, SWT.NONE);
menuItem.setText(favorite.getName());
menuItem.setData(FAVORITE, favorite);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
代码示例来源:origin: caoxinyu/RedisClient
MenuItem mntmNew_1 = new MenuItem(menu_dbContainer, SWT.CASCADE);
mntmNew_1.setText(i18nFile.getText(I18nFile.NEW));
mntmNew_1.setMenu(menu_1);
MenuItem menuItem_1 = new MenuItem(menu_1, SWT.NONE);
menuItem_1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
menuItem_1.setText(i18nFile.getText(I18nFile.STRING));
menuItem_1.setImage(strImage);
MenuItem menuItem_2 = new MenuItem(menu_1, SWT.NONE);
menuItem_2.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
menuItem_2.setText(i18nFile.getText(I18nFile.LIST));
menuItem_2.setImage(listImage);
MenuItem menuItem_3 = new MenuItem(menu_1, SWT.NONE);
menuItem_3.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
menuItem_3.setText(i18nFile.getText(I18nFile.SET));
menuItem_3.setImage(setImage);
代码示例来源:origin: org.eclipse.platform/org.eclipse.team.ui
public void createDefaultMenuItem(Menu menu, final IFileRevision revision, boolean markAsSelected) {
final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
menuItem.setSelection(markAsSelected);
menuItem.setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_DefaultEditorDescription);
Listener listener = event -> {
if (event.type == SWT.Selection && menuItem.getSelection()) {
openEditor(Utils.getDefaultEditor(revision), false);
}
};
menuItem.addListener(SWT.Selection, listener);
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override public void widgetSelected( SelectionEvent e ) {
Menu menu = new Menu( shell );
for ( final PerspectiveData perspectiveData : perspectiveList ) {
MenuItem item = new MenuItem( menu, SWT.CHECK );
if ( perspectiveData.isHidden() ) {
item.setEnabled( false );
}
if ( activePerspective.getId().equals( perspectiveData.getId() ) ) {
item.setSelection( true );
}
item.setText( perspectiveData.getName() );
item.addSelectionListener( new SelectionAdapter() {
@Override public void widgetSelected( SelectionEvent selectionEvent ) {
Spoon.getInstance().loadPerspective( perspectiveData.getId() );
swtToolbar.forceFocus();
}
} );
}
ToolItem item = (ToolItem) e.widget;
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay( new Point( rect.x, rect.y + rect.height ) );
menu.setLocation( pt.x, pt.y );
menu.setVisible( true );
}
} );
代码示例来源:origin: org.eclipse.platform/org.eclipse.tips.ui
private void startupMenuAboutToShow(final Menu menu) {
Arrays.asList(menu.getItems()).forEach(item -> item.dispose());
MenuItem item0 = new MenuItem(menu, SWT.CHECK);
item0.setText(Messages.TipComposite_1);
item0.setSelection(fTipManager.getStartupBehavior() == TipManager.START_DIALOG);
item0.addListener(SWT.Selection, event -> fTipManager.setStartupBehavior(TipManager.START_DIALOG));
item0.setImage(getStartupItemImage(TipManager.START_DIALOG));
MenuItem item1 = new MenuItem(menu, SWT.CHECK);
item1.setText(Messages.TipComposite_5);
item1.setSelection(fTipManager.getStartupBehavior() == TipManager.START_BACKGROUND);
item1.addListener(SWT.Selection, event -> fTipManager.setStartupBehavior(TipManager.START_BACKGROUND));
item1.setImage(getStartupItemImage(TipManager.START_BACKGROUND));
MenuItem item2 = new MenuItem(menu, SWT.CHECK);
item2.setText(Messages.TipComposite_6);
item2.setSelection(fTipManager.getStartupBehavior() == TipManager.START_DISABLE);
item2.addListener(SWT.Selection, event -> fTipManager.setStartupBehavior(TipManager.START_DISABLE));
item2.setImage(getStartupItemImage(TipManager.START_DISABLE));
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
void createMenuBar () {
Menu bar = new Menu (shell, SWT.BAR);
shell.setMenuBar (bar);
MenuItem fileItem = new MenuItem (bar, SWT.CASCADE);
fileItem.setText (resources.getString("File_menuitem"));
fileItem.setMenu (createFileMenu ());
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public void widgetSelected( SelectionEvent e ) {
if ( e.detail == SWT.DROP_DOWN ) {
Menu menu = new Menu( shell, SWT.POP_UP );
MenuItem item1 = new MenuItem( menu, SWT.PUSH );
item1.setText( BaseMessages.getString( PKG, "Spoon.Run.Run" ) );
item1.setAccelerator( SWT.F9 );
item1.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e1 ) {
runJob();
}
} );
MenuItem item2 = new MenuItem( menu, SWT.PUSH );
item2.setText( BaseMessages.getString( PKG, "Spoon.Run.RunOptions" ) );
item2.setAccelerator( SWT.F8 );
item2.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e2 ) {
runOptionsJob();
}
} );
menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) );
menu.setVisible( true );
} else {
runJob();
}
}
} );
代码示例来源:origin: pentaho/pentaho-kettle
} else {
for ( MenuItem item : helperMenu.getItems() ) {
item.dispose();
MenuItem item = new MenuItem( helperMenu, SWT.NONE );
if ( first == null ) {
first = item;
item.setText( proposal.getMenuText() );
item.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent se ) {
expressionEditor.insert( proposal.getCompletionString() );
int nr = 0;
for ( final CompletionProposal proposal : proposals ) {
MenuItem item = new MenuItem( helperMenu, SWT.NONE );
if ( first == null ) {
first = item;
item.setText( proposal.getMenuText() );
item.addSelectionListener( new SelectionAdapter() {
public void widgetSelected( SelectionEvent se ) {
expressionEditor.insert( proposal.getCompletionString() );
代码示例来源:origin: pentaho/pentaho-kettle
MenuItem undoItem = new MenuItem( styledTextPopupmenu, SWT.PUSH );
undoItem.setText( OsHelper.customizeMenuitemText( BaseMessages.getString( PKG, "WidgetDialog.Styled.Undo" ) ) );
undoItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
undo();
MenuItem redoItem = new MenuItem( styledTextPopupmenu, SWT.PUSH );
redoItem.setText( OsHelper.customizeMenuitemText( BaseMessages.getString( PKG, "WidgetDialog.Styled.Redo" ) ) );
redoItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
redo();
new MenuItem( styledTextPopupmenu, SWT.SEPARATOR );
MenuItem cutItem = new MenuItem( styledTextPopupmenu, SWT.PUSH );
cutItem.setText( OsHelper.customizeMenuitemText( BaseMessages.getString( PKG, "WidgetDialog.Styled.Cut" ) ) );
cutItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
styledText.cut();
MenuItem copyItem = new MenuItem( styledTextPopupmenu, SWT.PUSH );
copyItem.setText( OsHelper.customizeMenuitemText( BaseMessages.getString( PKG, "WidgetDialog.Styled.Copy" ) ) );
copyItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
styledText.copy();
MenuItem pasteItem = new MenuItem( styledTextPopupmenu, SWT.PUSH );
pasteItem
.setText( OsHelper.customizeMenuitemText( BaseMessages.getString( PKG, "WidgetDialog.Styled.Paste" ) ) );
pasteItem.addListener( SWT.Selection, new Listener() {
代码示例来源:origin: tvrenamer/tvrenamer
private Menu setupHelpMenuBar(final Menu menuBar) {
MenuItem helpMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
helpMenuHeader.setText("Help");
Menu helpMenu = new Menu(shell, SWT.DROP_DOWN);
helpMenuHeader.setMenu(helpMenu);
MenuItem helpHelpItem = new MenuItem(helpMenu, SWT.PUSH);
helpHelpItem.setText("Help");
MenuItem helpVisitWebPageItem = new MenuItem(helpMenu, SWT.PUSH);
helpVisitWebPageItem.setText("Visit Web Page");
helpVisitWebPageItem.addSelectionListener(new UrlLauncher(TVRENAMER_PROJECT_URL));
return helpMenu;
}
代码示例来源:origin: pentaho/pentaho-kettle
private void setUndoMenu() {
TransAction prev = viewPreviousUndo();
TransAction next = viewNextUndo();
if ( miEditUndo.isDisposed() || miEditRedo.isDisposed() ) {
return;
}
if ( prev != null ) {
miEditUndo.setEnabled( true );
miEditUndo.setText( OsHelper.customizeMenuitemText( BaseMessages.getString( PKG, "TableView.menu.Undo", prev
.toString() ) ) );
} else {
miEditUndo.setEnabled( false );
miEditUndo.setText( OsHelper.customizeMenuitemText( BaseMessages.getString(
PKG, "TableView.menu.UndoNotAvailable" ) ) );
}
if ( next != null ) {
miEditRedo.setEnabled( true );
miEditRedo.setText( OsHelper.customizeMenuitemText( BaseMessages.getString( PKG, "TableView.menu.Redo", next
.toString() ) ) );
} else {
miEditRedo.setEnabled( false );
miEditRedo.setText( OsHelper.customizeMenuitemText( BaseMessages.getString(
PKG, "TableView.menu.RedoNotAvailable" ) ) );
}
}
代码示例来源:origin: org.eclipse.e4.ui.workbench.renderers/swt
private void updateMenuItem() {
MenuItem item = (MenuItem) widget;
String text = model.getLocalizedLabel();
if (text != null) {
item.setText(text);
} else {
item.setText(""); //$NON-NLS-1$
}
item.setSelection(model.isSelected());
item.setEnabled(model.isEnabled());
}
代码示例来源:origin: BiglySoftware/BiglyBT
public static MenuItem createTopLevelMenuItem(Menu menuParent,
String localizationKey) {
Menu menu = new Menu(Utils.findAnyShell(), SWT.DROP_DOWN);
MenuItem menuItem = new MenuItem(menuParent, SWT.CASCADE);
Messages.setLanguageText(menuItem, localizationKey);
menuItem.setMenu(menu);
/*
* A top level menu and its menu item has the same ID; this is used to locate them at runtime
*/
menu.setData(KEY_MENU_ID, localizationKey);
menuItem.setData(KEY_MENU_ID, localizationKey);
return menuItem;
}
代码示例来源:origin: caoxinyu/RedisClient
private void removeFavoriteMenuItem() {
int num = menuFavorite.getItemCount();
if (num > 2) {
MenuItem[] items = menuFavorite.getItems();
for (int i = 2; i < num; i++) {
items[i].dispose();
}
}
}
代码示例来源:origin: BiglySoftware/BiglyBT
@Override
public void
handleEvent(
Event arg )
{
Utils.setQuickViewActive( all_files.get(0), itemQuickView.getSelection());
}
});
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
boolean setRadioSelection (boolean value) {
if ((style & SWT.RADIO) == 0) return false;
if (getSelection () != value) {
setSelection (value);
sendSelectionEvent (SWT.Selection);
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!