类org.eclipse.ui.actions.ActionGroup源码实例Demo

下面列出了怎么用org.eclipse.ui.actions.ActionGroup的API类实例代码及写法,或者点击链接到github查看源代码。


/**
 * Overwrite the OpenEditorActionGroup in the CompositeActionGroup with our
 * custom GWTOpenEditorActionGroup that contains our JSNI-aware GWTOpenAction.
 */
private void replaceOpenEditorAction(CompositeActionGroup actionGroup,
    GWTOpenEditorActionGroup newAction) throws Exception {

  // The fGroups backing array in CompositeActionGroup is private, so we have
  // to resort to reflection to update it.
  Field groupsField = CompositeActionGroup.class.getDeclaredField("fGroups");
  groupsField.setAccessible(true);
  ActionGroup[] actionGroups = (ActionGroup[]) groupsField.get(actionGroup);

  // Search the ActionGroup array and replace the OpenEditorActionGroup
  for (int i = 0; i < actionGroups.length; i++) {
    if (actionGroups[i] instanceof OpenEditorActionGroup) {
      actionGroups[i] = newAction;
      return;
    }
  }

  throw new Exception("No existing OpenEditorActionGroup found");
}
 

public JavaEditorBreadcrumbActionGroup(JavaEditor javaEditor, ISelectionProvider selectionProvider) {
	super(new ActionGroup[] {
			new BreadcrumbActionGroup(javaEditor),
			new UndoRedoActionGroup(javaEditor.getEditorSite(), (IUndoContext) ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class), true),
			new NewWizardsActionGroup(javaEditor.getEditorSite()),
			new JavaSearchActionGroup(javaEditor.getEditorSite(), selectionProvider),
			new NavigateActionGroup(javaEditor.getEditorSite(), selectionProvider),
			new CCPActionGroup(javaEditor.getEditorSite(), selectionProvider),
			new GenerateBuildPathActionGroup(javaEditor.getEditorSite(), selectionProvider),
			new GenerateActionGroup(javaEditor.getEditorSite(), selectionProvider),
			new RefactorActionGroup(javaEditor.getEditorSite(), selectionProvider),
			new BuildActionGroup(javaEditor.getEditorSite(), selectionProvider),
			new ProjectActionGroup(javaEditor.getEditorSite(), selectionProvider),
			new WorkingSetActionGroup(javaEditor.getEditorSite(), selectionProvider)
	});
}
 

@Override
protected void createActions() {
	super.createActions();

	setAction(ITextEditorActionConstants.SAVE, null);
	setAction(ITextEditorActionConstants.REVERT_TO_SAVED, null);

	fSourceCopyAction= getAction(ITextEditorActionConstants.COPY);
	fSelectAllAction= getAction(ITextEditorActionConstants.SELECT_ALL);

	final ActionGroup group= new RefactorActionGroup(this, ITextEditorActionConstants.GROUP_EDIT, true);
	fActionGroups.addGroup(group);
	fContextMenuGroup= new CompositeActionGroup(new ActionGroup[] {group});

	/*
	 * 1GF82PL: ITPJUI:ALL - Need to be able to add bookmark to class file
	 *
	 *  // replace default action with class file specific ones
	 *
	 *	setAction(ITextEditorActionConstants.BOOKMARK, new AddClassFileMarkerAction("AddBookmark.", this, IMarker.BOOKMARK, true)); //$NON-NLS-1$
	 *	setAction(ITextEditorActionConstants.ADD_TASK, new AddClassFileMarkerAction("AddTask.", this, IMarker.TASK, false)); //$NON-NLS-1$
	 *	setAction(ITextEditorActionConstants.RULER_MANAGE_BOOKMARKS, new ClassFileMarkerRulerAction("ManageBookmarks.", getVerticalRuler(), this, IMarker.BOOKMARK, true)); //$NON-NLS-1$
	 *	setAction(ITextEditorActionConstants.RULER_MANAGE_TASKS, new ClassFileMarkerRulerAction("ManageTasks.", getVerticalRuler(), this, IMarker.TASK, true)); //$NON-NLS-1$
	 */
}
 

public void addGroup(ActionGroup group) {
	if (fGroups == null) {
		fGroups= new ActionGroup[] { group };
	} else {
		ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
		System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
		newGroups[fGroups.length]= group;
		fGroups= newGroups;
	}
}
 
源代码5 项目: gama   文件: GamaNavigator.java

