本文整理汇总了Java中org.eclipse.jface.action.ActionContributionItem.getAction方法的典型用法代码示例。如果您正苦于以下问题:Java ActionContributionItem.getAction方法的具体用法?Java ActionContributionItem.getAction怎么用?Java ActionContributionItem.getAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.action.ActionContributionItem
的用法示例。
在下文中一共展示了ActionContributionItem.getAction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertContextMenuNoActionDuplicates
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
/**
* Asserts that the context menu for the current navigator selection does not contain any duplicates.
*
* That is, two menu items that represent an action of the same class.
*/
private void assertContextMenuNoActionDuplicates() {
MenuManager menu = new MenuManager();
projectExplorer.getNavigatorActionService().fillContextMenu(menu);
List<ActionContributionItem> actionContributions = Arrays.asList(menu.getItems()).stream()
.filter(i -> i instanceof ActionContributionItem)
.map(i -> ((ActionContributionItem) i))
.collect(Collectors.toList());
Map<String, ActionContributionItem> contributionNameMap = new HashMap<>();
for (ActionContributionItem item : actionContributions) {
ActionContributionItem mapItem = contributionNameMap.putIfAbsent(item.getAction().getText(), item);
if (mapItem != null) {
IAction mapAction = mapItem.getAction();
IAction otherAction = item.getAction();
// Double check if action is of the same type
if (mapAction.getClass().equals(otherAction.getClass())) {
fail("Action '" + mapAction.getClass().getSimpleName()
+ "' is contributed twice to the context menu: "
+ mapAction.toString() + " " + otherAction.toString());
}
}
}
}
示例2: fireAuthEnable
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
public void fireAuthEnable( boolean enabled){
IToolBarManager toolbar = this.getViewSite().getActionBars().getToolBarManager();
IContributionItem[] items = toolbar.getItems();
for (IContributionItem it : items) {
if (it instanceof ActionContributionItem) {
ActionContributionItem aci = (ActionContributionItem) it;
if (aci.getAction() instanceof AuthenticationAction) {
AuthenticationAction aa = (AuthenticationAction) aci.getAction();
String img = null;
if (enabled) {
img = CoreImages.AUTH_ENABLED;
} else {
img = CoreImages.AUTH;
}
aa.setImageDescriptor(ImageDescriptor.createFromImage(ResourceUtils.getImage(CoreConstants.PLUGIN_UI, img)));
}
}
}
}
示例3: fireProxyEnable
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
public void fireProxyEnable( boolean enabled){
IToolBarManager toolbar = this.getViewSite().getActionBars().getToolBarManager();
IContributionItem[] items = toolbar.getItems();
for (IContributionItem it : items) {
if (it instanceof ActionContributionItem) {
ActionContributionItem aci = (ActionContributionItem) it;
if (aci.getAction() instanceof ProxyAction) {
ProxyAction aa = (ProxyAction) aci.getAction();
String img = null;
if (enabled) {
img = CoreImages.PROXY_ENABLED;
} else {
img = CoreImages.PROXY;
}
aa.setImageDescriptor(ImageDescriptor.createFromImage(ResourceUtils.getImage(CoreConstants.PLUGIN_UI, img)));
}
}
}
}
示例4: run
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
@Override
public void run() {
IContributionItem[] items = toolBarManager.getItems();
for (int i = 0; i < items.length; i++) {
ActionContributionItem item = (ActionContributionItem) items[i];
if (item.getAction() == this) {
select(i);
/*
* We set focus to the tabbed property composite so that
* focus is moved to the appropriate widget in the section.
*/
Composite tabbedPropertyComposite = cBar.getParent();
while (!(tabbedPropertyComposite instanceof TabbedPropertyComposite)) {
tabbedPropertyComposite = tabbedPropertyComposite
.getParent();
}
tabbedPropertyComposite.setFocus();
}
}
}
示例5: AdvancedMenuForActions
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
/**
* @param actionContributionItem
*/
public AdvancedMenuForActions(final ActionContributionItem actionContributionItem) {
_actionContributionItem = actionContributionItem;
final IAction action = actionContributionItem.getAction();
if (action instanceof IAdvancedMenuForActions) {
((IAdvancedMenuForActions) action).setAdvancedMenuProvider(this);
}
_display = Display.getCurrent();
_animationRunnable = new Runnable() {
@Override
public void run() {
onAnimation20Run(this);
}
};
}
示例6: clearOldRestoreLibraryPropertiesAction
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
private void clearOldRestoreLibraryPropertiesAction( )
{
IContributionItem[] items = getSite( ).getActionBars( )
.getToolBarManager( )
.getItems( );
for ( IContributionItem item : items )
{
if ( item instanceof ActionContributionItem )
{
ActionContributionItem aItem = (ActionContributionItem) item;
if ( aItem.getAction( ) instanceof RestoreLibraryPropertiesAction )
{
getSite( ).getActionBars( )
.getToolBarManager( )
.remove( item );
}
}
}
}
示例7: getPyUnitViewAction
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
protected IAction getPyUnitViewAction(ViewPart view, Class<?> class1) {
IAction action = null;
IContributionItem[] items = view.getViewSite().getActionBars().getToolBarManager().getItems();
for (IContributionItem iContributionItem : items) {
if (iContributionItem instanceof ActionContributionItem) {
ActionContributionItem item = (ActionContributionItem) iContributionItem;
IAction lAction = item.getAction();
if (class1.isInstance(lAction)) {
action = lAction;
}
}
}
if (action == null) {
fail("Could not find action of class: " + class1);
}
return action;
}
示例8: fillContextMenu
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
private void fillContextMenu(IMenuManager manager, List<IContributionItem> contributionItems){
manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
for (IContributionItem contributionItem : contributionItems) {
if (contributionItem == null) {
manager.add(new Separator());
continue;
} else if (contributionItem instanceof ActionContributionItem) {
ActionContributionItem ac = (ActionContributionItem) contributionItem;
if (ac.getAction() instanceof RestrictedAction) {
((RestrictedAction) ac.getAction()).reflectRight();
}
}
contributionItem.update();
manager.add(contributionItem);
}
}
示例9: createRegionActions
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
private IAction createRegionActions() {
final String regionViewName = PlotUtil.getRegionViewName();
final ToolTip tip = new ToolTip(viewer.getTable().getShell(), SWT.BALLOON);
MenuAction rois = new MenuAction("Add Region");
ActionContributionItem menu = (ActionContributionItem)system.getActionBars().getMenuManager().find(BasePlottingConstants.ADD_REGION);
IAction menuAction = (IAction)menu.getAction();
for (RegionType regionType : regionTypes) {
IAction action = new Action("Press to click and drag a "+regionType.getName()+" on '"+PlotUtil.getRegionViewName()+"'") {
@Override
public void run() {
try {
ScanRegions.createRegion(system, regionType, null);
ViewUtil.showTip(tip, "Click and drag in the '"+regionViewName+"' to create a scan region.");
} catch (Exception e) {
logger.error("Unable to create region!", e);
}
rois.setSelectedAction(this);
}
};
final ImageDescriptor des = findImageDescriptor(menuAction, regionType.getId());
action.setImageDescriptor(des);
rois.add(action);
}
rois.setSelectedAction(rois.getAction(0));
return rois;
}
示例10: createMenu
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
/**
* Recursive method to create a menu from the contribute items of a manger
*
* @param menu actual menu
* @param items manager contributor items
*/
private void createMenu(Menu menu, IContributionItem[] items){
for(IContributionItem item : items){
if (item instanceof MenuManager){
MenuManager manager = (MenuManager) item;
MenuItem subMenuItem = new MenuItem(menu,SWT.CASCADE);
subMenuItem.setText(manager.getMenuText());
Menu subMenu = new Menu(Display.getCurrent().getActiveShell(), SWT.DROP_DOWN);
subMenuItem.setMenu(subMenu);
createMenu(subMenu, manager.getItems());
} else if (item instanceof ActionContributionItem){
ActionContributionItem actionItem = (ActionContributionItem) item;
if (actionItem.getAction() instanceof CustomSelectionAction){
final CustomSelectionAction action = (CustomSelectionAction)actionItem.getAction();
MenuItem actionEnrty = new MenuItem(menu,SWT.CHECK);
action.setSelection(getLastRawSelection());
actionEnrty.setText(actionItem.getAction().getText());
actionEnrty.setSelection(action.isChecked());
actionEnrty.setEnabled(action.canExecute());
actionEnrty.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
action.run();
}
});
}
}
}
}
示例11: createMenu
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
/**
* Recursive method to create a menu from the contribute items of a manger
*
* @param menu actual menu
* @param items manager contributor items
*/
private void createMenu(Menu menu, IContributionItem[] items){
for(IContributionItem item : items){
if (item instanceof MenuManager){
MenuManager manager = (MenuManager) item;
MenuItem subMenuItem = new MenuItem(menu,SWT.CASCADE);
subMenuItem.setText(manager.getMenuText());
Menu subMenu = new Menu(Display.getCurrent().getActiveShell(), SWT.DROP_DOWN);
subMenuItem.setMenu(subMenu);
createMenu(subMenu, manager.getItems());
} else if (item instanceof ActionContributionItem){
ActionContributionItem actionItem = (ActionContributionItem) item;
if (actionItem.getAction() instanceof CustomSelectionAction){
final CustomSelectionAction action = (CustomSelectionAction)actionItem.getAction();
MenuItem actionEnrty = new MenuItem(menu,SWT.CHECK);
action.setSelection(getSelection());
actionEnrty.setText(actionItem.getAction().getText());
actionEnrty.setSelection(action.isChecked());
actionEnrty.setEnabled(action.canExecute());
actionEnrty.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
action.run();
}
});
}
}
}
}
示例12: createPartControl
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
@SuppressWarnings ("deprecation")
@Override
public void createPartControl(final Composite compo) {
this.parent = GamaToolbarFactory.createToolbars(this, compo);
super.createPartControl(parent);
final IToolBarManager toolbar = getViewSite().getActionBars().getToolBarManager();
for (final IContributionItem item : toolbar.getItems()) {
if (item instanceof ActionContributionItem) {
final ActionContributionItem aci = (ActionContributionItem) item;
final IAction action = aci.getAction();
if (action instanceof LinkEditorAction) {
link = action;
toolbar.remove(aci);
} else if (action instanceof org.eclipse.ui.internal.navigator.actions.CollapseAllAction) {
toolbar.remove(aci);
}
}
}
linkItem.setSelection(link.isChecked());
toolbar.update(true);
// linkItem.setSelection(link.isChecked());
// final Action a = linkCommand.toCheckAction();
// a.setChecked(link.isChecked());
// toolbar.insertBefore("toolbar.toggle", a);
toolbar.insertBefore("toolbar.toggle", byDate.toCheckAction());
toolbar.insertBefore("toolbar.toggle", expandAll.toAction());
toolbar.insertBefore(expandAll.getId(), collapseAll.toAction());
try {
final IDecoratorManager mgr = PlatformUI.getWorkbench().getDecoratorManager();
mgr.setEnabled("msi.gama.application.date.decorator", false);
} catch (final CoreException e) {
e.printStackTrace();
}
properties =
new PropertyDialogAction(new SameShellProvider(getSite().getShell()), getSite().getSelectionProvider());
findControl.initialize();
}
示例13: run
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
@Override
public void run() {
for(ActionContributionItem item : items) {
IAction action = item.getAction();
if(action.isChecked()) {
action.run();
}
}
}
示例14: updateAutoSyncToggleButtonState
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
private void updateAutoSyncToggleButtonState() {
IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
ActionContributionItem autoSyncToggleContribution = (ActionContributionItem) toolBarManager
.find("com.abstratt.imageviewer.autoUpdate");
if (autoSyncToggleContribution != null) {
IAction action = autoSyncToggleContribution.getAction();
action.setChecked(isAutoSync());
}
}
示例15: init
import org.eclipse.jface.action.ActionContributionItem; //导入方法依赖的package包/类
@Override
public void init(IActionBars bars, IWorkbenchPage page)
{
super.init(bars, page);
for (LayerDefinition def : Activator.getLayerDefinitions().values())
{
Class<? extends IEditorActionBarContributor> clazz = def.getActionBarContributorClass();
if (clazz != null) try
{
IEditorActionBarContributor c = clazz.newInstance();
c.init(bars, page);
contributors.put(def.getName(), c);
}
catch (InstantiationException | IllegalAccessException e)
{
e.printStackTrace();
}
}
ToolBarManager toolBarManager = (ToolBarManager) bars.getToolBarManager();
IContributionItem[] items = toolBarManager.getItems();
for (int i = 0; i < items.length; i++)
{
if (items[i] instanceof ActionContributionItem)
{
ActionContributionItem item = (ActionContributionItem) items[i];
IAction action = item.getAction();
if (action instanceof EditorToolAction)
{
toolBarManager.remove(items[i]);
SaveActionContributionItem ci = new SaveActionContributionItem(action);
toolBarManager.insert(i, ci);
actions.put(action.getId(), ci);
action.addPropertyChangeListener(this);
}
}
}
setActiveTool(TerrainEditor.ACTION_CURSOR);
}