Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2014-07-30 18:58:06 -0400
committerSergey Prigogin2014-07-30 19:47:55 -0400
commit31f37f5b63cc75cbf8d39b14ab05019607c462b6 (patch)
tree1ad467aa4da30f6ee9c89f3bc55e2515c05f32a9
parent6a94e17ca785a27daf909dbddc6c401be9c38d50 (diff)
downloadorg.eclipse.cdt-31f37f5b63cc75cbf8d39b14ab05019607c462b6.tar.gz
org.eclipse.cdt-31f37f5b63cc75cbf8d39b14ab05019607c462b6.tar.xz
org.eclipse.cdt-31f37f5b63cc75cbf8d39b14ab05019607c462b6.zip
Proper enablement/disablement of Clean/Build Selected Files commands.
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java4
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties11
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF17
-rwxr-xr-xbuild/org.eclipse.cdt.managedbuilder.ui/plugin.properties21
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/plugin.xml242
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesAction.java381
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java186
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesAction.java315
-rw-r--r--build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java145
-rw-r--r--core/org.eclipse.cdt.core/META-INF/MANIFEST.MF9
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml3
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/AdapterUtil.java39
-rw-r--r--core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF3
-rwxr-xr-xcore/org.eclipse.cdt.ui/plugin.properties46
-rw-r--r--core/org.eclipse.cdt.ui/plugin.xml50
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/CPropertyTester.java64
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/ResourcePropertyTester.java44
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/AbstractResourceActionHandler.java174
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java56
19 files changed, 903 insertions, 907 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
index cc2297c59a..73ed1a7676 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java
@@ -1447,7 +1447,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
OutputStream stdout = buildRunnerHelper.getOutputStream();
OutputStream stderr = buildRunnerHelper.getErrorStream();
- buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("BuildFilesAction.buildingSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
+ buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("BuildFilesHandler.buildingSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
// Build artifacts for each file in the project
@@ -1574,7 +1574,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
ErrorParserManager epm = new ErrorParserManager(project, des.getDefaultBuildDirLocationURI(), this, errorParsers);
buildRunnerHelper.prepareStreams(epm, null , console, new SubProgressMonitor(monitor, TICKS_STREAM_PROGRESS_MONITOR));
- buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("CleanFilesAction.cleanSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
+ buildRunnerHelper.greeting(ManagedMakeMessages.getResourceString("CleanFilesHandler.cleanSelectedFiles"), cfgName, toolchainName, isSupported); //$NON-NLS-1$
buildRunnerHelper.printLine(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.internal.builder.header.note")); //$NON-NLS-1$
for (IFile file : files) {
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
index 7cbc02775a..458e8f3806 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
@@ -49,7 +49,7 @@ ManagedBuildManager.error.owner_not_null=addTarget: owner not null
ManagedBuildManager.error.null_owner=addTarget: null owner
ManagedBuildManager.error.owner_not_project=addTarget: owner not project
ManagedBuildManager.error.manifest_load_failed_title=Managed Build System Version Error
-ManagedBuildManager.error.manifest.version.error=The version number defined in the plugin manifest file\n{0}\nis greater than the version of the Managed Build System.\nThe definitions in the manifest file will not be loaded.
+ManagedBuildManager.error.manifest.version.error=The version number defined in the plug-in manifest file\n{0}\nis greater than the version of the Managed Build System.\nThe definitions in the manifest file will not be loaded.
ManagedBuildManager.error.manifest.header=Managed Build system manifest file error:
ManagedBuildManager.error.manifest.resolving=Unable to resolve the {0} identifier {1} in the {2} {3}.
ManagedBuildManager.error.manifest.duplicate=Duplicate identifier {1} for element type {0}.
@@ -115,7 +115,7 @@ UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist mac
# BuildMacroStatus messages
BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
-BuildFilesAction.buildingSelectedFiles=Building Selected Files
+BuildFilesHandler.buildingSelectedFiles=Building Selected Files
BuildDescriptionGnuMakefileGenerator.0=IO exception occurred:
BuildDescriptionGnuMakefileGenerator.1=IO exception occurred:
BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
@@ -133,7 +133,7 @@ ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
GeneratedMakefileBuilder.buildingProject=Building project {0}
GeneratedMakefileBuilder.cleaningProject=Cleaning project {0}
GeneratedMakefileBuilder.removingResourceMarkers=Removing problem markers for {0}
-GeneratedMakefileBuilder.refreshingArtifacts=Refreshing build artefacts for {0}
+GeneratedMakefileBuilder.refreshingArtifacts=Refreshing build artifacts for {0}
GeneratedMakefileBuilder.fileDeleted={0} deleted.
GeneratedMakefileBuilder.nothingToClean=Nothing to clean.
GenerateMakefileWithBuildDescription.0=info is null
@@ -144,9 +144,8 @@ ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Re
InternalBuilder.msg.header=Internal Builder: {0}
InternalBuilder.nothing.todo=Nothing to be done for project {0}
CfgScannerConfigUtil_ErrorNotSupported=Only type {0} is supported in this method.
-CleanFilesAction.cleanFiles=Clean File(s)
-CleanFilesAction.cleanSelectedFiles=Cleaning Selected Files
-CleanFilesAction.cleaningFiles=Cleaning files
+CleanFilesHandler.cleanSelectedFiles=Cleaning Selected Files
+CleanFilesHandler.cleaningFiles=Cleaning files
BuilderFactory.1=can not find builder with the specified id
FolderInfo.4=converter invocation failed
MbsMacroSupplier.1=tool parent must be one of configuration, toolchain, or resource configuration
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF
index 7f78479662..ff182a48d1 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.managedbuilder.ui/META-INF/MANIFEST.MF
@@ -11,19 +11,18 @@ Export-Package: org.eclipse.cdt.managedbuilder.ui.preferences,
org.eclipse.cdt.managedbuilder.ui.wizards,
org.eclipse.cdt.managedbuilder.internal.ui.actions;x-internal:=true,
org.eclipse.cdt.managedbuilder.internal.ui.workingsets;x-internal:=true
-Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
- org.eclipse.ui.console;bundle-version="[3.5.100,4.0.0)",
- org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)",
- org.eclipse.cdt.ui;bundle-version="[5.0.0,6.0.0)",
- org.eclipse.cdt.managedbuilder.core;bundle-version="[8.1.0,9.0.0)",
+Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
- org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
+ org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)",
org.eclipse.cdt.make.core,
org.eclipse.cdt.make.ui,
- org.eclipse.core.filesystem
+ org.eclipse.cdt.managedbuilder.core;bundle-version="[8.1.0,9.0.0)",
+ org.eclipse.cdt.ui;bundle-version="[5.0.0,6.0.0)",
+ org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.ui.console;bundle-version="[3.5.100,4.0.0)",
+ org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)";resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: com.ibm.icu.text
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
index c6927370e8..6d22cd22fa 100755
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.properties
@@ -7,21 +7,25 @@
#
# Contributors:
# IBM Corporation - initial API and implementation
+# Sergey Prigogin (Google)
###############################################################################
pluginName=C/C++ Managed Builder UI
providerName=Eclipse CDT
+category.build.name=C/C++ Build
+category.build.description= C/C++ Build Actions
+
# The Wizards
MngCWizard.name=Managed Make C Project
MngCWizard.description=Create a new C project and let Eclipse create and manage the makefile
MngCCWizard.name=Managed Make C++ Project
MngCCWizard.description=Create a new C++ project and let Eclipse create and manage the makefile
-#The property pages
+# The property pages
MngBuildProp.name=C/C++ Build
MngOtherProp.name= Error/Binary Parsers
-#The preference pages
+# The preference pages
MakeBuildPref.name=Makefile Project
MngBuildPref.name=Managed Build
NewCDTWizardPref.name=New C/C++ Project Wizard
@@ -29,20 +33,21 @@ varsPrefName=Build Variables
envPrefName=Environment
propSettingsPrefName=Property Pages Settings
-#The Resource Property page
+# The Resource Property page
MngResourceProp.name=C/C++ Build
-#The Project Converter page
+# The Project Converter page
ConvertTargetAction.label=Convert To...
# Build/clean selected files actions
BuildSelectedFiles.label=Build Selected &File(s)
+command.buildFiles.name=Build Selected File(s)
+command.buildFiles.description=Rebuilds the selected source files
CleanSelectedFiles.label=C&lean Selected File(s)
-BuildSelectedFilesActionSet.label=Build/Clean Selected File(s)
-BuildSelectedFiles.tooltip=Rebuilds the selected file(s)
-CleanSelectedFiles.tooltip=Cleans the output file(s) for the selected file(s)
+command.cleanFiles.name=Clean Selected File(s)
+command.cleanFiles.description=Deletes build output files for the selected source files
-## New CDT project model - property pages names
+# New CDT project model - property pages names
page.c.build=C/C++ Build
CDTPathSymbolsProperty.name=Paths and Symbols
CDTExpPathSymbolsProperty.name=Export Settings
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
index ba312a5b55..3260626260 100644
--- a/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.ui/plugin.xml
@@ -2,8 +2,160 @@
<?eclipse version="3.0"?>
<plugin>
- <extension-point id="buildDefinitionsUI" name="%buildDefinitionsUI.ep.name" schema="schema/buildDefinitionsUI.exsd"/>
- <extension-point id="newWizardPages" name="%extension-point.name" schema="schema/newWizardPages.exsd"/>
+ <extension-point id="buildDefinitionsUI" name="%buildDefinitionsUI.ep.name" schema="schema/buildDefinitionsUI.exsd"/>
+ <extension-point id="newWizardPages" name="%extension-point.name" schema="schema/newWizardPages.exsd"/>
+
+ <extension
+ point="org.eclipse.core.expressions.definitions">
+ <definition
+ id="org.eclipse.cdt.managedbuilder.ui.isBuildableFileOpenInEditor">
+ <and>
+ <with variable="selection">
+ <not>
+ <instanceof value="org.eclipse.jface.viewers.IStructuredSelection"/>
+ </not>
+ </with>
+ <with variable="activeEditorInput">
+ <reference definitionId="org.eclipse.cdt.managedbuilder.ui.isBuildableFile"/>
+ </with>
+ </and>
+ </definition>
+ <definition
+ id="org.eclipse.cdt.managedbuilder.ui.isBuildableFile">
+ <adapt type="org.eclipse.core.resources.IFile">
+ <and>
+ <test property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
+ <test property="org.eclipse.cdt.ui.projectBuilder"
+ value="org.eclipse.cdt.managedbuilder.core.genmakebuilder"/>
+ <test property="org.eclipse.cdt.ui.isSource"/>
+ </and>
+ </adapt>
+ </definition>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <category
+ name="%category.build.name"
+ description="%category.build.description"
+ id="org.eclipse.cdt.managedbuilder.ui.category.build"/>
+ <command
+ name="%command.cleanFiles.name"
+ description="%command.cleanFiles.description"
+ categoryId="org.eclipse.cdt.managedbuilder.ui.category.build"
+ id="org.eclipse.cdt.managedbuilder.ui.cleanFiles"/>
+ <command
+ name="%command.buildFiles.name"
+ description="%command.buildFiles.description"
+ categoryId="org.eclipse.cdt.managedbuilder.ui.category.build"
+ id="org.eclipse.cdt.managedbuilder.ui.buildFiles"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.cdt.managedbuilder.internal.ui.actions.CleanFilesHandler"
+ commandId="org.eclipse.cdt.managedbuilder.ui.cleanFiles"/>
+ <handler
+ class="org.eclipse.cdt.managedbuilder.internal.ui.actions.BuildFilesHandler"
+ commandId="org.eclipse.cdt.managedbuilder.ui.buildFiles"/>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?before=additions">
+ <command
+ commandId="org.eclipse.cdt.managedbuilder.ui.cleanFiles"
+ label="%CleanSelectedFiles.label"
+ style="push">
+ <visibleWhen checkEnabled="false">
+ <and>
+ <test property="org.eclipse.cdt.ui.checkPreference"
+ value="org.eclipse.core.resources/description.autobuilding=false"/>
+ <or>
+ <reference
+ definitionId="org.eclipse.cdt.managedbuilder.ui.isBuildableFileOpenInEditor"/>
+ <with variable="selection">
+ <iterate ifEmpty="false">
+ <reference
+ definitionId="org.eclipse.cdt.managedbuilder.ui.isBuildableFile"/>
+ </iterate>
+ </with>
+ </or>
+ </and>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.cdt.managedbuilder.ui.buildFiles"
+ label="%BuildSelectedFiles.label"
+ style="push">
+ <visibleWhen checkEnabled="false">
+ <and>
+ <test property="org.eclipse.cdt.ui.checkPreference"
+ value="org.eclipse.core.resources/description.autobuilding=false"/>
+ <or>
+ <reference
+ definitionId="org.eclipse.cdt.managedbuilder.ui.isBuildableFileOpenInEditor"/>
+ <with variable="selection">
+ <iterate ifEmpty="false">
+ <reference
+ definitionId="org.eclipse.cdt.managedbuilder.ui.isBuildableFile"/>
+ </iterate>
+ </with>
+ </or>
+ </and>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ adaptable="true"
+ id="org.eclipse.cdt.managedbuilder.ui.popupMenu.ConvertTargetContribution">
+ <action
+ label="%ConvertTargetAction.label"
+ class="org.eclipse.cdt.managedbuilder.internal.ui.actions.ConvertTargetAction"
+ menubarPath="additions"
+ enablesFor="1"
+ id="org.eclipse.cdt.managedbuilder.ui.ConvertTargetAction"/>
+ <filter
+ name="projectNature"
+ value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ adaptable="true"
+ id="org.eclipse.cdt.managedbuilder.ui.popupMenu.BuildAll">
+ <action
+ class="org.eclipse.cdt.managedbuilder.internal.ui.actions.CleanAndBuildAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.managedbuilder.ui.rebuildConfigurationsAction"
+ label="%RebuildConfigurationsMenu.label"
+ menubarPath="org.eclipse.cdt.ui.cfgmenu/build"/>
+ <action
+ class="org.eclipse.cdt.managedbuilder.internal.ui.actions.CleanAllConfigurationsAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.managedbuilder.ui.cleanAllConfigurationsAction"
+ label="%CleanAllConfigurationsMenu.label"
+ menubarPath="org.eclipse.cdt.ui.cfgmenu/build"/>
+ <action
+ class="org.eclipse.cdt.managedbuilder.internal.ui.actions.BuildAllConfigurationsAction"
+ enablesFor="+"
+ id="org.eclipse.cdt.managedbuilder.ui.buildAllConfigurationsAction"
+ label="%BuildAllConfigurationsMenu.label"
+ menubarPath="org.eclipse.cdt.ui.cfgmenu/build"/>
+ <visibility>
+ <objectState
+ name="projectNature"
+ value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
+ </visibility>
+ </objectContribution>
+ </extension>
<extension
point="org.eclipse.ui.newWizards">
@@ -89,83 +241,6 @@
<!-- Action for Project Converter in context menu -->
<extension
- point="org.eclipse.ui.popupMenus">
- <objectContribution
- objectClass="org.eclipse.core.resources.IProject"
- adaptable="true"
- id="org.eclipse.cdt.managedbuilder.ui.popupMenu.ConvertTargetContribution">
- <action
- label="%ConvertTargetAction.label"
- class="org.eclipse.cdt.managedbuilder.internal.ui.actions.ConvertTargetAction"
- menubarPath="additions"
- enablesFor="1"
- id="org.eclipse.cdt.managedbuilder.ui.ConvertTargetAction">
- </action>
- <filter
- name="projectNature"
- value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
- </filter>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.core.resources.IProject"
- adaptable="true"
- id="org.eclipse.cdt.managedbuilder.ui.popupMenu.BuildAll">
- <action
- class="org.eclipse.cdt.managedbuilder.internal.ui.actions.CleanAndBuildAction"
- enablesFor="+"
- id="org.eclipse.cdt.managedbuilder.ui.rebuildConfigurationsAction"
- label="%RebuildConfigurationsMenu.label"
- menubarPath="org.eclipse.cdt.ui.cfgmenu/build"/>
- <action
- class="org.eclipse.cdt.managedbuilder.internal.ui.actions.CleanAllConfigurationsAction"
- enablesFor="+"
- id="org.eclipse.cdt.managedbuilder.ui.cleanAllConfigurationsAction"
- label="%CleanAllConfigurationsMenu.label"
- menubarPath="org.eclipse.cdt.ui.cfgmenu/build"/>
- <action
- class="org.eclipse.cdt.managedbuilder.internal.ui.actions.BuildAllConfigurationsAction"
- enablesFor="+"
- id="org.eclipse.cdt.managedbuilder.ui.buildAllConfigurationsAction"
- label="%BuildAllConfigurationsMenu.label"
- menubarPath="org.eclipse.cdt.ui.cfgmenu/build"/>
- <visibility>
- <objectState
- name="projectNature"
- value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
- </visibility>
- </objectContribution>
- <objectContribution
- adaptable="true"
- id="org.eclipse.cdt.managedbuilder.ui.BuildSelectedFilesContribution"
- objectClass="org.eclipse.core.resources.IResource">
- <action
- class="org.eclipse.cdt.managedbuilder.internal.ui.actions.BuildFilesAction"
- enablesFor="+"
- id="org.eclipse.cdt.managedbuilder.ui.popups.buildFilesAction"
- label="%BuildSelectedFiles.label"
- menubarPath="additions"/>
- <action
- class="org.eclipse.cdt.managedbuilder.internal.ui.actions.CleanFilesAction"
- enablesFor="+"
- id="org.eclipse.cdt.managedbuilder.ui.popups.cleanFilesAction"
- label="%CleanSelectedFiles.label"
- menubarPath="additions"/>
- <visibility>
- <and>
- <not>
- <objectClass name="org.eclipse.core.resources.IProject"/>
- </not>
- <not>
- <objectClass name="org.eclipse.core.resources.IFolder"/>
- </not>
- <objectState
- name="projectNature"
- value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
- </and>
- </visibility>
- </objectContribution>
- </extension>
- <extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="org.eclipse.cdt.ui.CPerspective">
</perspectiveExtension>
@@ -553,7 +628,8 @@
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
</adapt>
- <test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.export.page.enable=true"/>
+ <test property="org.eclipse.cdt.ui.checkPreference"
+ value="org.eclipse.cdt.ui/properties.export.page.enable=true"/>
</and>
</enabledWhen>
</page>
@@ -589,7 +665,8 @@
<test property="org.eclipse.core.resources.projectNature"
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
</adapt>
- <test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.toolchain.modification.disable=false"/>
+ <test property="org.eclipse.cdt.ui.checkPreference"
+ value="org.eclipse.cdt.ui/properties.toolchain.modification.disable=false"/>
</and>
</enabledWhen>
<keywordReference
@@ -610,7 +687,8 @@
<adapt type="org.eclipse.core.resources.IProject">
<and>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.managedbuilder.core.managedBuildNature"/>
- <test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.sd.page.enable=true"/>
+ <test property="org.eclipse.cdt.ui.checkPreference"
+ value="org.eclipse.cdt.ui/properties.sd.page.enable=true"/>
</and>
</adapt>
</enabledWhen>
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesAction.java
deleted file mode 100644
index 6983bcc43c..0000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesAction.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Texas Instruments Incorporated 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:
- * Texas Instruments - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui.actions;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-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.NullProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionDelegate;
-import org.eclipse.ui.internal.ide.actions.BuildUtilities;
-
-/**
- * Action to build selected files.
- */
-public class BuildFilesAction extends ActionDelegate implements
- IWorkbenchWindowActionDelegate {
-
- /**
- * The workbench window; or <code>null</code> if this action has been
- * <code>dispose</code>d.
- */
- private IWorkbenchWindow workbenchWindow = null;
-
- private IAction action = null;
-
- /**
- *
- */
- public BuildFilesAction() {
- this(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
- }
-
- /**
- * Creates an instance of this action, for use in the given window.
- */
- public BuildFilesAction(IWorkbenchWindow window) {
- if (window == null) {
- throw new IllegalArgumentException();
- }
- this.workbenchWindow = window;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
- */
- @Override
- public void init(IAction action) {
- this.action = action;
- update();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- @Override
- public void init(IWorkbenchWindow window) {
- workbenchWindow = window;
-
- }
-
- /**
- * Helper method that converts an object to the <code>IFile</code>
- * interface. The conversion is a bare cast operation (if the object is
- * instance of <code>IFile</code>, or an adaptation (if the object is
- * instance of <code>IAdaptable</code>).
- *
- * @param object
- * the object to be cast to <code>IFile</code>
- * @return a reference to an IFile corresponding to the object provided, or
- * null if it is not possible to convert the provided object to
- * <code>IFile</code>.
- */
- private IFile convertToIFile(Object object) {
-
- if (object instanceof IFile) {
- return (IFile) object;
- }
-
- if (object instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) object;
- IFile file = (IFile) adaptable.getAdapter(IFile.class);
-
- if (file != null) {
- return file;
- }
- }
-
- // this *should* be redundant now that I've made CElement adaptable to IFile but we'll leave
- // it just to be safe
- if (object instanceof ITranslationUnit) {
- IResource resource = ((ITranslationUnit) object).getResource();
-
- // should be safe to cast to IFile (can't really have a non-file
- // translation unit), but check anyway
- if (resource instanceof IFile) {
- return (IFile) resource;
- }
-
- }
-
- return null;
- }
-
- /**
- * Returns a list of resources currently selected.
- * "Buildable" means buildable by MBS.
- *
- * @return a list of resources
- */
- private List<IFile> getSelectedBuildableFiles() {
-
- List<IFile> files = new LinkedList<IFile>();
-
- ISelectionService selectionService = workbenchWindow
- .getSelectionService();
- ISelection selection = selectionService.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- for (Iterator<?> elements = structuredSelection.iterator(); elements
- .hasNext();) {
- IFile file = convertToIFile(elements.next());
- if (file != null) {
- // we only add files that we can actually build
- IManagedBuildInfo buildInfo = ManagedBuildManager
- .getBuildInfo(file.getProject());
-
- if ((buildInfo != null) && buildInfo.isValid()
- && buildInfo
- .buildsFileType(file.getFileExtension())) {
- files.add(file);
- }
- }
- }
-
- // since we don't allow building folders, there can be no
- // redundancies
- // eliminateRedundancies(resources);
- }
-
- return files;
- }
-
- private static final class BuildFilesJob extends Job {
- private final List<IFile> files;
-
- BuildFilesJob(List<IFile> filesToBuild) {
- super(ManagedMakeMessages.getResourceString("BuildFilesAction.buildingSelectedFiles")); //$NON-NLS-1$
- files = filesToBuild;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
- return builder.invokeInternalBuilder(files, monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
- */
- @Override
- public boolean belongsTo(Object family) {
- return ResourcesPlugin.FAMILY_MANUAL_BUILD == family;
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- @Override
- public void run(IAction action) {
- List<IFile> selectedFiles = getSelectedBuildableFiles();
- Job buildFilesJob = new BuildFilesJob(selectedFiles);
-
- List<IProject> projects = getProjectsToBuild(selectedFiles);
- if (projects != null && !projects.isEmpty()) {
- // Save all resources prior to doing build
- BuildUtilities.saveEditors(projects);
- }
-
- buildFilesJob.schedule();
-
- }
-
- private boolean shouldBeEnabled() {
-
- // fix for bug 139663
- // if build automatically is turned on, then this menu should be turned off as
- // it will trigger the auto build
- Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences();
-
- if(preferences.getBoolean(ResourcesPlugin.PREF_AUTO_BUILDING))
- {
- // auto building is on... do not enable the menu
- return false;
- }
-
- ISelectionService selectionService = workbenchWindow
- .getSelectionService();
- ISelection selection = selectionService.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-
- if (structuredSelection.size() <= 0) {
- return false;
- }
-
- for (Iterator<?> elements = structuredSelection.iterator(); elements
- .hasNext();) {
- IFile file = convertToIFile(elements.next());
- if (file != null) {
- // we only add files that we can actually build
- if (!ManagedBuildManager.manages(file.getProject())) {
- return false;
- }
-
- IManagedBuildInfo buildInfo = ManagedBuildManager
- .getBuildInfo(file.getProject());
-
- if (buildInfo == null || !buildInfo.isValid()
- || buildInfo.getDefaultConfiguration() == null
- || !buildInfo.getDefaultConfiguration().isManagedBuildOn()) {
- return false;
- }
-
- IManagedBuilderMakefileGenerator buildfileGenerator = ManagedBuildManager
- .getBuildfileGenerator(buildInfo
- .getDefaultConfiguration());
-
- if (buildfileGenerator == null) {
- return false;
- }
-
- // make sure build file generator is initialized
- buildfileGenerator.initialize(file.getProject(), buildInfo,
- new NullProgressMonitor());
-
- // if we have no build info or we can't build the file, then
- // disable the action
- if (!buildInfo.buildsFileType(file.getFileExtension())
- || buildfileGenerator.isGeneratedResource(file)) {
-
- return false;
-
- }
- }
-
- else {
- return false;
- }
- }
- return true;
- }
-
- return false;
-
- }
-
- /*
- * Updates the enablement state for the action based upon the selection. If
- * the selection corresponds to files buildable by MBS, then the action will
- * be enabled.
- */
- private void update() {
- if (action != null) {
- action.setEnabled(shouldBeEnabled());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
- */
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- // update state
- update();
- }
-
-
- /*
- * Returns the projects to build.
- * This contains the set of projects which have builders, across all selected resources.
- */
- private List<IProject> getProjectsToBuild(List<IFile> selectedFiles) {
- List<IProject> projectsToBuild = new LinkedList<IProject>();
- for (Iterator<IFile> i = selectedFiles.iterator(); i.hasNext();) {
- IFile file = i.next();
- IProject project = file.getProject();
- if (project != null) {
- if (!projectsToBuild.contains(project)) {
- if (hasBuilder(project)) {
- projectsToBuild.add(project);
- }
- }
- }
- }
-
- return projectsToBuild;
- }
-
- /*
- * 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 couldn't be determined
- */
- private boolean hasBuilder(IProject project) {
- if (!project.isAccessible())
- return false;
- try {
- ICommand[] commands = project.getDescription().getBuildSpec();
- if (commands.length > 0) {
- return true;
- }
- } catch (CoreException e) {
- // this method is called when selection changes, so
- // just fall through if it fails.
- // this shouldn't happen anyway, since the list of selected resources
- // has already been checked for accessibility before this is called
- }
- return false;
- }
-
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java
new file mode 100644
index 0000000000..7e7b87583e
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/BuildFilesHandler.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2014 Texas Instruments Incorporated 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:
+ * Texas Instruments - initial API and implementation
+ * Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.cdt.internal.core.AdapterUtil;
+import org.eclipse.cdt.internal.ui.util.AbstractResourceActionHandler;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.internal.ide.actions.BuildUtilities;
+
+public class BuildFilesHandler extends AbstractResourceActionHandler {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ List<IFile> selectedFiles = getSelectedFiles(event);
+ if (selectedFiles.isEmpty())
+ return null;
+
+ Job buildFilesJob = new BuildFilesJob(selectedFiles);
+
+ Collection<IProject> projects = getProjectsToBuild(selectedFiles);
+ BuildUtilities.saveEditors(projects); // Save all resources prior to doing build.
+ buildFilesJob.schedule();
+ return null;
+ }
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ super.setEnabled(evaluationContext);
+ setBaseEnabled(shouldBeEnabled());
+ }
+
+ private boolean shouldBeEnabled() {
+ // Fix for bug 139663.
+ // If build automatically is turned on, then this command should be turned off as
+ // it will trigger the auto build.
+ IPreferencesService preferences = Platform.getPreferencesService();
+
+ if (preferences.getBoolean(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PREF_AUTO_BUILDING,
+ false, null)) {
+ // Auto building is on - do not enable the command.
+ return false;
+ }
+
+ IStructuredSelection selection = getSelection();
+ if (selection.isEmpty())
+ return false;
+
+ for (Iterator<?> elements = selection.iterator(); elements.hasNext();) {
+ IFile file = AdapterUtil.adapt(elements.next(), IFile.class);
+ if (file == null)
+ return false;
+
+ // We only add files that we can actually build.
+ if (!ManagedBuildManager.manages(file.getProject()))
+ return false;
+
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(file.getProject());
+
+ if (buildInfo == null || !buildInfo.isValid()
+ || buildInfo.getDefaultConfiguration() == null
+ || !buildInfo.getDefaultConfiguration().isManagedBuildOn()) {
+ return false;
+ }
+
+ IManagedBuilderMakefileGenerator buildfileGenerator =
+ ManagedBuildManager.getBuildfileGenerator(buildInfo.getDefaultConfiguration());
+
+ if (buildfileGenerator == null)
+ return false;
+
+ // Make sure build file generator is initialized.
+ buildfileGenerator.initialize(file.getProject(), buildInfo, new NullProgressMonitor());
+
+ // If we have no build info or we can't build the file, then disable the command.
+ if (!buildInfo.buildsFileType(file.getFileExtension())
+ || buildfileGenerator.isGeneratedResource(file)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private List<IFile> getSelectedFiles(ExecutionEvent event) throws ExecutionException {
+ Collection<IResource> selectedResources = getSelectedResources(event);
+ List<IFile> files = new ArrayList<>(selectedResources.size());
+ for (IResource resource : selectedResources) {
+ if (resource instanceof IFile)
+ files.add((IFile) resource);
+ }
+ return files;
+ }
+
+ /*
+ * Returns the projects to build. These are the projects which have builders,
+ * across all selected resources.
+ */
+ private Collection<IProject> getProjectsToBuild(List<IFile> selectedFiles) {
+ Set<IProject> projectsToBuild = new HashSet<IProject>();
+ for (IFile file : selectedFiles) {
+ IProject project = file.getProject();
+ if (!projectsToBuild.contains(project)) {
+ if (hasBuilder(project)) {
+ projectsToBuild.add(project);
+ }
+ }
+ }
+
+ return projectsToBuild;
+ }
+
+ /*
+ * Checks whether there are builders configured on the given project.
+ *
+ * @return {@code true} if it has builders, {@code false} if not, or if this couldn't be
+ * determined
+ */
+ private boolean hasBuilder(IProject project) {
+ if (!project.isAccessible())
+ return false;
+
+ try {
+ ICommand[] commands = project.getDescription().getBuildSpec();
+ if (commands.length > 0)
+ return true;
+ } catch (CoreException e) {
+ // This method is called when selection changes, so just fall through if it
+ // fails. This shouldn't happen anyway, since the list of selected resources
+ // has already been checked for accessibility before this is called.
+ }
+ return false;
+ }
+
+ private static class BuildFilesJob extends Job {
+ private final List<IFile> files;
+
+ BuildFilesJob(List<IFile> filesToBuild) {
+ super(ManagedMakeMessages.getResourceString("BuildFilesHandler.buildingSelectedFiles")); //$NON-NLS-1$
+ files = filesToBuild;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
+ return builder.invokeInternalBuilder(files, monitor);
+ }
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return ResourcesPlugin.FAMILY_MANUAL_BUILD == family;
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesAction.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesAction.java
deleted file mode 100644
index 91d33ec1d8..0000000000
--- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesAction.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Texas Instruments Incorporated 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:
- * Texas Instruments - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.ui.actions;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionDelegate;
-
-/**
- * Action to clean build output for selected files
- */
-public class CleanFilesAction extends ActionDelegate implements
- IWorkbenchWindowActionDelegate {
- /**
- * The workbench window; or <code>null</code> if this action has been
- * <code>dispose</code>d.
- */
- private IWorkbenchWindow workbenchWindow = null;
-
- private IAction action = null;
-
- /**
- *
- */
- public CleanFilesAction() {
- this(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
- }
-
- /**
- * Creates an instance of this action, for use in the given window.
- */
- public CleanFilesAction(IWorkbenchWindow window) {
- if (window == null) {
- throw new IllegalArgumentException();
- }
- this.workbenchWindow = window;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- @Override
- public void dispose() {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionDelegate#init(org.eclipse.jface.action.IAction)
- */
- @Override
- public void init(IAction action) {
- this.action = action;
- update();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- @Override
- public void init(IWorkbenchWindow window) {
- workbenchWindow = window;
-
- }
-
- /**
- * Helper method that converts an object to the <code>IFile</code>
- * interface. The conversion is a bare cast operation (if the object is
- * instance of <code>IFile</code>, or an adaptation (if the object is
- * instance of <code>IAdaptable</code>).
- *
- * @param object
- * the object to be cast to <code>IFile</code>
- * @return a reference to an IFile corresponding to the object provided, or
- * null if it is not possible to convert the provided object to
- * <code>IFile</code>.
- */
- private IFile convertToIFile(Object object) {
-
- if (object instanceof IFile) {
- return (IFile) object;
- }
-
- if (object instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) object;
- IFile file = (IFile) adaptable.getAdapter(IFile.class);
-
- if (file != null) {
- return file;
- }
- }
-
- // this *should* be redundant now that I've made CElement adaptable to IFile but we'll leave
- // it just to be safe
- if (object instanceof ITranslationUnit) {
- IResource resource = ((ITranslationUnit) object).getResource();
-
- // should be safe to cast to IFile (can't really have a non-file
- // translation unit), but check anyway
- if (resource instanceof IFile) {
- return (IFile) resource;
- }
-
- }
-
- return null;
- }
-
- /**
- * Returns a list of buildable resources currently selected.
- * "Buildable" means buildable by MBS.
- *
- * @return a list of resources
- */
- private List<IFile> getSelectedBuildableFiles() {
-
- List<IFile> files = new LinkedList<IFile>();
-
- ISelectionService selectionService = workbenchWindow
- .getSelectionService();
- ISelection selection = selectionService.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- for (Iterator<?> elements = structuredSelection.iterator(); elements
- .hasNext();) {
- IFile file = convertToIFile(elements.next());
- if (file != null) {
- // we only add files that we can actually build
- IManagedBuildInfo buildInfo = ManagedBuildManager
- .getBuildInfo(file.getProject());
-
- if (buildInfo.buildsFileType(file.getFileExtension())) {
- files.add(file);
- }
- }
- }
-
- // since we don't allow building folders, there can be no
- // redundancies
- // eliminateRedundancies(resources);
- }
-
- return files;
- }
-
- private static final class CleanFilesJob extends Job {
- private final List<IFile> files;
-
- private CleanFilesJob(List<IFile> filesToBuild) {
- super(ManagedMakeMessages.getResourceString("CleanFilesAction.cleaningFiles")); //$NON-NLS-1$
- files = filesToBuild;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- synchronized (getClass()) {
- if (monitor.isCanceled()) {
- return Status.CANCEL_STATUS;
- }
- Job[] buildJobs = Job.getJobManager().find(
- ResourcesPlugin.FAMILY_MANUAL_BUILD);
- for (int i = 0; i < buildJobs.length; i++) {
- Job curr = buildJobs[i];
- if ((curr != this) && (curr instanceof CleanFilesJob)) {
- curr.cancel(); // cancel all other build jobs of our
- // kind
-
- }
- }
- }
-
- GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
- return builder.cleanFiles(files, monitor);
- }
-
- @Override
- public boolean belongsTo(Object family) {
- return ResourcesPlugin.FAMILY_MANUAL_BUILD == family;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- @Override
- public void run(IAction action) {
- List<IFile> selectedFiles = getSelectedBuildableFiles();
- CleanFilesJob job = new CleanFilesJob(selectedFiles);
- job.schedule();
- }
-
- private boolean shouldBeEnabled() {
-
-
- // fix for Bugzilla 139663
- // if build automatically is turned on, then this menu should be turned off as
- // it will trigger the auto build
- Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences();
-
- if(preferences.getBoolean(ResourcesPlugin.PREF_AUTO_BUILDING))
- {
- // auto building is on... do not enable the menu
- return false;
- }
-
- ISelectionService selectionService = workbenchWindow
- .getSelectionService();
- ISelection selection = selectionService.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
-
- if (structuredSelection.size() <= 0) {
- return false;
- }
-
- for (Iterator<?> elements = structuredSelection.iterator(); elements
- .hasNext();) {
- IFile file = convertToIFile(elements.next());
- if (file != null) {
- // we only add files that we can actually build
- if (!ManagedBuildManager.manages(file.getProject())) {
- return false;
- }
-
- IManagedBuildInfo buildInfo = ManagedBuildManager
- .getBuildInfo(file.getProject());
-
- // if we have no build info or we can't build the file, then
- // disable the action
- if ((buildInfo == null) || !buildInfo.isValid()
- || !buildInfo.buildsFileType(file
- .getFileExtension())) {
- return false;
- }
- }
-
- else {
- return false;
- }
-
- }
-
- return true;
- }
-
- return false;
- }
-
- /*
- * Updates the enablement state for the action based upon the selection. If
- * the selection corresponds to files buildable by MBS, then the action will
- * be enabled.
- */
- private void update() {
- if (action != null) {
- action.setEnabled(shouldBeEnabled());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
- */
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- update();
- }
-
-}
diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java
new file mode 100644
index 0000000000..5e12e8bf17
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/actions/CleanFilesHandler.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2014 Texas Instruments Incorporated 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:
+ * Texas Instruments - initial API and implementation
+ * Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.internal.core.AdapterUtil;
+import org.eclipse.cdt.internal.ui.util.AbstractResourceActionHandler;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
+import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+/**
+ * Action to clean build output for selected files
+ */
+public class CleanFilesHandler extends AbstractResourceActionHandler {
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ List<IFile> selectedFiles = getSelectedBuildableFiles(event);
+ if (selectedFiles.isEmpty())
+ return null;
+
+ CleanFilesJob job = new CleanFilesJob(selectedFiles);
+ job.schedule();
+ return null;
+ }
+
+ /**
+ * Returns a list of buildable resources currently selected.
+ * "Buildable" means buildable by MBS.
+ */
+ private List<IFile> getSelectedBuildableFiles(ExecutionEvent event) throws ExecutionException {
+ Collection<IResource> selectedResources = getSelectedResources(event);
+ List<IFile> files = new ArrayList<>(selectedResources.size());
+ for (IResource resource : selectedResources) {
+ // We only add files that we can actually build.
+ if (resource instanceof IFile && isBuildable(resource)) {
+ files.add((IFile) resource);
+ }
+ }
+ return files;
+ }
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ super.setEnabled(evaluationContext);
+ setBaseEnabled(shouldBeEnabled());
+ }
+
+ private boolean shouldBeEnabled() {
+ // Fix for bug 139663.
+ // If build automatically is turned on, then this command should be turned off as
+ // it will trigger the auto build.
+ IPreferencesService preferences = Platform.getPreferencesService();
+
+ if (preferences.getBoolean(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PREF_AUTO_BUILDING,
+ false, null)) {
+ // Auto building is on - do not enable the command.
+ return false;
+ }
+
+ IStructuredSelection selection = getSelection();
+ if (selection.isEmpty())
+ return false;
+
+ for (Iterator<?> elements = selection.iterator(); elements.hasNext();) {
+ IFile file = AdapterUtil.adapt(elements.next(), IFile.class);
+ if (file == null)
+ return false;
+
+ // We only add files that we can actually build.
+ if (!isBuildable(file))
+ return false;
+ }
+
+ return true;
+ }
+
+ private static boolean isBuildable(IResource resource) {
+ IProject project = resource.getProject();
+ if (!ManagedBuildManager.manages(project))
+ return false;
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
+ return buildInfo != null && buildInfo.isValid()
+ && buildInfo.buildsFileType(resource.getFileExtension());
+ }
+
+ private static class CleanFilesJob extends Job {
+ private final List<IFile> files;
+
+ private CleanFilesJob(List<IFile> filesToBuild) {
+ super(ManagedMakeMessages.getResourceString("CleanFilesHandler.cleaningFiles")); //$NON-NLS-1$
+ files = filesToBuild;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ synchronized (getClass()) {
+ if (monitor.isCanceled()) {
+ return Status.CANCEL_STATUS;
+ }
+ Job[] buildJobs = Job.getJobManager().find(ResourcesPlugin.FAMILY_MANUAL_BUILD);
+ for (Job job : buildJobs) {
+ if ((job != this) && (job instanceof CleanFilesJob)) {
+ job.cancel(); // Cancel all other build jobs of our kind.
+ }
+ }
+ }
+
+ GeneratedMakefileBuilder builder = new GeneratedMakefileBuilder();
+ return builder.cleanFiles(files, monitor);
+ }
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return ResourcesPlugin.FAMILY_MANUAL_BUILD == family;
+ }
+ }
+}
diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
index 19f857dabf..c9ddbec67a 100644
--- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
@@ -43,13 +43,14 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.core.templateengine.process,
org.eclipse.cdt.core.templateengine.process.processes,
org.eclipse.cdt.internal.core;
- x-friends:="org.eclipse.cdt.ui,
+ x-friends:="org.eclipse.cdt.codan.core.cxx,
org.eclipse.cdt.debug.core,
- org.eclipse.cdt.managedbuilder.core,
+ org.eclipse.cdt.dsf.gdb,
org.eclipse.cdt.make.core,
org.eclipse.cdt.make.ui,
- org.eclipse.cdt.codan.core.cxx,
- org.eclipse.cdt.dsf.gdb",
+ org.eclipse.cdt.managedbuilder.core,
+ org.eclipse.cdt.managedbuilder.ui,
+ org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.browser;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.cdtvariables;x-internal:=true,
org.eclipse.cdt.internal.core.dom;x-internal:=true,
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index fea1dc39ff..055746e355 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -4,7 +4,7 @@
<!-- =================================================================================== -->
-<!-- Obsolete extension point no longer in use, will be remove. -->
+<!-- Obsolete extension point no longer in use, will be removed. -->
<!-- =================================================================================== -->
<extension-point id="CProject" name="%CProject.name" schema="schema/CProject.exsd"/>
<!-- =================================================================================== -->
@@ -289,6 +289,7 @@
class="org.eclipse.cdt.internal.errorparsers.VCErrorParser">
</errorparser>
</extension>
+
<!-- =================================================================================== -->
<!-- CDT customized problem markers: C Problem markers -->
<!-- =================================================================================== -->
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/AdapterUtil.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/AdapterUtil.java
new file mode 100644
index 0000000000..ad1c4a715a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/AdapterUtil.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Google, Inc 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:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * A collection of static adaptor-related methods.
+ */
+public class AdapterUtil {
+ /**
+ * Adapts the given object to the given type.
+ *
+ * @param object the object to adapt
+ * @param type the type to adapt to
+ * @return the adapted object, or {@code null} if the object cannot be adapted.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> T adapt(Object object, Class<T> type) {
+ if (object == null)
+ return null;
+
+ if (type.isInstance(object))
+ return (T) object;
+
+ if (object instanceof IAdaptable)
+ return (T) ((IAdaptable) object).getAdapter(type);
+
+ return null;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index 248fe7a974..d36a2aed43 100644
--- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
@@ -63,7 +63,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.internal.ui.text.template;x-internal:=true,
org.eclipse.cdt.internal.ui.text.util;x-internal:=true,
org.eclipse.cdt.internal.ui.typehierarchy;x-internal:=true,
- org.eclipse.cdt.internal.ui.util;x-friends:="org.eclipse.cdt.debug.ui,org.eclipse.cdt.debug.edc.tests",
+ org.eclipse.cdt.internal.ui.util;x-friends:="org.eclipse.cdt.debug.ui,org.eclipse.cdt.debug.edc.tests,org.eclipse.cdt.managedbuilder.ui",
org.eclipse.cdt.internal.ui.viewsupport;x-internal:=true,
org.eclipse.cdt.internal.ui.wizards;x-internal:=true,
org.eclipse.cdt.internal.ui.wizards.classwizard;x-internal:=true,
@@ -102,6 +102,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.utils.ui.controls
Require-Bundle: org.eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)",
org.eclipse.compare;bundle-version="[3.3.0,4.0.0)",
+ org.eclipse.core.expressions,
org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)",
org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index 2145d9f2f3..adcf5ba3a2 100755
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -80,65 +80,65 @@ ActionDefinition.sourceQuickMenu.name= Show Source Quick Menu
ActionDefinition.sourceQuickMenu.description= Shows the source quick menu
ActionDefinition.comment.name= Comment
-ActionDefinition.comment.description= Turn the selected lines into // style comments
+ActionDefinition.comment.description= Turns the selected lines into // style comments
ActionDefinition.uncomment.name= Uncomment
-ActionDefinition.uncomment.description= Uncomment the selected // style comment lines
+ActionDefinition.uncomment.description= Uncomments the selected // style comment lines
ActionDefinition.toggleComment.name= Comment/Uncomment
-ActionDefinition.toggleComment.description= Comment/Uncomment the selected lines
+ActionDefinition.toggleComment.description= Comments/Uncomments the selected lines
ActionDefinition.opendecl.name= Open Declaration
-ActionDefinition.opendecl.description= Open an editor on the selected element's declaration(s)
+ActionDefinition.opendecl.description= Opens an editor on the selected element's declaration(s)
ActionDefinition.opencview.name= Show in C/C++ Project view
-ActionDefinition.opencview.description= Show the selected resource in the C/C++ Project view
+ActionDefinition.opencview.description= Shows the selected resource in the C/C++ Project view
ActionDefinition.finddecl.name= Declaration
-ActionDefinition.finddecl.description= Search for declarations of the selected element in the workspace
+ActionDefinition.finddecl.description= Searches for declarations of the selected element in the workspace
ActionDefinition.finddecl.project.name= Declaration in Project
-ActionDefinition.finddecl.project.description= Search for declarations of the selected element in the enclosing project
+ActionDefinition.finddecl.project.description= Searches for declarations of the selected element in the enclosing project
ActionDefinition.finddecl.workingset.name= Declaration in Working Set
-ActionDefinition.finddecl.workingset.description= Search for declarations of the selected element in a working set
+ActionDefinition.finddecl.workingset.description= Searches for declarations of the selected element in a working set
ActionDefinition.findrefs.name= References
-ActionDefinition.findrefs.description= Search for references to the selected element in the workspace
+ActionDefinition.findrefs.description= Searches for references to the selected element in the workspace
ActionDefinition.findrefs.project.name= References in Project
-ActionDefinition.findrefs.project.description= Search for references to the selected element in the enclosing project
+ActionDefinition.findrefs.project.description= Searches for references to the selected element in the enclosing project
ActionDefinition.findrefs.workingset.name= References in Working Set
-ActionDefinition.findrefs.workingset.description= Search for references to the selected element in a working set
+ActionDefinition.findrefs.workingset.description= Searches for references to the selected element in a working set
ActionDefinition.openCallHierarchy.name= Open Call Hierarchy
-ActionDefinition.openCallHierarchy.description= Open the call hierarchy for the selected element
+ActionDefinition.openCallHierarchy.description= Opens the call hierarchy for the selected element
ActionDefinition.addBlockComment.name= Add Block Comment
-ActionDefinition.addBlockComment.description= Enclose the selection with a block comment
+ActionDefinition.addBlockComment.description= Encloses the selection with a block comment
ActionDefinition.removeBlockComment.name= Remove Block Comment
-ActionDefinition.removeBlockComment.description= Remove the block comment enclosing the selection
+ActionDefinition.removeBlockComment.description= Removes the block comment enclosing the selection
ActionDefinition.indent.name= Indent Line
ActionDefinition.indent.description=Indents the current line
ActionDefinition.format.name=Format
-ActionDefinition.format.description=Format Source Code
+ActionDefinition.format.description=Formats Source Code
ActionDefinition.gotoMatchingBracket.name= Go to Matching Bracket
ActionDefinition.gotoMatchingBracket.description= Moves the cursor to the matching bracket
ActionDefinition.gotoNextBookmark.name= Next Bookmark
-ActionDefinition.gotoNextBookmark.description= Goto next bookmark of the selected file
+ActionDefinition.gotoNextBookmark.description= Goes to the next bookmark of the selected file
ActionDefinition.FindWord.name= Find Word
-ActionDefinition.FindWord.description= Select a word and find the next occurrence
+ActionDefinition.FindWord.description= Selects a word and find the next occurrence
ActionDefinition.toggleSourceHeader.name= Toggle Source/Header
ActionDefinition.toggleSourceHeader.description= Toggles between corresponding source and header files
ActionDefinition.backwardMacroExpansion.name= Back
-ActionDefinition.backwardMacroExpansion.description= Step backward in macro expansions
+ActionDefinition.backwardMacroExpansion.description= Steps backward in macro expansions
ActionDefinition.forwardMacroExpansion.name= Forward
-ActionDefinition.forwardMacroExpansion.description= Step forward in macro expansions
+ActionDefinition.forwardMacroExpansion.description= Steps forward in macro expansions
ActionDefinition.showMacroExplorer.name= Explore Macro Expansion
ActionDefinition.showMacroExplorer.description= Opens a quick view for macro expansion exploration
@@ -151,13 +151,13 @@ refactoringHideMethod.label = Hide Member Function...
ActionDefinition.renameElement.name= Rename - Refactoring
-ActionDefinition.renameElement.description= Rename the selected element
+ActionDefinition.renameElement.description= Renames the selected element
ActionDefinition.extractConstant.name= Extract Constant - Refactoring
-ActionDefinition.extractConstant.description= Extract a constant for the selected expression
+ActionDefinition.extractConstant.description= Extracts a constant for the selected expression
ActionDefinition.extractLocalVariable.name= Extract Local Variable - Refactoring
-ActionDefinition.extractLocalVariable.description= Extract a local variable for the selected expression
+ActionDefinition.extractLocalVariable.description= Extracts a local variable for the selected expression
ActionDefinition.extractFunction.name= Extract Function - Refactoring
-ActionDefinition.extractFunction.description= Extract a function for the selected list of expressions or statements
+ActionDefinition.extractFunction.description= Extracts a function for the selected list of expressions or statements
ActionDefinition.toggleFunction.name= Toggle Function - Refactoring
ActionDefinition.toggleFunction.description= Toggles the implementation between header and implementation file
ActionDefinition.implementMethod.name= Implement Method - Source Generation
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 547eabd1ae..1d840b8926 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -3488,7 +3488,8 @@
<adapt type="org.eclipse.core.resources.IResource">
<and>
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
- <test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.core:language.settings.providers.disabled=false"/>
+ <test property="org.eclipse.cdt.ui.checkPreference"
+ value="org.eclipse.cdt.core/language.settings.providers.disabled=false"/>
</and>
</adapt>
</enabledWhen>
@@ -4079,30 +4080,37 @@
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
- id="org.eclipse.cdt.ui.preferenceTester"
- class="org.eclipse.cdt.ui.newui.PropertyTester"
- namespace="org.eclipse.cdt.ui"
- properties="checkPreference"
- type="java.lang.Object"/>
+ class="org.eclipse.cdt.internal.ui.expressions.CPropertyTester"
+ id="org.eclipse.cdt.ui.preferenceTester"
+ namespace="org.eclipse.cdt.ui"
+ properties="checkPreference"
+ type="java.lang.Object"/>
<propertyTester
- id="org.eclipse.cdt.Tester1"
- class="org.eclipse.cdt.ui.newui.PropertyTester"
- namespace="org.eclipse.cdt.ui"
- properties="isSource"
- type="org.eclipse.cdt.core.model.ITranslationUnit"/>
+ class="org.eclipse.cdt.internal.ui.expressions.CPropertyTester"
+ id="org.eclipse.cdt.Tester1"
+ namespace="org.eclipse.cdt.ui"
+ properties="isSource"
+ type="org.eclipse.cdt.core.model.ITranslationUnit"/>
<propertyTester
- id="org.eclipse.cdt.Tester2"
- class="org.eclipse.cdt.ui.newui.PropertyTester"
- namespace="org.eclipse.cdt.ui"
- properties="isSource"
- type="org.eclipse.core.resources.IFile"/>
+ class="org.eclipse.cdt.internal.ui.expressions.CPropertyTester"
+ id="org.eclipse.cdt.Tester2"
+ namespace="org.eclipse.cdt.ui"
+ properties="isSource"
+ type="org.eclipse.core.resources.IFile"/>
<propertyTester
- id="org.eclipse.cdt.ui.workingSetPropertyTester"
- class="org.eclipse.cdt.internal.ui.workingsets.WorkingSetPropertyTester"
- namespace="org.eclipse.cdt.ui"
- properties="hasCProjects"
- type="org.eclipse.ui.IWorkingSet"/>
+ class="org.eclipse.cdt.internal.ui.expressions.ResourcePropertyTester"
+ id="org.eclipse.cdt.core.projectBuilderTester"
+ namespace="org.eclipse.cdt.ui"
+ properties="projectBuilder"
+ type="org.eclipse.core.resources.IResource"/>
+ <propertyTester
+ class="org.eclipse.cdt.internal.ui.workingsets.WorkingSetPropertyTester"
+ id="org.eclipse.cdt.ui.workingSetPropertyTester"
+ namespace="org.eclipse.cdt.ui"
+ properties="hasCProjects"
+ type="org.eclipse.ui.IWorkingSet"/>
</extension>
+
<extension
point="org.eclipse.ui.exportWizards">
<category
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/CPropertyTester.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/CPropertyTester.java
new file mode 100644
index 0000000000..ecf152b317
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/CPropertyTester.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2014 Intel 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:
+ * Intel Corporation - initial API and implementation
+ * Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.expressions;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Property tester to test expressions in plugin.xml. Tests following expressions:
+ * 1. Checks whether given object is a source file. Usage:
+ * <test property="org.eclipse.cdt.ui.isSource"/>
+ * 2. Checks value of a preference. Usage:
+ * <test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.export.page.enable=true"/>
+ */
+public class CPropertyTester extends PropertyTester {
+ private static final String KEY_SRC = "isSource"; //$NON-NLS-1$
+ private static final String KEY_PREF = "checkPreference"; //$NON-NLS-1$
+ private static final Pattern PREFERENCE_PATTERN = Pattern.compile("(.*)[/:](.*)=(.*)"); //$NON-NLS-1$
+
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (KEY_SRC.equals(property)) {
+ if (receiver instanceof ITranslationUnit) {
+ return ((ITranslationUnit) receiver).isSourceUnit();
+ } else if (receiver instanceof IFile) {
+ IFile file = (IFile) receiver;
+ return CoreModel.isValidSourceUnitName(file.getProject(), file.getName());
+ }
+ } else if (KEY_PREF.equals(property) && expectedValue instanceof String) {
+ Matcher matcher = PREFERENCE_PATTERN.matcher((String) expectedValue);
+ if (matcher.matches()) {
+ String pluginId = matcher.group(1);
+ String preference = matcher.group(2);
+ String wantedValue = matcher.group(3);
+
+ IPreferencesService preferences = Platform.getPreferencesService();
+ String actualValue = preferences.getString(pluginId, preference, null, null);
+ if (wantedValue != null) {
+ return wantedValue.equals(actualValue) || (actualValue == null && wantedValue.equals("false")); //$NON-NLS-1$
+ } else {
+ return actualValue != null;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/ResourcePropertyTester.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/ResourcePropertyTester.java
new file mode 100644
index 0000000000..7764746df7
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/expressions/ResourcePropertyTester.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Google, Inc 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:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.expressions;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+
+public class ResourcePropertyTester extends PropertyTester {
+ private static final String PROP_PROJECT_BUILDER = "projectBuilder"; //$NON-NLS-1$
+
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (!(receiver instanceof IResource) || args.length != 0)
+ return false;
+ if (property.equals(PROP_PROJECT_BUILDER)) {
+ IProject project = ((IResource) receiver).getProject();
+ if (project == null)
+ return false;
+ try {
+ IProjectDescription description = project.getDescription();
+ ICommand[] buildSpec = description.getBuildSpec();
+ for (ICommand builder : buildSpec) {
+ if (builder.getBuilderName().equals(expectedValue))
+ return true;
+ }
+ } catch (CoreException e) {
+ // Ignore to return false;
+ }
+ }
+ return false;
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/AbstractResourceActionHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/AbstractResourceActionHandler.java
new file mode 100644
index 0000000000..172e9b570c
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/AbstractResourceActionHandler.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Google, Inc 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:
+ * Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.ide.ResourceUtil;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.AdapterUtil;
+
+/**
+ * Base class for command handlers operating on resources.
+ */
+public abstract class AbstractResourceActionHandler extends AbstractHandler {
+ private IEvaluationContext evaluationContext;
+ private IStructuredSelection selection;
+
+ public void setSelection(ISelection selection) {
+ this.selection = convertSelection(null, selection);
+ }
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ this.evaluationContext = (IEvaluationContext) evaluationContext;
+ }
+
+ protected IStructuredSelection getSelection() {
+ if (selection == null) {
+ selection = convertSelection(evaluationContext, null);
+ }
+ return selection;
+ }
+
+ protected IStructuredSelection getSelection(ExecutionEvent event) throws ExecutionException {
+ Object selection = HandlerUtil.getActiveMenuSelection(event);
+ if (selection == null) {
+ selection = HandlerUtil.getCurrentSelectionChecked(event);
+ }
+ if (selection instanceof ITextSelection) {
+ IEditorInput editorInput = HandlerUtil.getActiveEditorInputChecked(event);
+ IResource resource = ResourceUtil.getResource(editorInput);
+ if (resource != null) {
+ return new StructuredSelection(resource);
+ }
+
+ resource = ResourceUtil.getFile(editorInput);
+ if (resource != null) {
+ return new StructuredSelection(resource);
+ }
+ }
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ private static IStructuredSelection convertSelection(IEvaluationContext context,
+ Object selection) {
+ if (selection == null) {
+ if (context == null) {
+ return StructuredSelection.EMPTY;
+ }
+ selection = context.getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
+ if (!(selection instanceof ISelection)) {
+ selection = context.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
+ }
+ }
+ if (selection instanceof ITextSelection) {
+ if (context == null) {
+ context = getEvaluationContext();
+ }
+ IResource resource =
+ ResourceUtil.getResource(context.getVariable(ISources.ACTIVE_EDITOR_INPUT_NAME));
+ if (resource != null) {
+ return new StructuredSelection(resource);
+ }
+ }
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection) selection;
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ private static IEvaluationContext getEvaluationContext() {
+ IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (activeWindow == null) {
+ return null;
+ }
+ IHandlerService service = (IHandlerService) activeWindow.getService(IHandlerService.class);
+ return service.getCurrentState();
+ }
+
+ /**
+ * Returns the selected resources.
+ */
+ protected Collection<IResource> getSelectedResources() {
+ return getSelectedResources(getSelection());
+ }
+
+ /**
+ * Returns the selected resources.
+ */
+ protected Collection<IResource> getSelectedResources(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = getSelection(event);
+ return getSelectedResources(selection);
+ }
+
+ private static Collection<IResource> getSelectedResources(IStructuredSelection selection) {
+ Set<IResource> result = new LinkedHashSet<IResource>();
+ for (Object obj : selection.toList()) {
+ IResource resource = AdapterUtil.adapt(obj, IResource.class);
+ if (resource != null) {
+ result.add(resource);
+ } else {
+ result.addAll(extractResourcesFromMapping(obj));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Extracts resources associated with a {@link ResourceMapping}.
+ *
+ * @param obj an object adaptable to {@link ResourceMapping}
+ * @return a list of resources associated with the mapping
+ */
+ private static List<IResource> extractResourcesFromMapping(Object obj) {
+ ResourceMapping mapping = AdapterUtil.adapt(obj, ResourceMapping.class);
+ if (mapping != null) {
+ try {
+ ResourceTraversal[] traversals = mapping.getTraversals(null, null);
+ for (ResourceTraversal traversal : traversals) {
+ return Arrays.asList(traversal.getResources());
+ }
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
+ }
+ return Collections.emptyList();
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java
index cd2775223d..90ba32b556 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * Copyright (c) 2007, 2014 Intel 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
@@ -10,65 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.ui.newui;
-import java.util.Arrays;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.osgi.service.prefs.BackingStoreException;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CUIPlugin;
-
/**
- * Property tester to test expressions in plugin.xml. Tests following expressions:
- * 1. Checks whether given object is a source file. Usage:
- * <test property="org.eclipse.cdt.ui.isSource"/>
- * 2. Checks value of a preference. Usage:
- * <test property="org.eclipse.cdt.ui.checkPreference" value="org.eclipse.cdt.ui:properties.export.page.enable=true"/>
- *
+ * @deprecated Doesn't do anything useful.
* @noextend This class is not intended to be subclassed by clients.
*/
public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
- private static final String KEY_SRC = "isSource"; //$NON-NLS-1$
- private static final String KEY_PREF = "checkPreference"; //$NON-NLS-1$
-
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (KEY_SRC.equals(property)) {
- if (receiver instanceof ITranslationUnit) {
- return ((ITranslationUnit) receiver).isSourceUnit();
- } else if (receiver instanceof IFile) {
- IFile file = (IFile) receiver;
- return CoreModel.isValidSourceUnitName(file.getProject(), file.getName());
- }
- } else if (KEY_PREF.equals(property) && expectedValue instanceof String) {
- boolean result = false;
- final Pattern pat = Pattern.compile("(.*):(.*)=(.*)"); //$NON-NLS-1$
- Matcher matcher = pat.matcher((String) expectedValue);
- if (matcher.matches()) {
- String pluginId = matcher.group(1);
- String preference = matcher.group(2);
- String wantedValue = matcher.group(3);
-
- IEclipsePreferences node = InstanceScope.INSTANCE.getNode(pluginId);
- if (wantedValue != null) {
- String actualValue = node.get(preference, ""); //$NON-NLS-1$
- result = wantedValue.equals(actualValue) || (wantedValue.equals("false") && actualValue.isEmpty()); //$NON-NLS-1$
- } else {
- try {
- result = Arrays.asList(node.keys()).contains(preference);
- } catch (BackingStoreException e) {
- CUIPlugin.log(e);
- }
- }
- }
- return result;
- }
return false;
}
-
}

Back to the top