Java Code Examples for org.eclipse.swt.widgets.MenuItem#setText()

The following examples show how to use org.eclipse.swt.widgets.MenuItem#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditorMenu.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
/**
 *
 */
private void createBoxToggle(final Menu menu) {
	final MenuItem box = new MenuItem(menu, SWT.CHECK);
	box.setText(" Colorize code sections");
	box.setImage(GamaIcons.create("toggle.box").image());
	box.setSelection(getEditor().isDecorationEnabled());
	box.addSelectionListener(new SelectionAdapter() {

		@Override
		public void widgetSelected(final SelectionEvent e) {
			final boolean selection = box.getSelection();
			getEditor().setDecorationEnabled(selection);
			getEditor().decorate(selection);
		}
	});

}
 
Example 2
Source File: MenuItemProviders.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider clearToggleFilterRowMenuItemProvider(final String menuLabel) {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem menuItem = new MenuItem(popupMenu, SWT.PUSH);
			menuItem.setText(menuLabel);
			menuItem.setImage(GUIHelper.getImage("toggle_filter"));
			menuItem.setEnabled(true);

			menuItem.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					natTable.doCommand(new ToggleFilterRowCommand());
				}
			});
		}
	};
}
 
Example 3
Source File: MenuItemProviders.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider createColumnGroupMenuItemProvider() {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH);
			columnStyleEditor.setText("Create column group");
			columnStyleEditor.setEnabled(true);

			columnStyleEditor.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					natTable.doCommand(new OpenCreateColumnGroupDialog(natTable.getShell()));
				}
			});
		}
	};
}
 
Example 4
Source File: ModeMenu.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@Override
protected void insertAction(final Type type, Menu parentMenu) {
  MenuItem actionItem = new MenuItem(parentMenu, SWT.CHECK);
  actionItem.setText(type.getName());
  
  if (type.equals(editor.getAnnotationMode()))
      actionItem.setSelection(true);
  
  actionItem.addListener(SWT.Selection, new Listener() {
    @Override
    public void handleEvent(Event e) {

  	for (IModeMenuListener listener : listeners) {
  		listener.modeChanged(type);
  	}
    }
  });
}
 
Example 5
Source File: AbstractTableDialogEx.java    From logbook with MIT License 6 votes vote down vote up
/**
 * テーブルを追加します
 *
 * @param parent テーブルの親コンポジット
 * @return TableWrapper
 */
protected TableWrapper<T> addTable(Composite parent) {
    // テーブル
    Table table = new Table(parent, SWT.FULL_SELECTION | SWT.MULTI);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.addKeyListener(new TableKeyShortcutAdapter(table));

    // テーブル右クリックメニュー
    Menu tablemenu = new Menu(table);
    table.setMenu(tablemenu);
    MenuItem sendclipbord = new MenuItem(tablemenu, SWT.NONE);
    sendclipbord.addSelectionListener(new TableToClipboardAdapter(table));
    sendclipbord.setText("クリップボードにコピー(&C)");
    MenuItem reloadtable = new MenuItem(tablemenu, SWT.NONE);
    reloadtable.setText("再読み込み(&R)");
    reloadtable.addSelectionListener(new TableReloadAdapter());

    TableWrapper<T> wrapper = new TableWrapper<T>(table, this.clazz)
            .setDialogClass(this.getClass())
            .setDecorator(TableItemDecorator.stripe(SWTResourceManager.getColor(AppConstants.ROW_BACKGROUND)));
    this.tables.add(wrapper);
    return wrapper;
}
 
Example 6
Source File: MenuItemProviders.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public static IMenuItemProvider ungroupColumnsMenuItemProvider() {
	return new IMenuItemProvider() {

		public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
			MenuItem columnStyleEditor = new MenuItem(popupMenu, SWT.PUSH);
			columnStyleEditor.setText("Ungroup columns");
			columnStyleEditor.setEnabled(true);

			columnStyleEditor.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					natTable.doCommand(new UngroupColumnCommand());
				}
			});
		}
	};
}
 
