org.eclipse.ui.actions.CloseResourceAction Java Examples
The following examples show how to use
org.eclipse.ui.actions.CloseResourceAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Creates a new <code>ProjectActionGroup</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 selectionProvider the selection provider used instead of the * page selection provider. * * @since 3.4 */ public ProjectActionGroup(IWorkbenchSite site, ISelectionProvider selectionProvider) { fSelectionProvider= selectionProvider; ISelection selection= selectionProvider.getSelection(); fCloseAction= new CloseResourceAction(site); fCloseAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_CLOSE_PROJECT); fCloseUnrelatedAction= new CloseUnrelatedProjectsAction(site); fCloseUnrelatedAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_CLOSE_UNRELATED_PROJECTS); fOpenAction= new OpenProjectAction(site); fOpenAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_OPEN_PROJECT); if (selection instanceof IStructuredSelection) { IStructuredSelection s= (IStructuredSelection)selection; fOpenAction.selectionChanged(s); fCloseAction.selectionChanged(s); fCloseUnrelatedAction.selectionChanged(s); } fSelectionChangedListener= new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISelection s= event.getSelection(); if (s instanceof IStructuredSelection) { performSelectionChanged((IStructuredSelection) s); } } }; selectionProvider.addSelectionChangedListener(fSelectionChangedListener); IWorkspace workspace= ResourcesPlugin.getWorkspace(); workspace.addResourceChangeListener(fOpenAction); workspace.addResourceChangeListener(fCloseAction); workspace.addResourceChangeListener(fCloseUnrelatedAction); }
Example #2
Source File: ResourceMgmtActionProvider.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
protected void makeActions() { IShellProvider sp = new IShellProvider() { public Shell getShell() { return shell; } }; openProjectAction = new OpenResourceAction(sp); openProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_openProjectAction); closeProjectAction = new CloseResourceAction(sp); closeProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_closeProjectAction); // // closeUnrelatedProjectsAction = new CloseUnrelatedProjectsAction(sp); // closeUnrelatedProjectsAction.setText("关闭无关的项目"); refreshAction = new RefreshAction(sp) { public void run() { final IStatus[] errorStatus = new IStatus[1]; errorStatus[0] = Status.OK_STATUS; final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus); WorkspaceJob job = new WorkspaceJob("refresh") { //$NON-NLS-1$ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { try { op.run(monitor); if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(new Runnable() { public void run() { StructuredViewer viewer = getActionSite().getStructuredViewer(); if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { viewer.refresh(); } } }); } } catch (InvocationTargetException e) { String msg = NLS.bind(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_logTitle, getClass().getName(), e.getTargetException()); throw new CoreException(new Status(IStatus.ERROR, NavigatorPlugin.PLUGIN_ID, IStatus.ERROR, msg, e.getTargetException())); } catch (InterruptedException e) { return Status.CANCEL_STATUS; } return errorStatus[0]; } }; ISchedulingRule rule = op.getRule(); if (rule != null) { job.setRule(rule); } job.setUser(true); job.schedule(); } }; refreshAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_refreshAction); refreshAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));//$NON-NLS-1$ refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.gif"));//$NON-NLS-1$ refreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH); if (getContext() == null) { refreshAction.setEnabled(false); } else { IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); refreshAction.selectionChanged(selection); refreshAction.setEnabled(!selection.isEmpty()); } // buildAction = new BuildAction(sp, IncrementalProjectBuilder.INCREMENTAL_BUILD); // buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT); }
Example #3
Source File: ResourceMgmtActionProvider.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
protected void makeActions() { IShellProvider sp = new IShellProvider() { public Shell getShell() { return shell; } }; openProjectAction = new OpenResourceAction(sp); openProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_openProjectAction); closeProjectAction = new CloseResourceAction(sp); closeProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_closeProjectAction); // // closeUnrelatedProjectsAction = new CloseUnrelatedProjectsAction(sp); // closeUnrelatedProjectsAction.setText("关闭无关的项目"); refreshAction = new RefreshAction(sp) { public void run() { final IStatus[] errorStatus = new IStatus[1]; errorStatus[0] = Status.OK_STATUS; final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus); WorkspaceJob job = new WorkspaceJob("refresh") { //$NON-NLS-1$ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { try { op.run(monitor); if (shell != null && !shell.isDisposed()) { shell.getDisplay().asyncExec(new Runnable() { public void run() { StructuredViewer viewer = getActionSite().getStructuredViewer(); if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { viewer.refresh(); } } }); } } catch (InvocationTargetException e) { String msg = NLS.bind(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_logTitle, getClass().getName(), e.getTargetException()); throw new CoreException(new Status(IStatus.ERROR, NavigatorPlugin.PLUGIN_ID, IStatus.ERROR, msg, e.getTargetException())); } catch (InterruptedException e) { return Status.CANCEL_STATUS; } return errorStatus[0]; } }; ISchedulingRule rule = op.getRule(); if (rule != null) { job.setRule(rule); } job.setUser(true); job.schedule(); } }; refreshAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_refreshAction); refreshAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));//$NON-NLS-1$ refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.gif"));//$NON-NLS-1$ refreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH); if (getContext() == null) { refreshAction.setEnabled(false); } else { IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); refreshAction.selectionChanged(selection); refreshAction.setEnabled(!selection.isEmpty()); } // buildAction = new BuildAction(sp, IncrementalProjectBuilder.INCREMENTAL_BUILD); // buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT); }