summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-09-19 12:27:38 (EDT)
committerKaren Butzke2012-09-19 14:28:58 (EDT)
commite3491e16cd355c3cc86ee1bc004676e80c013214 (patch)
tree277c544f1c20b8056b02b04a8b1cdc9a012b72dd
parentfb70c890f6a9452cb9e8cb3dcf18ca27101b8dde (diff)
downloadwebtools.dali-e3491e16cd355c3cc86ee1bc004676e80c013214.zip
webtools.dali-e3491e16cd355c3cc86ee1bc004676e80c013214.tar.gz
webtools.dali-e3491e16cd355c3cc86ee1bc004676e80c013214.tar.bz2
Bug 389880 - fixing IllegalArgumentExceptions when an attribute or type is unmapped
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_details.properties5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JptUiDetailsMessages.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeMapAsComposite.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java13
8 files changed, 40 insertions, 35 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_details.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_details.properties
index dc0e17e..749a9e5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_details.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui_details.properties
@@ -1,5 +1,5 @@
################################################################################
-# Copyright (c) 2006, 2011 Oracle. All rights reserved.
+# Copyright (c) 2006, 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.
@@ -11,14 +11,15 @@
ProviderDefault=Default (<Provider-Specific>)
NoNameSet=<No name set>
-MapAsComposite_changeMappingType=here
MapAsComposite_default=Default
MapAsComposite_dialogTitle=Mapping Type Selection
MapAsComposite_labelText=&Enter mapping type or pattern (*, ?, or camel case):
MapAsComposite_mappedAttributeText=Attribute ''{0}'' is mapped as {1}.
MapAsComposite_mappedTypeText=Type ''{0}'' is mapped as {1}.
MapAsComposite_unmappedAttributeText=Attribute ''{0}'' is not mapped, click here to change the mapping type.
+MapAsComposite_unmappedAttributeText_linkLabel=click here
MapAsComposite_unmappedTypeText=Type ''{0}'' is not mapped, click here to change the mapping type.
+MapAsComposite_unmappedTypeText_linkLabel=click here
MapAsComposite_virtualAttributeText=Attribute ''{0}'' is not mapped.
BasicSection_title=Basic
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JptUiDetailsMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JptUiDetailsMessages.java
index 2cdce44..3521e04 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JptUiDetailsMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/JptUiDetailsMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2006, 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.
@@ -194,14 +194,15 @@ public class JptUiDetailsMessages {
public static String TransientMappingUiProvider_linkLabel;
public static String VersionMappingUiProvider_linkLabel;
- public static String MapAsComposite_changeMappingType;
public static String MapAsComposite_default;
public static String MapAsComposite_dialogTitle;
public static String MapAsComposite_labelText;
public static String MapAsComposite_mappedAttributeText;
public static String MapAsComposite_mappedTypeText;
public static String MapAsComposite_unmappedAttributeText;
+ public static String MapAsComposite_unmappedAttributeText_linkLabel;
public static String MapAsComposite_unmappedTypeText;
+ public static String MapAsComposite_unmappedTypeText_linkLabel;
public static String MapAsComposite_virtualAttributeText;
public static String EmbeddableUiProvider_label;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeMapAsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeMapAsComposite.java
index b71e185..351fdb6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeMapAsComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentAttributeMapAsComposite.java
@@ -10,7 +10,6 @@
package org.eclipse.jpt.jpa.ui.internal.details;
import java.util.Collection;
-import java.util.Iterator;
import org.eclipse.jpt.common.ui.internal.widgets.Pane;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.MappingKeys;
@@ -19,8 +18,6 @@ import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition;
import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition;
-import org.eclipse.jpt.jpa.ui.internal.details.MapAsComposite.MappingChangeHandler;
-import org.eclipse.jpt.jpa.ui.internal.details.PersistentTypeMapAsComposite.TypeMappingChangeHandler;
import org.eclipse.jpt.jpa.ui.internal.details.orm.UnsupportedOrmAttributeMappingUiDefinition;
import org.eclipse.swt.widgets.Composite;
@@ -86,10 +83,6 @@ public class PersistentAttributeMapAsComposite
AttributeMapping mapping = getSubject().getMapping();
String mappingKey = mapping.getKey();
- if (mappingKey == null) {
- return JptUiDetailsMessages.MapAsComposite_changeMappingType;
- }
-
return mapping.isDefault() ?
getDefaultDefinition(mappingKey).getLinkLabel() :
getMappingUiDefinition(mappingKey).getLinkLabel();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java
index f60709d..2266c31 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java
@@ -65,10 +65,7 @@ public class PersistentTypeMapAsComposite
}
public String getMappingText() {
- String mappingKey = getMappingKey();
- return (mappingKey == null) ?
- JptUiDetailsMessages.MapAsComposite_changeMappingType :
- getMappingUiDefinition(mappingKey).getLinkLabel();
+ return getMappingUiDefinition(getMappingKey()).getLinkLabel();
}
public void morphMapping(MappingUiDefinition definition) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java
index 66110db..990afd8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/AbstractJavaResourceUiDefinition.java
@@ -91,15 +91,15 @@ public abstract class AbstractJavaResourceUiDefinition
protected JavaTypeMappingUiDefinition<? extends TypeMapping> getJavaTypeMappingUiDefinition_(TypeMapping typeMapping) {
String mappingKey = (typeMapping == null) ? null : typeMapping.getKey();
+ return this.getTypeMappingUiDefinition(mappingKey);
+ }
+
+ public JavaTypeMappingUiDefinition<? extends TypeMapping> getTypeMappingUiDefinition(String mappingKey) {
return (mappingKey == null) ?
this.getDefaultTypeMappingUiDefinition() :
this.getSpecifiedJavaTypeMappingUiDefinition(mappingKey);
}
- public MappingUiDefinition<PersistentType, ? extends TypeMapping> getTypeMappingUiDefinition(String mappingKey) {
- return this.getSpecifiedJavaTypeMappingUiDefinition(mappingKey);
- }
-
protected JavaTypeMappingUiDefinition<? extends TypeMapping> getSpecifiedJavaTypeMappingUiDefinition(String mappingKey) {
for (JavaTypeMappingUiDefinition<? extends TypeMapping> definition : this.getSpecifiedTypeMappingUiDefinitions()) {
if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) {
@@ -147,13 +147,13 @@ public abstract class AbstractJavaResourceUiDefinition
protected JavaAttributeMappingUiDefinition<? extends AttributeMapping> getAttributeMappingUiDefinition_(AttributeMapping attributeMapping) {
String mappingKey = (attributeMapping == null) ? null : attributeMapping.getKey();
- return ((attributeMapping == null) || attributeMapping.isDefault()) ?
- this.getDefaultAttributeMappingUiDefinition(mappingKey) :
- this.getSpecifiedAttributeMappingUiDefinition(mappingKey);
+ return this.getAttributeMappingUiDefinition(mappingKey);
}
- public MappingUiDefinition<ReadOnlyPersistentAttribute, ? extends AttributeMapping> getAttributeMappingUiDefinition(String mappingKey) {
- return this.getSpecifiedAttributeMappingUiDefinition(mappingKey);
+ public JavaAttributeMappingUiDefinition<? extends AttributeMapping> getAttributeMappingUiDefinition(String mappingKey) {
+ return (mappingKey == null) ?
+ this.getDefaultAttributeMappingUiDefinition(mappingKey) :
+ this.getSpecifiedAttributeMappingUiDefinition(mappingKey);
}
protected JavaAttributeMappingUiDefinition<? extends AttributeMapping> getSpecifiedAttributeMappingUiDefinition(String mappingKey) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java
index c2a53db..21e9991 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaAttributeMappingUiDefinition.java
@@ -57,8 +57,16 @@ public class NullJavaAttributeMappingUiDefinition
return JptUiDetailsMessages.NullAttributeMappingUiProvider_label;
}
+ /**
+ * The MapAsComposite in the JPA Details view will display this text for
+ * an unmapped attribute:
+ * Attribute 'foo' is not mapped, click here to change the mapping type.
+ *
+ * We are returning the part of the string that will appear to the user as
+ * a link that they can click: 'click here'
+ */
public String getLinkLabel() {
- return null;
+ return JptUiDetailsMessages.MapAsComposite_unmappedAttributeText_linkLabel;
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java
index afedc07..25fb763 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/java/NullJavaTypeMappingUiDefinition.java
@@ -57,13 +57,21 @@ public class NullJavaTypeMappingUiDefinition
return JptUiDetailsMessages.NullTypeMappingUiProvider_label;
}
+ /**
+ * The MapAsComposite in the JPA Details view will display this text for
+ * an unmapped type:
+ * Type 'Far' is not mapped, click here to change the mapping type.
+ *
+ * We are returning the part of the string that will appear to the user as
+ * a link that they can click: 'click here'
+ */
public String getLinkLabel() {
- return null;
+ return JptUiDetailsMessages.MapAsComposite_unmappedTypeText_linkLabel;
}
@Override
protected String getImageKey() {
- return JptUiIcons.NULL_TYPE_MAPPING;
+ return JptUiIcons.WARNING;
}
public JpaComposite buildTypeMappingComposite(JavaUiFactory factory, PropertyValueModel<JavaTypeMapping> mappingModel, Composite parent, WidgetFactory widgetFactory) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java
index 38eebd7..98b0347 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java
@@ -233,20 +233,17 @@ public class PersistenceUnitClassesComposite extends Pane<PersistenceUnit>
ClassRef classRef = (ClassRef) element;
JavaPersistentType persistentType = classRef.getJavaPersistentType();
if (persistentType != null) {
- String mappingKey = persistentType.getMappingKey();
- if (mappingKey != null) {
- return this.getImage(persistentType, mappingKey);
- }
+ return this.getImage(persistentType);
}
return JptJpaUiPlugin.instance().getImage(JptUiIcons.WARNING);
}
- private Image getImage(JavaPersistentType persistentType, String mappingKey) {
- return this.getTypeMappingUiDefinition(persistentType, mappingKey).getImage();
+ private Image getImage(JavaPersistentType persistentType) {
+ return this.getTypeMappingUiDefinition(persistentType).getImage();
}
- private MappingUiDefinition<PersistentType, ? extends TypeMapping> getTypeMappingUiDefinition(JavaPersistentType persistentType, String mappingKey) {
- return this.getJpaPlatformUi(persistentType).getTypeMappingUiDefinition(persistentType.getResourceType(), mappingKey);
+ private MappingUiDefinition<PersistentType, ? extends TypeMapping> getTypeMappingUiDefinition(JavaPersistentType persistentType) {
+ return this.getJpaPlatformUi(persistentType).getTypeMappingUiDefinition(persistentType.getResourceType(), persistentType.getMappingKey());
}
private JpaPlatformUi getJpaPlatformUi(JavaPersistentType persistentType) {