本文整理匯總了Java中org.eclipse.jface.action.ContributionItem類的典型用法代碼示例。如果您正苦於以下問題:Java ContributionItem類的具體用法?Java ContributionItem怎麽用?Java ContributionItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ContributionItem類屬於org.eclipse.jface.action包,在下文中一共展示了ContributionItem類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getContributionItems
import org.eclipse.jface.action.ContributionItem; //導入依賴的package包/類
@Override
protected IContributionItem[] getContributionItems() {
File[] files = GpsQuickImportFiles.getGpsFiles();
if (files.length == 0) {
return new IContributionItem[] {
new ContributionItem() {
@Override
public void fill(Menu menu, int index) {
MenuItem item = new MenuItem(menu, 0);
item.setText("No files available");
}
}
};
}
IContributionItem[] result = new IContributionItem[files.length];
for (int i = 0; i < result.length; i++) {
CommandContributionItemParameter parameter = new CommandContributionItemParameter(
serviceLocator, "com.genuitec.eclipse.gerrit.tools.quickImportProjects." + i, //$NON-NLS-1$
"com.genuitec.eclipse.gerrit.tools.importProjects", SWT.PUSH); //$NON-NLS-1$
parameter.parameters = Collections.singletonMap("file", files[i].toString()); //$NON-NLS-1$
parameter.label = files[i].getName();
result[i] = new CommandContributionItem(parameter);
}
return result;
}
示例2: getMenuId
import org.eclipse.jface.action.ContributionItem; //導入依賴的package包/類
/**
* Retrieve the menu id to show from the contribution item's ID (following the documented approach
* for DROP_DOWN items).
*/
private static String getMenuId(ToolItem toolItem)
throws ExecutionException {
if (toolItem.getData() instanceof ContributionItem) {
ContributionItem data = (ContributionItem) toolItem.getData();
if (!Strings.isNullOrEmpty(data.getId())) {
return data.getId();
}
}
throw new ExecutionException("Unable to determine menu ID");
}
示例3: removeAll
import org.eclipse.jface.action.ContributionItem; //導入依賴的package包/類
public void removeAll() {
for (IContributionItem it : tbManager.getItems()) {
if (it instanceof ActionContributionItem && ((ActionContributionItem) it).getAction() instanceof IDisposable)
((IDisposable) ((ActionContributionItem) it).getAction()).dispose();
else if (it instanceof ContributionItem)
it.dispose();
}
tbManager.removeAll();
}
示例4: addLocalToolBar
import org.eclipse.jface.action.ContributionItem; //導入依賴的package包/類
private void addLocalToolBar(IToolBarManager manager, ContributionItem item){
manager.add(item);
}
示例5: fillMenu
import org.eclipse.jface.action.ContributionItem; //導入依賴的package包/類
private void fillMenu(final Menu menu) {
final int currentLabelPosition = _tourMarker.getLabelPosition();
for (final ContributionItem contribItem : _allActions) {
if (contribItem instanceof ActionContributionItem) {
final ActionContributionItem actionItem = (ActionContributionItem) contribItem;
final IAction action = actionItem.getAction();
if (action instanceof ActionSetMarkerPosition) {
final ActionSetMarkerPosition posAction = (ActionSetMarkerPosition) action;
final boolean isCurrentPosition = posAction.labelPosId == currentLabelPosition;
posAction.setChecked(isCurrentPosition);
posAction.setEnabled(!isCurrentPosition);
}
}
contribItem.fill(_menu, -1);
}
}
示例6: addActions
import org.eclipse.jface.action.ContributionItem; //導入依賴的package包/類
/**
* Adds the actions to the given menu manager.
*/
protected void addActions(IMenuManager viewMenu) {
viewMenu.add(new Separator());
fItems= new MenuItem[fActions.length];
for (int i= 0; i < fActions.length; i++) {
final int j= i;
viewMenu.add(new ContributionItem() {
@Override
public void fill(Menu menu, int index) {
int style= SWT.CHECK;
if ((fActions[j].getStyle() & IAction.AS_RADIO_BUTTON) != 0)
style= SWT.RADIO;
MenuItem mi= new MenuItem(menu, style, index);
ImageDescriptor d= fActions[j].getImageDescriptor();
mi.setImage(JavaPlugin.getImageDescriptorRegistry().get(d));
fItems[j]= mi;
mi.setText(fActions[j].getText());
mi.setSelection(fCurrentSelection == j);
mi.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (fCurrentSelection == j) {
fItems[fCurrentSelection].setSelection(true);
return;
}
fActions[j].run();
// Update checked state
fItems[fCurrentSelection].setSelection(false);
fCurrentSelection= j;
fItems[fCurrentSelection].setSelection(true);
}
});
}
@Override
public boolean isDynamic() {
return false;
}
});
}
}
示例7: addActions
import org.eclipse.jface.action.ContributionItem; //導入依賴的package包/類
/**
* Adds the actions to the given menu manager.
*/
protected void addActions(IMenuManager viewMenu) {
if (actions == null)
actions = createActions();
viewMenu.add(new Separator());
items = new MenuItem[actions.length];
for (int i = 0; i < actions.length; i++) {
final int j = i;
viewMenu.add(new ContributionItem() {
public void fill(Menu menu, int index) {
int style = SWT.CHECK;
if ((actions[j].getStyle() & IAction.AS_RADIO_BUTTON) != 0)
style = SWT.RADIO;
final MenuItem mi = new MenuItem(menu, style, index);
items[j] = mi;
mi.setText(actions[j].getText());
mi.setSelection(currentSelection == j);
mi.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (currentSelection == j) {
items[currentSelection].setSelection(true);
return;
}
actions[j].run();
// Update checked state
items[currentSelection].setSelection(false);
currentSelection = j;
items[currentSelection].setSelection(true);
}
});
}
public boolean isDynamic() {
return false;
}
});
}
}
示例8: init
import org.eclipse.jface.action.ContributionItem; //導入依賴的package包/類
protected void init() {
dataProvider = new DataProvider();
headingProvider = new HeadingProvider();
gridLayer = new DefaultGridLayer(dataProvider, headingProvider);
// CellLabelAccumulator determines how cells will be displayed
class CellLabelAccumulator implements IConfigLabelAccumulator {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
configLabels.addLabel("column" + columnPosition);
if (dataProvider.isEditableNonscalarDefinition(rowPosition) && columnPosition == Attr.HEADING_COLUMN)
configLabels.addLabel("nonscalareditor");
}
}
DataLayer bodyDataLayer = (DataLayer) gridLayer.getBodyDataLayer();
CellLabelAccumulator cellLabelAccumulator = new CellLabelAccumulator();
bodyDataLayer.setConfigLabelAccumulator(cellLabelAccumulator);
table = new NatTable(parent, gridLayer, false);
editorConfiguration = new EditorConfiguration();
DefaultNatTableStyleConfiguration defaultStyle = new DefaultNatTableStyleConfiguration();
table.addConfiguration(defaultStyle);
table.addConfiguration(editorConfiguration);
ContributionItem rowMenuItems = new ContributionItem() {
@Override
public void fill(Menu menu, int index) {
MenuItem doesDelete = new MenuItem(menu, SWT.PUSH);
doesDelete.setText("Delete");
doesDelete.setImage(IconLoader.loadIcon("table_row_delete"));
doesDelete.addListener(SWT.Selection, e -> askDeleteSelected());
}
};
table.addConfiguration(new MenuConfiguration(GridRegion.ROW_HEADER,
new PopupMenuBuilder(table).withContributionItem(rowMenuItems)));
// Tabbing wraps and moves up/down
gridLayer.registerCommandHandler(new MoveCellSelectionCommandHandler(
gridLayer.getBodyLayer().getSelectionLayer(), ITraversalStrategy.TABLE_CYCLE_TRAVERSAL_STRATEGY));
table.configure();
// Tooltip for row/column headings
new NatTableContentTooltip(table, GridRegion.ROW_HEADER) {
protected String getText(Event event) {
return "Right-click for options.";
}
};
}