Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 155229 Details for
Bug 298676
[CommonNavigator]override resourceAction (refresh,open, close, build)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
a patch for this bug
patch_298676.txt (text/plain), 25.68 KB, created by
Simon Bernard
on 2010-01-04 09:00:31 EST
(
hide
)
Description:
a patch for this bug
Filename:
MIME Type:
Creator:
Simon Bernard
Created:
2010-01-04 09:00:31 EST
Size:
25.68 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.navigator.resources >Index: src/org/eclipse/ui/internal/navigator/resources/actions/ResourceMgmtActionProvider.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/navigator/resources/actions/ResourceMgmtActionProvider.java >diff -N src/org/eclipse/ui/internal/navigator/resources/actions/ResourceMgmtActionProvider.java >--- src/org/eclipse/ui/internal/navigator/resources/actions/ResourceMgmtActionProvider.java 1 Apr 2009 16:14:46 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,268 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2006, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.ui.internal.navigator.resources.actions; >- >-import java.lang.reflect.InvocationTargetException; >-import java.util.Iterator; >- >-import org.eclipse.osgi.util.NLS; >- >-import org.eclipse.swt.widgets.Shell; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IAdaptable; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.core.runtime.jobs.ISchedulingRule; >- >-import org.eclipse.core.resources.ICommand; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.resources.IncrementalProjectBuilder; >-import org.eclipse.core.resources.ResourcesPlugin; >-import org.eclipse.core.resources.WorkspaceJob; >- >-import org.eclipse.jface.action.IMenuManager; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.jface.viewers.IStructuredSelection; >-import org.eclipse.jface.viewers.StructuredViewer; >-import org.eclipse.jface.window.IShellProvider; >- >-import org.eclipse.ui.IActionBars; >-import org.eclipse.ui.IWorkbenchCommandConstants; >-import org.eclipse.ui.actions.ActionFactory; >-import org.eclipse.ui.actions.BuildAction; >-import org.eclipse.ui.actions.CloseResourceAction; >-import org.eclipse.ui.actions.CloseUnrelatedProjectsAction; >-import org.eclipse.ui.actions.OpenResourceAction; >-import org.eclipse.ui.actions.RefreshAction; >-import org.eclipse.ui.actions.WorkspaceModifyOperation; >-import org.eclipse.ui.ide.IDEActionFactory; >-import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; >-import org.eclipse.ui.internal.navigator.NavigatorPlugin; >-import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages; >-import org.eclipse.ui.navigator.CommonActionProvider; >-import org.eclipse.ui.navigator.ICommonActionExtensionSite; >-import org.eclipse.ui.navigator.ICommonMenuConstants; >- >-/** >- * @since 3.2 >- * >- */ >-public class ResourceMgmtActionProvider extends CommonActionProvider { >- >- private BuildAction buildAction; >- >- private OpenResourceAction openProjectAction; >- >- private CloseResourceAction closeProjectAction; >- >- private CloseUnrelatedProjectsAction closeUnrelatedProjectsAction; >- >- private RefreshAction refreshAction; >- >- private Shell shell; >- >- /* >- * (non-Javadoc) >- * >- * @see >- * org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator >- * .ICommonActionExtensionSite) >- */ >- public void init(ICommonActionExtensionSite aSite) { >- super.init(aSite); >- shell = aSite.getViewSite().getShell(); >- makeActions(); >- } >- >- public void fillActionBars(IActionBars actionBars) { >- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); >- actionBars.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(), buildAction); >- actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), openProjectAction); >- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), closeProjectAction); >- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(), closeUnrelatedProjectsAction); >- updateActionBars(); >- } >- >- /** >- * Adds the build, open project, close project and refresh resource actions >- * to the context menu. >- * <p> >- * The following conditions apply: build-only projects selected, auto build >- * disabled, at least one builder present open project-only projects >- * selected, at least one closed project close project-only projects >- * selected, at least one open project refresh-no closed project selected >- * </p> >- * <p> >- * Both the open project and close project action may be on the menu at the >- * same time. >- * </p> >- * <p> >- * No disabled action should be on the context menu. >- * </p> >- * >- * @param menu >- * context menu to add actions to >- */ >- public void fillContextMenu(IMenuManager menu) { >- IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); >- boolean isProjectSelection = true; >- boolean hasOpenProjects = false; >- boolean hasClosedProjects = false; >- boolean hasBuilder = true; // false if any project is closed or does not >- // have builder >- Iterator resources = selection.iterator(); >- >- while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) { >- Object next = resources.next(); >- IProject project = null; >- >- if (next instanceof IProject) { >- project = (IProject) next; >- } else if (next instanceof IAdaptable) { >- project = (IProject) ((IAdaptable) next).getAdapter(IProject.class); >- } >- >- if (project == null) { >- isProjectSelection = false; >- continue; >- } >- if (project.isOpen()) { >- hasOpenProjects = true; >- if (hasBuilder && !hasBuilder(project)) { >- hasBuilder = false; >- } >- } else { >- hasClosedProjects = true; >- hasBuilder = false; >- } >- } >- if (!selection.isEmpty() && isProjectSelection && !ResourcesPlugin.getWorkspace().isAutoBuilding() && hasBuilder) { >- // Allow manual incremental build only if auto build is off. >- buildAction.selectionChanged(selection); >- menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, buildAction); >- } >- if (!hasClosedProjects) { >- refreshAction.selectionChanged(selection); >- menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, refreshAction); >- } >- if (isProjectSelection) { >- if (hasClosedProjects) { >- openProjectAction.selectionChanged(selection); >- menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, openProjectAction); >- } >- if (hasOpenProjects) { >- closeProjectAction.selectionChanged(selection); >- menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeProjectAction); >- closeUnrelatedProjectsAction.selectionChanged(selection); >- menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeUnrelatedProjectsAction); >- } >- } >- } >- >- /** >- * Returns whether there are builders configured on the given project. >- * >- * @return <code>true</code> if it has builders, <code>false</code> if not, >- * or if this could not be determined >- */ >- boolean hasBuilder(IProject project) { >- try { >- ICommand[] commands = project.getDescription().getBuildSpec(); >- if (commands.length > 0) { >- return true; >- } >- } catch (CoreException e) { >- // Cannot determine if project has builders. Project is closed >- // or does not exist. Fall through to return false. >- } >- return false; >- } >- >- protected void makeActions() { >- IShellProvider sp = new IShellProvider() { >- public Shell getShell() { >- return shell; >- } >- }; >- >- openProjectAction = new OpenResourceAction(sp); >- >- closeProjectAction = new CloseResourceAction(sp); >- >- closeUnrelatedProjectsAction = new CloseUnrelatedProjectsAction(sp); >- >- 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.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.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));//$NON-NLS-1$ >- refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.gif"));//$NON-NLS-1$ >- refreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH); >- >- buildAction = new BuildAction(sp, IncrementalProjectBuilder.INCREMENTAL_BUILD); >- buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT); >- } >- >- /** >- * Returns the image descriptor with the given relative path. >- */ >- protected ImageDescriptor getImageDescriptor(String relativePath) { >- return IDEWorkbenchPlugin.getIDEImageDescriptor(relativePath); >- >- } >- >- public void updateActionBars() { >- IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); >- refreshAction.selectionChanged(selection); >- buildAction.selectionChanged(selection); >- openProjectAction.selectionChanged(selection); >- closeUnrelatedProjectsAction.selectionChanged(selection); >- closeProjectAction.selectionChanged(selection); >- } >- >-} >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.navigator.resources/plugin.xml,v >retrieving revision 1.42 >diff -u -r1.42 plugin.xml >--- plugin.xml 22 Jan 2009 23:08:33 -0000 1.42 >+++ plugin.xml 4 Jan 2010 14:03:35 -0000 >@@ -221,7 +221,7 @@ > </actionProvider> > > <actionProvider >- class="org.eclipse.ui.internal.navigator.resources.actions.ResourceMgmtActionProvider" >+ class="org.eclipse.ui.navigator.resources.actions.ResourceMgmtActionProvider" > id="org.eclipse.ui.navigator.resources.ResourceMgmtActions"> > <enablement> > <or> >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.navigator.resources/META-INF/MANIFEST.MF,v >retrieving revision 1.29 >diff -u -r1.29 MANIFEST.MF >--- META-INF/MANIFEST.MF 1 Sep 2009 04:32:24 -0000 1.29 >+++ META-INF/MANIFEST.MF 4 Jan 2010 14:03:35 -0000 >@@ -11,7 +11,8 @@ > org.eclipse.ui.internal.navigator.resources.plugin;x-internal:=true, > org.eclipse.ui.internal.navigator.resources.workbench;x-internal:=true, > org.eclipse.ui.internal.navigator.workingsets;x-internal:=true, >- org.eclipse.ui.navigator.resources >+ org.eclipse.ui.navigator.resources, >+ org.eclipse.ui.navigator.resources.actions > Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)", > org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)", > org.eclipse.jface;bundle-version="[3.5.0,4.0.0)", >Index: src/org/eclipse/ui/navigator/resources/actions/RefreshResourceAction.java >=================================================================== >RCS file: src/org/eclipse/ui/navigator/resources/actions/RefreshResourceAction.java >diff -N src/org/eclipse/ui/navigator/resources/actions/RefreshResourceAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/navigator/resources/actions/RefreshResourceAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.navigator.resources.actions; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.core.resources.WorkspaceJob; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.ISchedulingRule; >+import org.eclipse.jface.viewers.StructuredViewer; >+import org.eclipse.jface.window.IShellProvider; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.actions.RefreshAction; >+import org.eclipse.ui.actions.WorkspaceModifyOperation; >+import org.eclipse.ui.internal.navigator.NavigatorPlugin; >+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorMessages; >+import org.eclipse.ui.navigator.ICommonActionExtensionSite; >+import org.eclipse.ui.navigator.resources.ProjectExplorer; >+ >+/** >+ * The default refresh action of the {@link ProjectExplorer} >+ * >+ * @since 3.6 >+ */ >+public class RefreshResourceAction extends RefreshAction { >+ >+ private Shell shell; >+ private ICommonActionExtensionSite actionSite; >+ >+ public RefreshResourceAction(IShellProvider provider, ICommonActionExtensionSite commonActionSite) { >+ super(provider); >+ shell = provider.getShell(); >+ this.actionSite = commonActionSite; >+ } >+ >+ 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 = actionSite.getStructuredViewer(); >+ if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) { >+ viewer.refresh(); >+ } >+ } >+ }); >+ } >+ } catch (InvocationTargetException e) { >+ String msg = NLS.bind(WorkbenchNavigatorMessages.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(); >+ } >+} >Index: src/org/eclipse/ui/navigator/resources/actions/ResourceMgmtActionProvider.java >=================================================================== >RCS file: src/org/eclipse/ui/navigator/resources/actions/ResourceMgmtActionProvider.java >diff -N src/org/eclipse/ui/navigator/resources/actions/ResourceMgmtActionProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/navigator/resources/actions/ResourceMgmtActionProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,262 @@ >+/******************************************************************************* >+ * Copyright (c) 2006, 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.ui.navigator.resources.actions; >+ >+import java.util.Iterator; >+ >+import org.eclipse.core.resources.ICommand; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IncrementalProjectBuilder; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.window.IShellProvider; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.IWorkbenchCommandConstants; >+import org.eclipse.ui.actions.ActionFactory; >+import org.eclipse.ui.actions.BuildAction; >+import org.eclipse.ui.actions.CloseResourceAction; >+import org.eclipse.ui.actions.CloseUnrelatedProjectsAction; >+import org.eclipse.ui.actions.OpenResourceAction; >+import org.eclipse.ui.actions.SelectionListenerAction; >+import org.eclipse.ui.ide.IDEActionFactory; >+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; >+import org.eclipse.ui.navigator.CommonActionProvider; >+import org.eclipse.ui.navigator.ICommonActionExtensionSite; >+import org.eclipse.ui.navigator.ICommonMenuConstants; >+import org.eclipse.ui.navigator.resources.ProjectExplorer; >+ >+/** >+ * The default resource action provider of the {@link ProjectExplorer}.<br> >+ * <br> >+ * It provides : refresh, open, close, and build action on a project. >+ * >+ * @since 3.2 >+ */ >+public class ResourceMgmtActionProvider extends CommonActionProvider { >+ >+ protected static final String DISABLE_REFRESH_ACTION_RELATIVE_PATH = "dlcl16/refresh_nav.gif";//$NON-NLS-1$ >+ >+ protected static final String ENABLE_REFRESH_ACTION_RELATIVE_PATH = "elcl16/refresh_nav.gif";//$NON-NLS-1$ >+ >+ private BuildAction buildAction; >+ >+ private SelectionListenerAction openProjectAction; >+ >+ private SelectionListenerAction closeProjectAction; >+ >+ private SelectionListenerAction closeUnrelatedProjectsAction; >+ >+ private SelectionListenerAction refreshAction; >+ >+ private Shell shell; >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see >+ * org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator >+ * .ICommonActionExtensionSite) >+ */ >+ public void init(ICommonActionExtensionSite aSite) { >+ super.init(aSite); >+ shell = aSite.getViewSite().getShell(); >+ makeActions(); >+ } >+ >+ public void fillActionBars(IActionBars actionBars) { >+ actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); >+ actionBars.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(), buildAction); >+ actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), openProjectAction); >+ actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), closeProjectAction); >+ actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(), >+ closeUnrelatedProjectsAction); >+ updateActionBars(); >+ } >+ >+ /** >+ * Adds the build, open project, close project and refresh resource actions >+ * to the context menu. >+ * <p> >+ * The following conditions apply: build-only projects selected, auto build >+ * disabled, at least one builder present open project-only projects >+ * selected, at least one closed project close project-only projects >+ * selected, at least one open project refresh-no closed project selected >+ * </p> >+ * <p> >+ * Both the open project and close project action may be on the menu at the >+ * same time. >+ * </p> >+ * <p> >+ * No disabled action should be on the context menu. >+ * </p> >+ * >+ * @param menu >+ * context menu to add actions to >+ */ >+ public void fillContextMenu(IMenuManager menu) { >+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); >+ boolean isProjectSelection = true; >+ boolean hasOpenProjects = false; >+ boolean hasClosedProjects = false; >+ boolean hasBuilder = true; // false if any project is closed or does not >+ // have builder >+ Iterator resources = selection.iterator(); >+ >+ while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) { >+ Object next = resources.next(); >+ IProject project = null; >+ >+ if (next instanceof IProject) { >+ project = (IProject) next; >+ } else if (next instanceof IAdaptable) { >+ project = (IProject) ((IAdaptable) next).getAdapter(IProject.class); >+ } >+ >+ if (project == null) { >+ isProjectSelection = false; >+ continue; >+ } >+ if (project.isOpen()) { >+ hasOpenProjects = true; >+ if (hasBuilder && !hasBuilder(project)) { >+ hasBuilder = false; >+ } >+ } else { >+ hasClosedProjects = true; >+ hasBuilder = false; >+ } >+ } >+ if (!selection.isEmpty() && isProjectSelection && !ResourcesPlugin.getWorkspace().isAutoBuilding() >+ && hasBuilder) { >+ // Allow manual incremental build only if auto build is off. >+ buildAction.selectionChanged(selection); >+ menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, buildAction); >+ } >+ if (!hasClosedProjects) { >+ refreshAction.selectionChanged(selection); >+ menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, refreshAction); >+ } >+ if (isProjectSelection) { >+ if (hasClosedProjects) { >+ openProjectAction.selectionChanged(selection); >+ menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, openProjectAction); >+ } >+ if (hasOpenProjects) { >+ closeProjectAction.selectionChanged(selection); >+ menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeProjectAction); >+ closeUnrelatedProjectsAction.selectionChanged(selection); >+ menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeUnrelatedProjectsAction); >+ } >+ } >+ } >+ >+ /** >+ * Returns whether there are builders configured on the given project. >+ * >+ * @return <code>true</code> if it has builders, <code>false</code> if not, >+ * or if this could not be determined >+ */ >+ boolean hasBuilder(IProject project) { >+ try { >+ ICommand[] commands = project.getDescription().getBuildSpec(); >+ if (commands.length > 0) { >+ return true; >+ } >+ } catch (CoreException e) { >+ // Cannot determine if project has builders. Project is closed >+ // or does not exist. Fall through to return false. >+ } >+ return false; >+ } >+ >+ protected void makeActions() { >+ IShellProvider sp = new IShellProvider() { >+ public Shell getShell() { >+ return shell; >+ } >+ }; >+ >+ openProjectAction = createOpenProjectAction(sp); >+ >+ closeProjectAction = createCloseProjectAction(sp); >+ >+ closeUnrelatedProjectsAction = createCloseUnrelatedProjectsAction(sp); >+ >+ refreshAction = createRefreshAction(sp); >+ >+ buildAction = createBuildAction(sp); >+ } >+ >+ /** >+ * create the 'open project' action >+ */ >+ protected SelectionListenerAction createOpenProjectAction(IShellProvider sp) { >+ return new OpenResourceAction(sp); >+ } >+ >+ /** >+ * create 'close project' action >+ */ >+ private SelectionListenerAction createCloseProjectAction(IShellProvider sp) { >+ return new CloseResourceAction(sp); >+ } >+ >+ /** >+ * create the 'Close Unrelated projects' action >+ */ >+ private SelectionListenerAction createCloseUnrelatedProjectsAction(IShellProvider sp) { >+ return new CloseUnrelatedProjectsAction(sp); >+ } >+ >+ /** >+ * create 'refresh resource' action >+ */ >+ private SelectionListenerAction createRefreshAction(IShellProvider sp) { >+ RefreshResourceAction refreshResourceAction = new RefreshResourceAction(sp, getActionSite()); >+ refreshResourceAction.setDisabledImageDescriptor(getImageDescriptor(DISABLE_REFRESH_ACTION_RELATIVE_PATH)); >+ refreshResourceAction.setImageDescriptor(getImageDescriptor(ENABLE_REFRESH_ACTION_RELATIVE_PATH)); >+ refreshResourceAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH); >+ return refreshResourceAction; >+ } >+ >+ /** >+ * create 'build project' action >+ */ >+ protected BuildAction createBuildAction(IShellProvider sp) { >+ BuildAction buildProjectAction = new BuildAction(sp, IncrementalProjectBuilder.INCREMENTAL_BUILD); >+ buildProjectAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT); >+ return buildProjectAction; >+ } >+ >+ /** >+ * Returns the image descriptor with the given relative path. >+ */ >+ protected ImageDescriptor getImageDescriptor(String relativePath) { >+ return IDEWorkbenchPlugin.getIDEImageDescriptor(relativePath); >+ >+ } >+ >+ public void updateActionBars() { >+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); >+ refreshAction.selectionChanged(selection); >+ buildAction.selectionChanged(selection); >+ openProjectAction.selectionChanged(selection); >+ closeUnrelatedProjectsAction.selectionChanged(selection); >+ closeProjectAction.selectionChanged(selection); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 298676
: 155229