本文整理了Java中org.eclipse.swt.widgets.MenuItem.setText()
方法的一些代码示例,展示了MenuItem.setText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setText()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.MenuItem
类名称:MenuItem
方法名:setText
[英]Sets the receiver's text. The string may include the mnemonic character and accelerator text.
Mnemonics are indicated by an '&' that causes the next character to be the mnemonic. When the user presses a key sequence that matches the mnemonic, a selection event occurs. On most platforms, the mnemonic appears underlined but may be emphasised in a platform specific manner. The mnemonic indicator character '&' can be escaped by doubling it in the string, causing a single '&' to be displayed.
Accelerator text is indicated by the '\t' character. On platforms that support accelerator text, the text that follows the '\t' character is displayed to the user, typically indicating the key stroke that will cause the item to become selected. On most platforms, the accelerator text appears right aligned in the menu. Setting the accelerator text does not install the accelerator key sequence. The accelerator key sequence is installed using #setAccelerator.
[中]设置接收者的文本。该字符串可能包括助记符和加速器文本。
助记符由一个“&”表示,使下一个字符成为助记符。当用户按下与助记符匹配的键序列时,会发生选择事件。在大多数平台上,助记符带下划线,但可能会以特定于平台的方式强调。助记符“&”可以通过在字符串中加倍来转义,从而显示单个“&”。
加速器文本由“\t”字符表示。在支持加速器文本的平台上,将向用户显示“\t”字符后面的文本,通常指示将导致选中项目的按键笔划。在大多数平台上,快捷键文本在菜单中右对齐。设置加速器文本不会安装加速器按键序列。加速器按键顺序使用#setAccelerator安装。
代码示例来源:origin: pentaho/pentaho-kettle
private Menu createRootPopupMenu( Tree tree ) {
if ( rootMenu == null ) {
rootMenu = new Menu( tree );
MenuItem menuItem = new MenuItem( rootMenu, SWT.NONE );
menuItem.setText( BaseMessages.getString( PKG, "RunConfigurationPopupMenuExtension.MenuItem.New" ) );
menuItem.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent selectionEvent ) {
runConfigurationDelegate.create();
}
} );
}
return rootMenu;
}
代码示例来源:origin: pentaho/pentaho-kettle
private Menu createItemPopupMenu( Tree tree ) {
if ( itemMenu == null ) {
itemMenu = new Menu( tree );
MenuItem editMenuItem = new MenuItem( itemMenu, SWT.NONE );
editMenuItem.setText( BaseMessages.getString( PKG, "RunConfigurationPopupMenuExtension.MenuItem.Edit" ) );
editMenuItem.addSelectionListener( new SelectionAdapter() {
@Override public void widgetSelected( SelectionEvent selectionEvent ) {
runConfigurationDelegate.edit( runConfigurationManager.load( runConfiguration ) );
}
} );
MenuItem deleteMenuItem = new MenuItem( itemMenu, SWT.NONE );
deleteMenuItem.setText( BaseMessages.getString( PKG, "RunConfigurationPopupMenuExtension.MenuItem.Delete" ) );
deleteMenuItem.addSelectionListener( new SelectionAdapter() {
@Override public void widgetSelected( SelectionEvent selectionEvent ) {
runConfigurationDelegate.delete( runConfigurationManager.load( runConfiguration ) );
}
} );
}
return itemMenu;
}
}
代码示例来源: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
private Menu initMenuTreeDB() {
Menu menu = initMenuTableDB();
new MenuItem(menu, SWT.SEPARATOR);
MenuItem mntmRefresh_2 = new MenuItem(menu, SWT.NONE);
mntmRefresh_2.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] items = tree.getSelection();
refreshOrder();
dbContainerTreeItemSelected(items[0], true);
}
});
mntmRefresh_2.setText(i18nFile.getText(I18nFile.REFRESH));
return menu;
}
代码示例来源: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: caoxinyu/RedisClient
mntmCut.setText(RedisClient.i18nFile.getText(I18nFile.CUT));
mntmCopy.setText(RedisClient.i18nFile.getText(I18nFile.COPY));
mntmPaste.setText(RedisClient.i18nFile.getText(I18nFile.PASTE));
mntmSelectAll.setText(RedisClient.i18nFile.getText(I18nFile.SELECTALL));
mntmClear.setText(RedisClient.i18nFile.getText(I18nFile.CLEAR));
代码示例来源:origin: caoxinyu/RedisClient
mntmDelete_5.setText(i18nFile.getText(I18nFile.DELETE));
mntmCut_2.setText(i18nFile.getText(I18nFile.CUT));
mntmCopy_3.setText(i18nFile.getText(I18nFile.COPY));
mntmExport_2.setText(i18nFile.getText(I18nFile.EXPORT));
代码示例来源:origin: caoxinyu/RedisClient
mntmNewConnection.setText(i18nFile.getText(I18nFile.ADDSERVER));
mntmFind.setText(i18nFile.getText(I18nFile.FIND));
mntmFindNext.setText(i18nFile.getText(I18nFile.FINDFORWARD));
mntmFindBackward_2.setText(i18nFile.getText(I18nFile.FINDBACKWARD));
mntmRefresh.setText(i18nFile.getText(I18nFile.REFRESH));
代码示例来源:origin: pentaho/pentaho-kettle
private void buildingFolderMenu() {
addNewItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.AddNewTab" ) );
addNewItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
copyItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.AddCopy" ) );
copyItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
setActiveScriptItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.SetTransformClass" ) );
setActiveScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
setRemoveScriptItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.RemoveClassType" ) );
setRemoveScriptItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
代码示例来源:origin: caoxinyu/RedisClient
for (Favorite favorite : favorites) {
final MenuItem menuItem = new MenuItem(menuFavorite, SWT.NONE);
menuItem.setText(favorite.getName());
menuItem.setData(FAVORITE, favorite);
menuItem.addSelectionListener(new SelectionAdapter() {
代码示例来源:origin: pentaho/pentaho-kettle
Menu menu = new Menu( cTabFolder );
MenuItem closeItem = new MenuItem( menu, SWT.NONE );
closeItem.setText( BaseMessages.getString( PKG, "Spoon.Tab.Close" ) );
closeItem.addSelectionListener( new SelectionAdapter() {
@Override
closeAllItems.setText( BaseMessages.getString( PKG, "Spoon.Tab.CloseAll" ) );
closeAllItems.addSelectionListener( new SelectionAdapter() {
@Override
closeOtherItems.setText( BaseMessages.getString( PKG, "Spoon.Tab.CloseOthers" ) );
closeOtherItems.addSelectionListener( new SelectionAdapter() {
@Override
代码示例来源:origin: pentaho/pentaho-kettle
private void buildingTreeMenu() {
addDeleteItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.Delete.Label" ) );
addDeleteItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
renItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.Rename.Label" ) );
renItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
helpItem.setText( BaseMessages.getString( PKG, "UserDefinedJavaClassDialog.Sample.Label" ) );
helpItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
代码示例来源:origin: pentaho/pentaho-kettle
private void buildingTreeMenu() {
addDeleteItem.setText( BaseMessages.getString( PKG, "ScriptDialog.Delete.Label" ) );
addDeleteItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
renItem.setText( BaseMessages.getString( PKG, "ScriptDialog.Rename.Label" ) );
renItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
helpItem.setText( BaseMessages.getString( PKG, "ScriptDialog.Sample.Label" ) );
helpItem.addListener( SWT.Selection, new Listener() {
public void handleEvent( Event e ) {
代码示例来源: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.Menu.StopTranformation" ) );
item1.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e1 ) {
stopTransformation();
}
} );
MenuItem item2 = new MenuItem( menu, SWT.PUSH );
item2.setText( BaseMessages.getString( PKG, "Spoon.Menu.SafeStopTranformation" ) );
item2.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e2 ) {
safeStop();
}
} );
menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) );
menu.setVisible( true );
} else {
stopTransformation();
}
}
} );
代码示例来源: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
@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 ) {
runTransformation();
}
} );
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 ) {
runOptionsTransformation();
}
} );
menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) );
menu.setVisible( true );
} else {
runTransformation();
}
}
} );
代码示例来源: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: pentaho/pentaho-kettle
for ( final StreamInterface stream : streams ) {
MenuItem item = new MenuItem( menu, SWT.NONE );
item.setText( Const.NVL( stream.getDescription(), "" ) );
item.setImage( getImageFor( stream ) );
item.addSelectionListener( new SelectionAdapter() {
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public void menuDetected( MenuDetectEvent event ) {
if ( tree.getSelectionCount() < 1 ) {
return;
}
TreeItem treeItem = tree.getSelection()[0];
if ( treeItem != null ) {
String[] labels = ConstUI.getTreeStrings( treeItem );
int depth = ConstUI.getTreeLevel( treeItem );
if ( depth == 3 ) {
final String metaStoreName = labels[0];
final String namespace = labels[1];
final String elementTypeName = labels[2];
final String elementName = labels[3];
Menu menu = new Menu( tree );
MenuItem removeItem = new MenuItem( menu, SWT.POP_UP );
removeItem.setText( "Remove element" );
removeItem.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent arg0 ) {
removeElement( metaStoreName, namespace, elementTypeName, elementName );
}
} );
tree.setMenu( menu );
menu.setVisible( true );
}
}
}
} );
代码示例来源:origin: pentaho/pentaho-kettle
MenuItem item = new MenuItem( connectionMenu, SWT.CHECK );
String truncatedName = truncateName( repositoriesMeta.getRepository( i ).getName() );
item.setText( truncatedName );
item.setData( repositoriesMeta.getRepository( i ).getName() );
if ( spoon.rep != null && spoon.getRepositoryName().equals( repositoriesMeta.getRepository( i ).getName() ) ) {
managerItem.setText( BaseMessages.getString( PKG, "RepositoryConnectMenu.RepositoryManager" ) );
managerItem.addSelectionListener( new SelectionAdapter() {
@Override
MenuItem disconnectItem = new MenuItem( connectionMenu, SWT.NONE );
disconnectItem.setEnabled( spoon.rep != null );
disconnectItem.setText( BaseMessages.getString( PKG, "RepositoryConnectMenu.Disconnect" ) );
disconnectItem.addSelectionListener( new SelectionAdapter() {
@Override
内容来源于网络,如有侵权,请联系作者删除!