diff options
author | sdimov | 2011-04-14 14:39:02 +0000 |
---|---|---|
committer | sdimov | 2011-04-14 14:39:02 +0000 |
commit | 7d1d4d3c40790479fcb1ba08683de044800c1b57 (patch) | |
tree | 8a806aa4af7f2e7365d5f27473ce8631b9e62907 /jpa_diagram_editor | |
parent | f90947e8394df1746c1429a0caa4e17d018e00f5 (diff) | |
download | webtools.dali-7d1d4d3c40790479fcb1ba08683de044800c1b57.tar.gz webtools.dali-7d1d4d3c40790479fcb1ba08683de044800c1b57.tar.xz webtools.dali-7d1d4d3c40790479fcb1ba08683de044800c1b57.zip |
[334149] Collection Type should be user specifiable
Diffstat (limited to 'jpa_diagram_editor')
37 files changed, 282 insertions, 137 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java index 287167959e..7a0ba8bf62 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java @@ -416,7 +416,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature { String headerTextString = JPAEditorUtil.getText(addedWrapper); ICompilationUnit cu = getFeatureProvider().getCompilationUnit(addedWrapper); JPAEditorUtil.becomeWorkingCopy(cu); - headerTextString = JPAEditorUtil.cutFromLastDot(headerTextString); + headerTextString = JPAEditorUtil.returnSimpleName(headerTextString); try { if (cu.hasUnsavedChanges()) { headerTextString = "* " + headerTextString; //$NON-NLS-1$ diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java index 16da9529ab..6e44389998 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java @@ -38,13 +38,13 @@ public class CreateManyToManyBiDirRelationFeature extends JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source)); JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target)); - String ownerAttributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String ownerAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = ownerAttributeName; if (JpaArtifactFactory.instance().isMethodAnnotated(owner)) nameWithNonCapitalLetter = JPAEditorUtil.produceValidAttributeName(ownerAttributeName); String ownerAttributeText = JPAEditorUtil.produceUniqueAttributeName(owner, nameWithNonCapitalLetter); - String inverseAttributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(owner)); + String inverseAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(owner)); String nameWithNonCapitalLetter2 = inverseAttributeName; if (JpaArtifactFactory.instance().isMethodAnnotated(inverse)) nameWithNonCapitalLetter2 = JPAEditorUtil.produceValidAttributeName(inverseAttributeName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java index b3f8bf9e72..1e58fd51f1 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java @@ -38,7 +38,7 @@ public class CreateManyToManyUniDirRelationFeature extends JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source)); JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target)); - String attributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String attributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = attributeName; if (JpaArtifactFactory.instance().isMethodAnnotated(owner)) nameWithNonCapitalLetter = JPAEditorUtil.produceValidAttributeName(attributeName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java index 6b84025cf6..ceeb529747 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java @@ -39,13 +39,13 @@ public class CreateManyToOneBiDirRelationFeature extends JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source)); JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target)); - String ownerAttributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String ownerAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = ownerAttributeName; if (JpaArtifactFactory.instance().isMethodAnnotated(owner)) nameWithNonCapitalLetter = JPAEditorUtil.produceValidAttributeName(ownerAttributeName); String ownerAttributeText = JPAEditorUtil.produceUniqueAttributeName(owner, nameWithNonCapitalLetter); - String inverseAttributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(owner)); + String inverseAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(owner)); String nameWithNonCapitalLetter2 = inverseAttributeName; if (JpaArtifactFactory.instance().isMethodAnnotated(inverse)) nameWithNonCapitalLetter2 = JPAEditorUtil.produceValidAttributeName(inverseAttributeName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java index 8e1da52270..fafc150fd4 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java @@ -38,7 +38,7 @@ public class CreateManyToOneUniDirRelationFeature extends JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source)); JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target)); - String attributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String attributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = attributeName; if (JpaArtifactFactory.instance().isMethodAnnotated(owner)) nameWithNonCapitalLetter = JPAEditorUtil.produceValidAttributeName(attributeName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java index f6896a77dd..2eb3367f5a 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java @@ -39,7 +39,7 @@ public class CreateOneToManyUniDirRelationFeature extends JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source)); JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target)); - String attributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String attributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = attributeName; if (JpaArtifactFactory.instance().isMethodAnnotated(owner)) nameWithNonCapitalLetter = JPAEditorUtil.produceValidAttributeName(attributeName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java index 7ea7a6dbc3..3a65a5dbcf 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java @@ -38,13 +38,13 @@ public class CreateOneToOneBiDirRelationFeature extends CreateOneToOneRelationFe JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source)); JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target)); - String ownerAttributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String ownerAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = ownerAttributeName; if (JpaArtifactFactory.instance().isMethodAnnotated(owner)) nameWithNonCapitalLetter = JPAEditorUtil.produceValidAttributeName(ownerAttributeName); String ownerAttributeText = JPAEditorUtil.produceUniqueAttributeName(owner, nameWithNonCapitalLetter); - String inverseAttributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(owner)); + String inverseAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(owner)); String nameWithNonCapitalLetter2 = inverseAttributeName; if (JpaArtifactFactory.instance().isMethodAnnotated(inverse)) nameWithNonCapitalLetter2 = JPAEditorUtil.produceValidAttributeName(inverseAttributeName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java index 4308196bca..dae132dc57 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java @@ -40,7 +40,7 @@ public class CreateOneToOneUniDirRelationFeature extends CreateOneToOneRelationF JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source)); JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target)); - String name = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String name = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = name; if (JpaArtifactFactory.instance().isMethodAnnotated(owner)) nameWithNonCapitalLetter = JPAEditorUtil.produceValidAttributeName(name); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java index 0b52e8d348..d67baa9149 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java @@ -65,7 +65,7 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature { Shape sh = (Shape)context.getPictogramElement(); ContainerShape csh = sh.getContainer(); JavaPersistentType jpt = (JavaPersistentType)getBusinessObjectForPictogramElement(csh); - return JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(jpt)); + return JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(jpt)); } @Override diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java index 0a97a529ef..5973db1486 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java @@ -59,7 +59,7 @@ public class RefactorAttributeTypeFeature extends AbstractCustomFeature { JavaPersistentAttribute jpa = (JavaPersistentAttribute)bo; String typeName = JPAEditorUtil.getAttributeTypeNameWithGenerics(jpa); String msg = MessageFormat.format(JPAEditorMessages.SelectTypeDialog_chooseAttributeTypeDialogText, - jpa.getName(), JPAEditorUtil.cutFromLastDot(((PersistentType)jpa.getParent()).getName())); + jpa.getName(), JPAEditorUtil.returnSimpleName(((PersistentType)jpa.getParent()).getName())); SelectTypeDialog d = new SelectTypeDialog(msg, typeName); if (d.open() != IDialogConstants.OK_ID) return; diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java index b1d57312bd..729d88c7fc 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java @@ -293,11 +293,11 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature { ICompilationUnit cu = getFeatureProvider().getCompilationUnit((JavaPersistentType) at.getParent()); if (!cu.exists()) { at = (JavaPersistentAttribute)at.getPersistenceUnit().getPersistentType(newJptName).getAttributeNamed(at.getName()); - JavaPersistentAttribute newAt = JpaArtifactFactory.instance().renameAttribute(at, JPAEditorUtil.cutFromLastDot(newJptName), newJptName, getFeatureProvider()); + JavaPersistentAttribute newAt = JpaArtifactFactory.instance().renameAttribute(at, JPAEditorUtil.returnSimpleName(newJptName), newJptName, getFeatureProvider()); atOldToNewName.put(at.getName(), newAt.getName()); newSelfAts.add(newAt); } else { - JpaArtifactFactory.instance().renameAttribute(at, JPAEditorUtil.cutFromLastDot(newJptName), newJptName, getFeatureProvider()); + JpaArtifactFactory.instance().renameAttribute(at, JPAEditorUtil.returnSimpleName(newJptName), newJptName, getFeatureProvider()); } } Iterator<JavaPersistentAttribute> itr = newSelfAts.iterator(); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java index 7d47fec3f5..e188f0705e 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java @@ -107,7 +107,7 @@ public class RemoveJPAEntityFeature extends DefaultRemoveFeature { return; JavaPersistentType jpt = (JavaPersistentType)bo; if (JPAEditorUtil.isEntityOpenElsewhere(jpt, true)) { - String shortEntName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(jpt)); + String shortEntName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(jpt)); String message = NLS.bind(JPAEditorMessages.RemoveJPAEntityFeature_discardWarningMsg, shortEntName); MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), JPAEditorMessages.JPASolver_closeEditors, null, message, diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RestoreEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RestoreEntityFeature.java index 0ea830abf6..c593559119 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RestoreEntityFeature.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RestoreEntityFeature.java @@ -43,7 +43,7 @@ public class RestoreEntityFeature extends AbstractCustomFeature { JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(context.getPictogramElements()[0]); if (JPAEditorUtil.isEntityOpenElsewhere(jpt, true)) { String shortEntName = JPAEditorUtil - .cutFromLastDot(JpaArtifactFactory.instance() + .returnSimpleName(JpaArtifactFactory.instance() .getEntityName(jpt)); String message = NLS.bind( JPAEditorMessages.JPASolver_closeWarningMsg, shortEntName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferenceInitializer.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferenceInitializer.java index 155fb61357..6c2d88dd7e 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferenceInitializer.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferenceInitializer.java @@ -42,6 +42,7 @@ public class JPAEditorPreferenceInitializer extends public static final String PROPERTY_VAL_COLLECTION_TYPE = "collection"; //$NON-NLS-1$ public static final String PROPERTY_VAL_LIST_TYPE = "list"; //$NON-NLS-1$ public static final String PROPERTY_VAL_SET_TYPE = "set"; //$NON-NLS-1$ + public static final String PROPERTY_VAL_MAP_TYPE = "map"; //$NON-NLS-1$ diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferencesPage.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferencesPage.java index d463214870..2753c5e9d6 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferencesPage.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferencesPage.java @@ -48,6 +48,7 @@ public class JPAEditorPreferencesPage extends FieldEditorPreferencePage private static final String COLLECTIION_TYPE = "java.util.Collection"; //$NON-NLS-1$ private static final String LIST_TYPE = "java.util.List"; //$NON-NLS-1$ private static final String SET_TYPE = "java.util.Set"; //$NON-NLS-1$ + private static final String MAP_TYPE = "java.util.Map"; //$NON-NLS-1$ private StringFieldEditor fDefaultDiagramFolderField; private StringFieldEditor fDefaultEntityPackageField; @@ -101,7 +102,8 @@ public class JPAEditorPreferencesPage extends FieldEditorPreferencePage new String[][] { {COLLECTIION_TYPE, JPAEditorPreferenceInitializer.PROPERTY_VAL_COLLECTION_TYPE}, {LIST_TYPE, JPAEditorPreferenceInitializer.PROPERTY_VAL_LIST_TYPE}, - {SET_TYPE, JPAEditorPreferenceInitializer.PROPERTY_VAL_SET_TYPE}}, + {SET_TYPE, JPAEditorPreferenceInitializer.PROPERTY_VAL_SET_TYPE}, + {MAP_TYPE, JPAEditorPreferenceInitializer.PROPERTY_VAL_MAP_TYPE}}, parent, true); defaultCollectionTypeChooser.setPreferenceStore(getPreferenceStore()); defaultCollectionTypeChooser.getRadioBoxControl(parent).setToolTipText(JPAEditorMessages.JPAEditorPreferencesPage_DefaultCollectionTypeSectionDescription); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertypage/JPADiagramPropertyPage.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertypage/JPADiagramPropertyPage.java index ec699d487e..56f0bee90a 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertypage/JPADiagramPropertyPage.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertypage/JPADiagramPropertyPage.java @@ -72,6 +72,7 @@ public class JPADiagramPropertyPage extends PropertyPage { private Button btnCollectionType; private Button btnListType; private Button btnSetType; + private Button btnMapType; private Button checkOneToManyOldStyle; private boolean propsModified = false; @@ -89,6 +90,7 @@ public class JPADiagramPropertyPage extends PropertyPage { public static final String COLLECTION_TYPE = "java.util.Collection"; //$NON-NLS-1$ public static final String LIST_TYPE = "java.util.List"; //$NON-NLS-1$ public static final String SET_TYPE = "java.util.Set"; //$NON-NLS-1$ + public static final String MAP_TYPE = "java.util.Map"; //$NON-NLS-1$ private IPreferenceStore store = JPADiagramEditorPlugin.getDefault().getPreferenceStore(); @@ -243,6 +245,7 @@ public class JPADiagramPropertyPage extends PropertyPage { createCollectionTypeButton(composite, gd, defaultCollectionType); createListTypeButton(composite, gd, defaultCollectionType); createSetTypeButton(composite, gd, defaultCollectionType); + createMapTypeButton(composite, gd, defaultCollectionType); } @@ -307,6 +310,20 @@ public class JPADiagramPropertyPage extends PropertyPage { }); } + private void createMapTypeButton(Composite composite, GridData gd, String defaultCollectionType) { + btnMapType = new Button(groupCollectionType, SWT.RADIO | SWT.FLAT); + btnMapType.setText(MAP_TYPE); + gd = new GridData(); + btnMapType.setLayoutData(gd); + btnMapType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_MAP_TYPE)); + btnMapType.addSelectionListener(new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + propsModified = true; + } + public void widgetDefaultSelected(SelectionEvent e) {} + }); + } + private void createFieldAccessButton(Composite composite, GridData gd, String defaultAccessType) { btnFieldBasedAccess = new Button(groupAccessType, SWT.RADIO | SWT.FLAT); btnFieldBasedAccess.setText(JPAEditorMessages.JPAEditorPreferencesPage_entityFieldBasedAccessButtonLabel); @@ -351,6 +368,7 @@ public class JPADiagramPropertyPage extends PropertyPage { btnCollectionType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_COLLECTION_TYPE)); btnListType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_LIST_TYPE)); btnSetType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_SET_TYPE)); + btnMapType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_MAP_TYPE)); boolean defaultOneToManyOldStyle = store.getBoolean(JPAEditorPreferenceInitializer.PROPERTY_ONE_TO_MANY_OLD_STYLE); if (!isJPA10Project) checkOneToManyOldStyle.setSelection(defaultOneToManyOldStyle); @@ -446,6 +464,8 @@ public class JPADiagramPropertyPage extends PropertyPage { return JPAEditorPreferenceInitializer.PROPERTY_VAL_LIST_TYPE; else if (btnSetType.getSelection()) return JPAEditorPreferenceInitializer.PROPERTY_VAL_SET_TYPE; + else if (btnMapType.getSelection()) + return JPAEditorPreferenceInitializer.PROPERTY_VAL_MAP_TYPE; return null; } @@ -551,6 +571,11 @@ public class JPADiagramPropertyPage extends PropertyPage { return isSetType(project, props); } + public static boolean isMapType(IProject project) { + Properties props = JPADiagramPropertyPage.loadProperties(project); + return isMapType(project, props); + } + public static boolean shouldOneToManyUnidirBeOldStyle(IProject project) { Properties props = JPADiagramPropertyPage.loadProperties(project); return shouldOneToManyUnidirBeOldStyle(project, props); @@ -594,6 +619,11 @@ public class JPADiagramPropertyPage extends PropertyPage { return accessType.equals("set"); //$NON-NLS-1$; } + public static boolean isMapType(IProject project, Properties props) { + String accessType = props.getProperty(PROP_COLLECTION_TYPE.getLocalName()); + return accessType.equals("map"); //$NON-NLS-1$; + } + public static boolean shouldOneToManyUnidirBeOldStyle(IProject project, Properties props) { return Boolean.parseBoolean(props.getProperty(PROP_ONE_TO_MANY_OLD_STYLE.getLocalName())); } diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java index 6f5b6cbdb4..1e28ca310b 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java @@ -18,6 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; +import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage; import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory; @@ -65,8 +66,8 @@ public class ManyToManyBiDirRelation extends ManyToManyRelation implements Bidir } private void createRelation(IJPAEditorFeatureProvider fp, ICompilationUnit ownerCU, ICompilationUnit inverseCU) { - String inverseAttributeName = JPAEditorUtil.cutFromLastDot(inverse.getName()); - String actInverseAttributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String inverseAttributeName = JPAEditorUtil.returnSimpleName(inverse.getName()); + String actInverseAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(inverseAttributeName); String actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actInverseAttributeName); @@ -79,14 +80,15 @@ public class ManyToManyBiDirRelation extends ManyToManyRelation implements Bidir actNameWithNonCapitalLetter = JPAEditorUtil.produceUniqueAttributeName(owner, actNameWithNonCapitalLetter); ownerAnnotatedAttribute = JpaArtifactFactory.instance().addAttribute(fp, owner, inverse, + JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject()) ? JpaArtifactFactory.instance().getIdType(inverse) : null, nameWithNonCapitalLetter, actNameWithNonCapitalLetter, true, ownerCU, inverseCU); - String ownerAttributeName = JPAEditorUtil.cutFromLastDot(owner.getName()); - String actOwnerAttributeName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(owner)); + String ownerAttributeName = JPAEditorUtil.returnSimpleName(owner.getName()); + String actOwnerAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(owner)); nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(ownerAttributeName); actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actOwnerAttributeName); @@ -98,6 +100,7 @@ public class ManyToManyBiDirRelation extends ManyToManyRelation implements Bidir actNameWithNonCapitalLetter = JPAEditorUtil.produceUniqueAttributeName(inverse, actNameWithNonCapitalLetter); inverseAnnotatedAttribute = JpaArtifactFactory.instance().addAttribute(fp, inverse, owner, + JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject()) ? JpaArtifactFactory.instance().getIdType(owner) : null, nameWithNonCapitalLetter, actNameWithNonCapitalLetter, true, diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java index 11680d4eaa..bec79d2f28 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java @@ -18,6 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; +import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage; import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory; @@ -47,8 +48,8 @@ public class ManyToManyUniDirRelation extends ManyToManyRelation implements Unid private void createRelation(IJPAEditorFeatureProvider fp, ICompilationUnit ownerCU, ICompilationUnit inverseCU) { - String name = JPAEditorUtil.cutFromLastDot(inverse.getName()); - String actName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String name = JPAEditorUtil.returnSimpleName(inverse.getName()); + String actName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(name); String actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actName); @@ -61,6 +62,7 @@ public class ManyToManyUniDirRelation extends ManyToManyRelation implements Unid actNameWithNonCapitalLetter = JPAEditorUtil.produceUniqueAttributeName(owner, actNameWithNonCapitalLetter); ownerAnnotatedAttribute = JpaArtifactFactory.instance().addAttribute(fp, owner, inverse, + JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject()) ? JpaArtifactFactory.instance().getIdType(inverse) : null, nameWithNonCapitalLetter, actNameWithNonCapitalLetter, true, diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java index 644a183802..8011eb4965 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java @@ -18,6 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; +import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage; import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory; @@ -57,8 +58,8 @@ public class ManyToOneBiDirRelation extends ManyToOneRelation implements Bidire } private void createRelation(IJPAEditorFeatureProvider fp, ICompilationUnit ownerCU, ICompilationUnit inverseCU) { - String name = JPAEditorUtil.cutFromLastDot(inverse.getName()); - String actName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String name = JPAEditorUtil.returnSimpleName(inverse.getName()); + String actName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(name); String actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actName); @@ -75,8 +76,8 @@ public class ManyToOneBiDirRelation extends ManyToOneRelation implements Bidire ownerCU, inverseCU); - name = JPAEditorUtil.cutFromLastDot(owner.getName()); - actName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(owner)); + name = JPAEditorUtil.returnSimpleName(owner.getName()); + actName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(owner)); nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(name); actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actName); @@ -88,6 +89,7 @@ public class ManyToOneBiDirRelation extends ManyToOneRelation implements Bidire actNameWithNonCapitalLetter = JPAEditorUtil.produceUniqueAttributeName(inverse, actNameWithNonCapitalLetter); inverseAnnotatedAttribute = JpaArtifactFactory.instance().addAttribute(fp, inverse, owner, + JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject()) ? JpaArtifactFactory.instance().getIdType(owner) : null, nameWithNonCapitalLetter, actNameWithNonCapitalLetter, true, inverseCU, diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java index 0c99c5bf19..099eb292bd 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java @@ -46,8 +46,8 @@ public class ManyToOneUniDirRelation extends ManyToOneRelation implements Unidir } private void createRelation(IJPAEditorFeatureProvider fp, ICompilationUnit ownerCU, ICompilationUnit inverseCU) { - String name = JPAEditorUtil.cutFromLastDot(inverse.getName()); - String actName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String name = JPAEditorUtil.returnSimpleName(inverse.getName()); + String actName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(name); String actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java index ac0fceea2f..02c71939b4 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java @@ -18,6 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; +import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage; import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory; @@ -47,8 +48,8 @@ public class OneToManyUniDirRelation extends OneToManyRelation implements Unidir private void createRelation(IJPAEditorFeatureProvider fp, ICompilationUnit ownerCU, ICompilationUnit inverseCU) { - String name = JPAEditorUtil.cutFromLastDot(inverse.getName()); - String actName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String name = JPAEditorUtil.returnSimpleName(inverse.getName()); + String actName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(name); String actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actName); @@ -61,6 +62,7 @@ public class OneToManyUniDirRelation extends OneToManyRelation implements Unidir actNameWithNonCapitalLetter = JPAEditorUtil.produceUniqueAttributeName(owner, actNameWithNonCapitalLetter); ownerAnnotatedAttribute = JpaArtifactFactory.instance().addAttribute(fp, owner, inverse, + JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject()) ? JpaArtifactFactory.instance().getIdType(inverse) : null, nameWithNonCapitalLetter, actNameWithNonCapitalLetter, true, ownerCU, diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java index b7a8416a0d..eae7ccccc9 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java @@ -57,8 +57,8 @@ public class OneToOneBiDirRelation extends OneToOneRelation implements Bidirecti } private void createRelation(IJPAEditorFeatureProvider fp, ICompilationUnit ownerCU, ICompilationUnit inverseCU) { - String name = JPAEditorUtil.cutFromLastDot(inverse.getName()); - String actName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String name = JPAEditorUtil.returnSimpleName(inverse.getName()); + String actName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(name); String actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actName); @@ -76,8 +76,8 @@ public class OneToOneBiDirRelation extends OneToOneRelation implements Bidirecti ownerCU, inverseCU); - name = JPAEditorUtil.cutFromLastDot(owner.getName()); - actName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(owner)); + name = JPAEditorUtil.returnSimpleName(owner.getName()); + actName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(owner)); nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(name); actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java index 6c7a62d368..b429068394 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java @@ -46,8 +46,8 @@ public class OneToOneUniDirRelation extends OneToOneRelation implements Unidirec } private void createRelation(IJPAEditorFeatureProvider fp, ICompilationUnit ownerCU, ICompilationUnit inverseCU) { - String name = JPAEditorUtil.cutFromLastDot(inverse.getName()); - String actName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(inverse)); + String name = JPAEditorUtil.returnSimpleName(inverse.getName()); + String actName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse)); String nameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(name); String actNameWithNonCapitalLetter = JPAEditorUtil.decapitalizeFirstLetter(actName); diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java index 4b11491185..1c4d152855 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java @@ -139,7 +139,7 @@ public class EntityChangeListener extends Thread { } else { ICompilationUnit cu = featureProvider.getCompilationUnit(jpt); - String entName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(jpt)); + String entName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(jpt)); try { final String newHeader = (cu.hasUnsavedChanges() ? "* " : "") + entName; //$NON-NLS-1$ //$NON-NLS-2$ Display.getDefault().asyncExec(new Runnable() { diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java index c6485373fb..f34bad2476 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java @@ -25,6 +25,10 @@ import org.eclipse.jpt.jpa.core.MappingKeys; public class JPAEditorConstants { + public static Hashtable<String, String> PRIMITIVE_TO_WRAPPER = new Hashtable<String,String>(); + + public static HashSet<String> WRAPPER_SIMPLE_NAMES = new HashSet<String>(); + public static Hashtable<String, String> ANNOTATION_NAME_TO_KEY = new Hashtable<String, String>(); public static Set<String> CARDINALITY_LABELS = new HashSet<String>(); @@ -141,6 +145,25 @@ public class JPAEditorConstants { CARDINALITY_LABELS.add(CARDINALITY_ZERO_ONE); CARDINALITY_LABELS.add(CARDINALITY_ONE); CARDINALITY_LABELS.add(CARDINALITY_ZERO_N); + + PRIMITIVE_TO_WRAPPER.put("int", Integer.class.getName()); //$NON-NLS-1$ + PRIMITIVE_TO_WRAPPER.put("long", Long.class.getName()); //$NON-NLS-1$ + PRIMITIVE_TO_WRAPPER.put("double", Double.class.getName()); //$NON-NLS-1$ + PRIMITIVE_TO_WRAPPER.put("float", Float.class.getName() ); //$NON-NLS-1$ + PRIMITIVE_TO_WRAPPER.put("boolean", Boolean.class.getName()); //$NON-NLS-1$ + PRIMITIVE_TO_WRAPPER.put("char", Character.class.getName()); //$NON-NLS-1$ + PRIMITIVE_TO_WRAPPER.put("byte", Byte.class.getName()); //$NON-NLS-1$ + PRIMITIVE_TO_WRAPPER.put("short", Short.class.getName()); //$NON-NLS-1$ + + WRAPPER_SIMPLE_NAMES.add("Integer"); //$NON-NLS-1$ + WRAPPER_SIMPLE_NAMES.add("Long"); //$NON-NLS-1$ + WRAPPER_SIMPLE_NAMES.add("Double"); //$NON-NLS-1$ + WRAPPER_SIMPLE_NAMES.add("Float"); //$NON-NLS-1$ + WRAPPER_SIMPLE_NAMES.add("Boolean"); //$NON-NLS-1$ + WRAPPER_SIMPLE_NAMES.add("Character"); //$NON-NLS-1$ + WRAPPER_SIMPLE_NAMES.add("Byte"); //$NON-NLS-1$ + WRAPPER_SIMPLE_NAMES.add("Short"); //$NON-NLS-1$ + WRAPPER_SIMPLE_NAMES.add("String"); //$NON-NLS-1$ } public final static String[] PRIMITIVE_TYPES_AND_WRAPPERS = {"int", //$NON-NLS-1$ diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java index e4a67e8ac1..61a4ef46e0 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java @@ -54,6 +54,7 @@ import org.eclipse.graphiti.mm.pictograms.Shape; import org.eclipse.graphiti.services.Graphiti; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; @@ -80,8 +81,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.facade.EclipseFacade; import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages; import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage; import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider; -import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider; import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorImageCreator.RelEndDir; +import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider; import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation; import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants.ShapeType; import org.eclipse.swt.graphics.Point; @@ -98,6 +99,7 @@ import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; public class JPAEditorUtil { + private static IPeServiceUtil peUtil = null; public static String capitalizeFirstLetter(String s) { @@ -156,7 +158,7 @@ public class JPAEditorUtil { return at.getName(); } - public static String cutFromLastDot(String s) { + public static String returnSimpleName(String s) { return s.substring(s.lastIndexOf('.') + 1); } @@ -227,10 +229,10 @@ public class JPAEditorUtil { public static String createCommaSeparatedListOfSimpleTypeNames(String[] strings) { if ((strings == null) || (strings.length == 0)) return null; - StringBuilder res = new StringBuilder(JPAEditorUtil.cutFromLastDot(strings[0])); + StringBuilder res = new StringBuilder(JPAEditorUtil.returnSimpleName(strings[0])); for (int i = 1; i < strings.length; i++) { res.append(", "); //$NON-NLS-1$ - res.append(JPAEditorUtil.cutFromLastDot(strings[i])); + res.append(JPAEditorUtil.returnSimpleName(strings[i])); } return res.toString(); } @@ -238,10 +240,10 @@ public class JPAEditorUtil { public static String createCommaSeparatedListOfSimpleTypeNames(ListIterator<String> strIt) { if ((strIt == null) || !strIt.hasNext()) return null; - StringBuilder res = new StringBuilder(JPAEditorUtil.cutFromLastDot(strIt.next())); + StringBuilder res = new StringBuilder(JPAEditorUtil.returnSimpleName(strIt.next())); while (strIt.hasNext()) { res.append(", "); //$NON-NLS-1$ - res.append(JPAEditorUtil.cutFromLastDot(strIt.next())); + res.append(JPAEditorUtil.returnSimpleName(strIt.next())); } return res.toString(); } @@ -259,7 +261,7 @@ public class JPAEditorUtil { public static String getText(JavaPersistentType jpt) { - return cutFromLastDot(JpaArtifactFactory.instance().getEntityName(jpt)); + return JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(jpt)); } public static String getTooltipText(JavaPersistentType jpt) { @@ -445,11 +447,35 @@ public class JPAEditorUtil { continue; try { cu.createImport(typeFQN, null, npm); - } catch (JavaModelException e) { - //$NON-NLS-1$ - } + } catch (JavaModelException e) {} } } + + public static String createImport(ICompilationUnit cu, String typeFQN) { + if (typeFQN.startsWith("java.lang.") || !typeFQN.contains(".")) //$NON-NLS-1$ //$NON-NLS-2$ + return returnSimpleName(typeFQN); + + NullProgressMonitor npm = new NullProgressMonitor(); + String simpleName = returnSimpleName(typeFQN); + IImportDeclaration[] ids = new IImportDeclaration[0]; + try { + ids = cu.getImports(); + } catch (JavaModelException e) {} + for (IImportDeclaration id : ids) { + String impName = id.getElementName(); + if (impName.endsWith("*")) //$NON-NLS-1$ + continue; + if (impName.endsWith("." + simpleName)) //$NON-NLS-1$ + return typeFQN; + if (JPAEditorConstants.WRAPPER_SIMPLE_NAMES.contains(simpleName)) + return typeFQN; + } + try { + cu.createImport(typeFQN, null, npm); + return returnSimpleName(typeFQN); + } catch (JavaModelException e) {} + return typeFQN; + } public static Image createAttributeIcon(Rectangle iconRect, Set<String> annotations) { Image icon = null; @@ -964,7 +990,7 @@ public class JPAEditorUtil { IProject project = jpt.getJpaProject().getProject(); Properties props = JPADiagramPropertyPage.loadProperties(project); String tableNamePrefix = JPADiagramPropertyPage.getDefaultTablePrefixName(project, props); - String shortEntityName = JPAEditorUtil.cutFromLastDot(JpaArtifactFactory.instance().getEntityName(jpt)); + String shortEntityName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(jpt)); if (tableNamePrefix.length() == 0) return shortEntityName; return tableNamePrefix + shortEntityName.toUpperCase(Locale.ENGLISH); @@ -1027,7 +1053,7 @@ public class JPAEditorUtil { name = NAME + i; if ((!fp.hasObjectWithName(name)) && !JPAProjectEntityNames.contains(name.toLowerCase(Locale.ENGLISH)) && - !JPAProjectEntitySimpleNames.contains(JPAEditorUtil.cutFromLastDot(name).toLowerCase(Locale.ENGLISH)) && + !JPAProjectEntitySimpleNames.contains(JPAEditorUtil.returnSimpleName(name).toLowerCase(Locale.ENGLISH)) && !isJavaFileInProject(jpaProject.getProject(), name, pack)) break; } @@ -1047,7 +1073,7 @@ public class JPAEditorUtil { name = NAME + i; if ((!fp.hasObjectWithName(name)) && !JPAProjectEntityNames.contains(name .toLowerCase(Locale.ENGLISH)) && !JPAProjectEntitySimpleNames.contains(JPAEditorUtil - .cutFromLastDot(name).toLowerCase(Locale.ENGLISH)) + .returnSimpleName(name).toLowerCase(Locale.ENGLISH)) && !isJavaFileInProject(jpaProject.getProject(), name, pack)) break; } @@ -1336,7 +1362,7 @@ public class JPAEditorUtil { Iterator<ClassRef> li = pu.classRefs(); while(li.hasNext()) { ClassRef cf = li.next(); - names.add(JPAEditorUtil.cutFromLastDot(cf.getClassName()).toLowerCase(Locale.ENGLISH)); + names.add(JPAEditorUtil.returnSimpleName(cf.getClassName()).toLowerCase(Locale.ENGLISH)); } return names; } @@ -1379,4 +1405,8 @@ public class JPAEditorUtil { return false; } + static public String getPrimitiveWrapper(String primitive) { + return JPAEditorConstants.PRIMITIVE_TO_WRAPPER.get(primitive); + } + }
\ No newline at end of file diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java index e07c4fb10e..9d376cd6bd 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java @@ -1383,7 +1383,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver { private void updateJPTName(JavaPersistentType jpt) { String entName = JpaArtifactFactory.instance().getEntityName(jpt); - entName = JPAEditorUtil.cutFromLastDot(entName); + entName = JPAEditorUtil.returnSimpleName(entName); ContainerShape entShape = (ContainerShape)featureProvider.getPictogramElementForBusinessObject(jpt); JPAEditorUtil.setJPTNameInShape(entShape, entName); } diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java index 587b313791..6e09e6c179 100644 --- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java +++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java @@ -75,6 +75,7 @@ import org.eclipse.jpt.jpa.core.resource.java.AttributeOverridesAnnotation; import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation; import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation; import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation; +import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation; import org.eclipse.jpt.jpa.core.resource.java.JavaResourceCompilationUnit; import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType; @@ -122,7 +123,7 @@ public class JpaArtifactFactory { private static final String COLLECTION_TYPE = "java.util.Collection"; //$NON-NLS-1$ private static final String LIST_TYPE = "java.util.List"; //$NON-NLS-1$ private static final String SET_TYPE = "java.util.Set"; //$NON-NLS-1$ - + private static final String MAP_TYPE = "java.util.Map"; //$NON-NLS-1$ synchronized public static JpaArtifactFactory instance() { return INSTANCE; @@ -572,13 +573,21 @@ public class JpaArtifactFactory { } public JavaPersistentAttribute addAttribute(IJPAEditorFeatureProvider fp, JavaPersistentType jpt, - JavaPersistentType attributeType, String attributeName, + JavaPersistentType attributeType, String attributeName, String actName, boolean isCollection, ICompilationUnit cu1, ICompilationUnit cu2) { + + return addAttribute(fp, jpt, attributeType, null, attributeName, + actName, isCollection, cu1, cu2); + } + + public JavaPersistentAttribute addAttribute(IJPAEditorFeatureProvider fp, JavaPersistentType jpt, + JavaPersistentType attributeType, String mapKeyType, String attributeName, + String actName, boolean isCollection, ICompilationUnit cu1, + ICompilationUnit cu2) { IType type = null; try { - cu1.createImport(cu2.getType(attributeType.getName()) - .getElementName(), null, new NullProgressMonitor()); + JPAEditorUtil.createImport(cu1, cu2.getType(attributeType.getName()).getElementName()); type = cu1.findPrimaryType(); refreshEntityModel(fp, jpt); if (doesAttributeExist(jpt, actName)) { @@ -589,48 +598,57 @@ public class JpaArtifactFactory { IProject project = jpt.getJpaProject().getProject(); Properties props = fp.loadProperties(project); - if(JPADiagramPropertyPage.isCollectionType(project, props)){ + if (JPADiagramPropertyPage.isCollectionType(project, props)) { createContentType(attributeType, actName, cu1, type, COLLECTION_TYPE); type.createMethod(genGetterWithAppropriateType(attributeName, - returnSimpleName(attributeType.getName()), + JPAEditorUtil.returnSimpleName(attributeType.getName()), actName, COLLECTION_TYPE), null, false, new NullProgressMonitor()); type.createMethod(genSetterWithAppropriateType(attributeName, - returnSimpleName(attributeType.getName()), + JPAEditorUtil.returnSimpleName(attributeType.getName()), actName, COLLECTION_TYPE), null, false, new NullProgressMonitor()); - } else if(JPADiagramPropertyPage.isListType(project, props)){ + } else if (JPADiagramPropertyPage.isListType(project, props)) { createContentType(attributeType, actName, cu1, type, LIST_TYPE); type.createMethod(genGetterWithAppropriateType(attributeName, - returnSimpleName(attributeType.getName()), + JPAEditorUtil.returnSimpleName(attributeType.getName()), actName, LIST_TYPE), null, false, new NullProgressMonitor()); type.createMethod(genSetterWithAppropriateType(attributeName, - returnSimpleName(attributeType.getName()), + JPAEditorUtil.returnSimpleName(attributeType.getName()), actName, LIST_TYPE), null, false, new NullProgressMonitor()); - } else { + } else if (JPADiagramPropertyPage.isSetType(project, props)) { createContentType(attributeType, actName, cu1, type, SET_TYPE); type.createMethod(genGetterWithAppropriateType(attributeName, - returnSimpleName(attributeType.getName()), + JPAEditorUtil.returnSimpleName(attributeType.getName()), actName, SET_TYPE), null, false, new NullProgressMonitor()); type.createMethod(genSetterWithAppropriateType(attributeName, - returnSimpleName(attributeType.getName()), + JPAEditorUtil.returnSimpleName(attributeType.getName()), actName, SET_TYPE), null, false, new NullProgressMonitor()); - + } else { + mapKeyType = createContentType(mapKeyType, attributeType, actName, cu1, type, MAP_TYPE); + type.createMethod(genGetterWithAppropriateType(attributeName, mapKeyType, + JPAEditorUtil.returnSimpleName(attributeType.getName()), + actName, MAP_TYPE), null, false, + new NullProgressMonitor()); + type.createMethod(genSetterWithAppropriateType(attributeName, mapKeyType, + JPAEditorUtil.returnSimpleName(attributeType.getName()), + actName, MAP_TYPE), null, false, + new NullProgressMonitor()); } } else { type .createField( - " private " + returnSimpleName(attributeType.getName()) + " " + JPAEditorUtil.decapitalizeFirstLetter(actName) + ";", null, false, new NullProgressMonitor()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + " private " + JPAEditorUtil.returnSimpleName(attributeType.getName()) + " " + JPAEditorUtil.decapitalizeFirstLetter(actName) + ";", null, false, new NullProgressMonitor()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ type.createMethod(genGetterContents(attributeName, - returnSimpleName(attributeType.getName()), null, + JPAEditorUtil.returnSimpleName(attributeType.getName()), null, actName, null, isCollection), null, false, new NullProgressMonitor()); type.createMethod(genSetterContents(attributeName, - returnSimpleName(attributeType.getName()), null, + JPAEditorUtil.returnSimpleName(attributeType.getName()), null, actName, isCollection), null, false, new NullProgressMonitor()); } @@ -647,10 +665,12 @@ public class JpaArtifactFactory { } public String getApropriateImplementedCollectionType(String collectionType){ - if(collectionType.equals(COLLECTION_TYPE) || collectionType.equals(LIST_TYPE)){ + if (collectionType.equals(COLLECTION_TYPE) || collectionType.equals(LIST_TYPE)) { return "java.util.ArrayList"; //$NON-NLS-1$ - } else if(collectionType.equals(SET_TYPE)){ + } else if(collectionType.equals(SET_TYPE)) { return "java.util.HashSet"; //$NON-NLS-1$ + } else if(collectionType.equals(MAP_TYPE)) { + return "java.util.HashMap"; //$NON-NLS-1$ } return null; } @@ -658,15 +678,27 @@ public class JpaArtifactFactory { private void createContentType(JavaPersistentType attributeType, String actName, ICompilationUnit cu1, IType type, String collectionType) throws JavaModelException { - cu1.createImport( - collectionType, null, new NullProgressMonitor()); //$NON-NLS-1$ - cu1.createImport( - getApropriateImplementedCollectionType(collectionType), null, new NullProgressMonitor()); //$NON-NLS-1$ + createContentType(null, attributeType, + actName, cu1, type, collectionType); + } + + private String createContentType(String mapKeyType, JavaPersistentType attributeType, + String actName, ICompilationUnit cu1, IType type, String collectionType) + throws JavaModelException { + + if (mapKeyType != null) { + mapKeyType = JPAEditorUtil.createImport(cu1, mapKeyType); + } + JPAEditorUtil.createImport(cu1, collectionType); + JPAEditorUtil.createImport(cu1, getApropriateImplementedCollectionType(collectionType)); type.createField( - " private " + JPAEditorUtil.cutFromLastDot(collectionType) + "<" //$NON-NLS-1$ //$NON-NLS-2$ - + returnSimpleName(attributeType.getName()) + "> " + JPAEditorUtil.decapitalizeFirstLetter(actName) + //$NON-NLS-1$ - " = new " + JPAEditorUtil.cutFromLastDot(getApropriateImplementedCollectionType(collectionType)) + "<" //$NON-NLS-1$ //$NON-NLS-2$ - + returnSimpleName(attributeType.getName()) + ">();", null, false, new NullProgressMonitor()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + " private " + JPAEditorUtil.returnSimpleName(collectionType) + "<" +//$NON-NLS-1$ //$NON-NLS-2$ + ((mapKeyType != null) ? (mapKeyType + ", ") : "") + //$NON-NLS-1$ //$NON-NLS-2$ + JPAEditorUtil.returnSimpleName(attributeType.getName()) + "> " + JPAEditorUtil.decapitalizeFirstLetter(actName) + //$NON-NLS-1$ + " = new " + JPAEditorUtil.returnSimpleName(getApropriateImplementedCollectionType(collectionType)) + "<" + //$NON-NLS-1$ //$NON-NLS-2$ + ((mapKeyType != null) ? (mapKeyType + ", ") : "") + //$NON-NLS-1$ //$NON-NLS-2$ + JPAEditorUtil.returnSimpleName(attributeType.getName()) + ">();", null, false, new NullProgressMonitor()); //$NON-NLS-1$ + return mapKeyType; } public void refreshEntityModel(IFeatureProvider fp, JavaPersistentType jpt) { @@ -692,7 +724,7 @@ public class JpaArtifactFactory { if(ob instanceof JavaPersistentType){ JavaPersistentType jpt = (JavaPersistentType) ob; ICompilationUnit cu = fp.getCompilationUnit(jpt); - IType type = cu.getType(JPAEditorUtil.cutFromLastDot(jpt.getName())); + IType type = cu.getType(JPAEditorUtil.returnSimpleName(jpt.getName())); IField field = type.getField(attrTxt); int cnt = 0; while ((cnt < 20) && !field.exists()) { @@ -729,7 +761,7 @@ public class JpaArtifactFactory { if(ob instanceof JavaPersistentType){ JavaPersistentType jpt = (JavaPersistentType) ob; ICompilationUnit cu = fp.getCompilationUnit(jpt); - IType type = cu.getType(JPAEditorUtil.cutFromLastDot(jpt.getName())); + IType type = cu.getType(JPAEditorUtil.returnSimpleName(jpt.getName())); String attrNameWithCapitalLetter = attrTxt.substring(0, 1) .toUpperCase(Locale.ENGLISH) + attrTxt.substring(1); @@ -845,17 +877,17 @@ public class JpaArtifactFactory { boolean shouldAddImport = true; IImportDeclaration[] importDeclarations = cu.getImports(); - String attrShortTypeName = JPAEditorUtil.cutFromLastDot(attrTypeName); + String attrShortTypeName = JPAEditorUtil.returnSimpleName(attrTypeName); for(IImportDeclaration importDecl : importDeclarations){ String importedDeclarationFQN = importDecl.getElementName(); - String importedDeclarationShortName = JPAEditorUtil.cutFromLastDot(importedDeclarationFQN); + String importedDeclarationShortName = JPAEditorUtil.returnSimpleName(importedDeclarationFQN); if(attrShortTypeName.equals(importedDeclarationShortName) && !attrTypeName.equals(importedDeclarationFQN)) shouldAddImport = false; } if(shouldAddImport){ JPAEditorUtil.createImports(cu, attrTypeName); - attrTypeName = JPAEditorUtil.cutFromLastDot(attrTypeName); + attrTypeName = JPAEditorUtil.returnSimpleName(attrTypeName); } if ((attrTypes != null) && (attrTypes.length > 0)) { JPAEditorUtil.createImports(cu, attrTypes); @@ -1077,7 +1109,7 @@ public class JpaArtifactFactory { HashSet<String> res = new HashSet<String>(); Iterator<Annotation> it = jrpt.annotations(); while (it.hasNext()) - res.add(JPAEditorUtil.cutFromLastDot(it.next().getAnnotationName())); + res.add(JPAEditorUtil.returnSimpleName(it.next().getAnnotationName())); /* it = jrpt.supportingAnnotations(); while (it.hasNext()) @@ -1186,7 +1218,7 @@ public class JpaArtifactFactory { IRelation res = null; Annotation[] ans = getAnnotations(persistentAttribite); for (Annotation an : ans) { - String annotationName = JPAEditorUtil.cutFromLastDot(an.getAnnotationName()); + String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName()); if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName)) { String relTypeName = getRelTypeName((RelationshipMappingAnnotation)an, jrpa); JavaPersistentType relJPT = (JavaPersistentType)fp.getBusinessObjectForKey(relTypeName); @@ -1214,7 +1246,7 @@ public class JpaArtifactFactory { JavaResourcePersistentAttribute jrpa = at.getResourcePersistentAttribute(); Annotation[] ans = this.getAnnotations(at); for (Annotation an : ans) { - String annotationName = JPAEditorUtil.cutFromLastDot(an.getAnnotationName()); + String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName()); if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName)) { String relTypeName = getRelTypeName((RelationshipMappingAnnotation)an, jrpa); if (!relTypeName.equals(jpt2.getName())) @@ -1431,7 +1463,7 @@ public class JpaArtifactFactory { Annotation[] ans = getAnnotations(at); String annotationName = null; for (Annotation an : ans) { - annotationName = JPAEditorUtil.cutFromLastDot(an.getAnnotationName()); + annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName()); if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName)) { String relTypeName = getRelTypeName((RelationshipMappingAnnotation)an, at.getResourcePersistentAttribute()); if (!relTypeName.equals(jpt.getName())) @@ -1775,7 +1807,7 @@ public class JpaArtifactFactory { JavaResourcePersistentAttribute relJRPA = relEntAt.getResourcePersistentAttribute(); Annotation[] ans = this.getAnnotations(relEntAt); for (Annotation an : ans) { - String annotationName = JPAEditorUtil.cutFromLastDot(an.getAnnotationName()); + String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName()); if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName)) { String relTypeName = getRelTypeName((RelationshipMappingAnnotation)an, relJRPA); if (!relTypeName.equals(jpt.getName())) @@ -1842,7 +1874,7 @@ public class JpaArtifactFactory { if (isNonOwner(at) || !JPAEditorUtil.getCompilationUnit((JavaPersistentType) at.getParent()).exists()) return null; - String annotationName = JPAEditorUtil.cutFromLastDot(an.getAnnotationName()); + String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName()); UnidirectionalRelation res = null; String attrName = at.getName(); if (annotationName.equals(JPAEditorConstants.ANNOTATION_ONE_TO_ONE)) { @@ -1883,8 +1915,8 @@ public class JpaArtifactFactory { JavaPersistentType relJPT, JavaPersistentAttribute relAt, Annotation relAn, IJPAEditorFeatureProvider fp) { JpaArtifactFactory.instance().refreshEntityModel(null, (JavaPersistentType)relAt.getParent()); - String annotationName = JPAEditorUtil.cutFromLastDot(an.getAnnotationName()); - String relAnnotationName = JPAEditorUtil.cutFromLastDot(relAn.getAnnotationName()); + String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName()); + String relAnnotationName = JPAEditorUtil.returnSimpleName(relAn.getAnnotationName()); if (!annotationNamesMatch(annotationName, relAnnotationName)) return null; if (annotationName.equals(JPAEditorConstants.ANNOTATION_ONE_TO_MANY)) @@ -1985,14 +2017,14 @@ public class JpaArtifactFactory { if (isCollection) { contents += " public Collection<"+ attrType + "> get" + attrNameWithCapitalA + "() {\n" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ " return " //$NON-NLS-1$ - + JPAEditorUtil.decapitalizeFirstLetter(actName) + ";\n" + //$NON-NLS-1$ //$NON-NLS-2$ - " }\n"; //$NON-NLS-1$ + + JPAEditorUtil.decapitalizeFirstLetter(actName) + ";\n" + //$NON-NLS-1$ + " }\n"; //$NON-NLS-1$ } else { contents += " public "+ attrType + //$NON-NLS-1$ ((attrTypeElementNames == null)?"":("<" + JPAEditorUtil.createCommaSeparatedListOfSimpleTypeNames(attrTypeElementNames) + ">")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ (attrType.equals("boolean") ? " is" : " get") + attrNameWithCapitalA + "() {\n" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ " return " //$NON-NLS-1$ - + JPAEditorUtil.decapitalizeFirstLetter(actName) + ";\n" + //$NON-NLS-1$ //$NON-NLS-2$ + + JPAEditorUtil.decapitalizeFirstLetter(actName) + ";\n" + //$NON-NLS-1$ " }\n"; //$NON-NLS-1$ } return contents; @@ -2005,11 +2037,12 @@ public class JpaArtifactFactory { + actName.substring(1); String contents = ""; //$NON-NLS-1$ if (isCollection) { - contents = " public void set" + attrNameWithCapitalA + "(Collection<" + attrType + "> param) {\n" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + contents = " public void set" + attrNameWithCapitalA + "(Collection<" + attrType + "> param) " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "{\n" + //$NON-NLS-1$ " this." //$NON-NLS-1$ + JPAEditorUtil.decapitalizeFirstLetter(actName) - + " = param;\n" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - " }\n"; //$NON-NLS-1$ + + " = param;\n" + //$NON-NLS-1$ + " }\n"; //$NON-NLS-1$ } else { contents = " public void set" + attrNameWithCapitalA + "(" + attrType + //$NON-NLS-1$ //$NON-NLS-2$ ((attrTypeElementNames == null)?"":("<" + JPAEditorUtil.createCommaSeparatedListOfSimpleTypeNames(attrTypeElementNames) + ">")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -2017,39 +2050,58 @@ public class JpaArtifactFactory { + " this." //$NON-NLS-1$ + JPAEditorUtil.decapitalizeFirstLetter(actName) - + " = param;\n" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - " }\n"; //$NON-NLS-1$ + + " = param;\n" + //$NON-NLS-1$ + " }\n"; //$NON-NLS-1$ } return contents; } private String genGetterWithAppropriateType(String attrName, String attrType, String actName, String type) { + return genGetterWithAppropriateType(attrName, null, attrType, + actName, type); + } + + + private String genGetterWithAppropriateType(String attrName, String mapKeyType, String attrType, + String actName, String type) { String attrNameWithCapitalA = actName.substring(0, 1).toUpperCase( Locale.ENGLISH) + actName.substring(1); - String contents = " public " + JPAEditorUtil.cutFromLastDot(type) + "<" + attrType + "> get" + attrNameWithCapitalA + "() {\n" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - " return " //$NON-NLS-1$ - + JPAEditorUtil.decapitalizeFirstLetter(actName) + ";\n" + //$NON-NLS-1$ //$NON-NLS-2$ - " }\n"; //$NON-NLS-1$ + String contents = " public " + JPAEditorUtil.returnSimpleName(type) + //$NON-NLS-1$ + "<" + ((mapKeyType != null) ? (mapKeyType + ", ") : "") + attrType + "> " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "get" + attrNameWithCapitalA + "() {\n" + //$NON-NLS-1$ //$NON-NLS-2$ + " return " //$NON-NLS-1$ + + JPAEditorUtil.decapitalizeFirstLetter(actName) + ";\n" + //$NON-NLS-1$ + " }\n"; //$NON-NLS-1$ return contents; } private String genSetterWithAppropriateType(String attrName, String attrType, String actName, String type) { + return genSetterWithAppropriateType(attrName, null, attrType, + actName, type); + } + + private String genSetterWithAppropriateType(String attrName, String mapKeyType, String attrType, + String actName, String type) { String attrNameWithCapitalA = actName.substring(0, 1).toUpperCase( Locale.ENGLISH) + actName.substring(1); - String contents = " public void set" + attrNameWithCapitalA + "(" + JPAEditorUtil.cutFromLastDot(type) + "<" + attrType + "> param) {\n" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - " this." //$NON-NLS-1$ + String contents = " public void set" + attrNameWithCapitalA + //$NON-NLS-1$ + "(" + JPAEditorUtil.returnSimpleName(type) + //$NON-NLS-1$ + "<" + ((mapKeyType != null) ? (mapKeyType + ", ") : "") + attrType + "> param) " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "{\n" + //$NON-NLS-1$ + " this." //$NON-NLS-1$ + JPAEditorUtil.decapitalizeFirstLetter(actName) - + " = param;\n" + //$NON-NLS-1$ - " }\n"; //$NON-NLS-1$ + + " = param;\n" + //$NON-NLS-1$ + " }\n"; //$NON-NLS-1$ return contents; } + /* private String returnSimpleName(String input) { String name = input; if (name.lastIndexOf('.') != -1) { @@ -2057,6 +2109,7 @@ public class JpaArtifactFactory { } return name; } + */ private JavaPersistentAttribute getAttributeFromEntity( JavaPersistentType jpt, String attributeName) { @@ -2144,12 +2197,12 @@ public class JpaArtifactFactory { TableAnnotation tan = (TableAnnotation)jrpt.getAnnotation("javax.persistence.Table"); //$NON-NLS-1$ String tableName = null; if (tan == null){ - tableName = JPAEditorUtil.cutFromLastDot(jpt.getName()); + tableName = JPAEditorUtil.returnSimpleName(jpt.getName()); } else { tableName = tan.getName(); } if (tableName == null) - tableName = JPAEditorUtil.cutFromLastDot(jpt.getName()); + tableName = JPAEditorUtil.returnSimpleName(jpt.getName()); return tableName; } @@ -2242,7 +2295,8 @@ public class JpaArtifactFactory { JavaResourcePersistentAttribute jrpa) { String relTypeName = null; try { - relTypeName = jrpa.getTypeTypeArgumentName(0); + boolean isMap = jrpa.getTypeName().equals("java.util.Map"); //$NON-NLS-1$ + relTypeName = jrpa.getTypeTypeArgumentName(isMap ? 1 : 0); } catch (Exception e) {} if (relTypeName == null) relTypeName = an.getTargetEntity(); @@ -2255,6 +2309,18 @@ public class JpaArtifactFactory { return JptJpaCorePlugin.getJpaProject(project); } + public String getIdType(JavaPersistentType jpt) { + IdClassAnnotation an = (IdClassAnnotation)jpt.getResourcePersistentType().getAnnotation(IdClassAnnotation.ANNOTATION_NAME); + if (an != null) + return an.getFullyQualifiedClassName(); + JavaPersistentAttribute[] ids = getIds(jpt); + if (ids.length == 0) + return null; + String type = ids[0].getTypeName(); + String wrapper = JPAEditorUtil.getPrimitiveWrapper(type); + return (wrapper != null) ? wrapper : type; + } + public JavaPersistentAttribute[] getIds(JavaPersistentType jpt) { ListIterator<JavaPersistentAttribute> attribsIter = jpt.attributes(); ArrayList<JavaPersistentAttribute> res = new ArrayList<JavaPersistentAttribute>(); diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java index 82c8fcc3c9..dfdf9d1588 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java @@ -22,23 +22,13 @@ import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.editor.EditorTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.AddAttributeFeatureTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.AddJPAEntityFeatureTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.AddRelationFeatureTest; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.ClickAddFeatureTest; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.CreateDeleteOnlyAttributeTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.DeleteRelationFeatureTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.DirectEditAttributeFeatureTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.LayoutEntityFeatureTest; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.OpenMiniatureViewFeatureTest; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.RefactorAttributeTypeFeatureTest; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature.SaveEntityFeatureTest; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.listener.JPAProjectListenerTest; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.modelintegration.ui.ModelIntegrationTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.modelintegration.util.ModelIntegrationUtilTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.preferences.JPAEditorPreferenceInitializerTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.preferences.JPAEditorPreferencesPageTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.provider.JPAEditorToolBehaviorProviderTest; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.relation.CreateRelationsTest; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.util.CreateDeleteEntity; -import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.util.JPAEditorUtilTest; import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.util.JPASolverTest; import org.junit.BeforeClass; import org.junit.runner.RunWith; diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java index 441d184d57..212a836f82 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java @@ -65,7 +65,6 @@ import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPACreateFactory; import org.junit.Before; import org.junit.Test; -@SuppressWarnings("restriction") public class CreateRelationFeaturesTest { final String TEST_PROJECT = "Test"; private JpaProject jpaProject = null; diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java index ab352d93e2..a033e1e7d9 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java @@ -43,7 +43,6 @@ import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPACreateFactory; import org.junit.Before; import org.junit.Test; -@SuppressWarnings("restriction") public class SaveEntityFeatureTest { final String TEST_PROJECT = "Test"; private JpaProject jpaProject = null; diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java index 6584dab502..84b5695802 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java @@ -50,7 +50,6 @@ import org.junit.Before; import org.junit.Test; -@SuppressWarnings("restriction") public class JPAProjectListenerTest { private IJPAEditorFeatureProvider featureProvider; final String TEST_PROJECT = "Test"; diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java index 322b59b254..80f7416c95 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java @@ -55,7 +55,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -@SuppressWarnings("restriction") public class ModelIntegrationTest { private static final String CODE_GENERATED = "CODE_GENERATED"; diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java index bb913fc62e..7006fef1f5 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java @@ -52,7 +52,6 @@ import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPACreateFactory; import org.junit.Before; import org.junit.Test; -@SuppressWarnings("restriction") public class CreateRelationAttributesTest { private IJPAEditorFeatureProvider featureProvider; diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java index 7b333d77ca..b8e49ef199 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java @@ -58,7 +58,6 @@ import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPACreateFactory; import org.junit.Before; import org.junit.Test; -@SuppressWarnings("restriction") public class CreateRelationsInFieldAnnotatedEntitiesTest { private IJPAEditorFeatureProvider featureProvider; diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java index ba81940fe2..9ab23b678f 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java @@ -69,7 +69,7 @@ import org.junit.Before; import org.junit.Test; -@SuppressWarnings({ "unused", "restriction" }) +@SuppressWarnings({ "unused" }) public class CreateRelationsTest { private IJPAEditorFeatureProvider featureProvider; diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java index e1a5e4c53f..2432c59650 100644 --- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java +++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java @@ -111,24 +111,24 @@ public class JPAEditorUtilTest { } @Test - public void testCutFromLastDot() { + public void testReturnSimpleName() { String s = ""; - String res = JPAEditorUtil.cutFromLastDot(s); + String res = JPAEditorUtil.returnSimpleName(s); assertEquals(s, res); s = "jdhksajhdk"; - res = JPAEditorUtil.cutFromLastDot(s); + res = JPAEditorUtil.returnSimpleName(s); assertEquals(s, res); s = "jdhksajhdk."; - res = JPAEditorUtil.cutFromLastDot(s); + res = JPAEditorUtil.returnSimpleName(s); assertEquals("", res); s = ".jdhksajhdk"; - res = JPAEditorUtil.cutFromLastDot(s); + res = JPAEditorUtil.returnSimpleName(s); assertEquals("jdhksajhdk", res); s = "jdhks.ajhdk"; - res = JPAEditorUtil.cutFromLastDot(s); + res = JPAEditorUtil.returnSimpleName(s); assertEquals("ajhdk", res); s = "dss.dsdsd.jd.hks.ajhdk"; - res = JPAEditorUtil.cutFromLastDot(s); + res = JPAEditorUtil.returnSimpleName(s); assertEquals("ajhdk", res); } |