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

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

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

[英]Sets the selection state of the receiver.

When the receiver is of type CHECK or RADIO, it is selected when it is checked.
[中]设置接收器的选择状态。
当接收器类型为CHECKRADIO时,选中时会选中它。

代码示例

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

private void updateOrder() {
  mntmAscend.setSelection(false);
  mntmDescend.setSelection(false);
  switch (clientOrder) {
  case Ascend:
    mntmAscend.setSelection(true);
    break;
  case Descend:
    mntmDescend.setSelection(true);
    break;
  }
}

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

private void updateOrderby() {
  mntmNameOrder.setSelection(false);
  mntmTypeOrder.setSelection(false);
  mntmSizeOrder.setSelection(false);
  switch (clientOrderBy) {
  case NAME:
    mntmNameOrder.setSelection(true);
    break;
  case TYPE:
    mntmTypeOrder.setSelection(true);
    break;
  case SIZE:
    mntmSizeOrder.setSelection(true);
    break;
  }
}

代码示例来源: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.setData( repositoriesMeta.getRepository( i ).getName() );
if ( spoon.rep != null && spoon.getRepositoryName().equals( repositoriesMeta.getRepository( i ).getName() ) ) {
 item.setSelection( true );
 continue;

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void widgetSelected(SelectionEvent e) {
    StartStopRulesDefaultPlugin.pauseChangeFlagChecker = !StartStopRulesDefaultPlugin.pauseChangeFlagChecker;
    ((MenuItem)e.widget).setSelection(StartStopRulesDefaultPlugin.pauseChangeFlagChecker);
  }
});

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

mntmFlat.setText(i18nFile.getText(I18nFile.FLAT));
if (!flatView)
  mntmHierarchy.setSelection(true);
if (flatView)
  mntmFlat.setSelection(true);
menuItem.setText("中文");
if (language == Language.English)
  mntmEnglish.setSelection(true);
if (language == Language.Chinese)
  menuItem.setSelection(true);

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void handleEvent(Event event) {
    item.setSelection(COConfigurationManager.getBooleanParameter(configID));
  }
});

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07

private boolean readSelection( MenuItem item ) {
 String value = WidgetLCAUtil.readPropertyValue( item, "selection" );
 if( value != null ) {
  item.setSelection( Boolean.valueOf( value ).booleanValue() );
 }
 return value != null;
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
public void menuShown(MenuEvent e) {
  menuItemShowUptime.setSelection(COConfigurationManager.getBooleanParameter( "MyTorrentsView.showuptime" ));
  menuItemShowRates.setSelection(COConfigurationManager.getBooleanParameter( "MyTorrentsView.showrates" ));
  menuItemShowCatBut.setSelection(COConfigurationManager.getBooleanParameter( "Library.ShowCatButtons" ));
  menuItemShowTagBut.setSelection(COConfigurationManager.getBooleanParameter( "Library.ShowTagButtons" ));
  menuItemShowCatBut.setEnabled( !neverShowCatButtons );
  menuItemShowTagBut.setEnabled( !neverShowTagButtons );
  menuEnableSimple.setSelection(COConfigurationManager.getBooleanParameter( "Library.EnableSimpleView" ));
}

代码示例来源:origin: org.codehaus.openxma/xmartclient

/**
 * Marks the named MenuItem as selected.
 * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
 * it is selected when it is checked.
 * @param menuId the name of the MenuItem to mark as selected.
 */
public void markMenu(String menuId) {
  if(menuW==null) return;
  MenuItem menuItem = (MenuItem) getMenu(menuId).getAttached();
  menuItem.setSelection(true);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc

boolean setRadioSelection (boolean value) {
  if ((style & SWT.RADIO) == 0) return false;
  if (getSelection () != value) {
    setSelection (value);
    sendSelectionEvent (SWT.Selection);
  }
  return true;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

/**
 * Refreshes the selected menu items to match the current state of the model.
 */
private void refreshSelection() {
  Iterator iter = items.iterator();
  while (iter.hasNext()) {
    MenuItem next = (MenuItem) iter.next();
    if (!next.isDisposed()) {
      next.setSelection(isEqual(data.getState(), next.getData()));
    }
  }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void
  menuShown(
    MenuEvent e )
  {
    int vt = chat.getViewType();
    
    for ( MenuItem mi: vt_menu.getItems()){
      mi.setSelection( vt == (Integer)mi.getData());
    }
  }
});

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void
  menuShown(
    MenuEvent e )
  {
    int pc_state = beta.getPrivateChatState();
    for ( MenuItem mi: status_priv_menu.getItems()){
      mi.setSelection( pc_state == (Integer)mi.getData());
    }
  }
});

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86

void selectRadio () {
  int index = 0;
  MenuItem [] items = parent.getItems ();
  while (index < items.length && items [index] != this) index++;
  int i = index - 1;
  while (i >= 0 && items [i].setRadioSelection (false)) --i;
  int j = index + 1;
  while (j < items.length && items [j].setRadioSelection (false)) j++;
  setSelection (true);
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt

private void deselectOtherRadios() {
 for( MenuItem item : parent.getItems() ) {
  if( item != this && ( item.getStyle() & SWT.RADIO ) != 0 && item.getSelection() ) {
   item.setSelection( false );
   item.notifyListeners( SWT.Selection, new Event() );
  }
 }
}

代码示例来源:origin: BiglySoftware/BiglyBT

@Override
  public void handleEvent(Event event) {
    if (item.isDisposed()) {
      menu.removeListener(SWT.Show, this);
    } else {
      item.setSelection(!MiniBarManager.getManager().getShellManager().isEmpty());
    }
  }
});

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

@Override
public void fill(Menu menu, int index) {
  MenuItem item = new MenuItem(menu, SWT.CHECK);
  item.setText(MarkerMessages.MarkerFilter_showAllCommand_title);
  item.setSelection(noFiltersSelected());
  item.addListener(SWT.Selection, event -> {
    ExtendedMarkersView view = getView();
    if (view != null) {
      view.disableAllFilters();
    }
  });
}

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

相关文章