當前位置: 首頁>>代碼示例>>Java>>正文


Java ContributionItem類代碼示例

本文整理匯總了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;
}
 
開發者ID:Genuitec,項目名稱:gerrit-tools,代碼行數:27,代碼來源:QuickGpsImportCommandsProvider.java

示例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");
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:15,代碼來源:OpenDropDownMenuHandler.java

示例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();
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:10,代碼來源:ATopToolBarManager.java

示例4: addLocalToolBar

import org.eclipse.jface.action.ContributionItem; //導入依賴的package包/類
private void addLocalToolBar(IToolBarManager manager, ContributionItem item){
	manager.add(item);
}
 
開發者ID:pohmann,項目名稱:CSIclipse,代碼行數:4,代碼來源:StackBrowserView.java

示例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);
		}
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:26,代碼來源:ActionSetMarkerLabelPositionMenu.java

示例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;
			}
		});
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:52,代碼來源:MultiActionGroup.java

示例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;
			}
		});
	}
}
 
開發者ID:heartsome,項目名稱:translationstudio8,代碼行數:51,代碼來源:WorkingSetRootModeActionGroup.java

示例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.";
		}
	};
}
 
開發者ID:DaveVoorhis,項目名稱:Rel,代碼行數:54,代碼來源:Designer.java


注:本文中的org.eclipse.jface.action.ContributionItem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。