当前位置: 首页>>代码示例>>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;未经允许,请勿转载。