當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItem.setText方法代碼示例

本文整理匯總了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()});
		  }
	  });
 }
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:24,代碼來源:ClipboardCopy.java

示例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);
       
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:26,代碼來源:AddElementAction.java

示例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;
}
 
開發者ID:moforw,項目名稱:albaum,代碼行數:18,代碼來源:GUI.java

示例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;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:21,代碼來源:TeamExplorerWorkItemPage.java

示例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));
		}
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:17,代碼來源:FileMenuItem.java

示例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);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:18,代碼來源:TGToolBarSectionChord.java

示例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());
			}
		});
	}
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:18,代碼來源:TGBrowserMenuBar.java

示例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;
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:11,代碼來源:BarManager.java

示例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;
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:8,代碼來源:MenuManager.java

示例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);
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:10,代碼來源:MenuManager.java

示例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 );
            }
        }
    } );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:33,代碼來源:DefinitionContributionItem.java

示例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();
		}
	});
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:15,代碼來源:ConvertJPFProjects.java

示例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;
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:33,代碼來源:RunAsAlloyContributionItem.java

示例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);
    }
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:20,代碼來源:KeyBindings.java

示例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 );
	  }
  });
 }
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:33,代碼來源:PingGraphic.java


注:本文中的org.eclipse.swt.widgets.MenuItem.setText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。