Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-11-09 21:42:52 +0000
committerKaren Butzke2012-11-12 12:07:42 +0000
commit4024930bd407f02e38b3a0433334f43031300ebd (patch)
tree37668f38ca302351d3cfe996fe940c457f419964 /jpa/plugins
parent5e192655d7fb354e0085c20cc657e079ca1bea95 (diff)
downloadwebtools.dali-4024930bd407f02e38b3a0433334f43031300ebd.tar.gz
webtools.dali-4024930bd407f02e38b3a0433334f43031300ebd.tar.xz
webtools.dali-4024930bd407f02e38b3a0433334f43031300ebd.zip
bug 393592 - JPA commands are appearing in Quick Access when not appropriate - cleaned up our handlers and menusv201211130301
Diffstat (limited to 'jpa/plugins')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/plugin.xml18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/plugin.xml15
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml277
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileXmlFileHandler.java48
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileXmlResourceHandler.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileHandler.java)39
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.properties10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml499
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlFileVersionHandler.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlResourceVersionHandler.java61
10 files changed, 494 insertions, 511 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.core/plugin.xml
index 40bab9e22d..c29aa858e0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/plugin.xml
@@ -19,6 +19,24 @@
name="%JPA_PLATFORM"
schema="schema/jpaPlatforms.exsd"/>
+ <!-- ***** expressions ***** -->
+
+ <extension point="org.eclipse.core.expressions.definitions">
+ <!-- A test for determining whether something adapts to an IProject and has the JPA facet.
+ Force activation of the wst facet plug-in containing the property tester.
+ Possible usage:
+ <adapt type="org.eclipse.core.resources.IProject">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
+ </adapt>
+ -->
+ <definition id="org.eclipse.jpt.jpa.reference.hasJpaFacet">
+ <test
+ property="org.eclipse.wst.common.project.facet.core.projectFacet"
+ value="jpt.jpa"
+ forcePluginActivation="true"/>
+ </definition>
+
+ </extension>
<!-- ***** adapters ***** -->
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/plugin.xml
index 013cc74b88..3c0b3a8539 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/plugin.xml
@@ -12,6 +12,21 @@
<plugin>
+ <!-- ***** expressions ***** -->
+
+ <extension point="org.eclipse.core.expressions.definitions">
+ <!-- A test for determining whether something has an EclipseLink JPA platform.
+ Typical usage:
+ <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
+ </adapt>
+ -->
+ <definition id="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform">
+ <test property="org.eclipse.jpt.jpa.core.jpaPlatformGroup" value="eclipselink"/>
+ </definition>
+
+ </extension>
+
<!-- ***** content types ***** -->
<extension
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.properties
index 6ffe00e1a1..b462fac2b7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.properties
@@ -34,6 +34,7 @@ newEclipseLinkDynamicEntityName=EclipseLink Dynamic Entity
newEclipseLinkDynamicEntityWizardDesc=Create an EclipseLink dynamic entity
convertJavaConverters=Java Converters...
+moveJavaConvertersToXML = Move Java Converters to XML...
jpaNode = JPA
eclipseLinkNode = EclipseLink
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml
index 28693ee538..212aa26e89 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml
@@ -119,14 +119,10 @@
<instanceof value="org.eclipse.jdt.core.IPackageFragment"/>
</or>
<adapt type="org.eclipse.core.resources.IResource">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"
- forcePluginActivation="true"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
- <adapt type = "org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
- <test property="org.eclipse.jpt.jpa.core.jpaPlatformGroup"
- value="eclipselink"/>
+ <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
</adapt>
</and>
</enablement>
@@ -144,14 +140,10 @@
<instanceof value="org.eclipse.jdt.core.IPackageFragment"/>
</or>
<adapt type="org.eclipse.core.resources.IResource">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"
- forcePluginActivation="true"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
<adapt type = "org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
- <test property="org.eclipse.jpt.jpa.core.jpaPlatformGroup"
- value="eclipselink"/>
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
<not>
<test
property="org.eclipse.jpt.jpa.core.jpaPlatform"
@@ -208,12 +200,16 @@
category="org.eclipse.jpt.jpa.ui.jpaProjectProperties"
class="org.eclipse.jpt.jpa.eclipselink.ui.internal.weave.EclipseLinkPreferencePage">
<enabledWhen>
- <adapt type="org.eclipse.core.resources.IProject">
- <test
- forcePluginActivation="true"
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
- </adapt>
+ <and>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
+ </adapt>
+ <!-- if the o.e.jpt.jpa.core plug-in is not loaded yet,
+ this will result in true and properties page will appear for a non-eclipselink platform project -->
+ <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
+ </adapt>
+ </and>
</enabledWhen>
</page>
@@ -231,7 +227,7 @@
<command
id="org.eclipse.jpt.jpa.eclipselink.ui.convertJavaConverters"
- name="%convertJavaConverters"
+ name="%moveJavaConvertersToXML"
categoryId="org.eclipse.jpt.jpa.ui.jpaMetadataConversionCommands"/>
<command
@@ -255,12 +251,10 @@
class="org.eclipse.jpt.jpa.eclipselink.ui.internal.handlers.AddVirtualAttributeHandler">
<activeWhen>
<and>
- <with variable="activePartId">
- <equals value="org.eclipse.jpt.ui.jpaStructureView"/>
- </with>
+ <reference definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
<with variable="selection">
<count value="1"/>
- <iterate operator="and">
+ <iterate>
<instanceof value="org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmPersistentType"/>
<test property="org.eclipse.jpt.common.core.resourceTypeIsKindOf" value="org.eclipse.jpt.jpa.eclipselink.core.content.orm:2.1"/>
</iterate>
@@ -272,34 +266,77 @@
<handler
commandId="org.eclipse.jpt.jpa.eclipselink.ui.convertJavaConverters"
class="org.eclipse.jpt.jpa.eclipselink.ui.internal.commands.JavaConverterConversionHandler">
+ <activeWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
+ </adapt>
+ <!-- if the o.e.jpt.jpa.core plug-in is not loaded yet,
+ this will result in true and the command will appear in the Quick Access -->
+ <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
+ </adapt>
+ </iterate>
+ </with>
+ </activeWhen>
</handler>
<handler
commandId="org.eclipse.jpt.jpa.eclipselink.ui.generateDynamicEntities"
class="org.eclipse.jpt.jpa.eclipselink.ui.internal.commands.GenerateDynamicEntitiesHandler">
+ <activeWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
+ </adapt>
+ <!-- if the o.e.jpt.jpa.core plug-in is not loaded yet,
+ this will result in true and the command will appear in the Quick Access -->
+ <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
+ </adapt>
+ </iterate>
+ </with>
+ </activeWhen>
</handler>
<handler
- class="org.eclipse.jpt.jpa.eclipselink.ui.internal.commands.UpgradeToEclipseLinkMappingFileHandler"
+ class="org.eclipse.jpt.jpa.eclipselink.ui.internal.commands.UpgradeToEclipseLinkMappingFileXmlResourceHandler"
commandId="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile">
- <enabledWhen>
- <iterate>
- <or>
- <adapt
- type="org.eclipse.jpt.jpa.core.context.XmlFile">
- <test
- property="org.eclipse.jpt.jpa.core.isGenericMappingFile">
- </test>
- </adapt>
- <adapt
- type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource">
- <test
- property="org.eclipse.jpt.jpa.core.isGenericMappingFile">
- </test>
- </adapt>
- </or>
- </iterate>
- </enabledWhen>
+
+ <activeWhen>
+ <iterate ifEmpty="false">
+ <!-- if the o.e.jpt.jpa.core plug-in is not loaded yet,
+ this will result in true and the command will appear in the Quick Access -->
+ <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
+ </adapt>
+ <adapt type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource">
+ <test property="org.eclipse.jpt.jpa.core.isGenericMappingFile"/>
+ </adapt>
+ </iterate>
+ </activeWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.jpt.jpa.eclipselink.ui.internal.commands.UpgradeToEclipseLinkMappingFileXmlFileHandler"
+ commandId="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile">
+
+ <activeWhen>
+ <iterate ifEmpty="false">
+ <!-- if the o.e.jpt.jpa.core plug-in is not loaded yet,
+ this will result in true and the command will appear in the Quick Access -->
+ <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
+ </adapt>
+ <adapt type="org.eclipse.jpt.jpa.core.context.XmlFile">
+ <test property="org.eclipse.jpt.jpa.core.isGenericMappingFile"/>
+ </adapt>
+ </iterate>
+ </activeWhen>
</handler>
</extension>
@@ -311,143 +348,63 @@
point="org.eclipse.ui.menus">
<!-- contributions to the "JPA Tools" submenu -->
- <menuContribution
- locationURI="popup:org.eclipse.jpt.jpa.ui.menu.JpaTools?after=generate">
+ <menuContribution locationURI="popup:org.eclipse.jpt.jpa.ui.menu.JpaTools?after=generate">
- <command
- commandId="org.eclipse.jpt.jpa.eclipselink.ui.generateDynamicEntities">
- <visibleWhen>
- <with
- variable="selection">
- <and>
- <count value="1"/>
- <iterate>
- <and>
- <adapt type="org.eclipse.core.resources.IProject">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
- </adapt>
- <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
- <test
- property="org.eclipse.jpt.jpa.core.jpaPlatformGroup"
- value="eclipselink"/>
- </adapt>
- </and>
- </iterate>
- </and>
- </with>
- </visibleWhen>
+ <command commandId="org.eclipse.jpt.jpa.eclipselink.ui.generateDynamicEntities">
+ <visibleWhen checkEnabled="true"/>
</command>
- <command
- commandId="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile"
- style="push">
- <visibleWhen>
- <with
- variable="selection">
- <iterate
- ifEmpty="false">
- <adapt
- type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
- <test
- property="org.eclipse.jpt.jpa.core.jpaPlatformGroup"
- value="eclipselink">
- </test>
- </adapt>
- <adapt
- type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource">
- <test
- property="org.eclipse.jpt.jpa.core.isGenericMappingFile">
- </test>
- </adapt>
- </iterate>
- </with>
- </visibleWhen>
- </command>
+ <command commandId="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile">
+ <visibleWhen>
+ <iterate ifEmpty="false">
+ <adapt type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource">
+ <test property="org.eclipse.jpt.jpa.core.isGenericMappingFile"/>
+ </adapt>
+ <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
+ </adapt>
+ </iterate>
+ </visibleWhen>
+ </command>
</menuContribution>
<!-- contributions to objects in the JPA structure view -->
- <menuContribution
- locationURI="popup:org.eclipse.jpt.ui.jpaStructureView">
+ <menuContribution locationURI="popup:org.eclipse.jpt.ui.jpaStructureView">
- <command
- commandId="org.eclipse.jpt.jpa.eclipselink.ui.persistentTypeAddVirtualAttribute">
- <visibleWhen>
- <with variable="selection">
- <count value="1"/>
- <iterate operator="and">
- <instanceof value="org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmPersistentType"/>
- <test property="org.eclipse.jpt.common.core.resourceTypeIsKindOf" value="org.eclipse.jpt.jpa.eclipselink.core.content.orm:2.1"/>
- </iterate>
- </with>
- </visibleWhen>
+ <command commandId="org.eclipse.jpt.jpa.eclipselink.ui.persistentTypeAddVirtualAttribute">
+ <visibleWhen checkEnabled="true"/>
</command>
</menuContribution>
<!-- contributions to "Move to XML" submenu-->
- <menuContribution
- locationURI="popup:org.eclipse.jpt.jpa.ui.menu.moveToXml">
+ <menuContribution locationURI="popup:org.eclipse.jpt.jpa.ui.menu.moveToXml">
- <command
- commandId="org.eclipse.jpt.jpa.eclipselink.ui.convertJavaConverters">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- ifEmpty="false"
- operator="and">
- <adapt
- type="org.eclipse.core.resources.IProject">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
- </adapt>
- <adapt type = "org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
- <test
- property="org.eclipse.jpt.jpa.core.jpaPlatformGroup"
- value="eclipselink"/>
- </adapt>
- </iterate>
- </with>
- </visibleWhen>
+ <command
+ commandId="org.eclipse.jpt.jpa.eclipselink.ui.convertJavaConverters"
+ label="%convertJavaConverters">
+ <visibleWhen checkEnabled="true"/>
</command>
</menuContribution>
<!-- contributions for any popup -->
- <menuContribution
- locationURI="popup:org.eclipse.ui.popup.any">
- <command
- commandId="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile">
- <visibleWhen>
- <with
- variable="selection">
- <iterate
- ifEmpty="false">
- <adapt
- type="org.eclipse.jpt.jpa.core.context.XmlFile">
- <test
- property="org.eclipse.jpt.jpa.core.isGenericMappingFile">
- </test>
- </adapt>
- <adapt
- type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
- <test
- property="org.eclipse.jpt.jpa.core.jpaPlatformGroup"
- value="eclipselink">
- </test>
- </adapt>
- </iterate>
- </with>
- </visibleWhen>
- </command>
+ <menuContribution locationURI="popup:org.eclipse.ui.popup.any">
+ <command commandId="org.eclipse.jpt.jpa.eclipselink.ui.upgradeToEclipseLinkMappingFile">
+ <visibleWhen>
+ <iterate ifEmpty="false">
+ <adapt type="org.eclipse.jpt.jpa.core.context.XmlFile">
+ <test property="org.eclipse.jpt.jpa.core.isGenericMappingFile"/>
+ </adapt>
+ <adapt type="org.eclipse.jpt.jpa.core.platform.JpaPlatformConfig">
+ <reference definitionId="org.eclipse.jpt.jpa.eclipselink.reference.hasEclipseLinkJpaPlatform"/>
+ </adapt>
+ </iterate>
+ </visibleWhen>
+ </command>
</menuContribution>
-
-
+
</extension>
</plugin>
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileXmlFileHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileXmlFileHandler.java
new file mode 100644
index 0000000000..d86d245753
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileXmlFileHandler.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. 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:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.ui.internal.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
+import org.eclipse.jpt.jpa.core.context.XmlFile;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Handler used to upgrade an orm.xml file to an eclipselink orm.xml file
+ * when the selected object adapts to an <code>XmlFile</code>.
+ * See org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml
+ */
+public class UpgradeToEclipseLinkMappingFileXmlFileHandler
+ extends AbstractHandler
+{
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
+
+ for (Object selectedObject : selection.toArray()) {
+ this.upgradeToEclipseLinkMappingFile(selectedObject);
+ }
+ return null;
+ }
+
+ protected void upgradeToEclipseLinkMappingFile(Object selectedObject) {
+ UpgradeToEclipseLinkMappingFileXmlResourceHandler.upgradeToEclipseLinkMappingFile(this.adaptSelection(selectedObject));
+ }
+
+ protected JptXmlResource adaptSelection(Object selectedObject) {
+ XmlFile xmlFile = PlatformTools.getAdapter(selectedObject, XmlFile.class);
+ return xmlFile.getXmlResource();
+ }
+
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileXmlResourceHandler.java
index 5132909981..fa2d4a70a7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileHandler.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/UpgradeToEclipseLinkMappingFileXmlResourceHandler.java
@@ -32,7 +32,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.XmlFile;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLink;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v1_1.EclipseLink1_1;
@@ -50,30 +49,34 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-public class UpgradeToEclipseLinkMappingFileHandler extends AbstractHandler {
+/**
+ * Handler used to upgrade an orm.xml file to an eclipselink orm.xml file
+ * when the selected object adapts to a <code>JptXmlResource</code>.
+ * See org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml
+ */
+public class UpgradeToEclipseLinkMappingFileXmlResourceHandler
+ extends AbstractHandler
+{
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
for (Object selectedObject : selection.toArray()) {
- upgradeToEclipseLinkOrm(selectedObject);
+ this.upgradeToEclipseLinkMappingFile(selectedObject);
}
return null;
}
- protected void upgradeToEclipseLinkOrm(Object selectedObject) {
- JptXmlResource xmlResource = PlatformTools.getAdapter(selectedObject, JptXmlResource.class);
- if (xmlResource == null) {
- XmlFile xmlFile = PlatformTools.getAdapter(selectedObject, XmlFile.class);
- if (xmlFile != null) {
- xmlResource = xmlFile.getXmlResource();
- }
- }
- if (xmlResource == null) {
- return;
- }
+ protected void upgradeToEclipseLinkMappingFile(Object selectedObject) {
+ upgradeToEclipseLinkMappingFile(this.adaptSelection(selectedObject));
+ }
+
+ protected JptXmlResource adaptSelection(Object selectedObject) {
+ return PlatformTools.getAdapter(selectedObject, JptXmlResource.class);
+ }
- JpaProject jpaProject = this.getJpaProject(xmlResource.getFile().getProject());
+ protected static void upgradeToEclipseLinkMappingFile(JptXmlResource xmlResource) {
+ JpaProject jpaProject = getJpaProject(xmlResource.getFile().getProject());
String fileLocation = xmlResource.getFile().getRawLocation().toOSString();
String newVersion = jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(XmlEntityMappings.CONTENT_TYPE).getVersion();
@@ -114,7 +117,7 @@ public class UpgradeToEclipseLinkMappingFileHandler extends AbstractHandler {
}
}
- private JpaProject getJpaProject(IProject project) {
+ private static JpaProject getJpaProject(IProject project) {
return (JpaProject) project.getAdapter(JpaProject.class);
}
@@ -122,11 +125,11 @@ public class UpgradeToEclipseLinkMappingFileHandler extends AbstractHandler {
return namespace + ' ' + schemaLocation;
}
- protected String getNamespace() {
+ protected static String getNamespace() {
return EclipseLink.SCHEMA_NAMESPACE;
}
- protected String getSchemaLocationForVersion(String schemaVersion) {
+ protected static String getSchemaLocationForVersion(String schemaVersion) {
return SCHEMA_LOCATIONS.get(schemaVersion);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.properties
index 7167d5b2ad..cb80718ed7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.properties
@@ -36,7 +36,7 @@ newJpaMappingFileWizardDesc = Create a JPA ORM Mapping File
newJpaEntityFromTableWizardName = JPA Entities from Tables
newJpaEntityFromTableWizardDesc = Create JPA Entities from database tables
-upgradeToLatestVersion = Upgrade Document Version
+upgradeToLatestVersion = Upgrade JPA Document Version
jpaStructureViewCommandCategory = JPA Structure View
addPersistentClass = Add Class...
removePersistentClass = Remove Class
@@ -55,7 +55,9 @@ generateEntities = Generate Entities from Tables...
generateDDL = Generate Tables from Entities...
moveToXml = Move to XML
convertJavaQueries = Java Queries...
-convertJavaGenerators= Java Generators...
+convertJavaGenerators = Java Generators...
+moveJavaQueriesToXML = Move Java Queries to XML...
+moveJavaGeneratorsToXML = Move Java Generators to XML...
jpaMetadataConversionCommandCategory=JPA Metadata Conversion
synchronizeClasses = Synchronize Class List
makePersistent = Make Persistent...
@@ -72,8 +74,8 @@ jpaDetails = JPA Details
jpaStructure = JPA Structure
JpaProposalCategory = JPA Proposals
-JptCreationActionSet.label = Jpt Creation
-JptCreationActionSet.description = Jpt Creation Action Set
+JptCreationActionSet.label = JPA Element Creation
+JptCreationActionSet.description = Command group for creating JPA elements
NewEntityAction.label = New Entity
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
index deb6c8ef1c..ecbdeebea8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
@@ -22,19 +22,15 @@
<!-- ***** expressions ***** -->
- <extension
- point="org.eclipse.core.expressions.definitions">
+ <extension point="org.eclipse.core.expressions.definitions">
<!--
A test for determining whether our current context is within the
JPA Structure View
-->
- <definition
- id="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView">
- <with
- variable="activePartId">
- <equals
- value="org.eclipse.jpt.ui.jpaStructureView"/>
+ <definition id="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView">
+ <with variable="activePartId">
+ <equals value="org.eclipse.jpt.ui.jpaStructureView"/>
</with>
</definition>
@@ -148,11 +144,8 @@
icon="$nl$/icons/full/eview16/jpa_perspective.gif">
<enablement>
<with variable="project">
- <adapt
- type="org.eclipse.core.resources.IProject">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa" forcePluginActivation="true"/>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
</with>
</enablement>
@@ -205,20 +198,16 @@
categoryId="org.eclipse.jpt.jpa.ui.xml.jpaProposalCategory"
class="org.eclipse.jpt.jpa.ui.internal.jpql.JpaJpqlSseCompletionProposalComputer"
id="org.eclipse.jpt.jpa.ui.internal.jpql.JpaJpqlSseCompletionProposalComputer">
- <contentType
- id="org.eclipse.core.runtime.xml">
- </contentType>
+ <contentType id="org.eclipse.core.runtime.xml"/>
</proposalComputer>
- <!-- Use xml instead of more specific mappingFile content type so JPA Proposals appears in the XMl preferences -->
+ <!-- Use xml instead of more specific mappingFile content type so JPA Proposals appears in the XML preferences -->
<proposalComputer
activate="true"
categoryId="org.eclipse.jpt.jpa.ui.xml.jpaProposalCategory"
class="org.eclipse.jpt.jpa.ui.internal.JpaXmlCompletionProposalComputer"
id="org.eclipse.jpt.jpa.ui.internal.JpaXmlCompletionProposalComputer">
- <contentType
- id="org.eclipse.core.runtime.xml">
- </contentType>
+ <contentType id="org.eclipse.core.runtime.xml"/>
</proposalComputer>
</extension>
@@ -337,13 +326,13 @@
<command
id="org.eclipse.jpt.jpa.ui.convertJavaGenerators"
- name="%convertJavaGenerators"
+ name="%moveJavaGeneratorsToXML"
categoryId="org.eclipse.jpt.jpa.ui.jpaMetadataConversionCommands">
</command>
<command
id="org.eclipse.jpt.jpa.ui.convertJavaQueries"
- name="%convertJavaQueries"
+ name="%moveJavaQueriesToXML"
categoryId="org.eclipse.jpt.jpa.ui.jpaMetadataConversionCommands">
</command>
@@ -361,8 +350,7 @@
icon="$nl$/icons/full/obj16/jpa-file.gif"
id="org.eclipse.jpt.jpa.ui.internal.editors.PersistenceEditor"
name="%persistenceEditor">
- <contentTypeBinding
- contentTypeId="org.eclipse.jpt.jpa.core.content.persistence"/>
+ <contentTypeBinding contentTypeId="org.eclipse.jpt.jpa.core.content.persistence"/>
</editor>
</extension>
@@ -374,49 +362,72 @@
point="org.eclipse.ui.handlers">
<handler
+ commandId="org.eclipse.jpt.jpa.ui.convertJavaProjectToJpa"
+ class="org.eclipse.jpt.jpa.ui.internal.commands.ConvertJavaProjectToJpaCommandHandler">
+ <activeWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <and>
+ <test
+ property="org.eclipse.core.resources.projectNature"
+ value="org.eclipse.jdt.core.javanature"/>
+ <not>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
+ </not>
+ </and>
+ </adapt>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
+ <handler
commandId="org.eclipse.jpt.jpa.ui.xmlFileUpgradeToLatestVersion"
class="org.eclipse.jpt.jpa.ui.internal.commands.UpgradeXmlFileVersionHandler">
- <enabledWhen>
- <iterate>
- <or>
- <adapt type="org.eclipse.jpt.jpa.core.context.XmlFile">
- <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
- </adapt>
- <adapt type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource">
- <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
- </adapt>
- </or>
+ <activeWhen>
+ <iterate ifEmpty="false">
+ <adapt type="org.eclipse.jpt.jpa.core.context.XmlFile">
+ <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
+ </adapt>
</iterate>
- </enabledWhen>
+ </activeWhen>
+ </handler>
+
+ <handler
+ commandId="org.eclipse.jpt.jpa.ui.xmlFileUpgradeToLatestVersion"
+ class="org.eclipse.jpt.jpa.ui.internal.commands.UpgradeXmlResourceVersionHandler">
+ <activeWhen>
+ <iterate ifEmpty="false">
+ <adapt type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource">
+ <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
+ </adapt>
+ </iterate>
+ </activeWhen>
</handler>
<handler
commandId="org.eclipse.jpt.jpa.ui.entityMappingsAddPersistentClass"
class="org.eclipse.jpt.jpa.ui.internal.commands.AddPersistentClassHandler">
<activeWhen>
- <reference
- definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView">
- </reference>
- </activeWhen>
- <enabledWhen>
- <and>
+ <and>
+ <reference definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
<count value="1"/>
<iterate>
<instanceof value="org.eclipse.jpt.jpa.core.context.orm.EntityMappings"/>
</iterate>
</and>
- </enabledWhen>
+ </activeWhen>
</handler>
<handler
commandId="org.eclipse.ui.edit.delete"
class="org.eclipse.jpt.jpa.ui.internal.commands.RemovePersistentClassHandler">
<activeWhen>
- <and>
- <with variable="activePartId">
- <equals value="org.eclipse.jpt.ui.jpaStructureView"/>
- </with>
- <iterate>
+ <and>
+ <reference definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
+ <iterate ifEmpty="false">
<instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType"/>
</iterate>
</and>
@@ -424,53 +435,43 @@
</handler>
<handler
- commandId="org.eclipse.jpt.jpa.ui.persistentAttributeAddToXml"
- class="org.eclipse.jpt.jpa.ui.internal.commands.AddPersistentAttributeToXmlHandler">
+ commandId="org.eclipse.ui.edit.delete"
+ class="org.eclipse.jpt.jpa.ui.internal.commands.RemovePersistentAttributeFromXmlHandler">
<activeWhen>
- <reference
- definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView">
- </reference>
- </activeWhen>
- <enabledWhen>
- <iterate>
- <and>
+ <and>
+ <reference definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
+ <iterate ifEmpty="false">
<instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute"/>
- <test property="org.eclipse.jpt.jpa.core.isVirtual"/>
- <test property="org.eclipse.jpt.jpa.core.isMapped"/>
- </and>
- </iterate>
- </enabledWhen>
+ <test property="org.eclipse.jpt.jpa.core.isNotVirtual"/>
+ </iterate>
+ </and>
+ </activeWhen>
</handler>
<handler
- commandId="org.eclipse.jpt.jpa.ui.persistentAttributeAddToXmlAndMap"
- class="org.eclipse.jpt.jpa.ui.internal.commands.AddPersistentAttributeToXmlAndMapHandler">
+ commandId="org.eclipse.jpt.jpa.ui.persistentAttributeAddToXml"
+ class="org.eclipse.jpt.jpa.ui.internal.commands.AddPersistentAttributeToXmlHandler">
<activeWhen>
- <reference
- definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView">
- </reference>
- </activeWhen>
- <enabledWhen>
- <iterate>
- <and>
+ <and>
+ <reference definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
+ <iterate ifEmpty="false">
<instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute"/>
<test property="org.eclipse.jpt.jpa.core.isVirtual"/>
- </and>
- </iterate>
- </enabledWhen>
+ <test property="org.eclipse.jpt.jpa.core.isMapped"/>
+ </iterate>
+ </and>
+ </activeWhen>
</handler>
<handler
- commandId="org.eclipse.ui.edit.delete"
- class="org.eclipse.jpt.jpa.ui.internal.commands.RemovePersistentAttributeFromXmlHandler">
+ commandId="org.eclipse.jpt.jpa.ui.persistentAttributeAddToXmlAndMap"
+ class="org.eclipse.jpt.jpa.ui.internal.commands.AddPersistentAttributeToXmlAndMapHandler">
<activeWhen>
<and>
- <with variable="activePartId">
- <equals value="org.eclipse.jpt.ui.jpaStructureView"/>
- </with>
- <iterate operator="and">
+ <reference definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
+ <iterate ifEmpty="false">
<instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute"/>
- <test property="org.eclipse.jpt.jpa.core.isNotVirtual"/>
+ <test property="org.eclipse.jpt.jpa.core.isVirtual"/>
</iterate>
</and>
</activeWhen>
@@ -480,64 +481,61 @@
commandId="org.eclipse.jpt.jpa.ui.persistentTypeMapAs"
class="org.eclipse.jpt.jpa.ui.internal.commands.PersistentTypeMapAsHandler">
<activeWhen>
- <reference
- definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
+ <and>
+ <reference definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
+ <iterate ifEmpty="false">
+ <instanceof value="org.eclipse.jpt.jpa.core.context.PersistentType"/>
+ </iterate>
+ </and>
</activeWhen>
- <enabledWhen>
- <iterate>
- <instanceof value="org.eclipse.jpt.jpa.core.context.PersistentType"/>
- </iterate>
- </enabledWhen>
</handler>
<handler
commandId="org.eclipse.jpt.jpa.ui.persistentAttributeMapAs"
class="org.eclipse.jpt.jpa.ui.internal.commands.PersistentAttributeMapAsHandler">
<activeWhen>
- <reference
- definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
- </activeWhen>
- <enabledWhen>
- <iterate>
- <and>
+ <and>
+ <reference definitionId="org.eclipse.jpt.jpa.ui.reference.inJpaStructureView"/>
+ <iterate ifEmpty="false">
<instanceof value="org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute"/>
<test property="org.eclipse.jpt.jpa.core.isNotVirtual"/>
- </and>
- </iterate>
- </enabledWhen>
+ </iterate>
+ </and>
+ </activeWhen>
</handler>
<handler
class="org.eclipse.jpt.jpa.ui.internal.commands.JavaGeneratorConversionHandler"
- commandId="org.eclipse.jpt.jpa.ui.convertJavaGenerators"/>
+ commandId="org.eclipse.jpt.jpa.ui.convertJavaGenerators">
+
+ <activeWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
+ </adapt>
+ </iterate>
+ </with>
+ </activeWhen>
+ </handler>
+
<handler
class="org.eclipse.jpt.jpa.ui.internal.commands.JavaQueryConversionHandler"
- commandId="org.eclipse.jpt.jpa.ui.convertJavaQueries"/>
-
- <handler
- commandId="org.eclipse.jpt.jpa.ui.convertJavaProjectToJpa"
- class="org.eclipse.jpt.jpa.ui.internal.commands.ConvertJavaProjectToJpaCommandHandler">
+ commandId="org.eclipse.jpt.jpa.ui.convertJavaQueries">
+
<activeWhen>
- <and>
- <count value="1"/>
- <iterate ifEmpty="false" operator="and">
- <adapt type="org.eclipse.core.resources.IProject">
- <and>
- <test
- property="org.eclipse.core.resources.projectNature"
- value="org.eclipse.jdt.core.javanature"/>
- <not>
- <test
- property="org.eclipse.core.resources.projectNature"
- value="org.eclipse.wst.common.project.facet.core.nature"/>
- </not>
- </and>
- </adapt>
- </iterate>
- </and>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
+ </adapt>
+ </iterate>
+ </with>
</activeWhen>
- </handler>
+ </handler>
</extension>
@@ -559,27 +557,20 @@
id="org.eclipse.jpt.jpa.ui.menu.JpaTools"
label="%jpaMenuName">
<visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <or>
- <adapt type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource"/>
- <adapt type="org.eclipse.core.resources.IProject">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
- </adapt>
- <and>
- <adapt type="org.eclipse.core.resources.IResource">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
- </adapt>
- <adapt type="org.eclipse.jdt.core.IJavaElement"/>
- </and>
- </or>
- </iterate>
- </with>
+ <iterate ifEmpty="false">
+ <or>
+ <adapt type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource"/>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
+ </adapt>
+ <and>
+ <adapt type="org.eclipse.core.resources.IResource">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
+ </adapt>
+ <adapt type="org.eclipse.jdt.core.IJavaElement"/>
+ </and>
+ </or>
+ </iterate>
</visibleWhen>
</menu>
@@ -587,14 +578,11 @@
<command
commandId="org.eclipse.jpt.jpa.ui.xmlFileUpgradeToLatestVersion">
<visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <adapt type="org.eclipse.jpt.jpa.core.context.XmlFile">
- <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
- </adapt>
- </iterate>
- </with>
+ <iterate ifEmpty="false">
+ <adapt type="org.eclipse.jpt.jpa.core.context.XmlFile">
+ <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
+ </adapt>
+ </iterate>
</visibleWhen>
</command>
@@ -608,14 +596,11 @@
<command
commandId="org.eclipse.jpt.jpa.ui.xmlFileUpgradeToLatestVersion">
<visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <adapt type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource">
- <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
- </adapt>
- </iterate>
- </with>
+ <iterate ifEmpty="false">
+ <adapt type="org.eclipse.jpt.common.core.resource.xml.JptXmlResource">
+ <test property="org.eclipse.jpt.jpa.core.isNotLatestSupportedVersion"/>
+ </adapt>
+ </iterate>
</visibleWhen>
</command>
@@ -623,70 +608,39 @@
<menu
id="org.eclipse.jpt.jpa.ui.menu.moveToXml"
label="%moveToXml">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- ifEmpty="false">
- <adapt
- type="org.eclipse.core.resources.IProject">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
+ <visibleWhen>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
</iterate>
- <count
- value="1"/>
- </with>
+ </with>
</visibleWhen>
+
+ <!-- contributions to "Move to XML" submenu -->
+ <command
+ commandId="org.eclipse.jpt.jpa.ui.convertJavaQueries"
+ label="%convertJavaQueries">
+ </command>
+
+ <command
+ commandId="org.eclipse.jpt.jpa.ui.convertJavaGenerators"
+ label="%convertJavaGenerators">
+ </command>
+
</menu>
- <separator
- name="generate"/>
-
- </menuContribution>
-
- <!-- contributions to "Move to XML" submenu -->
-
- <menuContribution
- locationURI="popup:org.eclipse.jpt.jpa.ui.menu.moveToXml">
-
- <command
- commandId="org.eclipse.jpt.jpa.ui.convertJavaQueries"
- label="%convertJavaQueries"
- style="push">
- </command>
+ <separator name="generate"/>
- <command
- commandId="org.eclipse.jpt.jpa.ui.convertJavaGenerators"
- label="%convertJavaGenerators"
- style="push">
- </command>
-
</menuContribution>
<!-- contributions to the project configure menu -->
<menuContribution locationURI="popup:org.eclipse.ui.projectConfigure?after=additions">
- <command commandId="org.eclipse.jpt.jpa.ui.convertJavaProjectToJpa" style="push">
- <visibleWhen checkEnabled="false">
- <and>
- <count value="1"/>
- <iterate ifEmpty="false" operator="and">
- <adapt type="org.eclipse.core.resources.IProject">
- <and>
- <test
- property="org.eclipse.core.resources.projectNature"
- value="org.eclipse.jdt.core.javanature"/>
- <not>
- <test
- property="org.eclipse.core.resources.projectNature"
- value="org.eclipse.wst.common.project.facet.core.nature"/>
- </not>
- </and>
- </adapt>
- </iterate>
- </and>
+ <command commandId="org.eclipse.jpt.jpa.ui.convertJavaProjectToJpa">
+ <visibleWhen
+ checkEnabled="true">
</visibleWhen>
</command>
</menuContribution>
@@ -697,68 +651,43 @@
<command
commandId="org.eclipse.jpt.jpa.ui.entityMappingsAddPersistentClass">
- <visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <instanceof value="org.eclipse.jpt.jpa.core.context.orm.EntityMappings"/>
- </iterate>
- </with>
- </visibleWhen>
+ <visibleWhen checkEnabled="true"/>
</command>
<command
commandId="org.eclipse.ui.edit.delete"
label="%removePersistentClass">
<visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType"/>
- </iterate>
- </with>
+ <iterate ifEmpty="false">
+ <instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType"/>
+ </iterate>
</visibleWhen>
</command>
<command
commandId="org.eclipse.jpt.jpa.ui.persistentAttributeAddToXml">
<visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <and>
- <instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute"/>
- <test property="org.eclipse.jpt.jpa.core.isVirtual"/>
- </and>
- </iterate>
- </with>
+ <iterate ifEmpty="false">
+ <instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute"/>
+ <test property="org.eclipse.jpt.jpa.core.isVirtual"/>
+ </iterate>
</visibleWhen>
</command>
<command
commandId="org.eclipse.jpt.jpa.ui.persistentAttributeAddToXmlAndMap">
<visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <and>
- <instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute"/>
- <test property="org.eclipse.jpt.jpa.core.isVirtual"/>
- </and>
- </iterate>
- </with>
+ <iterate ifEmpty="false">
+ <instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute"/>
+ <test property="org.eclipse.jpt.jpa.core.isVirtual"/>
+ </iterate>
</visibleWhen>
</command>
<command
commandId="org.eclipse.ui.edit.delete"
label="%removePersistentAttributeFromXml">
<visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <and>
- <instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute"/>
- <test property="org.eclipse.jpt.jpa.core.isNotVirtual"/>
- </and>
- </iterate>
- </with>
+ <iterate ifEmpty="false">
+ <instanceof value="org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute"/>
+ <test property="org.eclipse.jpt.jpa.core.isNotVirtual"/>
+ </iterate>
</visibleWhen>
</command>
@@ -768,12 +697,9 @@
mnemonic="%mapAsMnemonic"
icon="$nl$/icons/full/eview16/jpa_perspective.gif">
<visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <instanceof value="org.eclipse.jpt.jpa.core.context.PersistentType"/>
- </iterate>
- </with>
+ <iterate ifEmpty="false">
+ <instanceof value="org.eclipse.jpt.jpa.core.context.PersistentType"/>
+ </iterate>
</visibleWhen>
<dynamic
id="org.eclipse.jpt.jpa.ui.persistentTypeMapAs"
@@ -787,15 +713,10 @@
mnemonic="%mapAsMnemonic"
icon="$nl$/icons/full/eview16/jpa_perspective.gif">
<visibleWhen>
- <with
- variable="selection">
- <iterate ifEmpty="false">
- <and>
- <instanceof value="org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute"/>
- <test property="org.eclipse.jpt.jpa.core.isNotVirtual"/>
- </and>
- </iterate>
- </with>
+ <iterate ifEmpty="false">
+ <instanceof value="org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute"/>
+ <test property="org.eclipse.jpt.jpa.core.isNotVirtual"/>
+ </iterate>
</visibleWhen>
<dynamic
id="org.eclipse.jpt.jpa.ui.persistentAttributeMapAs"
@@ -843,10 +764,7 @@
<instanceof value="org.eclipse.jpt.jpa.core.context.JpaContextNode"/>
<instanceof value="org.eclipse.jpt.jpa.ui.JpaRootContextNodeModel"/>
<adapt type="org.eclipse.core.resources.IProject">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"
- forcePluginActivation="true"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
</or>
</triggerPoints>
@@ -875,10 +793,7 @@
<instanceof value="org.eclipse.jdt.core.IPackageFragmentRoot"/>
</or>
<adapt type="org.eclipse.core.resources.IResource">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"
- forcePluginActivation="true"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
</and>
</enablement>
@@ -897,10 +812,7 @@
<instanceof value="org.eclipse.jdt.core.IPackageFragment"/>
</or>
<adapt type="org.eclipse.core.resources.IResource">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"
- forcePluginActivation="true"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
</and>
</enablement>
@@ -918,10 +830,7 @@
<instanceof value="org.eclipse.jdt.core.IPackageFragmentRoot"/>
</or>
<adapt type="org.eclipse.core.resources.IResource">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"
- forcePluginActivation="true"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
</and>
</enablement>
@@ -1078,9 +987,7 @@
<!-- ignore the warning - see bug 247250 -->
<enablement>
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</enablement>
<action
@@ -1187,10 +1094,7 @@
class="org.eclipse.jpt.jpa.ui.internal.properties.JpaProjectPropertiesPage">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"
- forcePluginActivation="true"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
</enabledWhen>
</page>
@@ -1202,10 +1106,7 @@
class="org.eclipse.jpt.jpa.ui.internal.prefs.JpaEntityGenPreferencePage">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
- <test
- forcePluginActivation="true"
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
</enabledWhen>
</page>
@@ -1217,10 +1118,7 @@
class="org.eclipse.jpt.jpa.ui.internal.prefs.JpaProblemSeveritiesPage">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"
- forcePluginActivation="true"/>
+ <reference definitionId="org.eclipse.jpt.jpa.reference.hasJpaFacet"/>
</adapt>
</enabledWhen>
</page>
@@ -1256,11 +1154,8 @@
<!-- ***** WTP facet framework ***** -->
- <extension
- point="org.eclipse.wst.common.project.facet.ui.images">
-
+ <extension point="org.eclipse.wst.common.project.facet.ui.images">
<image facet="jpt.jpa" path="icons/full/etool16/jpa_facet.gif"/>
-
</extension>
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlFileVersionHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlFileVersionHandler.java
index f649513b0a..669bcd9f16 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlFileVersionHandler.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlFileVersionHandler.java
@@ -12,53 +12,36 @@ package org.eclipse.jpt.jpa.ui.internal.commands;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
-import org.eclipse.jpt.common.core.resource.xml.ERootObject;
import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
-import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.XmlFile;
import org.eclipse.ui.handlers.HandlerUtil;
/**
+ * Handler used to upgrade the version of a JptXmlResource
+ * when the selected object adapts to an <code>XmlFile</code>.
* See org.eclipse.jpt.jpa.ui/plugin.xml
*/
public class UpgradeXmlFileVersionHandler
extends AbstractHandler
{
public Object execute(ExecutionEvent event) throws ExecutionException {
- IStructuredSelection selection
- = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
+ IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
for (Object selectedObject : selection.toArray()) {
- upgradeXmlFileVersion(selectedObject);
+ this.upgradeXmlResourceVersion(selectedObject);
}
return null;
}
- protected void upgradeXmlFileVersion(Object selectedObject) {
- JptXmlResource xmlResource = PlatformTools.getAdapter(selectedObject, JptXmlResource.class);
- if (xmlResource == null) {
- XmlFile xmlFile = PlatformTools.getAdapter(selectedObject, XmlFile.class);
- if (xmlFile != null) {
- xmlResource = xmlFile.getXmlResource();
- }
- }
- if (xmlResource == null) {
- return;
- }
-
- ERootObject root = xmlResource.getRootObject();
- IContentType contentType = xmlResource.getContentType();
- JpaProject jpaProject = this.getJpaProject(xmlResource.getFile().getProject());
- String newVersion = jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion();
- root.setDocumentVersion(newVersion);
- xmlResource.save();
+ protected void upgradeXmlResourceVersion(Object selectedObject) {
+ UpgradeXmlResourceVersionHandler.upgradeXmlResourceVersion(this.adaptSelection(selectedObject));
}
- private JpaProject getJpaProject(IProject project) {
- return (JpaProject) project.getAdapter(JpaProject.class);
+ protected JptXmlResource adaptSelection(Object selectedObject) {
+ XmlFile xmlFile = PlatformTools.getAdapter(selectedObject, XmlFile.class);
+ return xmlFile.getXmlResource();
}
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlResourceVersionHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlResourceVersionHandler.java
new file mode 100644
index 0000000000..fb59d70b76
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/UpgradeXmlResourceVersionHandler.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2012 Oracle. 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.resource.xml.ERootObject;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * Handler used to upgrade the version of a JptXmlResource
+ * when the selected object adapts to an <code>JptXmlResource</code>.
+ * See org.eclipse.jpt.jpa.ui/plugin.xml
+ */
+public class UpgradeXmlResourceVersionHandler
+ extends AbstractHandler
+{
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
+
+ for (Object selectedObject : selection.toArray()) {
+ upgradeXmlResourceVersion(selectedObject);
+ }
+ return null;
+ }
+
+ protected void upgradeXmlResourceVersion(Object selectedObject) {
+ upgradeXmlResourceVersion(this.adaptSelection(selectedObject));
+ }
+
+ protected JptXmlResource adaptSelection(Object selectedObject) {
+ return PlatformTools.getAdapter(selectedObject, JptXmlResource.class);
+ }
+
+
+ protected static void upgradeXmlResourceVersion(JptXmlResource xmlResource) {
+ ERootObject root = xmlResource.getRootObject();
+ IContentType contentType = xmlResource.getContentType();
+ JpaProject jpaProject = getJpaProject(xmlResource);
+ String newVersion = jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion();
+ root.setDocumentVersion(newVersion);
+ xmlResource.save();
+ }
+
+ private static JpaProject getJpaProject(JptXmlResource xmlResource) {
+ return (JpaProject) xmlResource.getFile().getProject().getAdapter(JpaProject.class);
+ }
+}

Back to the top