Example 7
Source File: ClassSelectionButton.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void populateMenuItems( )
{
	for ( int i = 0; i < menu.getItemCount( ); i++ )
	{
		menu.getItem( i ).dispose( );
		i--;
	}

	String[] types = this.provider.getMenuItems( );
	for ( int i = 0; i < types.length; i++ )
	{
		MenuItem item = new MenuItem( menu, SWT.PUSH );
		item.setText( provider.getMenuItemText( types[i] ) );
		item.setData( types[i] );
		item.setImage( this.provider.getMenuItemImage( types[i] ) );
		item.addSelectionListener( listener );
	}

	if ( menu.getItemCount( ) <= 0 )
	{
		button.setDropDownMenu( null );
	}

	button.setText( provider.getButtonText( ) );
	refresh( );
}
 
Example 8
Source File: SwitchThemesPulldownContributionItem.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void fill(Menu menu, int index)
{
	MenuItem menuItem = new MenuItem(menu, SWT.PUSH, index);
	menuItem.setText(branchName);
	menuItem.setEnabled(!branchName.equals(manager.getCurrentTheme().getName()));
	menuItem.addSelectionListener(new SelectionAdapter()
	{
		public void widgetSelected(SelectionEvent e)
		{
			// what to do when menu is subsequently selected.
			switchTheme(manager, branchName);
		}
	});
}
 
Example 9
Source File: GitRepositoryPreferencePageView.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * @param parent a widget which will be the parent of the new instance (cannot
 *               be null)
 * @param style  the style of widget to construct
 */
public GitRepositoryPreferencePageView(Composite parent, int style) {
	super(parent, style);
	final TableColumnLayout tableColumnLayout = new TableColumnLayout();
	setLayout(tableColumnLayout);

	tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
	final Table table = tableViewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(true);

	columnRepository = new TableViewerColumn(tableViewer, SWT.NONE);
	TableColumn colRepository = columnRepository.getColumn();
	tableColumnLayout.setColumnData(colRepository, new ColumnWeightData(1));
	colRepository.setText("Repository");

	columnLocalPath = new TableViewerColumn(tableViewer, SWT.NONE);
	TableColumn colLocalPath = columnLocalPath.getColumn();
	tableColumnLayout.setColumnData(colLocalPath, new ColumnWeightData(1));
	colLocalPath.setText("Local Path");

	columnMemory = new TableViewerColumn(tableViewer, SWT.RIGHT);
	TableColumn colMemory = columnMemory.getColumn();
	tableColumnLayout.setColumnData(colMemory, new ColumnPixelData(80, true, true));
	colMemory.setText("Memory");

	final Menu menu = new Menu(tableViewer.getTable());
	menuItemGoToRepository = new MenuItem(menu, SWT.NONE);
	menuItemGoToRepository.setText("Go to Repository");
	tableViewer.getTable().setMenu(menu);
}
 
Example 10
Source File: NewCoolbarItem.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean add(String commandId, String label) {
    Command command = commandService.getCommand(commandId);
    if (command != null && command.isDefined() && command.isHandled()) {
        final MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
        try {
            menuItem.setText(label != null ? label : command.getName());
            getCommandImage(commandId).ifPresent(menuItem::setImage);
        } catch (NotDefinedException e1) {
            BonitaStudioLog.error(e1);
            menuItem.setText("unknown command: " + commandId);
        }
        menuItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(final SelectionEvent event) {
                try {
                    handlerService.executeCommand(command.getId(), null);
                } catch (final Exception e) {
                    BonitaStudioLog.error(e);
                }
            }

        });
        return true;
    }
    return false;
}
 
Example 11
Source File: OutputsMenu.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private static MenuItem menuItem(final Menu parent, final ISelecter listener, final Image image,
		final String prefix) {
	final MenuItem result = new MenuItem(parent, SWT.PUSH);
	result.setText(prefix);
	if (listener != null)
		result.addSelectionListener(listener);
	if (image != null)
		result.setImage(image);
	return result;
}
 
Example 12
Source File: MultiPlotGraphic.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
@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 );
	  }
  });
 }
 
Example 13
Source File: QuestTable.java    From logbook with MIT License 5 votes vote down vote up
@Override
protected void createContents() {
    this.addTable(this.shell)
            .setContentSupplier(CreateReportLogic::getQuestContent)
            .reload()
            .update();

    // 任務をリセット
    final MenuItem reset = new MenuItem(this.opemenu, SWT.NONE);
    reset.setText("任務をリセット");
    reset.addSelectionListener((SelectedListener) e -> {
        GlobalContext.getQuest().clear();
        this.getSelectionTable().reload().update();
    });
}
 
