Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-08-18 19:15:10 +0000
committerkmoore2010-08-18 19:15:10 +0000
commitc6157db37e3da23320e3d5bad580a2867c492d05 (patch)
treee66ffe70a2fc2aa877526560a84916e7768f6f2a
parentc890c39295ce4ea7190a22bd4e38e5093e292df9 (diff)
downloadwebtools.dali-c6157db37e3da23320e3d5bad580a2867c492d05.tar.gz
webtools.dali-c6157db37e3da23320e3d5bad580a2867c492d05.tar.xz
webtools.dali-c6157db37e3da23320e3d5bad580a2867c492d05.zip
313176 - Upgrade XML Document Version action could apply for multi-select
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/plugin.xml35
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/commands/UpgradeXmlFileVersionHandler.java21
2 files changed, 28 insertions, 28 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
index eb74b4e200..10c5cc7b8e 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
@@ -217,25 +217,22 @@
commandId="org.eclipse.jpt.ui.xmlFileUpgradeToLatestVersion"
class="org.eclipse.jpt.ui.internal.commands.UpgradeXmlFileVersionHandler">
<enabledWhen>
- <and>
- <count value="1"/>
- <iterate>
- <or>
- <adapt
- type="org.eclipse.jpt.core.context.XmlFile">
- <test
- property="org.eclipse.jpt.core.isLatestSupportedVersion"
- value="false"/>
- </adapt>
- <adapt
- type="org.eclipse.jpt.core.resource.xml.JpaXmlResource">
- <test
- property="org.eclipse.jpt.core.isLatestSupportedVersion"
- value="false"/>
- </adapt>
- </or>
- </iterate>
- </and>
+ <iterate>
+ <or>
+ <adapt
+ type="org.eclipse.jpt.core.context.XmlFile">
+ <test
+ property="org.eclipse.jpt.core.isLatestSupportedVersion"
+ value="false"/>
+ </adapt>
+ <adapt
+ type="org.eclipse.jpt.core.resource.xml.JpaXmlResource">
+ <test
+ property="org.eclipse.jpt.core.isLatestSupportedVersion"
+ value="false"/>
+ </adapt>
+ </or>
+ </iterate>
</enabledWhen>
</handler>
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/commands/UpgradeXmlFileVersionHandler.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/commands/UpgradeXmlFileVersionHandler.java
index 571eb16e5b..7ca61cc604 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/commands/UpgradeXmlFileVersionHandler.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/commands/UpgradeXmlFileVersionHandler.java
@@ -27,11 +27,16 @@ public class UpgradeXmlFileVersionHandler extends AbstractHandler
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection
= (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
-
- // only applies for a singly selected objects that adapt to JpaXmlResource or XmlFile
- Object selectedObject = selection.getFirstElement();
+
+ for (Object selectedObject : selection.toArray()) {
+ upgradeXmlFileVersion(selectedObject);
+ }
+ return null;
+ }
+
+ protected void upgradeXmlFileVersion(Object selectedObject) {
JpaXmlResource xmlResource =
- (JpaXmlResource) Platform.getAdapterManager().getAdapter(selectedObject, JpaXmlResource.class);
+ (JpaXmlResource) Platform.getAdapterManager().getAdapter(selectedObject, JpaXmlResource.class);
if (xmlResource == null) {
XmlFile xmlFile =
(XmlFile) Platform.getAdapterManager().getAdapter(selectedObject, XmlFile.class);
@@ -40,21 +45,19 @@ public class UpgradeXmlFileVersionHandler extends AbstractHandler
}
}
if (xmlResource == null) {
- return null;
+ return;
}
-
+
final JpaRootEObject root = xmlResource.getRootObject();
IContentType contentType = xmlResource.getContentType();
JpaProject jpaProject = JptCorePlugin.getJpaProject(xmlResource.getProject());
final String newVersion = jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion();
-
+
xmlResource.modify(
new Runnable() {
public void run() {
root.setVersion(newVersion);
}
});
-
- return null;
}
}

Back to the top