org.eclipse.swt.widgets.MenuItem.addSelectionListener()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(12.8k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中org.eclipse.swt.widgets.MenuItem.addSelectionListener()方法的一些代码示例,展示了MenuItem.addSelectionListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.addSelectionListener()方法的具体详情如下:
包路径:org.eclipse.swt.widgets.MenuItem
类名称:MenuItem
方法名:addSelectionListener

[英]Adds the listener to the collection of listeners who will be notified when the menu item is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

When widgetSelected is called, the stateMask field of the event object is valid. widgetDefaultSelected is not called.

When the SWT.RADIO style bit is set, the widgetSelected method is also called when the receiver loses selection because another item in the same radio group was selected by the user. During widgetSelected the application can use getSelection() to determine the current selected state of the receiver.
[中]通过发送SelectionListener界面中定义的消息之一,将侦听器添加到用户选择菜单项时将收到通知的侦听器集合中。
调用widgetSelected时,事件对象的stateMask字段有效。未调用widgetDefaultSelected
当设置SWT.RADIO样式位时,由于用户选择了同一无线电组中的另一项,因此接收器失去选择时,也会调用widgetSelected方法。在widgetSelected期间,应用程序可以使用getSelection()确定接收器的当前选定状态。

代码示例

代码示例来源: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: pentaho/pentaho-kettle

item.addSelectionListener( new SelectionAdapter() {
 public void widgetSelected( SelectionEvent se ) {
  expressionEditor.insert( proposal.getCompletionString() );
 item.addSelectionListener( new SelectionAdapter() {
  public void widgetSelected( SelectionEvent se ) {
   expressionEditor.insert( proposal.getCompletionString() );

代码示例来源: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: caoxinyu/RedisClient

mntmCut.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmCopy.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmPaste.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmSelectAll.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmClear.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {

代码示例来源:origin: caoxinyu/RedisClient

mntmDelete_5.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmCut_2.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmCopy_3.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmExport_2.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {

代码示例来源:origin: caoxinyu/RedisClient

mntmNewConnection.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent arg0) {
mntmFind.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmFindNext.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmFindBackward_2.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmRefresh.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent arg0) {

代码示例来源:origin: caoxinyu/RedisClient

menuItem.setText(favorite.getName());
menuItem.setData(FAVORITE, favorite);
menuItem.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {

代码示例来源:origin: pentaho/pentaho-kettle

MenuItem closeItem = new MenuItem( menu, SWT.NONE );
closeItem.setText( BaseMessages.getString( PKG, "Spoon.Tab.Close" ) );
closeItem.addSelectionListener( new SelectionAdapter() {
 @Override
 public void widgetSelected( SelectionEvent event ) {
closeAllItems.addSelectionListener( new SelectionAdapter() {
 @Override
 public void widgetSelected( SelectionEvent event ) {
closeOtherItems.addSelectionListener( new SelectionAdapter() {
 @Override
 public void widgetSelected( SelectionEvent event ) {

代码示例来源:origin: caoxinyu/RedisClient

mntmRename.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmDelete_4.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmProperties_1.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
menuItem.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmCut_1.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmCopy_2.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmExport_3.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {

代码示例来源:origin: caoxinyu/RedisClient

mntmUpdate.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmDelete.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent arg0) {
mntmProperties_4.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmNewItem_1.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmNewItem_2.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmNewItem_3.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
menuItem_2.addSelectionListener(new SelectionAdapter() {
  @Override
  public void widgetSelected(SelectionEvent e) {
mntmFindForward.addSelectionListener(new SelectionAdapter() {

代码示例来源: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 ) {
     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 ) {
  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

MenuItem item = new MenuItem( menu, SWT.NONE );
item.setText( BaseMessages.getString( PKG, "LogBrowser.CopySelectionToClipboard.MenuItem" ) );
item.addSelectionListener( new SelectionAdapter() {
 public void widgetSelected( SelectionEvent event ) {
  String selection = text.getSelectionText();

代码示例来源: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

item.setText( Const.NVL( stream.getDescription(), "" ) );
item.setImage( getImageFor( stream ) );
item.addSelectionListener( new SelectionAdapter() {
 @Override
 public void widgetSelected( SelectionEvent e ) {

代码示例来源: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

continue;
  item.addSelectionListener( new SelectionAdapter() {
   @Override
   public void widgetSelected( SelectionEvent selectionEvent ) {
MenuItem managerItem = new MenuItem( connectionMenu, SWT.NONE );
managerItem.setText( BaseMessages.getString( PKG, "RepositoryConnectMenu.RepositoryManager" ) );
managerItem.addSelectionListener( new SelectionAdapter() {
 @Override
 public void widgetSelected( SelectionEvent selectionEvent ) {
disconnectItem.setEnabled( spoon.rep != null );
disconnectItem.setText( BaseMessages.getString( PKG, "RepositoryConnectMenu.Disconnect" ) );
disconnectItem.addSelectionListener( new SelectionAdapter() {
 @Override
 public void widgetSelected( SelectionEvent selectionEvent ) {

相关文章