下面列出了org.eclipse.jface.text.information.IInformationProvider#org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* {@inheritDoc}
*/
public void init(IWorkbenchWindow window) {
disposeSubmenuActions(); // paranoia code: double initialization should not happen
if (window != null) {
fPartService= window.getPartService();
if (fPartService != null) {
fRetargetActions= new RetargetAction[] {
createSubmenuAction(fPartService, JdtActionConstants.FIND_OCCURRENCES_IN_FILE, ActionMessages.OccurrencesSearchMenuAction_occurrences_in_file_label, IJavaEditorActionDefinitionIds.SEARCH_OCCURRENCES_IN_FILE),
createSubmenuAction(fPartService, JdtActionConstants.FIND_IMPLEMENT_OCCURRENCES, ActionMessages.OccurrencesSearchMenuAction_implementing_methods_label, IJavaEditorActionDefinitionIds.SEARCH_IMPLEMENT_OCCURRENCES_IN_FILE),
createSubmenuAction(fPartService, JdtActionConstants.FIND_EXCEPTION_OCCURRENCES, ActionMessages.OccurrencesSearchMenuAction_throwing_exception_label, IJavaEditorActionDefinitionIds.SEARCH_EXCEPTION_OCCURRENCES_IN_FILE),
createSubmenuAction(fPartService, JdtActionConstants.FIND_METHOD_EXIT_OCCURRENCES, ActionMessages.OccurrencesSearchMenuAction_method_exits_label, IJavaEditorActionDefinitionIds.SEARCH_METHOD_EXIT_OCCURRENCES),
createSubmenuAction(fPartService, JdtActionConstants.FIND_BREAK_CONTINUE_TARGET_OCCURRENCES, ActionMessages.OccurrencesSearchMenuAction_break_continue_target_label, IJavaEditorActionDefinitionIds.SEARCH_BREAK_CONTINUE_TARGET_OCCURRENCES)
};
}
}
}
/**
* Note: This constructor is for internal use only. Clients should not call
* this constructor.
*
* @param editor the Java editor
*/
public GWTOpenEditorActionGroup(JavaEditor editor) {
isEditorOwner = true;
openAction = new GWTOpenAction(editor);
openAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR);
editor.setAction("OpenEditor", openAction); //$NON-NLS-1$
site = editor.getEditorSite();
initialize(site.getSelectionProvider());
}
/**
* WARNING: only works in workbench window context!
* @return the keybinding for Refactor > Rename
*/
private static String getOpenDialogBinding() {
IBindingService bindingService= (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
if (bindingService == null)
return ""; //$NON-NLS-1$
String binding= bindingService.getBestActiveBindingFormattedFor(IJavaEditorActionDefinitionIds.RENAME_ELEMENT);
return binding == null ? "" : binding; //$NON-NLS-1$
}
@Override
protected void createActions() {
super.createActions();
IAction action= new ToggleCommentAction(PropertiesFileEditorMessages.getBundleForConstructedKeys(), "ToggleComment.", this); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.TOGGLE_COMMENT);
setAction(IJavaEditorActionDefinitionIds.TOGGLE_COMMENT, action);
markAsStateDependentAction(IJavaEditorActionDefinitionIds.TOGGLE_COMMENT, true);
PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
configureToggleCommentAction();
fOpenAction= new OpenAction(this);
fOpenAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR);
setAction(JdtActionConstants.OPEN, fOpenAction);
}
/**
* Configures the toggle comment action.
*
* @since 3.4
*/
private void configureToggleCommentAction() {
IAction action= getAction(IJavaEditorActionDefinitionIds.TOGGLE_COMMENT);
if (action instanceof ToggleCommentAction) {
ISourceViewer sourceViewer= getSourceViewer();
SourceViewerConfiguration configuration= getSourceViewerConfiguration();
((ToggleCommentAction)action).configure(sourceViewer, configuration);
}
}
@Override
public void editorContextMenuAboutToShow(IMenuManager menu) {
super.editorContextMenuAboutToShow(menu);
menu.insertAfter(IContextMenuConstants.GROUP_OPEN, new GroupMarker(IContextMenuConstants.GROUP_SHOW));
ActionContext context= new ActionContext(getSelectionProvider().getSelection());
fContextMenuGroup.setContext(context);
fContextMenuGroup.fillContextMenu(menu);
fContextMenuGroup.setContext(null);
//Breadcrumb
IAction action= getAction(IJavaEditorActionDefinitionIds.SHOW_IN_BREADCRUMB);
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action);
// Quick views
action= getAction(IJavaEditorActionDefinitionIds.SHOW_OUTLINE);
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action);
action= getAction(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY);
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, action);
// Copy qualified name
action= getAction(IJavaEditorActionConstants.COPY_QUALIFIED_NAME);
if (menu.find(ITextEditorActionConstants.COPY) != null)
menu.insertAfter(ITextEditorActionConstants.COPY, action);
else
addAction(menu, ITextEditorActionConstants.GROUP_COPY, IJavaEditorActionConstants.COPY_QUALIFIED_NAME);
}
/**
* Constructs and updates the action.
*/
public ToggleTextHoverAction() {
super(JavaEditorMessages.getBundleForConstructedKeys(), "ToggleTextHover.", null); //$NON-NLS-1$
JavaPluginImages.setToolImageDescriptors(this, "jdoc_hover_edit.gif"); //$NON-NLS-1$
setActionDefinitionId(IJavaEditorActionDefinitionIds.TOGGLE_TEXT_HOVER);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.TOGGLE_TEXTHOVER_ACTION);
update();
}
@Override
public void init(IActionBars bars, IWorkbenchPage page) {
fToggleBreadcrumbAction= new ToggleBreadcrumbAction(page);
Iterator<RetargetAction> e= fPartListeners.iterator();
while (e.hasNext())
page.addPartListener(e.next());
super.init(bars, page);
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
bars.setGlobalActionHandler(IJavaEditorActionDefinitionIds.TOGGLE_MARK_OCCURRENCES, fToggleMarkOccurrencesAction);
bars.setGlobalActionHandler(IJavaEditorActionDefinitionIds.TOGGLE_BREADCRUMB, fToggleBreadcrumbAction);
}
static SurroundWithTryCatchAction createSurroundWithTryCatchAction(CompilationUnitEditor editor) {
SurroundWithTryCatchAction result= new SurroundWithTryCatchAction(editor);
result.setText(ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTryCatchActionName);
result.setImageDescriptor(JavaPluginImages.getDescriptor(JavaPluginImages.IMG_CORRECTION_CHANGE));
result.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_CATCH);
editor.setAction("SurroundWithTryCatch", result); //$NON-NLS-1$
return result;
}
static SurroundWithTryMultiCatchAction createSurroundWithTryMultiCatchAction(CompilationUnitEditor editor) {
SurroundWithTryMultiCatchAction result= new SurroundWithTryMultiCatchAction(editor);
result.setText(ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTryMultiCatchActionName);
result.setImageDescriptor(JavaPluginImages.getDescriptor(JavaPluginImages.IMG_CORRECTION_CHANGE));
result.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_MULTI_CATCH);
editor.setAction("SurroundWithTryMultiCatch", result); //$NON-NLS-1$
return result;
}
@Override
protected void createActions() {
super.createActions();
//Disable unsupported actions for groovy editor inside dialogs
setAction(ITextEditorActionConstants.FIND, null);
setAction(IJavaEditorActionDefinitionIds.SHOW_OUTLINE, null);
setAction(IJavaEditorActionDefinitionIds.EXTRACT_CLASS, null);
setAction(IJavaEditorActionDefinitionIds.EXTERNALIZE_STRINGS, null);
setAction(IJavaEditorActionDefinitionIds.EXTRACT_INTERFACE, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_CALL_HIERARCHY, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_EDITOR, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_HYPERLINK, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_IMPLEMENTATION, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_ATTACHED_JAVADOC, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_STRUCTURE, null);
setAction(IJavaEditorActionDefinitionIds.SHOW_IN_BREADCRUMB, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY, null);
setAction(IJavaEditorActionDefinitionIds.PULL_UP, null);
setAction(IJavaEditorActionDefinitionIds.PUSH_DOWN, null);
setAction(IJavaEditorActionDefinitionIds.SHOW_IN_NAVIGATOR_VIEW, null);
setAction(IJavaEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_HIERARCHY, null);
setAction(IJavaEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_PROJECTS, null);
setAction(IJavaEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKING_SET, null);
setAction(IJavaEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKSPACE, null);
if (fActionGroups != null) {
fActionGroups.dispose();
fActionGroups = null;
}
}
@Override
protected void createActions() {
super.createActions();
//Disable unsupported actions for groovy editor inside dialogs
setAction(ITextEditorActionConstants.FIND, null);
setAction(IJavaEditorActionDefinitionIds.SHOW_OUTLINE, null);
setAction(IJavaEditorActionDefinitionIds.EXTRACT_CLASS, null);
setAction(IJavaEditorActionDefinitionIds.EXTERNALIZE_STRINGS, null);
setAction(IJavaEditorActionDefinitionIds.EXTRACT_INTERFACE, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_CALL_HIERARCHY, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_EDITOR, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_HYPERLINK, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_IMPLEMENTATION, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_ATTACHED_JAVADOC, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_STRUCTURE, null);
setAction(IJavaEditorActionDefinitionIds.SHOW_IN_BREADCRUMB, null);
setAction(IJavaEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY, null);
setAction(IJavaEditorActionDefinitionIds.PULL_UP, null);
setAction(IJavaEditorActionDefinitionIds.PUSH_DOWN, null);
setAction(IJavaEditorActionDefinitionIds.SHOW_IN_NAVIGATOR_VIEW, null);
setAction(IJavaEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_HIERARCHY, null);
setAction(IJavaEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_PROJECTS, null);
setAction(IJavaEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKING_SET, null);
setAction(IJavaEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKSPACE, null);
if (fActionGroups != null) {
fActionGroups.dispose();
fActionGroups = null;
}
}
@Override
protected void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
actionBars.setGlobalActionHandler(JdtActionConstants.OPEN, fOpen);
fOpen.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR);
}
@Override
protected void editorContextMenuAboutToShow(IMenuManager menu) {
super.editorContextMenuAboutToShow(menu);
addAction(menu, ITextEditorActionConstants.GROUP_EDIT, IJavaEditorActionDefinitionIds.TOGGLE_COMMENT);
}
@Override
public String getCommandId() {
return IJavaEditorActionDefinitionIds.RENAME_ELEMENT;
}
public BreadcrumbActionGroup(JavaEditor javaEditor) {
fGoToEditor= new GoToEditorAction(javaEditor);
fGoToEditor.setActionDefinitionId(IJavaEditorActionDefinitionIds.SHOW_IN_BREADCRUMB);
fHideBreadcrumb= new ToggleBreadcrumbAction(javaEditor.getSite().getPage(), true);
fHideBreadcrumb.setActionDefinitionId(IJavaEditorActionDefinitionIds.TOGGLE_BREADCRUMB);
}
@Override
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
actionBars.setGlobalActionHandler(IJavaEditorActionDefinitionIds.SHOW_IN_BREADCRUMB, fGoToEditor);
}
/**
* @deprecated As of 3.5, got replaced by generic Navigate > Show In >
*/
private void createDeprecatedShowInPackageExplorerAction() {
IAction action= new org.eclipse.jdt.ui.actions.ShowInPackageViewAction(this);
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.SHOW_IN_PACKAGE_VIEW);
setAction("ShowInPackageView", action); //$NON-NLS-1$
}
public BasicJavaEditorActionContributor() {
super();
ResourceBundle b= JavaEditorMessages.getBundleForConstructedKeys();
fRetargetShowInformationAction= new RetargetTextEditorAction(b, "Editor.ShowInformation."); //$NON-NLS-1$
fRetargetShowInformationAction.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
// actions that are "contributed" to editors, they are considered belonging to the active editor
fTogglePresentation= new TogglePresentationAction();
fToggleMarkOccurrencesAction= new ToggleMarkOccurrencesAction();
fGotoMatchingBracket= new RetargetTextEditorAction(b, "GotoMatchingBracket."); //$NON-NLS-1$
fGotoMatchingBracket.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
fShowOutline= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "ShowOutline."); //$NON-NLS-1$
fShowOutline.setActionDefinitionId(IJavaEditorActionDefinitionIds.SHOW_OUTLINE);
fOpenHierarchy= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "OpenHierarchy."); //$NON-NLS-1$
fOpenHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_HIERARCHY);
fOpenStructure= new RetargetTextEditorAction(JavaEditorMessages.getBundleForConstructedKeys(), "OpenStructure."); //$NON-NLS-1$
fOpenStructure.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_STRUCTURE);
fStructureSelectEnclosingAction= new RetargetTextEditorAction(b, "StructureSelectEnclosing."); //$NON-NLS-1$
fStructureSelectEnclosingAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_ENCLOSING);
fStructureSelectNextAction= new RetargetTextEditorAction(b, "StructureSelectNext."); //$NON-NLS-1$
fStructureSelectNextAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_NEXT);
fStructureSelectPreviousAction= new RetargetTextEditorAction(b, "StructureSelectPrevious."); //$NON-NLS-1$
fStructureSelectPreviousAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_PREVIOUS);
fStructureSelectHistoryAction= new RetargetTextEditorAction(b, "StructureSelectHistory."); //$NON-NLS-1$
fStructureSelectHistoryAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SELECT_LAST);
fGotoNextMemberAction= new RetargetTextEditorAction(b, "GotoNextMember."); //$NON-NLS-1$
fGotoNextMemberAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
fGotoPreviousMemberAction= new RetargetTextEditorAction(b, "GotoPreviousMember."); //$NON-NLS-1$
fGotoPreviousMemberAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
fRemoveOccurrenceAnnotationsAction= new RetargetTextEditorAction(b, "RemoveOccurrenceAnnotations."); //$NON-NLS-1$
fRemoveOccurrenceAnnotationsAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.REMOVE_OCCURRENCE_ANNOTATIONS);
}
public HierarchyInformationControl(Shell parent, int shellStyle, int treeStyle) {
super(parent, shellStyle, treeStyle, IJavaEditorActionDefinitionIds.OPEN_HIERARCHY, true);
fOtherExpandedElements= null;
fDoFilter= true;
fMethodOverrideTester= null;
}
public String getCommandId() {
return IJavaEditorActionDefinitionIds.RENAME_ELEMENT;
}
/**
* Creates a new <code>GWTOpenEditorActionGroup</code>. The group requires
* that the selection provided by the part's selection provider is of type
* <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param part the view part that owns this action group
*/
public GWTOpenEditorActionGroup(IViewPart part) {
site = part.getSite();
openAction = new GWTOpenAction(site);
openAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EDITOR);
initialize(site.getSelectionProvider());
}