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


Java MenuItem.addSelectionListener方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.MenuItem.addSelectionListener方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItem.addSelectionListener方法的具體用法?Java MenuItem.addSelectionListener怎麽用?Java MenuItem.addSelectionListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.MenuItem的用法示例。


在下文中一共展示了MenuItem.addSelectionListener方法的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: 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

示例3: getSubActionMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
protected Menu getSubActionMenu(final Control parent) {
    if (subActionMenu != null) {
        return subActionMenu;
    }

    subActionMenu = new Menu(parent);

    for (final Iterator<IAction> it = subActions.iterator(); it.hasNext();) {
        final IAction subAction = it.next();
        final ActionContributionItem aci = new ActionContributionItem(subAction);
        aci.fill(subActionMenu, -1);
        final MenuItem menuItem = subActionMenu.getItem(subActionMenu.getItemCount() - 1);
        menuItem.addSelectionListener(menuItemSelectionListener);
    }

    return subActionMenu;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:18,代碼來源:ToolbarPulldownAction.java

示例4: fill

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
@Override
public void fill(Menu menu, int index) {
	final IProject project = getSelectedProject();
	final boolean exists = AddBuilder.hasBuilder(project);
	MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index);
	menuItem.setText((exists ? "Remove" : "Add") + " Layered Builder");
	menuItem.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			G.reset();
			if (exists) {
				RemoveBuilder.removeBuilder(project);
			} else {
				AddBuilder.addBuilder(project);
			}
			Activator.getDefault().getAnalysis().removeWarnings(1000);
		}
	});
}
 
開發者ID:secure-software-engineering,項目名稱:cheetah,代碼行數:20,代碼來源:BuildHandler.java

示例5: 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

示例6: createDivisionTypeMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createDivisionTypeMenu(TGToolBar toolBar, ToolItem item) {
	TGDuration duration = TablatureEditor.getInstance(toolBar.getContext()).getTablature().getCaret().getDuration();
	Menu menu = new Menu(item.getParent().getShell());
	
	for( int i = 0 ; i < TGDivisionType.ALTERED_DIVISION_TYPES.length ; i ++ ){
		TGDivisionType divisionType = TGDivisionType.ALTERED_DIVISION_TYPES[i];
		
		MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
		menuItem.setText(toolBar.toCheckString(Integer.toString(TGDivisionType.ALTERED_DIVISION_TYPES[i].getEnters()), (divisionType.isEqual(duration.getDivision()))));
		menuItem.addSelectionListener(this.createDivisionTypeAction(toolBar, divisionType));
	}
	
	Rectangle rect = item.getBounds();
	Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
	
	menu.setLocation(pt.x, pt.y + rect.height);
	menu.setVisible(true);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:19,代碼來源:TGToolBarSectionDuration.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: showCompareMenu

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void showCompareMenu(final Point location, final ConflictDescription conflict) {
    final ConflictComparisonOption[] comparisons =
        ConflictComparisonFactory.getConflictComparison(conflict).getOptions();

    final Menu compareMenu = new Menu(getSite().getShell(), SWT.POP_UP);

    for (final ConflictComparisonOption comparison : comparisons) {
        final Object originalNode = comparison.getOriginalNode();
        final Object modifiedNode = comparison.getModifiedNode();

        final MenuItem compareItem = new MenuItem(compareMenu, SWT.NONE);

        final String messageFormat = Messages.getString("ConflictResolutionEditor.CompareActionTextFormat"); //$NON-NLS-1$
        final String message =
            MessageFormat.format(messageFormat, comparison.getModifiedTitle(), comparison.getOriginalTitle());

        compareItem.setText(message);
        compareItem.setEnabled(modifiedNode != null && originalNode != null);

        compareItem.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(final SelectionEvent e) {
                openComparison(conflict, originalNode, modifiedNode);
            }
        });
    }

    getSite().getShell().setMenu(compareMenu);

    compareMenu.setLocation(location);
    compareMenu.setVisible(true);
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:33,代碼來源:ConflictResolutionEditor.java

示例13: addSelectionListener

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
public static boolean addSelectionListener(MenuItem mi, SelectionListener l) {
	if (isDisposed(mi))
		return false;
	
	mi.addSelectionListener(l);
	return true;
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:8,代碼來源:SWTUtil.java

示例14: createItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createItem(final Menu parent, final int index,
    final ICoverageLaunch launch) {
  final MenuItem item = new MenuItem(parent, SWT.PUSH, index);
  item.setImage(EclEmmaUIPlugin.getImage(EclEmmaUIPlugin.ELCL_DUMP));
  item.setText(LaunchLabelProvider.getLaunchText(launch));
  item.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      DumpExecutionDataHandler.requestDump(launch);
    }
  });
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:13,代碼來源:DumpExecutionDataItems.java

示例15: createItem

import org.eclipse.swt.widgets.MenuItem; //導入方法依賴的package包/類
private void createItem(final Menu parent, final int index,
    final ICoverageSession session, final boolean selected,
    final int position, final ISessionManager sm) {
  final MenuItem item = new MenuItem(parent, SWT.RADIO, index);
  item.setImage(EclEmmaUIPlugin.getImage(EclEmmaUIPlugin.ELCL_SESSION));
  item.setText(getLabel(session, position));
  item.setSelection(selected);
  item.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      sm.activateSession(session);
    }
  });
}
 
開發者ID:eclipse,項目名稱:eclemma,代碼行數:15,代碼來源:SelectActiveSessionsItems.java


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