本文整理了Java中org.eclipse.swt.widgets.MenuItem.setData()
方法的一些代码示例,展示了MenuItem.setData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setData()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.MenuItem
类名称:MenuItem
方法名:setData
暂无
代码示例来源:origin: caoxinyu/RedisClient
final MenuItem menuItem = new MenuItem(menuFavorite, SWT.NONE);
menuItem.setText(favorite.getName());
menuItem.setData(FAVORITE, favorite);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
代码示例来源:origin: pentaho/pentaho-kettle
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() ) ) {
item.setSelection( true );
代码示例来源:origin: org.eclipse/org.eclipse.jst.pagedesigner
public void dispose() {
if (_hiearchyMenu != null) {
for (int i = 0, n = _hiearchyMenu.getItemCount(); i < n; i++) {
MenuItem menuItem = _hiearchyMenu.getItem(i);
menuItem.setData(null);
}
_hiearchyMenu.dispose();
_hiearchyMenu = null;
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jst.pagedesigner
public Menu getMenu(Control parent) {
dispose();
_hiearchyMenu = new Menu(parent);
// next we need to add the list of parents node into the menu.
Node node = _startNode;
List list = new ArrayList();
while (node != null && !(node instanceof Document)
&& !(node instanceof DocumentFragment)) {
list.add(node);
node = node.getParentNode();
}
// adding ancesters reverse order.
for (int i = list.size() - 1; i >= 0; i--) {
Node thenode = (Node) list.get(i);
MenuItem item = new MenuItem(_hiearchyMenu, SWT.CHECK);
item.setSelection(thenode == _currentNode ? true : false);
String text = thenode.getNodeName();
item.setText(text);
item.setData(thenode);
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Node selectedNode = (Node) e.widget.getData();
_propertyPage.internalChangeSelection(selectedNode,
_startNode);
}
});
}
return _hiearchyMenu;
}
}
代码示例来源:origin: com.eclipsesource.tabris/tabris
private void createMenuItem( String proposal ) {
MenuItem item = new MenuItem( proposalsMenu, SWT.PUSH );
item.setData( RWT.CUSTOM_VARIANT, CUSTOM_VARIANT_TABRIS_UI );
item.setText( proposal );
item.addListener( SWT.Selection, new MenuItemSelectionListener() );
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Populates the client's menu bar
* @param locales
* @param parent
*/
private void createViewInfoMenuItem(Menu parent, final IViewInfo info) {
MenuItem item = new MenuItem(parent, SWT.NULL);
item.setText(info.name);
if (info.viewID != null) {
item.setData("ViewID", info.viewID);
}
item.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
info.openView(uiFunctions);
}
}
});
}
代码示例来源:origin: BiglySoftware/BiglyBT
public static final MenuItem addMenuItem(Menu menu, String localizationKey,
Listener selListener, int style) {
MenuItem menuItem = new MenuItem(menu, style);
Messages.setLanguageText(menuItem, localizationKey);
KeyBindings.setAccelerator(menuItem, localizationKey);
if (null != selListener) {
menuItem.addListener(SWT.Selection, selListener);
}
/*
* Using the localizationKey as the id for the menu item; this can be used to locate it at runtime
* using .KN: missing method pointers
*/
menuItem.setData(KEY_MENU_ID, localizationKey);
return menuItem;
}
代码示例来源:origin: com.eclipsesource.tabris/tabris
private void addMenuItem( PageDescriptor pageDescriptor ) {
MenuItem item = new MenuItem( pageSwitcherMenu, SWT.PUSH );
item.setData( RWT.CUSTOM_VARIANT, CUSTOM_VARIANT_TABRIS_UI );
String title = pageDescriptor.getTitle();
item.setText( title == null ? "" : title );
item.setImage( getImage( uiParent.getDisplay(), pageDescriptor.getImage() ) );
item.setData( pageDescriptor );
item.addListener( SWT.Selection, new MenuItemSelectionListener() );
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public void setHelp(MenuItem item, String contextId) {
if (WorkbenchPlugin.DEBUG)
setHelpTrace(contextId);
item.setData(HELP_KEY, contextId);
// ensure that the listener is only registered once
item.removeHelpListener(getHelpListener());
item.addHelpListener(getHelpListener());
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
private ToolItem createDropDown(ToolBar toolBar, Object[][] menuItemsData, List<MenuItem> outItems, Images images) {
final ToolItem dropDown= new ToolItem(toolBar, SWT.DROP_DOWN);
final Menu menu= new Menu(toolBar.getShell());
dropDown.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fControl.setFocus();
Rectangle rect= dropDown.getBounds();
Point pt= dropDown.getParent().toDisplay(new Point(rect.x, rect.y));
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}
});
for (Object[] itemData : menuItemsData) {
MenuItem menuItem= new MenuItem(menu, SWT.RADIO);
menuItem.setText((String) itemData[0]);
menuItem.setImage(images.get((ImageDescriptor) itemData[1]));
menuItem.setData(DATA_IMAGE_DISABLED, images.get((ImageDescriptor) itemData[2]));
menuItem.setData(itemData[3]);
outItems.add(menuItem);
}
return dropDown;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
/**
* Creates a new menu item with the given text and value. When
* the item is selected, the state of the model will change to
* match the given value.
*
* @param text
* @param value
*/
public void addMenuItem(String text, Object value) {
MenuItem newItem = new MenuItem(parent, SWT.RADIO);
newItem.setSelection(isEqual(data.getState(), value));
newItem.setText(text);
newItem.setData(value);
items.add(newItem);
newItem.addSelectionListener(selectionAdapter);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
/**
* Sets the given help contexts on the given menu item.
* <p>
* Use this method when the list of help contexts is known in advance. Help
* contexts can either supplied as a static list, or calculated with a
* context computer (but not both).
* </p>
*
* @param item
* the menu item on which to register the context
* @param contexts
* the contexts to use when F1 help is invoked; a mixed-type
* array of context ids (type <code>String</code>) and/or help
* contexts (type <code>IContext</code>)
* @deprecated use setHelp with single context id parameter
*/
@Deprecated
public void setHelp(MenuItem item, Object[] contexts) {
for (Object context : contexts) {
Assert.isTrue(context instanceof String
|| context instanceof IContext);
}
item.setData(HELP_KEY, contexts);
// ensure that the listener is only registered once
item.removeHelpListener(getHelpListener());
item.addHelpListener(getHelpListener());
}
代码示例来源: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: openaudible/openaudible
protected void createSortMenu(String menuNames[]) {
if (table == null)
return;
sortMenu = new Menu(table.getShell(), SWT.POP_UP);
for (int x = 0; x < menuNames.length; x++) {
MenuItem item = new MenuItem(sortMenu, SWT.PUSH);
Integer ID = x;
item.setData(ID);
item.setText(menuNames[x]);
item.addSelectionListener(this);
}
table.setMenu(sortMenu);
}
代码示例来源:origin: BiglySoftware/BiglyBT
public static final MenuItem addMenuItem(Menu menu, int style, int index,
String localizationKey, Listener selListener) {
if (index < 0 || index > menu.getItemCount()) {
index = menu.getItemCount();
}
MenuItem menuItem = new MenuItem(menu, style, index);
Messages.setLanguageText(menuItem, localizationKey);
KeyBindings.setAccelerator(menuItem, localizationKey);
menuItem.addListener(SWT.Selection, selListener);
/*
* Using the localizationKey as the id for the menu item; this can be used to locate it at runtime
* using .KN: missing method pointers
*/
menuItem.setData(KEY_MENU_ID, localizationKey);
return menuItem;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
/** Adds the gradient menu item. */
private void addGradientItems(Menu menu, MenuItemListener menuListener) {
if (menu.getItemCount() != 0) {
new MenuItem(menu, SWT.SEPARATOR);
}
menuListener.customGradientMI = new MenuItem(menu, SWT.NONE);
menuListener.customGradientMI.setText(GraphicsExample.getResourceString("Gradient")); //$NON-NLS-1$
menuListener.customGradientMI.addListener(SWT.Selection, menuListener);
GraphicsBackground gb = new GraphicsBackground();
menuListener.customGradientMI.setData(gb);
}
代码示例来源:origin: BiglySoftware/BiglyBT
protected static void addNetworksSubMenu(DownloadManager[] dms,
Menu menuNetworks) {
for (int i = 0; i < AENetworkClassifier.AT_NETWORKS.length; i++) {
final String nn = AENetworkClassifier.AT_NETWORKS[i];
String msg_text = "ConfigView.section.connection.networks." + nn;
final MenuItem itemNetwork = new MenuItem(menuNetworks, SWT.CHECK);
itemNetwork.setData("network", nn);
Messages.setLanguageText(itemNetwork, msg_text); //$NON-NLS-1$
itemNetwork.addListener(SWT.Selection, new ListenerDMTask(dms) {
@Override
public void run(DownloadManager dm) {
dm.getDownloadState().setNetworkEnabled(nn,
itemNetwork.getSelection());
}
});
boolean bChecked = dms.length > 0;
if (bChecked) {
// turn on check if just one dm is not enabled
for (int j = 0; j < dms.length; j++) {
DownloadManager dm = dms[j];
if (!dm.getDownloadState().isNetworkEnabled(nn)) {
bChecked = false;
break;
}
}
}
itemNetwork.setSelection(bChecked);
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
menuItem = new MenuItem(parent, SWT.CASCADE);
menuItem.setData(this);
widget = menuItem;
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
@Override
public void fill(Menu parent, int index) {
if (command == null) {
return;
}
if (widget != null || parent == null) {
return;
}
// Menus don't support the pulldown style
int tmpStyle = style;
if (tmpStyle == STYLE_PULLDOWN)
tmpStyle = STYLE_PUSH;
MenuItem item = null;
if (index >= 0) {
item = new MenuItem(parent, tmpStyle, index);
} else {
item = new MenuItem(parent, tmpStyle);
}
item.setData(this);
if (workbenchHelpSystem != null) {
workbenchHelpSystem.setHelp(item, helpContextId);
}
item.addListener(SWT.Dispose, getItemListener());
item.addListener(SWT.Selection, getItemListener());
widget = item;
update(null);
updateIcons();
establishReferences();
}
代码示例来源:origin: org.eclipse.e4.ui.workbench.renderers/swt
@Override
public void fill(Menu menu, int index) {
if (model == null) {
return;
}
if (widget != null) {
return;
}
int style = SWT.PUSH;
if (model.getType() == ItemType.PUSH)
style = SWT.PUSH;
else if (model.getType() == ItemType.CHECK)
style = SWT.CHECK;
else if (model.getType() == ItemType.RADIO)
style = SWT.RADIO;
MenuItem item = null;
if (index >= 0) {
item = new MenuItem(menu, style, index);
} else {
item = new MenuItem(menu, style);
}
item.setData(this);
item.addListener(SWT.Dispose, getItemListener());
item.addListener(SWT.Selection, getItemListener());
item.addListener(SWT.DefaultSelection, getItemListener());
widget = item;
model.setWidget(widget);
widget.setData(AbstractPartRenderer.OWNING_ME, model);
update(null);
}
内容来源于网络,如有侵权,请联系作者删除!