Example 14
Source File: StartSessionWithContacts.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/** Creates a menu entry which indicates that no contacts with Saros are online. */
private MenuItem createInvalidContactsMenuItem(Menu parentMenu, int index) {
  MenuItem menuItem = new MenuItem(parentMenu, SWT.NONE, index);
  menuItem.setText(Messages.SessionWithContacts_menuItem_no_contacts_available_text);
  menuItem.setEnabled(false);
  return menuItem;
}
 
Example 15
Source File: ClipboardCopy.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
public static void
 addCopyToClipMenu(
final Menu					menu,
final copyToClipProvider	provider )
 {
  for ( MenuItem e: menu.getItems()){
	  
	  if ( e.getData( MENU_ITEM_KEY ) != null ){
		  
		  e.dispose();
	  }
  }
  
  MenuItem   item = new MenuItem( menu,SWT.NONE );

  item.setData( MENU_ITEM_KEY, "" );
  
  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[] { provider.getText()}, new Transfer[] {TextTransfer.getInstance()});
		  }
	  });
 }
 
Example 16
Source File: ClipboardHandlerTable.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a pop up menu for this handler.
 *
 * @return
 */
public Menu getMenu() {
    Menu menu = new Menu(table);
    MenuItem itemCopy = new MenuItem(menu, SWT.NONE);
    itemCopy.setText(Resources.getMessage("ClipboardHandlerTable.0")); //$NON-NLS-1$
    itemCopy.addSelectionListener(new SelectionAdapter(){
        public void widgetSelected(SelectionEvent arg0) {
            copy();
        }
    });
    return menu;
}
 
Example 17
Source File: AgentsMenu.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
private static MenuItem actionAgentMenuItem(final Menu parent, final IAgent agent, final IStatement command,
		final String prefix) {
	final MenuItem result = new MenuItem(parent, SWT.PUSH);
	result.setText(prefix + " " + command.getName());
	result.setImage(GamaIcons.create(IGamaIcons.MENU_RUN_ACTION).image());
	result.addSelectionListener(runner);
	result.setData("agent", agent);
	result.setData("command", command);
	return result;
}
 
Example 18
Source File: PingGraphic.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
@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 );
	  }
  });
 }
 
Example 19
Source File: AskOrdersPart.java    From offspring with MIT License 4 votes vote down vote up
@PostConstruct
public void postConstruct(final Composite parent, final INxtService nxt,
    final IUserService userService, IStylingEngine engine, UISynchronize sync) {
  mainComposite = new Composite(parent, SWT.NONE);
  GridLayoutFactory.fillDefaults().numColumns(1).spacing(5, 2).margins(0, 0)
      .applyTo(mainComposite);
  GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
      .applyTo(mainComposite);

  paginationContainer = new PaginationContainer(mainComposite, SWT.NONE);
  GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true)
      .applyTo(paginationContainer);

  ordersViewer = new AskOrdersViewer(paginationContainer.getViewerParent(),
      nxt, ContactsService.getInstance(), engine, userService, sync);
  ordersViewer.getTable().setToolTipText("Right click for Quick Buy");
  paginationContainer.setTableViewer(ordersViewer, 100);

  // add context menu for quick buy
  Menu contextMenu = new Menu(ordersViewer.getTable());
  ordersViewer.getTable().setMenu(contextMenu);
  MenuItem itemQuickBuy = new MenuItem(contextMenu, SWT.PUSH);
  itemQuickBuy.setText("Quick Buy");
  itemQuickBuy.addSelectionListener(new SelectionAdapter() {

    @Override
    public void widgetSelected(SelectionEvent e) {
      IStructuredSelection selection = (IStructuredSelection) ordersViewer
          .getSelection();
      Object order = selection.getFirstElement();
      if (order instanceof Order.Ask) {
        Shell shell = parent.getShell();
        Long assetId = ((Order.Ask) order).getAssetId();
        int quantity = ((Order.Ask) order).getQuantity();
        long price = ((Order.Ask) order).getPrice();

        new WizardDialog(shell, new PlaceBidOrderWizard(userService, nxt,
            assetId, quantity, price)).open();
      }
    }
  });

}
 
Example 20
Source File: OSSpecific.java    From Rel with Apache License 2.0 4 votes vote down vote up
public static void addHelpMenuItems(Menu menu) {
	MenuItem about = new MenuItem(menu, SWT.PUSH);
	about.setText("About " + appName);
	about.addListener(SWT.Selection, aboutListener);
}