Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authorbvosburgh2010-04-21 13:25:59 +0000
committerbvosburgh2010-04-21 13:25:59 +0000
commit3790f291e418146357444bca2028153eedfae4cc (patch)
tree6b8d957b53b706c939e6e0a61f4bc479b8a9bb00 /jpa
parentf3c4a3c7ee0c18697c2274e0bc0eb7c41c4114b8 (diff)
downloadwebtools.dali-3790f291e418146357444bca2028153eedfae4cc.tar.gz
webtools.dali-3790f291e418146357444bca2028153eedfae4cc.tar.xz
webtools.dali-3790f291e418146357444bca2028153eedfae4cc.zip
minor tweaks
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaPlatform.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/PersistentType.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNode.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/persistence/GenericPersistenceXml.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourcePropertyTester.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/xml/JpaXmlResource.java113
-rw-r--r--jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/commands/UpgradeXmlFileVersionHandler.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/editors/PersistenceEditor.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/BaseJpaPlatformUi.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassName.java2
14 files changed, 135 insertions, 109 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaPlatform.java
index 50c294e0e8..75f15eed11 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaPlatform.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaPlatform.java
@@ -15,9 +15,6 @@ import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.context.java.NullDefaultJavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.NullJavaTypeMappingDefinition;
-import org.eclipse.jpt.core.context.java.NullSpecifiedJavaAttributeMappingDefinition;
import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter;
import org.eclipse.jpt.db.ConnectionProfileFactory;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
index 1e7f0220d4..8047e52def 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.core;
import javax.xml.parsers.SAXParserFactory;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
@@ -33,7 +34,6 @@ import org.eclipse.jpt.core.internal.GenericJpaPlatformProvider;
import org.eclipse.jpt.core.internal.JpaPlatformRegistry;
import org.eclipse.jpt.core.internal.JptCoreMessages;
import org.eclipse.jpt.core.internal.jpa2.Generic2_0JpaPlatformProvider;
-import org.eclipse.jpt.core.internal.prefs.JpaPreferenceInitializer;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.osgi.util.NLS;
@@ -489,7 +489,7 @@ public class JptCorePlugin extends Plugin {
preferenceKey = DEFAULT_JPA_PLATFORM_2_0_PREF_KEY;
}
else {
- throw new IllegalArgumentException("Illegal JPA facet version: " + jpaFacetVersion);
+ throw new IllegalArgumentException("Illegal JPA facet version: " + jpaFacetVersion); //$NON-NLS-1$
}
prefs.put(preferenceKey, platformId);
flush(prefs);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/PersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/PersistentType.java
index 86d8b362ee..580b01f628 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/PersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/PersistentType.java
@@ -37,7 +37,7 @@ public interface PersistentType
/**
* Return the persistent type's [fully-qualified] name.
- * Uses '.' as the enclosing type separator instead of '$'.
+ * The enclosing type separator is '.', as opposed to '$'.
* @see #getShortName()
*/
String getName();
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNode.java
index bf80c0f667..a6441f79c0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNode.java
@@ -16,19 +16,23 @@ import org.eclipse.jpt.core.internal.context.AbstractXmlContextNode;
import org.eclipse.jpt.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory;
/**
- * Use this abstract class for context nodes that are part of an OrmXml file.
- * This will not work for purely MappingFile implementations
+ * Use this abstract class for context nodes that are part of an
+ * <code>orm.xml</code> file.
+ * This will not work for a pure {@link org.eclipse.jpt.core.context.MappingFile}
+ * implementation.
*/
public abstract class AbstractOrmXmlContextNode
extends AbstractXmlContextNode
{
-
// ********** constructor **********
protected AbstractOrmXmlContextNode(JpaContextNode parent) {
super(parent);
}
+
+ // ********** convenience methods **********
+
protected OrmXmlDefinition getMappingFileDefinition() {
return (OrmXmlDefinition) this.getJpaPlatform().getResourceDefinition(this.getResourceType());
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java
index 6a1cb03fa6..71a4449f83 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 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.
@@ -16,28 +16,32 @@ import org.eclipse.jpt.core.context.persistence.PersistenceXmlDefinition;
import org.eclipse.jpt.core.internal.context.AbstractXmlContextNode;
/**
- * Use this abstract class for context nodes that are part of an OrmXml file.
- * This will not work for purely MappingFile implementations
+ * Use this abstract class for context nodes that are part of an
+ * <code>orm.xml</code> file.
+ * This will not work for a pure {@link org.eclipse.jpt.core.context.MappingFile}
+ * implementation.
*/
public abstract class AbstractPersistenceXmlContextNode
extends AbstractXmlContextNode
{
-
// ********** constructor **********
protected AbstractPersistenceXmlContextNode(JpaContextNode parent) {
super(parent);
}
- public PersistenceXmlDefinition getPersistenceXmlDefinition() {
+
+ // ********** convenience methods **********
+
+ protected PersistenceXmlDefinition getPersistenceXmlDefinition() {
return (PersistenceXmlDefinition) this.getJpaPlatform().getResourceDefinition(this.getResourceType());
}
- public EFactory getResourceNodeFactory() {
+ protected EFactory getResourceNodeFactory() {
return this.getPersistenceXmlDefinition().getResourceNodeFactory();
}
- public PersistenceXmlContextNodeFactory getContextNodeFactory() {
+ protected PersistenceXmlContextNodeFactory getContextNodeFactory() {
return this.getPersistenceXmlDefinition().getContextNodeFactory();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java
index 95df482848..9b39249296 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmXml.java
@@ -192,11 +192,7 @@ public class GenericOrmXml
setEntityMappings(buildEntityMappings(newXmlEntityMappings));
}
- JpaFile jpaFile = getJpaFile();
- if (jpaFile == null) {
- System.out.print("Jpa file is null");
- }
- jpaFile.addRootStructureNode(this.xmlResource, this.entityMappings);
+ this.getJpaFile().addRootStructureNode(this.xmlResource, this.entityMappings);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/persistence/GenericPersistenceXml.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/persistence/GenericPersistenceXml.java
index 83f7e0d9c5..80d40f7bcc 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/persistence/GenericPersistenceXml.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/persistence/GenericPersistenceXml.java
@@ -154,11 +154,7 @@ public class GenericPersistenceXml
setPersistence(buildPersistence(newXmlPersistence));
}
- JpaFile jpaFile = getJpaFile();
- if (jpaFile == null) {
- System.out.print("Jpa file is null");
- }
- jpaFile.addRootStructureNode(this.xmlResource, this.persistence);
+ this.getJpaFile().addRootStructureNode(this.xmlResource, this.persistence);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourcePropertyTester.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourcePropertyTester.java
index 6bb19d5084..f1c518dffa 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourcePropertyTester.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/xml/JpaXmlResourcePropertyTester.java
@@ -1,25 +1,27 @@
/*******************************************************************************
- * Copyright (c) 2009 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
- *******************************************************************************/
+ * Copyright (c) 2009, 2010 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.core.internal.resource.xml;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.context.XmlFile;
import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
+// TODO move to o.e.jpt.core.internal(.context)?
+// rename to JpaXmlPropertyTester
public class JpaXmlResourcePropertyTester
extends PropertyTester
{
- public static final String IS_LATEST_SUPPORTED_VERSION = "isLatestSupportedVersion";
+ public static final String IS_LATEST_SUPPORTED_VERSION = "isLatestSupportedVersion"; //$NON-NLS-1$
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
@@ -35,15 +37,15 @@ public class JpaXmlResourcePropertyTester
}
if (IS_LATEST_SUPPORTED_VERSION.equals(property)) {
- Boolean expectedIsLatestSupportedVersion = (Boolean) expectedValue;
- JpaProject jpaProject = xmlResource.getJpaProject();
+ boolean expected = ((Boolean) expectedValue).booleanValue();
+ JpaProject jpaProject = JptCorePlugin.getJpaProject(xmlResource.getProject());
IContentType contentType = xmlResource.getContentType();
- Boolean actualIsLatestSupportedVersion =
+ boolean actual =
xmlResource.getVersion() != null
&& xmlResource.getVersion().equals(
jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion());
- return actualIsLatestSupportedVersion == expectedIsLatestSupportedVersion;
+ return actual == expected;
}
return false;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/xml/JpaXmlResource.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/xml/JpaXmlResource.java
index 11fe86adc9..b17102f77b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/xml/JpaXmlResource.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/xml/JpaXmlResource.java
@@ -7,11 +7,11 @@
* Contributors:
* Oracle - initial API and implementation
******************************************************************************/
-
package org.eclipse.jpt.core.resource.xml;
import java.io.IOException;
import java.util.Collections;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -25,7 +25,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase;
import org.eclipse.jem.util.plugin.JEMUtilPlugin;
-import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.JpaResourceModel;
import org.eclipse.jpt.core.JpaResourceModelListener;
import org.eclipse.jpt.core.JpaResourceType;
@@ -60,21 +59,14 @@ public class JpaXmlResource
protected final Translator rootTranslator;
- protected final ListenerList<JpaResourceModelListener> resourceModelListenerList;
+ protected final ListenerList<JpaResourceModelListener> resourceModelListenerList =
+ new ListenerList<JpaResourceModelListener>(JpaResourceModelListener.class);
public JpaXmlResource(URI uri, Renderer renderer, IContentType contentType, Translator rootTranslator) {
super(uri, renderer);
this.contentType = contentType;
this.rootTranslator = rootTranslator;
- this.resourceModelListenerList = new ListenerList<JpaResourceModelListener>(JpaResourceModelListener.class);
- }
-
-
- //296544 - override this to avoid internet access finding the schema during tests
- @Override
- public EntityResolver getEntityResolver() {
- return J2EEXmlDtDEntityResolver.INSTANCE;
}
public IContentType getContentType() {
@@ -82,16 +74,10 @@ public class JpaXmlResource
}
public String getVersion() {
- return getRootObject() == null ? null : getRootObject().getVersion();
+ JpaRootEObject root = this.getRootObject();
+ return (root == null) ? null : root.getVersion();
}
-
- public JpaResourceType getResourceType() {
- if (getContentType() == null || getVersion() == null) {
- return null;
- }
- return new JpaResourceType(getContentType(), getVersion());
- }
-
+
// ********** BasicNotifierImpl override **********
@@ -106,14 +92,13 @@ public class JpaXmlResource
*/
@Override
public void eNotify(Notification notification) {
- //Unload events can happen before the resource set is removed - should always react to unload events
- if (notification.getEventType() == Notification.SET && notification.getFeatureID(null) == Resource.RESOURCE__IS_LOADED) {
+ // unload events can happen before the resource set is removed - should always react to unload events
+ if (this.loadedFlagCleared(notification)) {
super.eNotify(notification);
- if (isReverting()) {
- resourceModelReverted();
- }
- else {
- resourceModelUnloaded();
+ if (this.isReverting()) {
+ this.resourceModelReverted();
+ } else {
+ this.resourceModelUnloaded();
}
}
else if ( ! notification.isTouch() && this.isLoaded() && (this.resourceSet != null)) {
@@ -123,13 +108,30 @@ public class JpaXmlResource
}
/**
+ * Return whether the specified notification indicates the resource has been
+ * unloaded.
* we could use this method to suppress some notifications; or we could just
* check whether 'resourceSet' is 'null' (which is what we do)
*/
+ protected boolean loadedFlagCleared(Notification notification) {
+ return (notification.getNotifier() == this) &&
+ (notification.getEventType() == Notification.SET) &&
+ (notification.getFeatureID(Resource.class) == RESOURCE__IS_LOADED) &&
+ ( ! notification.getNewBooleanValue());
+ }
+
+ /**
+ * Return whether the specified notification indicates the resource's
+ * resource set was cleared.
+ * We could use this method to suppress some resource set notifications;
+ * or we could just check whether <code>resourceSet</code> is
+ * <code>null</code> (which is what we do)/
+ */
protected boolean resultSetCleared(Notification notification) {
return (notification.getNotifier() == this) &&
- (notification.getFeatureID(Resource.class) == RESOURCE__RESOURCE_SET) &&
- (notification.getNewValue() == null);
+ (notification.getEventType() == Notification.SET) &&
+ (notification.getFeatureID(Resource.class) == RESOURCE__RESOURCE_SET) &&
+ (notification.getNewValue() == null);
}
@@ -184,6 +186,12 @@ public class JpaXmlResource
}
}
+ //296544 - override this to avoid internet access finding the schema during tests
+ @Override
+ public EntityResolver getEntityResolver() {
+ return J2EEXmlDtDEntityResolver.INSTANCE;
+ }
+
// ********** convenience methods **********
@@ -192,7 +200,7 @@ public class JpaXmlResource
}
public IFile getFile() {
- IFile file = getFile(this.uri);
+ IFile file = this.getFile(this.uri);
return (file != null) ? file : this.getConvertedURIFile();
}
@@ -201,7 +209,7 @@ public class JpaXmlResource
return null;
}
URI convertedURI = this.resourceSet.getURIConverter().normalize(this.uri);
- return this.uri.equals(convertedURI) ? null : getFile(convertedURI);
+ return this.uri.equals(convertedURI) ? null : this.getFile(convertedURI);
}
/**
@@ -209,20 +217,16 @@ public class JpaXmlResource
* This URI is assumed to be absolute in the following format:
* platform:/resource/....
*/
- protected static IFile getFile(URI uri) {
- if ( ! WorkbenchResourceHelperBase.isPlatformResourceURI(uri)) {
+ protected IFile getFile(URI fileURI) {
+ if ( ! WorkbenchResourceHelperBase.isPlatformResourceURI(fileURI)) {
return null;
}
- String fileName = URI.decode(uri.path()).substring(JEMUtilPlugin.PLATFORM_RESOURCE.length() + 1);
+ String fileName = URI.decode(fileURI.path()).substring(JEMUtilPlugin.PLATFORM_RESOURCE.length() + 1);
return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileName));
}
public IProject getProject() {
- return getFile().getProject();
- }
-
- public JpaProject getJpaProject() {
- return JptCorePlugin.getJpaProject(getProject());
+ return this.getFile().getProject();
}
public void modify(Runnable runnable) {
@@ -230,11 +234,11 @@ public class JpaXmlResource
runnable.run();
try {
save(Collections.EMPTY_MAP);
- } catch (IOException ioe) {
- JptCorePlugin.log(ioe);
+ } catch (IOException ex) {
+ JptCorePlugin.log(ex);
}
- } catch (Exception e) {
- JptCorePlugin.log(e);
+ } catch (Exception ex) {
+ JptCorePlugin.log(ex);
}
}
@@ -247,6 +251,14 @@ public class JpaXmlResource
// ********** JpaResourceModel implementation **********
+ public JpaResourceType getResourceType() {
+ if (this.contentType == null) {
+ return null;
+ }
+ String version = this.getVersion();
+ return (version == null) ? null : new JpaResourceType(this.contentType, version);
+ }
+
public void addResourceModelListener(JpaResourceModelListener listener) {
this.resourceModelListenerList.add(listener);
}
@@ -254,28 +266,31 @@ public class JpaXmlResource
public void removeResourceModelListener(JpaResourceModelListener listener) {
this.resourceModelListenerList.remove(listener);
}
-
+
+
+ // ********** listener notifications **********
+
protected void resourceModelChanged() {
for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) {
listener.resourceModelChanged(this);
}
}
-
+
protected void resourceModelReverted() {
for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) {
listener.resourceModelReverted(this);
}
}
-
+
protected void resourceModelUnloaded() {
for (JpaResourceModelListener listener : this.resourceModelListenerList.getListeners()) {
listener.resourceModelUnloaded(this);
}
}
-
-
+
+
// ********** cast things back to what they are in EMF **********
-
+
@SuppressWarnings("unchecked")
@Override
public EList<Adapter> eAdapters() {
diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java
index 0ab0d11236..907acb5b90 100644
--- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java
+++ b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ORMGenCustomizer.java
@@ -194,7 +194,7 @@ public abstract class ORMGenCustomizer implements java.io.Serializable
restore(customizer);
}
} catch (Exception ex) {
- System.out.println("***ORMGenCustomizer.load failed "+file+": " + ex);
+ JptGenPlugin.logException("***ORMGenCustomizer.load failed "+file, ex);
}
finally
{
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 afa0169bc2..571eb16e5b 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
@@ -1,13 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2009 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
- *******************************************************************************/
+ * Copyright (c) 2009, 2010 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.ui.internal.commands;
import org.eclipse.core.commands.AbstractHandler;
@@ -16,6 +15,8 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.context.XmlFile;
import org.eclipse.jpt.core.resource.xml.JpaRootEObject;
import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
@@ -44,8 +45,8 @@ public class UpgradeXmlFileVersionHandler extends AbstractHandler
final JpaRootEObject root = xmlResource.getRootObject();
IContentType contentType = xmlResource.getContentType();
- final String newVersion =
- xmlResource.getJpaProject().getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion();
+ JpaProject jpaProject = JptCorePlugin.getJpaProject(xmlResource.getProject());
+ final String newVersion = jpaProject.getJpaPlatform().getMostRecentSupportedResourceType(contentType).getVersion();
xmlResource.modify(
new Runnable() {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/editors/PersistenceEditor.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/editors/PersistenceEditor.java
index 602f34707d..ec8a07da72 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/editors/PersistenceEditor.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/editors/PersistenceEditor.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.ui.internal.editors;
import java.util.ListIterator;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
@@ -20,6 +21,7 @@ import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.JpaResourceType;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.context.JpaRootContextNode;
import org.eclipse.jpt.core.context.persistence.Persistence;
@@ -128,10 +130,18 @@ public class PersistenceEditor extends FormEditor
return;
}
+ PersistenceXml persistenceXml = jpaProject.getRootContextNode().getPersistenceXml();
+ if (persistenceXml == null) {
+ return;
+ }
+ JpaResourceType resourceType = persistenceXml.getResourceType();
+ if (resourceType == null) {
+ return; // might not ever get here... (if we have a p.xml, it probably has a resource type...)
+ }
String platformId = jpaProject.getJpaPlatform().getId();
JpaPlatformUi jpaPlatformUI = JpaPlatformUiRegistry.instance().getJpaPlatformUi(platformId);
PersistenceXmlResourceUiDefinition definition =
- (PersistenceXmlResourceUiDefinition) jpaPlatformUI.getResourceUiDefinition(jpaProject.getRootContextNode().getPersistenceXml().getResourceType());
+ (PersistenceXmlResourceUiDefinition) jpaPlatformUI.getResourceUiDefinition(resourceType);
ListIterator<JpaPageComposite> pages = definition.buildPersistenceUnitComposites(
buildPersistenceUnitHolder(),
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/BaseJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/BaseJpaPlatformUi.java
index 1a4f84e161..04e3c1058a 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/BaseJpaPlatformUi.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/base/BaseJpaPlatformUi.java
@@ -67,19 +67,20 @@ public abstract class BaseJpaPlatformUi
// ********** structure providers **********
public JpaStructureProvider getStructureProvider(JpaFile jpaFile) {
- return getStructureProvider(jpaFile.getResourceModel().getResourceType());
+ JpaResourceType resourceType = jpaFile.getResourceModel().getResourceType();
+ return (resourceType == null) ? null : this.getStructureProvider(resourceType);
}
protected JpaStructureProvider getStructureProvider(JpaResourceType resourceType) {
- ResourceUiDefinition resourceUiDefinition;
+ ResourceUiDefinition definition;
try {
- resourceUiDefinition = getResourceUiDefinition(resourceType);
+ definition = getResourceUiDefinition(resourceType);
}
catch (IllegalArgumentException iae) {
JptUiPlugin.log(iae);
return null;
}
- return resourceUiDefinition.getStructureProvider();
+ return definition.getStructureProvider();
}
@@ -159,7 +160,7 @@ public abstract class BaseJpaPlatformUi
return definition;
}
}
- throw new IllegalArgumentException("No resource ui definition for the resource type: " + resourceType); //$NON-NLS-1$
+ throw new IllegalArgumentException("No resource UI definition for the resource type: " + resourceType); //$NON-NLS-1$
}
public MappingResourceUiDefinition getMappingResourceUiDefinition(JpaResourceType resourceType) {
@@ -167,7 +168,7 @@ public abstract class BaseJpaPlatformUi
return (MappingResourceUiDefinition) getResourceUiDefinition(resourceType);
}
catch (ClassCastException cce) {
- throw new IllegalArgumentException("No mapping resource ui definition for the resource type: " + resourceType, cce); //$NON-NLS-1$
+ throw new IllegalArgumentException("No mapping resource UI definition for the resource type: " + resourceType, cce); //$NON-NLS-1$
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassName.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassName.java
index aeb62c66fa..92ef041278 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassName.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassName.java
@@ -13,7 +13,7 @@ package org.eclipse.jpt.utility.internal;
* Convenience methods related to Java class names as returned by
* {@link java.lang.Class#getName()}.
*/
-public class ClassName {
+public final class ClassName {
public static final String VOID_CLASS_NAME = ReflectionTools.VOID_CLASS.getName();
public static final String VOID_WRAPPER_CLASS_NAME = ReflectionTools.VOID_WRAPPER_CLASS.getName();

Back to the top