Java 类org.eclipse.ui.actions.CloseResourceAction 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:ProjectActionGroup.java   
/**
 * 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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProjectActionGroup.java   
/**
 * 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);
}