@Override
protected ActionGroup createCommonActionGroup() {
	return new CommonNavigatorActionGroup(this, getCommonViewer(), getLinkHelperService()) {

		@Override
		protected void fillViewMenu(final IMenuManager menu) {
			menu.removeAll();
		}

	};
}
 

public NewSearchViewActionGroup(IViewPart part) {
	Assert.isNotNull(part);
	OpenViewActionGroup openViewActionGroup;
	setGroups(new ActionGroup[]{
		new OpenEditorActionGroup(part),
		openViewActionGroup= new OpenViewActionGroup(part),
		new GenerateActionGroup(part),
		new RefactorActionGroup(part),
		new JavaSearchActionGroup(part)
	});
	openViewActionGroup.containsShowInMenu(false);
}
 

public void addGroup(ActionGroup group) {
	if (fGroups == null) {
		fGroups= new ActionGroup[] { group };
	} else {
		ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
		System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
		newGroups[fGroups.length]= group;
		fGroups= newGroups;
	}
}
 

protected void createActions() {
	fActionGroups= new CompositeActionGroup(new ActionGroup[] {
			new NewWizardsActionGroup(this.getSite()),
			fOpenEditorGroup= new OpenEditorActionGroup(this),
			new OpenViewActionGroup(this),
			fCCPActionGroup= new CCPActionGroup(this),
			new GenerateActionGroup(this),
			new RefactorActionGroup(this),
			new ImportActionGroup(this),
			fBuildActionGroup= new BuildActionGroup(this),
			new JavaSearchActionGroup(this)});


	if (fHasWorkingSetFilter) {
		String viewId= getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
		Assert.isNotNull(viewId);
		IPropertyChangeListener workingSetListener= new IPropertyChangeListener() {
			public void propertyChange(PropertyChangeEvent event) {
				doWorkingSetChanged(event);
			}
		};
		fWorkingSetFilterActionGroup= new WorkingSetFilterActionGroup(getSite(), workingSetListener);
		fViewer.addFilter(fWorkingSetFilterActionGroup.getWorkingSetFilter());
	}

	// Custom filter group
	if (fHasCustomFilter)
		fCustomFiltersActionGroup= new CustomFiltersActionGroup(this, fViewer);

	fToggleLinkingAction= new ToggleLinkingAction(this);
	fToggleLinkingAction.setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR);
}
 

/**
 * {@inheritDoc}
 */
@Override
public void fillActionBars(IActionBars actionBars) {
	super.fillActionBars(actionBars);
	fMenuManager= actionBars.getMenuManager();
	fillViewMenu(fMenuManager);

	if (fActiveActionGroup == null)
		fActiveActionGroup= fFilterActionGroup;
	((ActionGroup)fActiveActionGroup).fillActionBars(actionBars);
}
 
源代码10 项目: xds-ide   文件: ModulaEditor.java

protected ActionGroup createOpenViewActionGroup() {
	return new OpenViewActionGroup(this);
}
 
源代码11 项目: xds-ide   文件: ModulaEditor.java

protected ActionGroup createDeclarationsSearchGroup() {
	return new DeclarationsSearchGroup(this);
}
 
源代码12 项目: xds-ide   文件: ModulaEditor.java

protected ActionGroup createReferencesSearchGroup() {
	return new ReferencesSearchGroup(this);
}
 

public CompositeActionGroup(ActionGroup[] groups) {
	setGroups(groups);
}
 

protected void setGroups(ActionGroup[] groups) {
	Assert.isTrue(fGroups == null);
	Assert.isNotNull(groups);
	fGroups= groups;		
}
 

public ActionGroup get(int index) {
	if (fGroups == null)
		return null;
	return fGroups[index];
}
 
源代码16 项目: typescript.java   文件: TypeScriptEditor.java

protected ActionGroup getActionGroup() {
	return fActionGroups;
}
 

