本文整理匯總了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()});
}
});
}
示例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));
}
}
}
示例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;
}
示例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);
}
});
}
示例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());
}
});
}
}
示例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);
}
示例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;
}
示例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;
}
示例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 );
}
}
} );
}
示例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();
}
});
}
示例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;
}
}
示例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);
}
示例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;
}
示例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);
}
});
}
示例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);
}
});
}