本文整理汇总了Java中org.eclipse.swt.widgets.MenuItem.setText方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.setText方法的具体用法?Java MenuItem.setText怎么用?Java MenuItem.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.widgets.MenuItem
的用法示例。
在下文中一共展示了MenuItem.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCopyToClipMenu
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
public static void
addCopyToClipMenu(
final Menu menu,
final String text )
{
MenuItem item = new MenuItem( menu,SWT.NONE );
String msg_text_id= "label.copy.to.clipboard";
item.setText( MessageText.getString( msg_text_id ));
item.addSelectionListener(
new SelectionAdapter()
{
@Override
public void
widgetSelected(
SelectionEvent arg0)
{
new Clipboard(menu.getDisplay()).setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});
}
});
}
示例2: openPopupMenu
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
protected void openPopupMenu(NodeType[] availableTypes, final AvroNode targetNode, final AvroContext context) {
Shell shell = Display.getCurrent().getActiveShell();
final Menu menu = new Menu(shell, SWT.POP_UP);
for (NodeType availableType : availableTypes) {
final NodeType type = availableType;
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText(type.getDisplayLabel());
item.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
menu.dispose();
IEditCommand cmd = context.getService(IEditCommandFactory.class)
.createAddElementCommand(targetNode, type, getNotifications());
context.getService(ICommandExecutor.class).execute(cmd);
}
});
}
Point location = MouseInfo.getPointerInfo().getLocation();
int x = location.x;
int y = location.y;
menu.setLocation(x, y);
menu.setVisible(true);
}
示例3: createViewMenu
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private Menu createViewMenu() {
final MenuItem mi = new MenuItem(menuBar, SWT.CASCADE);
mi.setText("&View");
final Menu m = new Menu(shell, SWT.DROP_DOWN);
mi.setMenu(m);
SWTUtils.addMenuItem(m, "Increase Font Size", SWT.CTRL + '+', () -> {
setFontSize(fontSize + 1);
});
SWTUtils.addMenuItem(m, "Decrease Font Size", SWT.CTRL + '-', () -> {
setFontSize(fontSize - 1);
});
return m;
}
示例4: createNewWorkItemMenu
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private Menu createNewWorkItemMenu(final Shell shell, final TeamExplorerContext context) {
final WorkItemClient client = context.getServer().getConnection().getWorkItemClient();
final Project project = client.getProjects().get(context.getCurrentProjectInfo().getName());
final Menu menu = new Menu(shell, SWT.POP_UP);
for (final WorkItemType workItemType : project.getVisibleWorkItemTypes()) {
final MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(workItemType.getName());
menuItem.setData(workItemType);
menuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final WorkItem workItem = client.newWorkItem(workItemType);
WorkItemEditorHelper.openEditor(context.getServer(), workItem);
}
});
}
return menu;
}
示例5: addNewSongTemplates
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private void addNewSongTemplates() {
TGTemplateManager templateManager = TGTemplateManager.getInstance(this.findContext());
if( templateManager.countTemplates() > 0 ){
//--SEPARATOR--
new MenuItem(this.newSongMenu, SWT.SEPARATOR);
Iterator<TGTemplate> it = templateManager.getTemplates();
while( it.hasNext() ){
TGTemplate tgTemplate = (TGTemplate)it.next();
MenuItem menuItem = new MenuItem(this.newSongMenu, SWT.PUSH);
menuItem.setText(tgTemplate.getName());
menuItem.addSelectionListener(this.createNewSongFromTemplateActionProcessor(tgTemplate));
}
}
}
示例6: createMenu
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
public void createMenu(TGToolBar toolBar, ToolItem item) {
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
Menu menu = new Menu(item.getParent().getShell());
TGCustomChordManager customChordManager = TuxGuitar.getInstance().getCustomChordManager();
for(int i = 0; i < customChordManager.countChords(); i++){
TGChord chord = TuxGuitar.getInstance().getCustomChordManager().getChord(i);
MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText(chord.getName());
menuItem.addSelectionListener(this.createInsertChordAction(toolBar, chord));
}
menu.setLocation(pt.x, pt.y + rect.height);
menu.setVisible(true);
}
示例7: updateTypes
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
public void updateTypes(){
MenuItem[] items = this.newCollection.getItems();
for(int i = 0;i < items.length; i ++){
items[i].dispose();
}
Iterator<TGBrowserFactory> bookTypes = TGBrowserManager.getInstance(getBrowser().getContext()).getFactories();
while(bookTypes.hasNext()){
final TGBrowserFactory bookType = (TGBrowserFactory)bookTypes.next();
MenuItem item = new MenuItem(this.newCollection,SWT.PUSH);
item.setText(bookType.getName());
item.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
newCollection( bookType.getType());
}
});
}
}
示例8: addMenuItem
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private MenuItem addMenuItem(Menu menu, String text, int accelerator,
Object data, SelectionListener listener) {
MenuItem item = new MenuItem(menu, SWT.NONE);
item.setText(text);
item.addSelectionListener(listener);
if (accelerator != SWT.NONE)
item.setAccelerator(accelerator);
item.setData(data);
return item;
}
示例9: addMenuItem
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private MenuItem addMenuItem(Menu menu, String text,
SelectionListener listener) {
MenuItem item = new MenuItem(menu, SWT.NONE);
item.setText(text);
item.addSelectionListener(listener);
return item;
}
示例10: updateAccelerator
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
private void updateAccelerator(MenuItem item, String itemText,
char newAccelerator) {
itemText += " \t Ctrl+"
+ (newAccelerator == ' ' ? "[space]" : newAccelerator);
int acc = SWT.MOD1
+ (newAccelerator == ' ' ? SWT.SPACE : newAccelerator);
item.setText(itemText);
item.setAccelerator(acc);
}
示例11: fill
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
@Override
public void fill ( final org.eclipse.swt.widgets.Menu menu, final int index )
{
final MenuItem item = new MenuItem ( menu, SWT.NONE, index );
final Profile profile = getProfile ();
final String name = this.definition.getName () == null ? "<unnamed>" : this.definition.getName ();
String profileName = profile != null ? profile.getName () : "default";
if ( profileName == null )
{
profileName = "<unnamed>";
}
item.setText ( String.format ( "Run %s (%s)", name, profileName ) );
item.addSelectionListener ( new SelectionAdapter () {
@Override
public void widgetSelected ( final SelectionEvent evt )
{
try
{
run ( name );
}
catch ( final Exception e )
{
logger.warn ( "Failed to run", e );
StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.BLOCK );
}
}
} );
}
示例12: fill
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
@Override
public void fill(Menu menu, int index)
{
final MenuItem menuItem = new MenuItem(menu, SWT.NONE, index);
menuItem.setText("Convert existing JPF Projects to new format");
menuItem.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
run();
}
});
}
示例13: fill
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
@Override
public void fill(Menu menu, int index) {
super.fill(menu, index);
int i = index;
// FIXME y this works on Sirius editor?
try {
String filePath = "";
IFile selectedFile = AlloyParseUtil.getSelectedFile();
if (selectedFile == null) {
editor = Activator.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
editor.doSave(new NullProgressMonitor());
filePath = ((FileEditorInput) editor.getEditorInput()).getPath().toOSString();
} else {
filePath = selectedFile.getRawLocation().toOSString();
}
alloyExecuter.parse(filePath);
final ConstList<Command> allCommands = alloyExecuter.getRunCommands();
if (allCommands.size() > 0) {
for (final Command com : allCommands) {
final MenuItem menuItem = new MenuItem(menu, SWT.PUSH, i++);
menuItem.setText(com.toString());
menuItem.setData("command", com);
menuItem.addSelectionListener(this);
}
}
} catch (Exception e) {
// e.printStackTrace();
return;
}
}
示例14: setAccelerator
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
/**
* Helper method to set a keyboard accelerator for a MenuItem. If kbInfo is SWT.NONE, no accelerator will be set.
* @param menu SWT MenuItem
* @param kbInfo KeyBindingInfo object, which contains the SWT accelerator value and its display name
*/
private static void setAccelerator(final MenuItem menu, final KeyBindingInfo kbInfo)
{
if ( menu.isDisposed()){
return;
}
if(kbInfo.accelerator != SWT.NONE)
{
menu.setAccelerator(kbInfo.accelerator);
// SWT on OS X now uses native drawing
if(!Constants.isOSX && !menu.getText().endsWith(kbInfo.name))
menu.setText(menu.getText() + kbInfo.name);
}
}
示例15: addMenuItems
import org.eclipse.swt.widgets.MenuItem; //导入方法依赖的package包/类
@Override
protected void
addMenuItems(
Menu menu )
{
new MenuItem( menu, SWT.SEPARATOR );
MenuItem mi_reset = new MenuItem( menu, SWT.PUSH );
mi_reset.setText( MessageText.getString( "label.clear.history" ));
mi_reset.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
try{
this_mon.enter();
nbValues = 0;
currentPosition = 0;
for ( int i=0;i<all_values.length;i++ ){
all_values[i] = new int[all_values[i].length];
}
}finally{
this_mon.exit();
}
refresh( true );
}
});
}