private void makeActions() {
      fRefreshViewAction = new RefreshViewAction(this);
      fRefreshSingleElementAction= new RefreshElementAction(fCallHierarchyViewer);

new CallHierarchyOpenEditorHelper(fLocationViewer);
new CallHierarchyOpenEditorHelper(fCallHierarchyViewer);

fOpenLocationAction= new OpenLocationAction(this, getSite());
fLocationCopyAction= fLocationViewer.initCopyAction(getViewSite(), fClipboard);
      fFocusOnSelectionAction = new FocusOnSelectionAction(this);
      fCopyAction= new CopyCallHierarchyAction(this, fClipboard, fCallHierarchyViewer);
      fSearchScopeActions = new SearchScopeActionGroup(this, fDialogSettings);
      fShowSearchInDialogAction= new ShowSearchInDialogAction(this, fCallHierarchyViewer);
      fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this,
              fCallHierarchyViewer);
      fHistoryDropDownAction = new HistoryDropDownAction(this);
      fHistoryDropDownAction.setEnabled(false);
      fCancelSearchAction = new CancelSearchAction(this);
      setCancelEnabled(false);
      fExpandWithConstructorsAction= new ExpandWithConstructorsAction(this, fCallHierarchyViewer);
      fRemoveFromViewAction= new RemoveFromViewAction(this, fCallHierarchyViewer);
      fPinViewAction= new PinCallHierarchyViewAction(this);
      fToggleOrientationActions = new ToggleOrientationAction[] {
              new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
              new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL),
              new ToggleOrientationAction(this, VIEW_ORIENTATION_AUTOMATIC),
              new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE)
          };
fRemoveFromViewAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
      fToggleCallModeActions = new ToggleCallModeAction[] {
              new ToggleCallModeAction(this, CALL_MODE_CALLERS),
              new ToggleCallModeAction(this, CALL_MODE_CALLEES)
          };
      fToggleFieldModeActions = new SelectFieldModeAction[] {
              new SelectFieldModeAction(this, IJavaSearchConstants.REFERENCES),
              new SelectFieldModeAction(this, IJavaSearchConstants.READ_ACCESSES),
              new SelectFieldModeAction(this, IJavaSearchConstants.WRITE_ACCESSES)
          };
      fActionGroups = new CompositeActionGroup(new ActionGroup[] {
                  new OpenEditorActionGroup(this),
                  new OpenViewActionGroup(this),
			new CCPActionGroup(this, true),
                  new GenerateActionGroup(this),
                  new RefactorActionGroup(this),
                  new JavaSearchActionGroup(this),
                  fSearchScopeActions, fFiltersActionGroup
              });
  }
 

@Override
protected ActionGroup createContextMenuActionGroup(ISelectionProvider selectionProvider) {
	return new JavaEditorBreadcrumbActionGroup(getJavaEditor(), selectionProvider);
}
 

public CompositeActionGroup(ActionGroup[] groups) {
	setGroups(groups);
}
 

protected void setGroups(ActionGroup[] groups) {
	Assert.isTrue(fGroups == null);
	Assert.isNotNull(groups);
	fGroups= groups;
}
 
源代码21 项目: birt   文件: ReportLayoutEditorBreadcrumb.java

@Override
protected ActionGroup createContextMenuActionGroup(
		ISelectionProvider selectionProvider )
{
	return null;
}
 

@Override
public void setContext(ActionContext context) {
	for(ActionGroup actionGroup : actionGroups) {
		actionGroup.setContext(context);
	}
}
 

@Override
public void fillActionBars(IActionBars actionBars) {
	for(ActionGroup actionGroup : actionGroups) {
		actionGroup.fillActionBars(actionBars);
	}
}
 

@Override
public void fillContextMenu(IMenuManager menu) {
	for(ActionGroup actionGroup : actionGroups) {
		actionGroup.fillContextMenu(menu);
	}
}
 

/**
 * Create an action group for the context menu shown for the selection of the given selection
 * provider or <code>null</code> if no context menu should be shown.
 *
 * @param selectionProvider the provider of the context selection
 * @return action group to use to fill the context menu or <code>null</code>
 */
protected abstract ActionGroup createContextMenuActionGroup(ISelectionProvider selectionProvider);
 

/**
 * Returns the standard action group of this editor.
 *
 * @return returns this editor's standard action group
 */
protected ActionGroup getActionGroup() {
	return fActionGroups;
}
 
源代码27 项目: birt   文件: EditorBreadcrumb.java

/**
 * Create an action group for the context menu shown for the selection of
 * the given selection provider or <code>null</code> if no context menu
 * should be shown.
 * 
 * @param selectionProvider
 *            the provider of the context selection
 * @return action group to use to fill the context menu or <code>null</code>
 */
protected abstract ActionGroup createContextMenuActionGroup(
		ISelectionProvider selectionProvider );
 
 类所在包
 类方法
 同包方法