下面列出了org.eclipse.swt.widgets.MenuItem#setText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
*
*/
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);
}
});
}
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());
}
});
}
};
}
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());
}
});
}
};
}
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( );
}
/**
* テーブルを追加します
*
* @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;
}
@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);
}
}
});
}
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()));
}
});
}
};
}
/**
* @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);
}
@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 );
}
});
}
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;
}
/**
* 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;
}
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()});
}
});
}
/** 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;
}
@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();
});
}
@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 );
}
});
}
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;
}
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;
}
@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);
}
});
}
public static void addHelpMenuItems(Menu menu) {
MenuItem about = new MenuItem(menu, SWT.PUSH);
about.setText("About " + appName);
about.addListener(SWT.Selection, aboutListener);
}
@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();
}
}
});
}