下面列出了怎么用org.eclipse.ui.IWorkbenchSite的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Returns an OSGi service from {@link ExecutionEvent}. It looks up a service in the following
* locations (if exist) in the given order:
*
* {@code HandlerUtil.getActiveSite(event)}
* {@code HandlerUtil.getActiveEditor(event).getEditorSite()}
* {@code HandlerUtil.getActiveEditor(event).getSite()}
* {@code HandlerUtil.getActiveWorkbenchWindow(event)}
* {@code PlatformUI.getWorkbench()}
*/
public static <T> T getService(ExecutionEvent event, Class<T> api) {
IWorkbenchSite activeSite = HandlerUtil.getActiveSite(event);
if (activeSite != null) {
return activeSite.getService(api);
}
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor != null) {
IEditorSite editorSite = activeEditor.getEditorSite();
if (editorSite != null) {
return editorSite.getService(api);
}
IWorkbenchPartSite site = activeEditor.getSite();
if (site != null) {
return site.getService(api);
}
}
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
if (workbenchWindow != null) {
return workbenchWindow.getService(api);
}
return PlatformUI.getWorkbench().getService(api);
}
/**
* Creates a new <code>ReferencesSearchGroup</code>. The group requires
* that the selection provided by the given selection provider is of type
* {@link IStructuredSelection}.
*
* @param site the site that will own the action group.
* @param specialSelectionProvider the selection provider used instead of the
* sites selection provider.
*
* @since 3.4
*/
public ReferencesSearchGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider) {
fSite= site;
fGroupId= IContextMenuConstants.GROUP_SEARCH;
fFindReferencesAction= new FindReferencesAction(site);
fFindReferencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKSPACE);
fFindReferencesInProjectAction= new FindReferencesInProjectAction(site);
fFindReferencesInProjectAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_PROJECT);
fFindReferencesInHierarchyAction= new FindReferencesInHierarchyAction(site);
fFindReferencesInHierarchyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY);
fFindReferencesInWorkingSetAction= new FindReferencesInWorkingSetAction(site);
fFindReferencesInWorkingSetAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKING_SET);
// register the actions as selection listeners
ISelectionProvider provider= specialSelectionProvider == null ? fSite.getSelectionProvider() : specialSelectionProvider;
ISelection selection= provider.getSelection();
registerAction(fFindReferencesAction, provider, selection, specialSelectionProvider);
registerAction(fFindReferencesInProjectAction, provider, selection, specialSelectionProvider);
registerAction(fFindReferencesInHierarchyAction, provider, selection, specialSelectionProvider);
registerAction(fFindReferencesInWorkingSetAction, provider, selection, specialSelectionProvider);
}
/**
* Creates a new <code>ReadReferencesSearchGroup</code>. The group requires
* that the selection provided by the given selection provider is of type
* {@link IStructuredSelection}.
*
* @param site the site that will own the action group.
* @param specialSelectionProvider the selection provider used instead of the
* sites selection provider.
*
* @since 3.4
*/
public ReadReferencesSearchGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider) {
fSite= site;
fGroupId= IContextMenuConstants.GROUP_SEARCH;
fFindReadReferencesAction= new FindReadReferencesAction(site);
fFindReadReferencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_WORKSPACE);
fFindReadReferencesInProjectAction= new FindReadReferencesInProjectAction(site);
fFindReadReferencesInProjectAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_READ_ACCESS_IN_PROJECT);
fFindReadReferencesInHierarchyAction= new FindReadReferencesInHierarchyAction(site);
fFindReadReferencesInHierarchyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_HIERARCHY);
fFindReadReferencesInWorkingSetAction= new FindReadReferencesInWorkingSetAction(site);
fFindReadReferencesInWorkingSetAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_WORKING_SET);
// register the actions as selection listeners
ISelectionProvider provider= specialSelectionProvider == null ? fSite.getSelectionProvider() : specialSelectionProvider;
ISelection selection= provider.getSelection();
registerAction(fFindReadReferencesAction, provider, selection, specialSelectionProvider);
registerAction(fFindReadReferencesInProjectAction, provider, selection, specialSelectionProvider);
registerAction(fFindReadReferencesInHierarchyAction, provider, selection, specialSelectionProvider);
registerAction(fFindReadReferencesInWorkingSetAction, provider, selection, specialSelectionProvider);
}
/**
* Creates a new <code>WriteReferencesSearchGroup</code>. The group requires
* that the selection provided by the given selection provider is of type
* {@link IStructuredSelection}.
*
* @param site the site that will own the action group.
* @param specialSelectionProvider the selection provider used instead of the
* sites selection provider.
*
* @since 3.4
*/
public WriteReferencesSearchGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider) {
fSite= site;
fGroupId= IContextMenuConstants.GROUP_SEARCH;
fFindWriteReferencesAction= new FindWriteReferencesAction(site);
fFindWriteReferencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_WORKSPACE);
fFindWriteReferencesInProjectAction= new FindWriteReferencesInProjectAction(site);
fFindWriteReferencesInProjectAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_PROJECT);
fFindWriteReferencesInHierarchyAction= new FindWriteReferencesInHierarchyAction(site);
fFindWriteReferencesInHierarchyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_HIERARCHY);
fFindWriteReferencesInWorkingSetAction= new FindWriteReferencesInWorkingSetAction(site);
fFindWriteReferencesInWorkingSetAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_WORKING_SET);
// register the actions as selection listeners
ISelectionProvider provider= specialSelectionProvider == null ? fSite.getSelectionProvider() : specialSelectionProvider;
ISelection selection= provider.getSelection();
registerAction(fFindWriteReferencesAction, provider, selection, specialSelectionProvider);
registerAction(fFindWriteReferencesInProjectAction, provider, selection, specialSelectionProvider);
registerAction(fFindWriteReferencesInHierarchyAction, provider, selection, specialSelectionProvider);
registerAction(fFindWriteReferencesInWorkingSetAction, provider, selection, specialSelectionProvider);
}
private EditFilterAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
super(site, selectionTarget, BuildpathModifierAction.EDIT_FILTERS);
setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_label);
setImageDescriptor(JavaPluginImages.DESC_ELCL_CONFIGURE_BUILDPATH_FILTERS);
setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_tooltip);
setDescription(NewWizardMessages.PackageExplorerActionGroup_FormText_Edit);
setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CONFIGURE_BUILDPATH_FILTERS);
}
private void createSiteActions(IWorkbenchSite site, ISelectionProvider specialProvider) {
fOpenImplementation= new OpenImplementationAction(site);
fOpenImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_IMPLEMENTATION);
fOpenImplementation.setSpecialSelectionProvider(specialProvider);
fOpenSuperImplementation= new OpenSuperImplementationAction(site);
fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION);
fOpenSuperImplementation.setSpecialSelectionProvider(specialProvider);
fOpenAttachedJavadoc= new OpenAttachedJavadocAction(site);
fOpenAttachedJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_ATTACHED_JAVADOC);
fOpenAttachedJavadoc.setSpecialSelectionProvider(specialProvider);
fOpenTypeHierarchy= new OpenTypeHierarchyAction(site);
fOpenTypeHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
fOpenTypeHierarchy.setSpecialSelectionProvider(specialProvider);
fOpenCallHierarchy= new OpenCallHierarchyAction(site);
fOpenCallHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
fOpenCallHierarchy.setSpecialSelectionProvider(specialProvider);
ISelectionProvider provider= specialProvider != null ? specialProvider : site.getSelectionProvider();
fOpenPropertiesDialog= new PropertyDialogAction(site, provider);
fOpenPropertiesDialog.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);
initialize(provider);
}
private CreateLinkedSourceFolderAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
super(site, selectionTarget, BuildpathModifierAction.CREATE_LINK);
setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_label);
setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_tooltip);
setImageDescriptor(JavaPluginImages.DESC_ELCL_ADD_LINKED_SOURCE_TO_BUILDPATH);
setDescription(NewWizardMessages.PackageExplorerActionGroup_FormText_createLinkedFolder);
}
private TypeScriptSearchActionGroup(IWorkbenchSite site) {
fReferencesGroup= new ReferencesSearchGroup(site);
// fReadAccessGroup= new ReadReferencesSearchGroup(site);
// fWriteAccessGroup= new WriteReferencesSearchGroup(site);
// fDeclarationsGroup= new DeclarationsSearchGroup(site);
//// fImplementorsGroup= new ImplementorsSearchGroup(site);
// fOccurrencesGroup= new OccurrencesSearchGroup(site);
}
/**
* Creates a new <code>RenameAction</code>. The action requires
* that the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public RenameAction(IWorkbenchSite site) {
super(site);
setText(RefactoringMessages.RenameAction_text);
fRenameJavaElement= new RenameTypeScriptElementAction(site);
fRenameJavaElement.setText(getText());
// fRenameResource= new RenameResourceAction(site);
// fRenameResource.setText(getText());
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.RENAME_ACTION);
}
/**
* Creates a new <code>ReferencesSearchGroup</code>. The group requires that
* the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site
* the view part that owns this action group
*/
public ReferencesSearchGroup(IWorkbenchSite site) {
fSite = site;
fGroupId = IContextMenuConstants.GROUP_SEARCH;
// fFindReferencesAction= new FindReferencesAction(site);
// fFindReferencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKSPACE);
fFindReferencesInProjectAction = new FindReferencesInProjectAction(site);
fFindReferencesInProjectAction
.setActionDefinitionId(ITypeScriptEditorActionDefinitionIds.SEARCH_REFERENCES_IN_PROJECT);
// fFindReferencesInHierarchyAction= new
// FindReferencesInHierarchyAction(site);
// fFindReferencesInHierarchyAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_HIERARCHY);
// fFindReferencesInWorkingSetAction= new
// FindReferencesInWorkingSetAction(site);
// fFindReferencesInWorkingSetAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_REFERENCES_IN_WORKING_SET);
// register the actions as selection listeners
ISelectionProvider provider = fSite.getSelectionProvider();
ISelection selection = provider.getSelection();
// registerAction(fFindReferencesAction, provider, selection);
registerAction(fFindReferencesInProjectAction, provider, selection);
// registerAction(fFindReferencesInHierarchyAction, provider,
// selection);
// registerAction(fFindReferencesInWorkingSetAction, provider,
// selection);
}
@Override
public void setEnabled(Object evaluationContext)
{
Object activeSite = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_SITE_NAME);
Object activeEditor = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_EDITOR_NAME);
if (activeSite instanceof IWorkbenchSite && activeEditor instanceof AbstractThemeableEditor)
{
ICommandService commandService = (ICommandService) ((IWorkbenchSite) activeSite)
.getService(ICommandService.class);
Command command = commandService.getCommand(COMMAND_ID);
State state = command.getState(RegistryToggleState.STATE_ID);
state.setValue(((AbstractThemeableEditor) activeEditor).getWordWrapEnabled());
}
}
public CutAction(IWorkbenchSite site) {
super(site);
setText(ReorgMessages.CutAction_text);
fCopyToClipboardAction= new CopyToClipboardAction(site);
ISharedImages workbenchImages= JavaPlugin.getDefault().getWorkbench().getSharedImages();
setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED));
setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_CUT));
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CUT_ACTION);
}
/**
* Creates a new <code>CCPActionGroup</code>. The group requires that the selection provided by
* the given selection provider is of type {@link IStructuredSelection}.
*
* @param site the site that will own the action group.
* @param specialSelectionProvider the selection provider used instead of the sites selection
* provider.
* @param includeOnlyCopyActions <code>true</code> if the group only included the copy actions,
* <code>false</code> otherwise
* @since 3.7
*/
private CCPActionGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider, boolean includeOnlyCopyActions) {
fSelectionProvider= specialSelectionProvider == null ? site.getSelectionProvider() : specialSelectionProvider;
fCopyAction= new CopyToClipboardAction(site);
fCopyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
fCopyQualifiedNameAction= new CopyQualifiedNameAction(site);
fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.ACTION_DEFINITION_ID);
if (!includeOnlyCopyActions) {
fPasteAction= new PasteAction(site);
fPasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
fDeleteAction= new DeleteAction(site);
fDeleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
fCutAction= new CutAction(site);
fCutAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
fActions= new SelectionDispatchAction[] { fCutAction, fCopyAction, fCopyQualifiedNameAction, fPasteAction, fDeleteAction };
} else {
fPasteAction= null;
fDeleteAction= null;
fCutAction= null;
fActions= new SelectionDispatchAction[] { fCopyAction, fCopyQualifiedNameAction };
}
if (specialSelectionProvider != null) {
for (int i= 0; i < fActions.length; i++) {
fActions[i].setSpecialSelectionProvider(specialSelectionProvider);
}
}
registerActionsAsSelectionChangeListeners();
}
public ReorgCopyAction(IWorkbenchSite site) {
super(site);
setText(ReorgMessages.ReorgCopyAction_3);
setDescription(ReorgMessages.ReorgCopyAction_4);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.COPY_ACTION);
}
/**
* Creates a new <code>IntroduceIndirectionAction</code>.
*
* @param site the site providing context information for this action
*/
public IntroduceIndirectionAction(IWorkbenchSite site) {
super(site);
setText(RefactoringMessages.IntroduceIndirectionAction_title);
setToolTipText(RefactoringMessages.IntroduceIndirectionAction_tooltip);
setDescription(RefactoringMessages.IntroduceIndirectionAction_description);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.INTRODUCE_INDIRECTION_ACTION);
}
/**
* Creates a new <code>IntroduceFactoryAction</code>. The action requires
* that the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public IntroduceFactoryAction(IWorkbenchSite site) {
super(site);
setText(RefactoringMessages.IntroduceFactoryAction_label);
setToolTipText(RefactoringMessages.IntroduceFactoryAction_tooltipText);
setDescription(RefactoringMessages.IntroduceFactoryAction_description);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.INTRODUCE_FACTORY_ACTION);
}
private JavaSearchActionGroup(IWorkbenchSite site) {
fReferencesGroup= new ReferencesSearchGroup(site);
fReadAccessGroup= new ReadReferencesSearchGroup(site);
fWriteAccessGroup= new WriteReferencesSearchGroup(site);
fDeclarationsGroup= new DeclarationsSearchGroup(site);
fImplementorsGroup= new ImplementorsSearchGroup(site);
fOccurrencesGroup= new OccurrencesSearchGroup(site);
}
private ExcludeFromBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
super(site, selectionTarget, BuildpathModifierAction.EXCLUDE);
fContext= context;
setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_label);
setImageDescriptor(JavaPluginImages.DESC_ELCL_EXCLUDE_FROM_BUILDPATH);
setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_tooltip);
setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_EXCLUDE_FROM_BUILDPATH);
}
/**
* Creates a new <code>OpenTypeHierarchyAction</code>. The action requires
* that the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public OpenTypeHierarchyAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.OpenTypeHierarchyAction_label);
setToolTipText(ActionMessages.OpenTypeHierarchyAction_tooltip);
setDescription(ActionMessages.OpenTypeHierarchyAction_description);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_TYPE_HIERARCHY_ACTION);
}
/**
* Creates a new <code>OccurrencesSearchGroup</code>. The group requires
* that the selection provided by the given selection provider is of type
* {@link IStructuredSelection}.
*
* @param site the site that will own the action group.
* @param specialSelectionProvider the selection provider used instead of the
* sites selection provider.
*
* @since 3.4
*/
public OccurrencesSearchGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider) {
fSite= site;
fGroupId= IContextMenuConstants.GROUP_SEARCH;
fOccurrencesInFileAction= new FindOccurrencesInFileAction(site);
fOccurrencesInFileAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_OCCURRENCES_IN_FILE);
// Need to reset the label
fOccurrencesInFileAction.setText(SearchMessages.Search_FindOccurrencesInFile_shortLabel);
fExceptionOccurrencesAction= new FindExceptionOccurrencesAction(site);
fExceptionOccurrencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_EXCEPTION_OCCURRENCES_IN_FILE);
fFindImplementorOccurrencesAction= new FindImplementOccurrencesAction(site);
fFindImplementorOccurrencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_IMPLEMENT_OCCURRENCES_IN_FILE);
fBreakContinueTargetOccurrencesAction= new FindBreakContinueTargetOccurrencesAction(site);
fBreakContinueTargetOccurrencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_BREAK_CONTINUE_TARGET_OCCURRENCES);
fMethodExitOccurrencesAction= new FindMethodExitOccurrencesAction(site);
fMethodExitOccurrencesAction.setActionDefinitionId(IJavaEditorActionDefinitionIds.SEARCH_METHOD_EXIT_OCCURRENCES);
// register the actions as selection listeners
ISelectionProvider provider= specialSelectionProvider == null ? fSite.getSelectionProvider() : specialSelectionProvider;
ISelection selection= provider.getSelection();
registerAction(fOccurrencesInFileAction, provider, selection, specialSelectionProvider);
registerAction(fExceptionOccurrencesAction, provider, selection, specialSelectionProvider);
registerAction(fFindImplementorOccurrencesAction, provider, selection, specialSelectionProvider);
registerAction(fBreakContinueTargetOccurrencesAction, provider, selection, specialSelectionProvider);
registerAction(fMethodExitOccurrencesAction, provider, selection, specialSelectionProvider);
}
private AddFolderToBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
super(site, selectionTarget, BuildpathModifierAction.ADD_SEL_SF_TO_BP);
fContext= context;
setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_label);
setImageDescriptor(JavaPluginImages.DESC_ELCL_ADD_AS_SOURCE_FOLDER);
setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_tooltip);
}
/**
* Creates an <code>OpenImplementationAction</code>.
*
* @param site the workbench site
*/
protected OpenImplementationAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.OpenImplementationAction_label);
setDescription(ActionMessages.OpenImplementationAction_description);
setToolTipText(ActionMessages.OpenImplementationAction_tooltip);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_IMPLEMENTATION_ACTION);
}
public AllCleanUpsAction(IWorkbenchSite site) {
super(site);
setToolTipText(ActionMessages.CleanUpAction_tooltip);
setDescription(ActionMessages.CleanUpAction_description);
installPreferenceListener();
updateActionLabel();
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.ORGANIZE_IMPORTS_ACTION);
}
/**
* Creates a new <code>OpenProjectAction</code>. The action requires
* that the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public OpenProjectAction(IWorkbenchSite site) {
super(site);
fWorkbenchAction= new OpenResourceAction(site);
setText(fWorkbenchAction.getText());
setToolTipText(fWorkbenchAction.getToolTipText());
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_PROJECT_ACTION);
setEnabled(hasClosedProjectsInWorkspace());
}
private void initialize(IWorkbenchSite site, boolean isJavaEditor) {
fSite= site;
ISelectionProvider provider= fSite.getSelectionProvider();
ISelection selection= provider.getSelection();
fShowInPackagesViewAction.update(selection);
if (!isJavaEditor) {
provider.addSelectionChangedListener(fShowInPackagesViewAction);
}
}
/**
* Creates a new <code>OpenSuperImplementationAction</code>. The action requires
* that the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public OpenSuperImplementationAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.OpenSuperImplementationAction_label);
setDescription(ActionMessages.OpenSuperImplementationAction_description);
setToolTipText(ActionMessages.OpenSuperImplementationAction_tooltip);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_SUPER_IMPLEMENTATION_ACTION);
}
/**
* Creates a new <code>FormatAllAction</code>. The action requires
* that the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public FormatAllAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.FormatAllAction_label);
setToolTipText(ActionMessages.FormatAllAction_tooltip);
setDescription(ActionMessages.FormatAllAction_description);
fCleanUpDelegate= new MultiFormatAction(site);
}
public ResetAllOutputFoldersAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context, IJavaProject javaProject) {
super(site, selectionTarget, BuildpathModifierAction.RESET_ALL_OUTPUT_FOLDERS);
fContext= context;
fJavaProject= javaProject;
setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip);
setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip);
}
/**
* Creates a new <code>AddGetterSetterAction</code>. The action requires that the
* selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public AddGetterSetterAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.AddGetterSetterAction_label);
setDescription(ActionMessages.AddGetterSetterAction_description);
setToolTipText(ActionMessages.AddGetterSetterAction_tooltip);
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GETTERSETTER_ACTION);
}
public SelectionParseAction(IWorkbenchSite site) {
super();
this.site = site;
}