Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpsabeva2012-03-26 09:55:00 -0400
committerpsabeva2012-03-26 09:55:00 -0400
commitf51f3f16544fbe0f2f904198d4e6837ec2676d2a (patch)
tree85ae41ddc657472732451c3e2612e91775873de9
parent943a6ef6487578a4698c8dee4cac27ce9b6ed131 (diff)
downloadwebtools.dali-f51f3f16544fbe0f2f904198d4e6837ec2676d2a.tar.gz
webtools.dali-f51f3f16544fbe0f2f904198d4e6837ec2676d2a.tar.xz
webtools.dali-f51f3f16544fbe0f2f904198d4e6837ec2676d2a.zip
[334142]
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/icons/ent/add_mapped-superclass.gifbin0 -> 998 bytes
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddInheritedEntityFeature.java86
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java127
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateInheritedEntityFeature.java106
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java31
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateMappedSuperclassFeature.java123
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java3
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java33
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java19
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java11
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ICreateBiDirRelationFeature.java5
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ICreateUniDirRelationFeature.java5
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java13
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAllEntitiesFeature.java12
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAttributeFeature.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java33
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/UpdateAttributeFeature.java17
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java12
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties7
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java13
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java23
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorImageCreator.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java3
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java127
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageCreator.java41
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageProvider.java109
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java16
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IBidirectionalRelation.java (renamed from jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/BidirectionalRelation.java)2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IsARelation.java107
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java3
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java38
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorPredefinedRenderingStyle.java27
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java13
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java20
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorPredefinedColoredAreas.java150
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java104
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java40
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java205
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/ResourceChangeListener.java52
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/AllJpaEditorTests.java2
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddRelationFeatureTest.java12
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java4
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/LayoutEntityFeatureTest.java2
59 files changed, 1487 insertions, 391 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/icons/ent/add_mapped-superclass.gif b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/icons/ent/add_mapped-superclass.gif
new file mode 100644
index 0000000000..139585f3cf
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/icons/ent/add_mapped-superclass.gif
Binary files differ
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java
index ec3cb7e3b1..025c8afbab 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java
@@ -35,13 +35,14 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.ModelIntegrationUtil;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class AddAllEntitiesFeature extends AbstractCustomFeature implements IAddFeature {
@@ -90,11 +91,12 @@ public class AddAllEntitiesFeature extends AbstractCustomFeature implements IAdd
numInARow = (numInARow > 0) ? numInARow : 1;
lowerEdges[0] = lowestRightestPointOfExistingDiagram.y + ((lowestRightestPointOfExistingDiagram.y == 0) ? DIST_FROM_EDGE_V : DIST_V);
+ TransactionalEditingDomain ted = ModelIntegrationUtil.getTransactionalEditingDomain(d);
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) { // null if
JavaPersistentType jpt = classRef.getJavaPersistentType();
- if (jpt.getMappingKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY) {
+ if (JpaArtifactFactory.instance().hasEntityOrMappedSuperclassAnnotation(jpt)) {
PictogramElement pe = getFeatureProvider().getPictogramElementForBusinessObject(jpt);
if (pe != null)
continue;
@@ -107,10 +109,8 @@ public class AddAllEntitiesFeature extends AbstractCustomFeature implements IAdd
int x = DIST_FROM_EDGE_H + ie.index * (JPAEditorConstants.ENTITY_WIDTH + DIST_H);
ctx.setLocation(x, ie.lowerEdge);
- final AddJPAEntityFeature ft = new AddJPAEntityFeature(getFeatureProvider());
+ final AddJPAEntityFeature ft = new AddJPAEntityFeature(getFeatureProvider(), false);
- final Diagram targetDiagram = (Diagram) ctx.getTargetContainer();
- TransactionalEditingDomain ted = ModelIntegrationUtil.getTransactionalEditingDomain(targetDiagram);
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
@@ -122,6 +122,13 @@ public class AddAllEntitiesFeature extends AbstractCustomFeature implements IAdd
}
}
}
+ ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
+ protected void doExecute() {
+ JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
+ }
+ });
+
}
private IndexAndLowerEdge getMinLowerEdge() {
@@ -177,4 +184,9 @@ public class AddAllEntitiesFeature extends AbstractCustomFeature implements IAdd
return JPAEditorMessages.JPAEditorToolBehaviorProvider_showAllTheEntities;
}
+ public IJPAEditorFeatureProvider getFeatureProvider() {
+ return (IJPAEditorFeatureProvider) super.getFeatureProvider();
+ }
+
+
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddInheritedEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddInheritedEntityFeature.java
new file mode 100644
index 0000000000..86cf387641
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddInheritedEntityFeature.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2005, 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Dimov - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.IAddConnectionContext;
+import org.eclipse.graphiti.features.context.IAddContext;
+import org.eclipse.graphiti.features.impl.AbstractAddFeature;
+import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorImageCreator;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageCreator;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IsARelation;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IJPAEditorUtil;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtilImpl;
+
+public class AddInheritedEntityFeature extends AbstractAddFeature {
+
+ private IJPAEditorImageCreator imageCreator;
+
+ public AddInheritedEntityFeature(IFeatureProvider fp) {
+ this(fp, new JPAEditorImageCreator(), new JPAEditorUtilImpl());
+ }
+
+
+ public AddInheritedEntityFeature(IFeatureProvider fp,
+ IJPAEditorImageCreator imageCreator,
+ IJPAEditorUtil jpaEditorUtil) {
+ super(fp);
+ this.imageCreator = imageCreator;
+ }
+
+
+ public boolean canAdd(IAddContext context) {
+ return true;
+ }
+
+ public PictogramElement add(IAddContext context) {
+ final IAddConnectionContext addConContext = (IAddConnectionContext) context;
+ final IsARelation relation = (IsARelation)context.getNewObject();
+ final Diagram diagram = getDiagram();
+ FreeFormConnection connection = createIsAConnection(addConContext, relation, diagram);
+ imageCreator.createIsAConnectionLine(diagram, connection);
+ layoutPictogramElement(connection);
+ return connection;
+ }
+
+ private FreeFormConnection createIsAConnection(IAddConnectionContext addConContext, IsARelation relation,
+ final Diagram diagram) {
+ FreeFormConnection connection = getFeatureProvider().getPeService().createFreeFormConnection(diagram);
+ connection.setStart(addConContext.getSourceAnchor());
+ connection.setEnd(addConContext.getTargetAnchor());
+ connection.setVisible(true);
+ connection.setActive(true);
+ getFeatureProvider().getPeServiceUtil().setPropertyValue(connection, IsARelation.IS_A_CONNECTION_PROP_KEY, Boolean.TRUE.toString());
+ addDecorators(connection);
+ return connection;
+ }
+
+ public IJPAEditorFeatureProvider getFeatureProvider() {
+ return (IJPAEditorFeatureProvider)super.getFeatureProvider();
+ }
+
+ private void addDecorators(FreeFormConnection c) {
+ ConnectionDecorator d = imageCreator.createArrowConnectionDecorator(c, 0.9999, true);
+ Graphiti.getGaService().setLocation(d.getGraphicsAlgorithm(), 0, 0);
+ }
+
+}
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 2da00febd6..eb40753f4c 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
@@ -18,10 +18,9 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IAddContext;
-import org.eclipse.graphiti.features.context.ICreateContext;
-import org.eclipse.graphiti.features.context.impl.CreateContext;
import org.eclipse.graphiti.features.impl.AbstractAddShapeFeature;
import org.eclipse.graphiti.mm.algorithms.Image;
import org.eclipse.graphiti.mm.algorithms.Polyline;
@@ -35,15 +34,11 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.graphiti.util.IPredefinedRenderingStyle;
-import org.eclipse.graphiti.util.PredefinedColoredAreas;
+import org.eclipse.graphiti.util.IColorConstant;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IPackageDeclaration;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.SourceType;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
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.JPADiagramEditorPlugin;
@@ -54,22 +49,25 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeaturePr
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.GraphicsUpdater;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants.ShapeType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorPredefinedColoredAreas;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants.ShapeType;
@SuppressWarnings({ "restriction" })
public class AddJPAEntityFeature extends AbstractAddShapeFeature {
private IPeUtilFacade facade;
+ private boolean shouldRearrangeIsARelations = true;
private static ContainerShape primaryShape;
private static ContainerShape relationShape;
private static ContainerShape basicShape;
- public AddJPAEntityFeature(IFeatureProvider fp) {
+ public AddJPAEntityFeature(IFeatureProvider fp, boolean shouldRearrangeIsARelations) {
super(fp);
+ this.shouldRearrangeIsARelations = shouldRearrangeIsARelations;
facade = new PeUtilFacade();
}
@@ -126,15 +124,9 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
JavaPersistentType jpt = null;
if (newObj instanceof JavaPersistentType) {
jpt = (JavaPersistentType) newObj;
- if (jpt.getMapping() instanceof JavaMappedSuperclass) {
- jpt = createEntityFromExistingMappedSuperclass(fp, jpt);
- }
} else if (newObj instanceof ICompilationUnit) {
ICompilationUnit cu = (ICompilationUnit) newObj;
jpt = JPAEditorUtil.getJPType(cu);
- if (jpt.getMapping() instanceof JavaMappedSuperclass) {
- jpt = createEntityFromExistingMappedSuperclass(fp, jpt);
- }
} else if (newObj instanceof SourceType) {
ICompilationUnit cu = ((SourceType)newObj).getCompilationUnit();
@@ -144,8 +136,9 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
ContainerShape entityShape = facade.createContainerShape(targetDiagram, true);
- createEntityRectangle(context, entityShape,
- this.getFeatureProvider().getDiagramTypeProvider().getDiagram());
+ JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(jpt);
+ createEntityRectangle(context, entityShape, dot,
+ this.getFeatureProvider().getDiagramTypeProvider().getDiagram());
link(entityShape, jpt);
Shape shape = Graphiti.getPeService().createShape(entityShape, false);
Polyline headerBottomLine = Graphiti.getGaService().createPolyline(shape, new int[] { 0,
@@ -154,7 +147,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
.setForeground(manageColor(JPAEditorConstants.ENTITY_BORDER_COLOR));
headerBottomLine.setLineWidth(JPAEditorConstants.ENTITY_BORDER_WIDTH);
- addHeader(jpt, entityShape, JPAEditorConstants.ENTITY_WIDTH);
+ addHeader(jpt, entityShape, JPAEditorConstants.ENTITY_WIDTH, dot);
createCompartments(context, jpt, entityShape);
fillCompartments(jpt,entityShape);
@@ -169,64 +162,26 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
UpdateAttributeFeature updateFeature = new UpdateAttributeFeature(fp);
updateFeature.reconnect(jpt);
-
+ if (shouldRearrangeIsARelations)
+ JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
return entityShape;
}
-
- private JavaPersistentType createEntityFromExistingMappedSuperclass(
- IJPAEditorFeatureProvider fp, JavaPersistentType jpt) {
- ICreateContext cont = new CreateContext();
- String packageName = null;
- try {
- packageName = getMappedSuperclassPackageDeclaration(fp, jpt,
- packageName);
- } catch (JavaModelException e) {
- JPADiagramEditorPlugin.logError(e);
- }
-
- boolean hasPrimaryKey = hasMappedSuperclassPrimaryKeyAttribute(jpt);
-
- CreateJPAEntityFeature createFeature = new CreateJPAEntityFeature(fp,
- true, jpt.getName(), packageName, hasPrimaryKey);
- Object[] objects = createFeature.create(cont);
- if (objects.length != 0) {
- Object obj = objects[0];
- if (obj instanceof JavaPersistentType) {
- jpt = (JavaPersistentType) obj;
- }
- }
- return jpt;
- }
-
- private boolean hasMappedSuperclassPrimaryKeyAttribute(
- JavaPersistentType jpt) {
-
- for (AttributeMapping map : ((JavaMappedSuperclass) jpt.getMapping()).getAllAttributeMappings()) {
- if (map.getPrimaryKeyColumnName() != null) {
- return true;
- }
- }
- return false;
- }
-
- private String getMappedSuperclassPackageDeclaration(
- IJPAEditorFeatureProvider fp, JavaPersistentType jpt,
- String packageName) throws JavaModelException {
- IPackageDeclaration[] packages = fp.getCompilationUnit(jpt)
- .getPackageDeclarations();
- if (packages.length > 0) {
- IPackageDeclaration packageDecl = packages[0];
- packageName = packageDecl.getElementName();
- }
- return packageName;
- }
private void createCompartments(IAddContext context, JavaPersistentType jpt,
ContainerShape entityShape) {
- primaryShape = createCompartmentRectangle(entityShape, JPAEditorConstants.ENTITY_MIN_HEIGHT, JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
- relationShape = createCompartmentRectangle(entityShape, GraphicsUpdater.getNextCompartmentY(primaryShape) + JPAEditorConstants.SEPARATOR_HEIGHT,
- JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes);
- basicShape = createCompartmentRectangle(entityShape, GraphicsUpdater.getNextCompartmentY(relationShape) + JPAEditorConstants.SEPARATOR_HEIGHT, JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes);
+ JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(jpt);
+ primaryShape = createCompartmentRectangle(entityShape,
+ JPAEditorConstants.ENTITY_MIN_HEIGHT,
+ JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape,
+ dot);
+ relationShape = createCompartmentRectangle(entityShape,
+ GraphicsUpdater.getNextCompartmentY(primaryShape) + JPAEditorConstants.SEPARATOR_HEIGHT,
+ JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
+ dot);
+ basicShape = createCompartmentRectangle(entityShape,
+ GraphicsUpdater.getNextCompartmentY(relationShape) + JPAEditorConstants.SEPARATOR_HEIGHT,
+ JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+ dot);
if (IAddEntityContext.class.isInstance(context)) {
IAddEntityContext entityContext = (IAddEntityContext) context;
GraphicsUpdater.setCollapsed(primaryShape, entityContext.isPrimaryCollapsed());
@@ -255,7 +210,8 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
}
private ContainerShape createCompartmentRectangle(
- ContainerShape entityShape, int y, String attribTxt) {
+ ContainerShape entityShape, int y, String attribTxt,
+ JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot) {
int width = entityShape.getGraphicsAlgorithm().getWidth();
ContainerShape containerShape = Graphiti.getPeService().createContainerShape(
entityShape, false);
@@ -268,7 +224,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
UpdateAttributeFeature updateFeature = new UpdateAttributeFeature(getFeatureProvider());
- updateFeature.addSeparatorsToShape(containerShape);
+ updateFeature.addSeparatorsToShape(containerShape, dot);
return containerShape;
}
@@ -341,17 +297,23 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
}
public static RoundedRectangle createEntityRectangle(IAddContext context,
- ContainerShape entityShape, Diagram diagram) {
+ ContainerShape entityShape,
+ JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot,
+ Diagram diagram) {
+ IColorConstant foreground = JpaArtifactFactory.instance().getForeground(dot);
+ IColorConstant background = JpaArtifactFactory.instance().getBackground(dot);
+ String renderingStyle = JpaArtifactFactory.instance().getRenderingStyle(dot);
+
RoundedRectangle entityRectangle = Graphiti.getGaService().createRoundedRectangle(
entityShape, JPAEditorConstants.ENTITY_CORNER_WIDTH,
JPAEditorConstants.ENTITY_CORNER_HEIGHT);
entityRectangle
- .setForeground(Graphiti.getGaService().manageColor(diagram, JPAEditorConstants.ENTITY_BORDER_COLOR));
+ .setForeground(Graphiti.getGaService().manageColor(diagram, foreground));
entityRectangle
- .setBackground(Graphiti.getGaService().manageColor(diagram, JPAEditorConstants.ENTITY_BACKGROUND));
+ .setBackground(Graphiti.getGaService().manageColor(diagram, background));
Graphiti.getGaService().setRenderingStyle(entityRectangle.getPictogramElement().getGraphicsAlgorithm(),
- PredefinedColoredAreas.getAdaptedGradientColoredAreas(IPredefinedRenderingStyle.BLUE_WHITE_GLOSS_ID));
+ JPAEditorPredefinedColoredAreas.getAdaptedGradientColoredAreas(renderingStyle));
entityRectangle.setLineWidth(JPAEditorConstants.ENTITY_BORDER_WIDTH);
entityRectangle.setLineStyle(LineStyle.SOLID);
Graphiti.getGaService().setLocationAndSize(entityRectangle, context
@@ -370,8 +332,13 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
}
private ContainerShape addHeader(JavaPersistentType addedWrapper,
- ContainerShape entityShape, int width) {
-
+ ContainerShape entityShape,
+ int width,
+ JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot) {
+ String entityIconId = dot.equals(JPAEditorConstants.DIAGRAM_OBJECT_TYPE.Entity) ?
+ JPAEditorImageProvider.JPA_ENTITY :
+ JPAEditorImageProvider.MAPPED_SUPERCLASS;
+
ContainerShape headerIconShape = Graphiti.getPeService().createContainerShape(
entityShape, false);
Rectangle iconRect = Graphiti.getGaService().createRectangle(headerIconShape);
@@ -383,7 +350,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
iconRect.setHeight(JPAEditorConstants.HEADER_ICON_RECT_HEIGHT);
iconRect.setY(0);
Image headerIcon = Graphiti.getGaService().createImage(iconRect,
- JPAEditorImageProvider.JPA_ENTITY);
+ entityIconId);
Graphiti.getGaService().setLocationAndSize(headerIcon,
JPAEditorConstants.ICON_HEADER_X,
JPAEditorConstants.ICON_HEADER_Y,
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java
index c8c62db78c..494b8655d5 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java
@@ -103,7 +103,7 @@ public class AddRelationFeature extends AbstractAddFeature {
private FreeFormConnection createConnection(IAddConnectionContext addConContext, IRelation relation,
final Diagram diagram) {
- FreeFormConnection connection = getFeatureProvider().getPeUtil().createFreeFormConnection(diagram);
+ FreeFormConnection connection = getFeatureProvider().getPeServiceUtil().createFreeFormConnection(diagram);
connection.setStart(addConContext.getSourceAnchor());
connection.setEnd(addConContext.getTargetAnchor());
connection.setVisible(true);
@@ -154,7 +154,7 @@ public class AddRelationFeature extends AbstractAddFeature {
double endCoefficient = 1.0 - startCoefficient;
int len = JPAEditorUtil.calcConnectionLength(c);
if (UNI.equals(direction)) {
- ConnectionDecorator d = imageCreator.createArrowConnectionDecorator(c, endCoefficient);
+ ConnectionDecorator d = imageCreator.createArrowConnectionDecorator(c, endCoefficient, false);
Graphiti.getGaService().setLocation(d.getGraphicsAlgorithm(),Math.round(-len/10), 0);
}
}
@@ -175,7 +175,7 @@ public class AddRelationFeature extends AbstractAddFeature {
ConnectionDecorator d1 = imageCreator.createManyStartDecorator(c, startCoefficient);
Graphiti.getGaService().setLocation(d1.getGraphicsAlgorithm(),Math.round(len/10), 0);
if (UNI.equals(direction)) {
- ConnectionDecorator d2 = imageCreator.createArrowConnectionDecorator(c, endCoefficient);
+ ConnectionDecorator d2 = imageCreator.createArrowConnectionDecorator(c, endCoefficient, false);
Graphiti.getGaService().setLocation(d2.getGraphicsAlgorithm(),Math.round(-len/10), 0);
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateInheritedEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateInheritedEntityFeature.java
new file mode 100644
index 0000000000..df7edb2a68
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateInheritedEntityFeature.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2005, 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Dimov - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateConnectionContext;
+import org.eclipse.graphiti.features.context.ICreateContext;
+import org.eclipse.graphiti.features.context.impl.AddContext;
+import org.eclipse.graphiti.features.context.impl.CreateContext;
+import org.eclipse.graphiti.features.impl.AbstractCreateConnectionFeature;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
+
+public class CreateInheritedEntityFeature extends AbstractCreateConnectionFeature {
+
+ public CreateInheritedEntityFeature(IFeatureProvider fp) {
+ this(fp, JPAEditorMessages.CreateIsARelationFeature_name, JPAEditorMessages.CreateIsARelationFeature_description);
+ }
+
+ public CreateInheritedEntityFeature(IFeatureProvider fp, String name,
+ String description) {
+ super(fp, name, description);
+ }
+
+ public boolean canCreate(ICreateConnectionContext context) {
+ JavaPersistentType superclass = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ if (superclass == null)
+ return false;
+ if (context.getTargetAnchor() == null)
+ return true;
+ if (context.getTargetAnchor().getParent() instanceof Diagram)
+ return true;
+ return false;
+ }
+
+ public Connection create(ICreateConnectionContext context) {
+ JavaPersistentType mappedSuperclass = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ CreateJPAEntityFeature createEntityFeature = null;
+ try {
+ createEntityFeature = new CreateJPAEntityFeature(
+ getFeatureProvider(), mappedSuperclass);
+ } catch (JavaModelException e) {
+ JPADiagramEditorPlugin.logError("Cannot create a new JPA entity class", e); //$NON-NLS-1$
+ return null;
+ }
+ ICreateContext ctx = new CreateContext();
+ Object[] res = createEntityFeature.create(ctx);
+ JavaPersistentType newEntity = (JavaPersistentType)res[0];
+ AddJPAEntityFeature ft = new AddJPAEntityFeature(getFeatureProvider(), true);
+ AddContext cont = new AddContext();
+ cont.setTargetContainer(getFeatureProvider().getDiagram());
+ cont.setNewObject(newEntity);
+ cont.setLocation(context.getTargetLocation().getX(), context.getTargetLocation().getY());
+ ft.add(cont);
+ return null;
+ }
+
+ public boolean canStartConnection(ICreateConnectionContext context) {
+ JavaPersistentType superclass = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ if (superclass == null)
+ return false;
+ return true;
+ }
+
+ public String getCreateImageId() {
+ return JPAEditorImageProvider.ADD_INHERITED_ENTITY;
+ }
+
+ protected PersistentType getPersistentType(Anchor anchor) {
+ if (anchor != null) {
+ Object refObject =
+ getBusinessObjectForPictogramElement(anchor.getParent());
+ if (refObject instanceof PersistentType) {
+ return (PersistentType) refObject;
+ }
+ }
+ return null;
+ }
+
+ public IJPAEditorFeatureProvider getFeatureProvider() {
+ return (IJPAEditorFeatureProvider)super.getFeatureProvider();
+ }
+
+
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
index 6b685441b1..ded03573e9 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
@@ -30,6 +30,7 @@ import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jpt.jpa.core.JpaProject;
@@ -43,6 +44,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPrope
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.util.JPAEditorUtil;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchSite;
@@ -52,9 +54,10 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
private IPreferenceStore jpaPreferenceStore = JPADiagramEditorPlugin.getDefault().getPreferenceStore();
private boolean isMappedSuperclassChild;
+ private JavaPersistentType mappedSuperclass;
private String mappedSuperclassName;
private String mappedSuperclassPackage;
- private boolean hasPrimarykey;
+ private boolean superHasPrimarykey;
public CreateJPAEntityFeature(IFeatureProvider fp) {
@@ -75,14 +78,24 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
public CreateJPAEntityFeature(IFeatureProvider fp,
boolean isMappedSuperclassChild, String mappedSuperclassName,
- String mappedSuperClassPackage, boolean hasPrimaryKey) {
+ String mappedSuperClassPackage, boolean superHasPrimaryKey) {
this(fp);
this.isMappedSuperclassChild = isMappedSuperclassChild;
this.mappedSuperclassName = mappedSuperclassName;
this.mappedSuperclassPackage = mappedSuperClassPackage;
- this.hasPrimarykey = hasPrimaryKey;
+ this.superHasPrimarykey = superHasPrimaryKey;
}
+ public CreateJPAEntityFeature(IJPAEditorFeatureProvider fp,
+ JavaPersistentType mappedSuperclass) throws JavaModelException {
+ this(fp);
+ this.isMappedSuperclassChild = true;
+ this.mappedSuperclass = mappedSuperclass;
+ this.mappedSuperclassName = mappedSuperclass.getName();
+ this.mappedSuperclassPackage = JpaArtifactFactory.instance().getMappedSuperclassPackageDeclaration(mappedSuperclass);
+ this.superHasPrimarykey = JpaArtifactFactory.instance().hasOrInheritsPrimaryKey(mappedSuperclass);
+ }
+
public boolean canCreate(ICreateContext context) {
return context.getTargetContainer() instanceof Diagram;
@@ -122,7 +135,17 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
}
try {
- this.getFeatureProvider().getJPAEditorUtil().createEntityInProject(targetProject, entityName, jpaPreferenceStore, isMappedSuperclassChild, mappedSuperclassName, mappedSuperclassPackage, hasPrimarykey);
+ if (mappedSuperclass != null) {
+ this.getFeatureProvider().
+ getJPAEditorUtil().
+ createEntityInProject(targetProject, entityName, mappedSuperclass); //$NON-NLS-1$
+ } else {
+ this.getFeatureProvider().
+ getJPAEditorUtil().
+ createEntityInProject(targetProject, entityName, jpaPreferenceStore,
+ isMappedSuperclassChild, mappedSuperclassName,
+ mappedSuperclassPackage, "id", superHasPrimarykey); //$NON-NLS-1$
+ }
} catch (Exception e1) {
JPADiagramEditorPlugin.logError("Cannot create an entity in the project " + targetProject.getName(), e1); //$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 6e44389998..a861fbfc7c 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
@@ -25,8 +25,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class CreateManyToManyBiDirRelationFeature extends
- CreateManyToManyRelationFeature {
+public class CreateManyToManyBiDirRelationFeature extends CreateManyToManyRelationFeature
+ implements ICreateBiDirRelationFeature {
public CreateManyToManyBiDirRelationFeature(IJPAEditorFeatureProvider fp) {
super(fp, JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
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 1e58fd51f1..54f5bd38b1 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
@@ -25,8 +25,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class CreateManyToManyUniDirRelationFeature extends
- CreateManyToManyRelationFeature {
+public class CreateManyToManyUniDirRelationFeature extends CreateManyToManyRelationFeature
+ implements ICreateUniDirRelationFeature {
public CreateManyToManyUniDirRelationFeature(IJPAEditorFeatureProvider fp) {
super(fp, JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
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 ceeb529747..c29e2b81b5 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
@@ -25,8 +25,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class CreateManyToOneBiDirRelationFeature extends
- CreateManyToOneRelationFeature {
+public class CreateManyToOneBiDirRelationFeature extends CreateManyToOneRelationFeature
+ implements ICreateBiDirRelationFeature {
public CreateManyToOneBiDirRelationFeature(IJPAEditorFeatureProvider fp) {
super(fp, JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
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 fafc150fd4..8355aa6b07 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
@@ -25,8 +25,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class CreateManyToOneUniDirRelationFeature extends
- CreateManyToOneRelationFeature {
+public class CreateManyToOneUniDirRelationFeature extends CreateManyToOneRelationFeature
+ implements ICreateUniDirRelationFeature {
public CreateManyToOneUniDirRelationFeature(IJPAEditorFeatureProvider fp) {
super(fp, JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateMappedSuperclassFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateMappedSuperclassFeature.java
new file mode 100644
index 0000000000..16b458d724
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateMappedSuperclassFeature.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2005, 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Dimov - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.features.context.ICreateContext;
+import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
+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.util.JPAEditorUtil;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchSite;
+
+
+
+public class CreateMappedSuperclassFeature extends
+ AbstractCreateFeature {
+
+ public CreateMappedSuperclassFeature(IFeatureProvider fp) {
+ super(
+ fp,
+ JPAEditorMessages.CreateMappedSuperclassFeature_createMappedSuperclassFeatureName,
+ JPAEditorMessages.CreateMappedSuperclassFeature_createMappedSuperclassFeatureDescription);
+ }
+
+ public boolean canCreate(ICreateContext context) {
+ return context.getTargetContainer() instanceof Diagram;
+ }
+
+ public Object[] create(ICreateContext context) {
+ List<Shape> shapes = this.getFeatureProvider().getDiagramTypeProvider()
+ .getDiagram().getChildren();
+ IProject targetProject = null;
+ JpaProject jpaProject = null;
+ if ((shapes == null) || (shapes.size() == 0)) {
+ jpaProject = getTargetJPAProject();
+ targetProject = jpaProject.getProject();
+ } else {
+ Shape sh = shapes.get(0);
+ JavaPersistentType jpt = (JavaPersistentType) getFeatureProvider()
+ .getBusinessObjectForPictogramElement(sh);
+ if (jpt == null)
+ return new Object[] {};
+ jpaProject = jpt.getJpaProject();
+ targetProject = jpaProject.getProject();
+ }
+
+ String mappedSuperclassName = getFeatureProvider()
+ .getJPAEditorUtil()
+ .generateUniqueMappedSuperclassName(
+ jpaProject,
+ JPADiagramPropertyPage.getDefaultPackage(jpaProject.getProject()),
+ getFeatureProvider());
+
+ if (!JptJpaCorePlugin.getDiscoverAnnotatedClasses(jpaProject.getProject())) {
+ JPAEditorUtil.createRegisterEntityInXMLJob(jpaProject, mappedSuperclassName);
+ }
+
+ try {
+ getFeatureProvider().getJPAEditorUtil().createMappedSuperclassInProject(targetProject, mappedSuperclassName);
+ } catch (Exception e1) {
+ JPADiagramEditorPlugin.logError("Cannot create a mapped superclass in the project " + targetProject.getName(), e1); //$NON-NLS-1$
+ }
+// jpaProject.updateAndWait();
+ PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
+ JavaPersistentType jpt = JpaArtifactFactory.instance().getJPT(mappedSuperclassName, pu);
+
+ if (jpt != null) {
+ addGraphicalRepresentation(context, jpt);
+ IWorkbenchSite ws = ((IEditorPart)getDiagramEditor()).getSite();
+ ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
+ getFeatureProvider().getJPAEditorUtil().formatCode(cu, ws);
+ return new Object[] { jpt };
+ } else {
+ JPADiagramEditorPlugin.logError("The mapped superclass " + //$NON-NLS-1$
+ mappedSuperclassName + " could not be created", new Exception()); //$NON-NLS-1$
+ }
+
+ return new Object[] {};
+ }
+
+ public String getCreateImageId() {
+ return JPAEditorImageProvider.ADD_MAPPED_SUPERCLASS;
+ }
+
+
+ public IJPAEditorFeatureProvider getFeatureProvider() {
+ return (IJPAEditorFeatureProvider) super.getFeatureProvider();
+ }
+
+ private JpaProject getTargetJPAProject() {
+ return getFeatureProvider().getMoinIntegrationUtil()
+ .getProjectByDiagram(getDiagram());
+ }
+
+}
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 2eb3367f5a..574c0b720b 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
@@ -25,8 +25,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class CreateOneToManyUniDirRelationFeature extends
- CreateOneToManyRelationFeature {
+public class CreateOneToManyUniDirRelationFeature extends CreateOneToManyRelationFeature
+ implements ICreateUniDirRelationFeature {
public CreateOneToManyUniDirRelationFeature(IJPAEditorFeatureProvider fp) {
super(fp, JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
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 3a65a5dbcf..d664af2e0f 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
@@ -25,7 +25,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class CreateOneToOneBiDirRelationFeature extends CreateOneToOneRelationFeature {
+public class CreateOneToOneBiDirRelationFeature extends CreateOneToOneRelationFeature
+ implements ICreateBiDirRelationFeature {
public CreateOneToOneBiDirRelationFeature(IJPAEditorFeatureProvider fp) {
super(fp, JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
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 dae132dc57..5c1d766c85 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
@@ -25,8 +25,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-
-public class CreateOneToOneUniDirRelationFeature extends CreateOneToOneRelationFeature {
+public class CreateOneToOneUniDirRelationFeature extends CreateOneToOneRelationFeature
+ implements ICreateUniDirRelationFeature {
public CreateOneToOneUniDirRelationFeature(IJPAEditorFeatureProvider fp) {
super(fp, JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java
index 752b5bc4c6..341429398a 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java
@@ -25,6 +25,7 @@ import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.AbstractRelation;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
abstract public class CreateRelationFeature extends AbstractCreateConnectionFeature {
@@ -34,25 +35,33 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
}
public boolean canCreate(ICreateConnectionContext context) {
- JavaPersistentType source = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
- JavaPersistentType target = (JavaPersistentType)getPersistentType(context.getTargetAnchor());
- if (source != null && target != null) {
- return true;
- }
- return false;
+ JavaPersistentType owner = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ JavaPersistentType inverse = (JavaPersistentType)getPersistentType(context.getTargetAnchor());
+ if ((owner == null) || (inverse == null))
+ return false;
+ if (JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(inverse))
+ return false;
+ if ((this instanceof ICreateBiDirRelationFeature) &&
+ (JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(owner)))
+ return false;
+ return true;
}
public boolean canStartConnection(ICreateConnectionContext context) {
- if (getPersistentType(context.getSourceAnchor()) != null)
- return true;
- return false;
+ JavaPersistentType owner = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ if (owner == null)
+ return false;
+ if ((this instanceof ICreateBiDirRelationFeature) &&
+ JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(owner))
+ return false;
+ return true;
}
public Connection create(ICreateConnectionContext context) {
Connection newConnection = null;
- PersistentType source = getPersistentType(context.getSourceAnchor());
- PersistentType target = getPersistentType(context.getTargetAnchor());
- if (source != null && target != null) {
+ PersistentType owner = getPersistentType(context.getSourceAnchor());
+ PersistentType inverse = getPersistentType(context.getTargetAnchor());
+ if (owner != null && inverse != null) {
AbstractRelation rel = createRelation(getFeatureProvider(), context.getSourceAnchor().getParent(),
context.getTargetAnchor().getParent());
AddConnectionContext addContext =
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java
index 89e18ce7a1..9dc301b69c 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java
@@ -26,7 +26,7 @@ import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.AbstractRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.BidirectionalRelation;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IBidirectionalRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.UnidirectionalRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IJPAEditorUtil;
@@ -81,8 +81,8 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
feat.delete(delCtx, false);
}
- if (rel instanceof BidirectionalRelation) {
- BidirectionalRelation relation = (BidirectionalRelation)(rel);
+ if (rel instanceof IBidirectionalRelation) {
+ IBidirectionalRelation relation = (IBidirectionalRelation)(rel);
ClickRemoveAttributeButtonFeature feat = new ClickRemoveAttributeButtonFeature(getFeatureProvider());
JavaPersistentAttribute ownerAttribute = relation.getOwnerAnnotatedAttribute();
@@ -97,17 +97,6 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
}
postDelete(context);
-
- /*
- IRemoveContext rc = new RemoveContext(pe);
- IFeatureProvider featureProvider = getFeatureProvider();
- IRemoveFeature removeFeature = featureProvider.getRemoveFeature(rc);
- if (removeFeature != null) {
- removeFeature.remove(rc);
- }
- */
-
-
}
public void postDelete(IDeleteContext context) {
@@ -117,7 +106,7 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
IWorkbenchSite ws = ((IEditorPart)getDiagramEditor()).getSite();
ICompilationUnit cu = getFeatureProvider().getCompilationUnit(rel.getOwner());
ut.organizeImports(cu, ws);
- if (rel instanceof BidirectionalRelation) {
+ if (rel instanceof IBidirectionalRelation) {
cu = getFeatureProvider().getCompilationUnit(rel.getInverse());
ut.organizeImports(cu, ws);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java
index bd0b3850a5..63d7ef3bd7 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java
@@ -35,7 +35,7 @@ import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.BidirectionalRelation;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IBidirectionalRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -106,7 +106,7 @@ public class DirectEditAttributeFeature extends AbstractDirectEditingFeature {
IRelation rel = getFeatureProvider().getRelationRelatedToAttribute(oldAt);
String inverseJPTName = null;
- if (BidirectionalRelation.class.isInstance(rel))
+ if (IBidirectionalRelation.class.isInstance(rel))
inverseJPTName = rel.getInverse().getName();
if (oldAt.getName().equals(value))
return;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
index c8d8cdffb8..60d59754ff 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
@@ -92,18 +92,19 @@ class GraphicalRemoveAttributeFeature extends AbstractCustomFeature {
.getAnchors().iterator().next());
ctx.setNewObject(rel);
relF.add(ctx);
-// JpaArtifactFactory.instance().refreshEntityModel(fp, jpt);
}
+ JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
+
}
@SuppressWarnings("deprecation")
private void readdCompartmentsChildren(JavaPersistentType javaPersistentType, ContainerShape entityShape,
ContainerShape primaryShape, ContainerShape relationShape, ContainerShape basicShape) {
-
+ JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(javaPersistentType);
UpdateAttributeFeature updateFeature = new UpdateAttributeFeature(getFeatureProvider());
- updateFeature.addSeparatorsToShape(primaryShape);
- updateFeature.addSeparatorsToShape(relationShape);
- updateFeature.addSeparatorsToShape(basicShape);
+ updateFeature.addSeparatorsToShape(primaryShape, dot);
+ updateFeature.addSeparatorsToShape(relationShape, dot);
+ updateFeature.addSeparatorsToShape(basicShape, dot);
for (JavaPersistentAttribute attribute : javaPersistentType.getAttributes()) {
updateFeature.addAttributes(entityShape, attribute);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ICreateBiDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ICreateBiDirRelationFeature.java
new file mode 100644
index 0000000000..c24cd9d94c
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ICreateBiDirRelationFeature.java
@@ -0,0 +1,5 @@
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
+
+public interface ICreateBiDirRelationFeature {
+
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ICreateUniDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ICreateUniDirRelationFeature.java
new file mode 100644
index 0000000000..1e174d99f6
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ICreateUniDirRelationFeature.java
@@ -0,0 +1,5 @@
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
+
+public interface ICreateUniDirRelationFeature {
+
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java
index b9eae4f056..a45e2d7363 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java
@@ -45,7 +45,7 @@ public class LayoutJPAEntityFeature extends AbstractLayoutFeature {
public LayoutJPAEntityFeature(IJPAEditorFeatureProvider fp) {
super(fp);
- peUtil = fp.getPeUtil();
+ peUtil = fp.getPeServiceUtil();
}
public boolean canLayout(ILayoutContext context) {
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 1790b31cd7..490688c104 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
@@ -114,6 +114,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
final Shape pict = (Shape)getFeatureProvider().getPictogramElementForBusinessObject(jpt);
JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().
getBusinessObjectForPictogramElement(pict);
+ final JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(jpt);
final PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpt);
final Semaphore s = new Semaphore(0);
final JPAProjectListener lsnr = new JPAProjectListener(s);
@@ -137,12 +138,13 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
- remapEntity(oldName, pict, pu, rename, lsnr, getFeatureProvider());
+ remapEntity(oldName, pict, pu, rename, lsnr, dot, getFeatureProvider());
}
});
}
public void execute(ICustomContext context, String newName, ICompilationUnit cu, JavaPersistentType jpt) {
+ final JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(jpt);
final String oldName = jpt.getName();
final Shape pict = (Shape)getFeatureProvider().getPictogramElementForBusinessObject(jpt);
jpt = (JavaPersistentType)getFeatureProvider().
@@ -161,7 +163,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
- remapEntity(oldName, pict, pu, true, lsnr, getFeatureProvider());
+ remapEntity(oldName, pict, pu, true, lsnr, dot, getFeatureProvider());
}
});
}
@@ -171,6 +173,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
final PersistenceUnit pu,
final boolean rename,
final JPAProjectListener lsnr,
+ final JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot,
final IJPAEditorFeatureProvider fp) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
@@ -190,11 +193,11 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
cont.setY(y);
cont.setWidth(width);
cont.setHeight(height);
- RoundedRectangle rect = AddJPAEntityFeature.createEntityRectangle(cont, cs, fp.getDiagramTypeProvider().getDiagram());
+ RoundedRectangle rect = AddJPAEntityFeature.createEntityRectangle(cont, cs, dot, fp.getDiagramTypeProvider().getDiagram());
rect.setFilled(true);
IRemoveContext ctx = new RemoveContext(pict);
- RemoveJPAEntityFeature ft = new RemoveJPAEntityFeature(fp);
+ RemoveJPAEntityFeature ft = new RemoveJPAEntityFeature(fp, true);
boolean primaryCollapsed = JPAEditorConstants.TRUE_STRING.equals(Graphiti.getPeService().getPropertyValue(pict, JPAEditorConstants.PRIMARY_COLLAPSED));
boolean relationCollapsed = JPAEditorConstants.TRUE_STRING.equals(Graphiti.getPeService().getPropertyValue(pict, JPAEditorConstants.RELATION_COLLAPSED));
@@ -217,7 +220,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
addCtx.setY(y);
addCtx.setWidth(width);
addCtx.setHeight(height);
- AddJPAEntityFeature ft1 = new AddJPAEntityFeature(fp);
+ AddJPAEntityFeature ft1 = new AddJPAEntityFeature(fp, true);
ft.remove(ctx);
ft1.add(addCtx);
PictogramElement pe = fp.getPictogramElementForBusinessObject(newJPT);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAllEntitiesFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAllEntitiesFeature.java
index f1225ab4c6..4b5f6ce3a8 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAllEntitiesFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAllEntitiesFeature.java
@@ -27,8 +27,8 @@ import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.impl.RemoveContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
-import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
public abstract class RemoveAllEntitiesFeature extends AbstractCustomFeature {
@@ -45,14 +45,12 @@ public abstract class RemoveAllEntitiesFeature extends AbstractCustomFeature {
}
public void execute(ICustomContext context) {
+ TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(getFeatureProvider().getDiagram());
Iterator<Shape> it = allShapes.iterator();
while (it.hasNext()) {
Shape sh = it.next();
- final RemoveJPAEntityFeature ft = new RemoveJPAEntityFeature(this.getFeatureProvider());
+ final RemoveJPAEntityFeature ft = new RemoveJPAEntityFeature(this.getFeatureProvider(), false);
final IRemoveContext ctx = new RemoveContext(sh);
- PictogramElement pe = ctx.getPictogramElement();
-
- TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(pe);
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
@@ -62,4 +60,8 @@ public abstract class RemoveAllEntitiesFeature extends AbstractCustomFeature {
}
}
+ public IJPAEditorFeatureProvider getFeatureProvider() {
+ return (IJPAEditorFeatureProvider) super.getFeatureProvider();
+ }
+
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java
index b70aaa5289..aac451f932 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java
@@ -30,6 +30,7 @@ import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -67,4 +68,9 @@ public class RemoveAndSaveEntityFeature extends DefaultRemoveFeature {
return (IJPAEditorFeatureProvider)super.getFeatureProvider();
}
+ public void postRemove(IRemoveContext context) {
+ JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
+ }
+
+
} \ 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/feature/RemoveAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAttributeFeature.java
index 055d602afb..e43dd9139e 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAttributeFeature.java
@@ -154,8 +154,8 @@ public class RemoveAttributeFeature extends DefaultRemoveFeature {
cntx.setNewObject(rel);
AddRelationFeature ft = new AddRelationFeature(getFeatureProvider());
ft.add(cntx);
-// JpaArtifactFactory.instance().refreshEntityModel(getFeatureProvider(), jpt);
}
+ JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
}
} \ 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/feature/RemoveJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java
index e188f0705e..f5bfb477c2 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
@@ -43,18 +43,15 @@ import org.eclipse.ui.PlatformUI;
public class RemoveJPAEntityFeature extends DefaultRemoveFeature {
+ private boolean shouldRearrangeIsARelations = true;
- public RemoveJPAEntityFeature(IFeatureProvider fp) {
+ public RemoveJPAEntityFeature(IFeatureProvider fp, boolean shouldRearrangeIsARelations) {
super(fp);
+ this.shouldRearrangeIsARelations = shouldRearrangeIsARelations;
}
public void preRemove(IRemoveContext context) {
PictogramElement pe = context.getPictogramElement();
-
-// RestoreEntityFeature ft = new RestoreEntityFeature(getFeatureProvider());
-// ICustomContext customContext = new CustomContext(new PictogramElement[] { pe });
-// ft.execute(customContext);
-
final Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
Set<Shape> shapesForDeletion = new HashSet<Shape>();
if (bo instanceof JavaPersistentType) {
@@ -75,20 +72,8 @@ public class RemoveJPAEntityFeature extends DefaultRemoveFeature {
IRemoveContext ctx = new RemoveContext(it.next());
f.remove(ctx);
}
- //---------------------------------------------------------------------
- //--Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=281345
- //Job job = new Job("Remove JPA entity") { //$NON-NLS-1$
- // protected IStatus run(IProgressMonitor monitor) {
- String name = ((PersistentType)bo).getName();
- getFeatureProvider().remove(name, true);
- //return new Status(IStatus.OK,
- // JPADiagramEditorPlugin.PLUGIN_ID,
- // name + " is removed"); //$NON-NLS-1$
-
- // }
- //};
- //job.schedule();
- //---------------------------------------------------------------------
+ String name = ((PersistentType)bo).getName();
+ getFeatureProvider().remove(name, true);
}
}
@@ -123,9 +108,9 @@ public class RemoveJPAEntityFeature extends DefaultRemoveFeature {
super.execute(context);
}
-
-
-
-
+ public void postRemove(IRemoveContext context) {
+ if (shouldRearrangeIsARelations)
+ JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
+ }
} \ 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/feature/UpdateAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/UpdateAttributeFeature.java
index 853f916909..ef4ad8a550 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/UpdateAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/UpdateAttributeFeature.java
@@ -31,6 +31,7 @@ import org.eclipse.graphiti.mm.pictograms.AnchorContainer;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.util.IColorConstant;
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.provider.IJPAEditorFeatureProvider;
@@ -128,17 +129,21 @@ public class UpdateAttributeFeature extends AbstractCustomFeature {
return rect;
}
- public void addSeparatorsToShape(ContainerShape compartmentShape) {
- addSeparatorToCollection(compartmentShape, 0);
- addSeparatorToCollection(compartmentShape, JPAEditorConstants.COMPARTMENT_MIN_HEIGHT);
+ public void addSeparatorsToShape(ContainerShape compartmentShape,
+ JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot) {
+ addSeparatorToCollection(compartmentShape, 0, dot);
+ addSeparatorToCollection(compartmentShape, JPAEditorConstants.COMPARTMENT_MIN_HEIGHT, dot);
}
- private Shape addSeparatorToCollection(ContainerShape containerShape, int y) {
+ private Shape addSeparatorToCollection(ContainerShape containerShape, int y,
+ JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot) {
final int width = containerShape.getGraphicsAlgorithm().getWidth();
Shape shape = Graphiti.getPeService().createShape(containerShape, false);
Rectangle rectangle = Graphiti.getGaService().createRectangle(shape);
- rectangle.setForeground(manageColor(JPAEditorConstants.ENTITY_BACKGROUND));
- rectangle.setBackground(manageColor(JPAEditorConstants.ENTITY_BORDER_COLOR));
+ IColorConstant foreground = JpaArtifactFactory.instance().getForeground(dot);
+ IColorConstant background = JpaArtifactFactory.instance().getBackground(dot);
+ rectangle.setForeground(manageColor(background));
+ rectangle.setBackground(manageColor(foreground));
rectangle.setLineVisible(false);
Graphiti.getGaService().setSize(rectangle, width, JPAEditorConstants.SEPARATOR_HEIGHT);
Graphiti.getGaService().setLocationAndSize(rectangle, 0, y, width, JPAEditorConstants.SEPARATOR_HEIGHT);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java
index 14afdf1c89..208eb6592f 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java
@@ -36,18 +36,20 @@ public class JPAEditorMessages extends NLS {
public static String CreateDiagramJob_createDiagramJobName;
public static String CreateDiagramJob_getJPADiagramMonitorTaskName;
+ public static String CreateIsARelationFeature_description;
+ public static String CreateIsARelationFeature_name;
+
public static String CreateJPAEntityFeature_createEntityErrorMsg;
-
public static String CreateJPAEntityFeature_createEntityErrorMsgTitle;
-
public static String CreateJPAEntityFeature_createEntityErrorStatusMsg;
-
public static String CreateJPAEntityFeature_jpaEntityFeatureDescription;
public static String CreateJPAEntityFeature_jpaEntityFeatureName;
public static String CreateJPAEntityFeature_jpaProjectSelectionDialogDescription;
public static String CreateJPAEntityFeature_jpaProjectSelectionDialogTitle;
public static String CreateJPAEntityFromMappedSuperclassFeature_createInheritedEntityFeatureDescription;
public static String CreateJPAEntityFromMappedSuperclassFeature_createInheritedEntityFeatureName;
+ public static String CreateMappedSuperclassFeature_createMappedSuperclassFeatureDescription;
+ public static String CreateMappedSuperclassFeature_createMappedSuperclassFeatureName;
public static String CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName;
public static String CreateManyToManyBiDirRelationFeature_manyToManyUniDirFeatureDescription;
@@ -181,7 +183,9 @@ public class JPAEditorMessages extends NLS {
public static String JPAEditorToolBehaviorProvider_expandEntitymenuItemDescr;
public static String JPAEditorToolBehaviorProvider_expandAllEntitiesMenuItem;
- public static String JPAEditorToolBehaviorProvider_expandAllEntitiesMenuItemDescr;
+ public static String JPAEditorToolBehaviorProvider_expandAllEntitiesMenuItemDescr;
+
+ public static String JPAEditorToolBehaviorProvider_InheritanceCompartmentTitle;
public static String JPAEditorToolBehaviorProvider_refactorAttributeType;
public static String JPAEditorToolBehaviorProvider_refactorAttributeTypeDesc;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties
index 1a9895f849..9af5b772be 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties
@@ -25,6 +25,10 @@ ClickRemoveAttributeButtonFeature_deleteAttributeQuestion=Do you want to delete
CreateDiagramJob_createDiagramJobName=Creating diagram for: {0}...
CreateDiagramJob_getJPADiagramMonitorTaskName=Get JPA Diagram
+
+CreateIsARelationFeature_description=Click on an entity or mapped superclass and then click somewhere in the diagram to create new inherited entity
+CreateIsARelationFeature_name=Inherited Entity
+
CreateJPAEntityFeature_createEntityErrorMsg=Entity could not be created.
CreateJPAEntityFeature_createEntityErrorMsgTitle=Cannot Create Entity
CreateJPAEntityFeature_createEntityErrorStatusMsg=Persistence API library is not into the project's classpath.
@@ -34,6 +38,8 @@ CreateJPAEntityFeature_jpaProjectSelectionDialogDescription=Select a JPA project
CreateJPAEntityFeature_jpaProjectSelectionDialogTitle=Select JPA Project
CreateJPAEntityFromMappedSuperclassFeature_createInheritedEntityFeatureDescription=Create a new JPA entity that will inherit a new Mapped Superclass.
CreateJPAEntityFromMappedSuperclassFeature_createInheritedEntityFeatureName=Inherited Entity
+CreateMappedSuperclassFeature_createMappedSuperclassFeatureDescription=Create a new Mapped Superclass.
+CreateMappedSuperclassFeature_createMappedSuperclassFeatureName=Mapped Superclass
CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName=Many-to-Many
CreateManyToManyBiDirRelationFeature_manyToManyUniDirFeatureDescription=Create new bidirectional many-to-many relation.
@@ -152,6 +158,7 @@ JPAEditorToolBehaviorProvider_expandEntityMenuItem=Expand Entity
JPAEditorToolBehaviorProvider_expandEntitymenuItemDescr=Expand entity.
JPAEditorToolBehaviorProvider_expandAllEntitiesMenuItem=Expand All
JPAEditorToolBehaviorProvider_expandAllEntitiesMenuItemDescr=Expand all entities.
+JPAEditorToolBehaviorProvider_InheritanceCompartmentTitle=Inheritance
JPAEditorToolBehaviorProvider_refactorAttributeType=Refactor Attribute Type...
JPAEditorToolBehaviorProvider_refactorAttributeTypeDesc=Change the type of the selected attribute.
JPAEditorToolBehaviorProvider_removeAllEntitiesMenu=Remove All Entities From Diagram
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
index a629d3dc93..ce5aaf00fe 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
@@ -178,7 +178,18 @@ public class OpenJpaDiagramActionDelegate implements IObjectActionDelegate {
if (firstElement instanceof JpaNode) {
jpaProject = ((JpaNode)firstElement).getJpaProject();
} else if (firstElement instanceof IProject) {
- jpaProject = JpaArtifactFactory.instance().getJpaProject((IProject)firstElement);
+ int cnt = 0;
+ while ((jpaProject == null) && (cnt < 25)) {
+ jpaProject = JpaArtifactFactory.instance().getJpaProject((IProject)firstElement);
+ if (jpaProject == null) {
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException e) {
+ JPADiagramEditorPlugin.logError("Thread sleep interrupted", e); //$NON-NLS-1$
+ }
+ }
+ cnt++;
+ }
}
return JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java
index 086de3b17b..e344e39bd4 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java
@@ -294,6 +294,8 @@ public class ModelIntegrationUtil {
public static JPAEditorDiagramTypeProvider getProviderByDiagram(String diagramName) {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (workbenchWindow == null)
+ return null;
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
IEditorReference[] editorRefs = workbenchPage.getEditorReferences();
for (IEditorReference editorRef : editorRefs) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java
index 995bbc2bdb..8c37d93ce2 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java
@@ -15,6 +15,8 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.provider;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.Properties;
import org.eclipse.core.resources.IProject;
@@ -23,7 +25,9 @@ import org.eclipse.graphiti.features.IDeleteFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.features.custom.ICustomFeature;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.services.IPeService;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
@@ -32,6 +36,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.IModel
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.RelDir;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.RelType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IsARelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IGraphicsUpdater;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IJPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IPeServiceUtil;
@@ -39,6 +44,12 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IPeServiceUtil;
public interface IJPAEditorFeatureProvider extends IFeatureProvider{
+ public Diagram getDiagram();
+
+ public HashSet<IsARelation> getAllRedundantIsARelations();
+
+ public HashSet<IsARelation> getAllExistingIsARelations();
+
public ICompilationUnit getCompilationUnit(JavaPersistentType jpt);
public boolean hasObjectWithName(String name);
@@ -80,8 +91,10 @@ public interface IJPAEditorFeatureProvider extends IFeatureProvider{
public void replaceAttribute(JavaPersistentAttribute oldAt, JavaPersistentAttribute newAt);
public void renewAttributeJoiningStrategyPropertyListener(JavaPersistentAttribute jpa);
+
+ public IPeService getPeService();
- public IPeServiceUtil getPeUtil();
+ public IPeServiceUtil getPeServiceUtil();
public IJPAEditorUtil getJPAEditorUtil();
@@ -99,4 +112,12 @@ public interface IJPAEditorFeatureProvider extends IFeatureProvider{
public Properties loadProperties(IProject project);
+ public Collection<JavaPersistentType> getPersistentTypes();
+
+ public JavaPersistentType getFirstSuperclassBelongingToTheDiagram(JavaPersistentType subclass);
+
+ public void removeAllRedundantIsARelations();
+
+ public boolean existRedundantIsARelations();
+
} \ 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/provider/IJPAEditorImageCreator.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorImageCreator.java
index 625d575b27..12e399c248 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorImageCreator.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorImageCreator.java
@@ -31,9 +31,11 @@ public interface IJPAEditorImageCreator {
public Polyline createConnectionLine(Diagram d, Connection connection);
+ public Polyline createIsAConnectionLine(Diagram d, Connection connection);
+
//public ConnectionDecorator createTextConnectionDecorator(Connection connection, String text, double location);
- public ConnectionDecorator createArrowConnectionDecorator(Connection connection, double location);
+ public ConnectionDecorator createArrowConnectionDecorator(Connection connection, double location, boolean isA);
public ConnectionDecorator createManyEndWithArrowDecorator(Connection connection, double location);
@@ -45,5 +47,7 @@ public interface IJPAEditorImageCreator {
public ConnectionDecorator createCardinalityConnectionDecorator(Diagram d, Connection c, String text, double location);
+ public ConnectionDecorator createIsATextConnectionDecorator(Diagram d, Connection c);
+
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java
index d89265d328..ff4c5c016b 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java
@@ -266,10 +266,11 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
ctx.setHeight(sp.getHeight());
ctx.setX(sp.getX());
ctx.setY(sp.getY());
- AddJPAEntityFeature ft = new AddJPAEntityFeature(getFeatureProvider());
+ AddJPAEntityFeature ft = new AddJPAEntityFeature(getFeatureProvider(), false);
ft.add(ctx);
}
}
+ JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
}
});
getDiagramEditor().saveWithoutEntities(new NullProgressMonitor());
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java
index bc94dccfee..3449be405a 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java
@@ -19,10 +19,12 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import org.eclipse.core.resources.IProject;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
@@ -61,12 +63,14 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.services.IPeService;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.internal.core.CompilationUnit;
import org.eclipse.jdt.internal.core.SourceType;
import org.eclipse.jpt.jpa.core.JpaNode;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
@@ -82,11 +86,11 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CollapseAllEntitiesF
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CollapseCompartmentShapeFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CollapseEntityFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateJPAEntityFeature;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateJPAEntityFromMappedSuperclassFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateManyToManyBiDirRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateManyToManyUniDirRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateManyToOneBiDirRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateManyToOneUniDirRelationFeature;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateMappedSuperclassFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateOneToManyUniDirRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateOneToOneBiDirRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateOneToOneUniDirRelationFeature;
@@ -113,6 +117,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.AbstractRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.RelDir;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.RelType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IsARelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.GraphicsUpdaterImpl;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IGraphicsUpdater;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IJPAEditorUtil;
@@ -132,7 +137,8 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
private ClickAddAttributeButtonFeature clickAddAttBtnFeat = null;
private ClickRemoveAttributeButtonFeature clickRemoveAttBtnFeat = null;
- private IPeServiceUtil peUtil = new PeServiceUtilImpl();
+ private IPeServiceUtil peServiceUtil = new PeServiceUtilImpl();
+ private IPeService peService = Graphiti.getPeService();
private IJPAEditorUtil jpaEditorUtil = new JPAEditorUtilImpl();
private IModelIntegrationUtil moinIntegrationUtil = new ModelIntegrationUtilImpl();
private IGraphicsUpdater graphicsUpdater = new GraphicsUpdaterImpl();
@@ -148,6 +154,100 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
((JPASolver)getIndependenceSolver()).stopThread();
}
+ public Diagram getDiagram() {
+ return getDiagramTypeProvider().getDiagram();
+ }
+
+ public HashSet<IsARelation> getAllExistingIsARelations() {
+ EList<Connection> allCons = getDiagram().getConnections();
+ HashSet<IsARelation> res = new HashSet<IsARelation>();
+ HashSet<Connection> tbd = new HashSet<Connection>();
+ for (Connection conn : allCons) {
+ if (IsARelation.isIsAConnection(conn))
+ try {
+ res.add(new IsARelation(this, conn));
+ } catch (NullPointerException e) {
+ tbd.add(conn);
+ }
+ }
+ Iterator<Connection> it = tbd.iterator();
+ while (it.hasNext()) {
+ Graphiti.getPeService().deletePictogramElement(it.next());
+ }
+ return res;
+ }
+
+ public HashSet<IsARelation> getAllRedundantIsARelations() {
+ EList<Connection> allCons = getDiagram().getConnections();
+ HashSet<IsARelation> res = new HashSet<IsARelation>();
+ for (Connection conn : allCons) {
+ if (IsARelation.isIsAConnection(conn))
+ res.add(new IsARelation(this, conn));
+ }
+ return res;
+ }
+
+ public void removeAllRedundantIsARelations() {
+ EList<Connection> allCons = getDiagram().getConnections();
+ Collection<Connection> redundantConnections = new LinkedList<Connection>();
+ for (Connection conn : allCons) {
+ if (IsARelation.isIsAConnection(conn)) {
+ IsARelation rel = null;
+ try {
+ rel = new IsARelation(this, conn);
+ } catch (NullPointerException e) {
+ redundantConnections.add(conn);
+ continue;
+ }
+ if (!rel.getSuperclass().getName().equals(getFirstSuperclassBelongingToTheDiagram(rel.getSubclass()).getName())) {
+ redundantConnections.add(conn);
+ }
+ }
+ }
+ Iterator<Connection> it = redundantConnections.iterator();
+ while (it.hasNext()) {
+ Connection conn = it.next();
+ peService.deletePictogramElement(conn);
+ }
+ }
+
+ public boolean existRedundantIsARelations() {
+ EList<Connection> allCons = getDiagram().getConnections();
+ for (Connection conn : allCons) {
+ if (IsARelation.isIsAConnection(conn)) {
+ IsARelation rel = null;
+ try {
+ rel = new IsARelation(this, conn);
+ } catch (NullPointerException e) {
+ return true;
+ }
+ if (!rel.getSuperclass().equals(getFirstSuperclassBelongingToTheDiagram(rel.getSubclass()))) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public JavaPersistentType getFirstSuperclassBelongingToTheDiagram(JavaPersistentType subclass) {
+ Iterable<PersistentType> h = subclass.getInheritanceHierarchy();
+ Iterator<PersistentType> iter = h.iterator();
+ if (!iter.hasNext())
+ return null;
+ HashSet<PersistentType> cycleChecker = new HashSet<PersistentType>();
+ cycleChecker.add(iter.next());
+ while (iter.hasNext()) {
+ PersistentType superclass = iter.next();
+ if (hasObjectWithName(getKeyForBusinessObject(superclass))) {
+ return (JavaPersistentType) superclass;
+ }
+ if (!cycleChecker.add(superclass))
+ return null;
+ }
+ return null;
+ }
+
+
public void addJPTForUpdate(String jptName) {
((JPASolver)getIndependenceSolver()).addJPTForUpdate(jptName);
}
@@ -178,7 +278,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
public IAddFeature getAddFeature(IAddContext context) {
Object newObj = context.getNewObject();
if (newObj instanceof JavaPersistentType) {
- return new AddJPAEntityFeature(this);
+ return new AddJPAEntityFeature(this, true);
} else if (newObj instanceof AbstractRelation) {
return new AddRelationFeature(this);
} else if (newObj instanceof PersistentAttribute) {
@@ -190,11 +290,11 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
} else if (newObj instanceof CompilationUnit) {
CompilationUnit cu = (CompilationUnit)newObj;
JavaPersistentType jpt = JPAEditorUtil.getJPType(cu);
- if (jpt != null) return new AddJPAEntityFeature(this);
+ if (jpt != null) return new AddJPAEntityFeature(this, true);
} else if ((newObj instanceof JpaNode)) {
return new AddAllEntitiesFeature(this);
} else if (newObj instanceof SourceType) {
- return new AddJPAEntityFeature(this);
+ return new AddJPAEntityFeature(this, true);
}
return super.getAddFeature(context);
}
@@ -202,7 +302,8 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
@Override
public ICreateFeature[] getCreateFeatures() {
- return new ICreateFeature[] { new CreateJPAEntityFeature(this), new CreateJPAEntityFromMappedSuperclassFeature(this) };
+ return new ICreateFeature[] {new CreateJPAEntityFeature(this),
+ new CreateMappedSuperclassFeature(this)};
}
@Override
@@ -278,7 +379,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
if (bo == null)
super.getRemoveFeature(context);
if (bo instanceof JavaPersistentType) {
- return new RemoveJPAEntityFeature(this);
+ return new RemoveJPAEntityFeature(this, true);
} else if (bo instanceof AbstractRelation) {
return new RemoveRelationFeature(this);
}
@@ -456,6 +557,9 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
return ((JPASolver)getIndependenceSolver()).remove(key);
}
+ public Collection<JavaPersistentType> getPersistentTypes() {
+ return ((JPASolver)getIndependenceSolver()).getPersistentTypes();
+ }
protected void removeAllConnections(Shape shape) {
for (Iterator<Anchor> iter = shape.getAnchors().iterator(); iter.hasNext();) {
@@ -590,10 +694,13 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
((JPASolver)getIndependenceSolver()).dispose();
setIndependenceSolver(null);
}
+
+ public IPeService getPeService() {
+ return peService;
+ }
-
- public IPeServiceUtil getPeUtil() {
- return peUtil;
+ public IPeServiceUtil getPeServiceUtil() {
+ return peServiceUtil;
}
public IJPAEditorUtil getJPAEditorUtil() {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageCreator.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageCreator.java
index eb3198065a..628f4dcd86 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageCreator.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageCreator.java
@@ -18,6 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.provider;
import org.eclipse.graphiti.mm.algorithms.Image;
import org.eclipse.graphiti.mm.algorithms.Polyline;
import org.eclipse.graphiti.mm.algorithms.Text;
+import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.Diagram;
@@ -37,18 +38,14 @@ public class JPAEditorImageCreator implements IJPAEditorImageCreator {
return polyline;
}
- /*
- public ConnectionDecorator createTextConnectionDecorator(Connection connection, String text, double location) {
- ConnectionDecorator textDecorator = Graphiti.getPeService().createConnectionDecorator(connection, true, 0.5, true);
- Text txt = Graphiti.getGaService().createDefaultText(textDecorator);
- txt.setLineWidth(JPAEditorConstants.CONNECTION_LINE_WIDTH);
- txt.setValue(text);
- Graphiti.getGaService().manageColor(connection.getParent(), IColorConstant.BLACK);
- Graphiti.getGaService().setLocation(txt, 5, -20);
- return textDecorator;
+ public Polyline createIsAConnectionLine(Diagram d, Connection connection) {
+ Polyline polyline = Graphiti.getGaService().createPolyline(connection);
+ polyline.setForeground(Graphiti.getGaService().manageColor(d, JPAEditorConstants.IS_A_CONNECTION_LINE_COLOR));
+ polyline.setLineWidth(JPAEditorConstants.IS_A_CONNECTION_LINE_WIDTH);
+ polyline.setLineStyle(LineStyle.DASH);
+ return polyline;
}
- */
-
+
public ConnectionDecorator createCardinalityConnectionDecorator(Diagram d, Connection c, String text, double location) {
ConnectionDecorator textDecorator = Graphiti.getPeService().createConnectionDecorator(c, true, location, true);
Text txt = Graphiti.getGaService().createDefaultText(d, textDecorator);
@@ -60,11 +57,14 @@ public class JPAEditorImageCreator implements IJPAEditorImageCreator {
return textDecorator;
}
- public ConnectionDecorator createArrowConnectionDecorator(Connection connection, double location) {
+ public ConnectionDecorator createArrowConnectionDecorator(Connection connection,
+ double location,
+ boolean isA) {
ConnectionDecorator cd = Graphiti.getPeService().createConnectionDecorator(connection, false, location, true);
- Polyline arrow = null;
- arrow = Graphiti.getGaService().createPolyline(cd, new int[] { 11, 3, 0, 0, 11, -3, 11, 3});
- arrow.setForeground(Graphiti.getGaService().manageColor(connection.getParent(), JPAEditorConstants.CONNECTION_LINE_COLOR));
+ Polyline arrow = Graphiti.getGaService().createPolyline(cd, new int[] { 11, 3, 0, 0, 11, -3, 11, 3 });
+ arrow.setForeground(Graphiti.getGaService().manageColor(connection.getParent(), isA ?
+ JPAEditorConstants.IS_A_CONNECTION_LINE_COLOR :
+ JPAEditorConstants.CONNECTION_LINE_COLOR));
arrow.setLineWidth(JPAEditorConstants.CONNECTION_LINE_WIDTH);
return cd;
}
@@ -107,4 +107,15 @@ public class JPAEditorImageCreator implements IJPAEditorImageCreator {
return iconDecorator;
}
+ public ConnectionDecorator createIsATextConnectionDecorator(Diagram d, Connection c) {
+ ConnectionDecorator textDecorator = Graphiti.getPeService().createConnectionDecorator(c, true, 0.5, true);
+ Text txt = Graphiti.getGaService().createDefaultText(d, textDecorator);
+ txt.setLineWidth(JPAEditorConstants.CONNECTION_LINE_WIDTH);
+ txt.setValue(JPAEditorConstants.IS_A);
+ Graphiti.getGaService().manageColor(c.getParent(), IColorConstant.BLACK);
+ //Point pt = JPAEditorUtil.recalcTextDecoratorPosition((FreeFormConnection)c, textDecorator);
+ Graphiti.getGaService().setLocation(txt, 5, 5, false);
+ return textDecorator;
+ }
+
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageProvider.java
index 46905aeafd..cd1a814765 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorImageProvider.java
@@ -18,42 +18,45 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.provider;
import org.eclipse.graphiti.ui.platform.AbstractImageProvider;
public class JPAEditorImageProvider extends AbstractImageProvider {
-
- public final static String ID = "org.eclipse.jpt.jpadiagrameditor.ui.JPAEditorImageProvider"; //$NON-NLS-1$
- static final String PRE = "org.eclipse.jpt.jpadiagrameditor.ui."; //$NON-NLS-1$
- public static final String JPA_ENTITY = PRE + "entity"; //$NON-NLS-1$
- public static final String ADD_JPA_ENTITY = PRE + "add_entity"; //$NON-NLS-1$
- public static final String ADD_INHERITED_ENTITY = PRE + "mapped_superclass"; //$NON-NLS-1$
- public static final String PRIMARY_KEY = PRE + "pk"; //$NON-NLS-1$
- public static final String ICON_BASIC = PRE + "field"; //$NON-NLS-1$
- public static final String ADD_ATTRIBUTE = PRE + "add_attribute"; //$NON-NLS-1$
- public static final String REMOVE_ATTRIBUTE = PRE + "remove_attribute"; //$NON-NLS-1$
- public static final String ICON_ONE_TO_ONE = PRE + "one_to_one_relation"; //$NON-NLS-1$
- public static final String ICON_ONE_TO_MANY = PRE + "one_to_many_relation"; //$NON-NLS-1$
- public static final String ICON_MANY_TO_ONE = PRE + "many_to_one_relation"; //$NON-NLS-1$
- public static final String ICON_MANY_TO_MANY = PRE + "many_to_many_relation"; //$NON-NLS-1$
- public static final String ICON_EMBEDDED_ID = PRE + "embedded_id"; //$NON-NLS-1$
- public static final String ICON_VERSION = PRE + "version"; //$NON-NLS-1$
- public static final String ICON_TRANSIENT = PRE + "transient"; //$NON-NLS-1$
- public static final String ICON_EMBEDDED = PRE + "embedded"; //$NON-NLS-1$
- public static final String ICON_UNMAPPED = PRE + "unmapped"; //$NON-NLS-1$
+
+ private final static String PREFIX = "org.eclipse.jpt.jpadiagrameditor.ui."; //$NON-NLS-1$
+ public final static String ID = "org.eclipse.jpt.jpadiagrameditor.ui.JPAEditorImageProvider"; //$NON-NLS-1$
+
+ public static final String JPA_ENTITY = PREFIX + "entity"; //$NON-NLS-1$
+ public static final String MAPPED_SUPERCLASS = PREFIX + "mapped_superclass"; //$NON-NLS-1$
+ public static final String ADD_JPA_ENTITY = PREFIX + "add_entity"; //$NON-NLS-1$
+ public static final String ADD_INHERITED_ENTITY = PREFIX + "add_inherited_entity"; //$NON-NLS-1$
+ public static final String ADD_MAPPED_SUPERCLASS = PREFIX + "add_mapped_superclass"; //$NON-NLS-1$
+ public static final String PRIMARY_KEY = PREFIX + "pk"; //$NON-NLS-1$
+ public static final String ICON_BASIC = PREFIX + "field"; //$NON-NLS-1$
+ public static final String ADD_ATTRIBUTE = PREFIX + "add_attribute"; //$NON-NLS-1$
+ public static final String REMOVE_ATTRIBUTE = PREFIX + "remove_attribute"; //$NON-NLS-1$
+ public static final String ICON_ONE_TO_ONE = PREFIX + "one_to_one_relation"; //$NON-NLS-1$
+ public static final String ICON_ONE_TO_MANY = PREFIX + "one_to_many_relation"; //$NON-NLS-1$
+ public static final String ICON_MANY_TO_ONE = PREFIX + "many_to_one_relation"; //$NON-NLS-1$
+ public static final String ICON_MANY_TO_MANY = PREFIX + "many_to_many_relation"; //$NON-NLS-1$
+ public static final String ICON_EMBEDDED_ID = PREFIX + "embedded_id"; //$NON-NLS-1$
+ public static final String ICON_VERSION = PREFIX + "version"; //$NON-NLS-1$
+ public static final String ICON_TRANSIENT = PREFIX + "transient"; //$NON-NLS-1$
+ public static final String ICON_EMBEDDED = PREFIX + "embedded"; //$NON-NLS-1$
+ public static final String ICON_UNMAPPED = PREFIX + "unmapped"; //$NON-NLS-1$
- public static final String ICON_ONE_TO_ONE_1_DIR = PRE + "one_to_one_1_dir_relation"; //$NON-NLS-1$
- public static final String ICON_ONE_TO_MANY_1_DIR = PRE + "one_to_many_1_dir_relation"; //$NON-NLS-1$
- public static final String ICON_MANY_TO_ONE_1_DIR = PRE + "many_to_one_1_dir_relation"; //$NON-NLS-1$
- public static final String ICON_MANY_TO_MANY_1_DIR = PRE + "many_to_many_1_dir_relation"; //$NON-NLS-1$
+ public static final String ICON_ONE_TO_ONE_1_DIR = PREFIX + "one_to_one_1_dir_relation"; //$NON-NLS-1$
+ public static final String ICON_ONE_TO_MANY_1_DIR = PREFIX + "one_to_many_1_dir_relation"; //$NON-NLS-1$
+ public static final String ICON_MANY_TO_ONE_1_DIR = PREFIX + "many_to_one_1_dir_relation"; //$NON-NLS-1$
+ public static final String ICON_MANY_TO_MANY_1_DIR = PREFIX + "many_to_many_1_dir_relation"; //$NON-NLS-1$
- public static final String ICON_ONE_TO_ONE_2_DIR = PRE + "one_to_one_2_dir_relation"; //$NON-NLS-1$
- public static final String ICON_MANY_TO_ONE_2_DIR = PRE + "many_to_one_2_dir_relation"; //$NON-NLS-1$
- public static final String ICON_MANY_TO_MANY_2_DIR = PRE + "many_to_many_2_dir_relation"; //$NON-NLS-1$
+ public static final String ICON_ONE_TO_ONE_2_DIR = PREFIX + "one_to_one_2_dir_relation"; //$NON-NLS-1$
+ public static final String ICON_MANY_TO_ONE_2_DIR = PREFIX + "many_to_one_2_dir_relation"; //$NON-NLS-1$
+ public static final String ICON_MANY_TO_MANY_2_DIR = PREFIX + "many_to_many_2_dir_relation"; //$NON-NLS-1$
- public static final String ICON_SAVE = PRE + "save"; //$NON-NLS-1$
- public static final String ICON_RESTORE = PRE + "restore"; //$NON-NLS-1$
- public static final String ICON_SAVE_AND_REMOVE = PRE + "save_and_remove"; //$NON-NLS-1$
+ public static final String ICON_SAVE = PREFIX + "save"; //$NON-NLS-1$
+ public static final String ICON_RESTORE = PREFIX + "restore"; //$NON-NLS-1$
+ public static final String ICON_SAVE_AND_REMOVE = PREFIX + "save_and_remove"; //$NON-NLS-1$
- private static final String ROOT_FOLDER_FOR_IMG = "icons/"; //$NON-NLS-1$
+ private static final String ROOT_FOLDER_FOR_IMG = "icons/"; //$NON-NLS-1$
public JPAEditorImageProvider() {
super();
@@ -62,34 +65,36 @@ public class JPAEditorImageProvider extends AbstractImageProvider {
@Override
protected void addAvailableImages() {
addImageFilePath(ICON_BASIC, ROOT_FOLDER_FOR_IMG + "ent/basic.gif"); //$NON-NLS-1$
- addImageFilePath(JPA_ENTITY, ROOT_FOLDER_FOR_IMG + "ent/entity.gif"); //$NON-NLS-1$
+ addImageFilePath(JPA_ENTITY, ROOT_FOLDER_FOR_IMG + "ent/entity.gif"); //$NON-NLS-1$
+ addImageFilePath(MAPPED_SUPERCLASS, ROOT_FOLDER_FOR_IMG + "ent/mapped-superclass.gif"); //$NON-NLS-1$
addImageFilePath(ADD_JPA_ENTITY, ROOT_FOLDER_FOR_IMG + "ent/add_entity.gif"); //$NON-NLS-1$
- addImageFilePath(ADD_INHERITED_ENTITY, ROOT_FOLDER_FOR_IMG + "ent/mapped-superclass.gif"); //$NON-NLS-1$
- addImageFilePath(PRIMARY_KEY, ROOT_FOLDER_FOR_IMG + "ent/id.gif"); //$NON-NLS-1$
- addImageFilePath(ADD_ATTRIBUTE, ROOT_FOLDER_FOR_IMG + "ent/add_attribute.gif"); //$NON-NLS-1$
- addImageFilePath(REMOVE_ATTRIBUTE, ROOT_FOLDER_FOR_IMG + "ent/remove_attribute.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_ONE_TO_ONE, ROOT_FOLDER_FOR_IMG + "ent/one-to-one.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_ONE_TO_MANY, ROOT_FOLDER_FOR_IMG + "ent/one-to-many.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_MANY_TO_ONE, ROOT_FOLDER_FOR_IMG + "ent/many-to-one.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_MANY_TO_MANY, ROOT_FOLDER_FOR_IMG + "ent/many-to-many.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_EMBEDDED_ID, ROOT_FOLDER_FOR_IMG + "ent/embedded-id.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_VERSION, ROOT_FOLDER_FOR_IMG + "ent/version.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_TRANSIENT, ROOT_FOLDER_FOR_IMG + "ent/transient.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_EMBEDDED, ROOT_FOLDER_FOR_IMG + "ent/embedded.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_UNMAPPED, ROOT_FOLDER_FOR_IMG + "ent/null-attribute-mapping.gif"); //$NON-NLS-1$
+ addImageFilePath(ADD_INHERITED_ENTITY, ROOT_FOLDER_FOR_IMG + "ent/add_entity.gif"); //$NON-NLS-1$
+ addImageFilePath(ADD_MAPPED_SUPERCLASS, ROOT_FOLDER_FOR_IMG + "ent/add_mapped-superclass.gif"); //$NON-NLS-1$
+ addImageFilePath(PRIMARY_KEY, ROOT_FOLDER_FOR_IMG + "ent/id.gif"); //$NON-NLS-1$
+ addImageFilePath(ADD_ATTRIBUTE, ROOT_FOLDER_FOR_IMG + "ent/add_attribute.gif"); //$NON-NLS-1$
+ addImageFilePath(REMOVE_ATTRIBUTE, ROOT_FOLDER_FOR_IMG + "ent/remove_attribute.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_ONE_TO_ONE, ROOT_FOLDER_FOR_IMG + "ent/one-to-one.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_ONE_TO_MANY, ROOT_FOLDER_FOR_IMG + "ent/one-to-many.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_MANY_TO_ONE, ROOT_FOLDER_FOR_IMG + "ent/many-to-one.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_MANY_TO_MANY, ROOT_FOLDER_FOR_IMG + "ent/many-to-many.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_EMBEDDED_ID, ROOT_FOLDER_FOR_IMG + "ent/embedded-id.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_VERSION, ROOT_FOLDER_FOR_IMG + "ent/version.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_TRANSIENT, ROOT_FOLDER_FOR_IMG + "ent/transient.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_EMBEDDED, ROOT_FOLDER_FOR_IMG + "ent/embedded.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_UNMAPPED, ROOT_FOLDER_FOR_IMG + "ent/null-attribute-mapping.gif"); //$NON-NLS-1$
addImageFilePath(ICON_ONE_TO_ONE_1_DIR, ROOT_FOLDER_FOR_IMG + "ent/one-to-one-1-dir.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_ONE_TO_MANY_1_DIR, ROOT_FOLDER_FOR_IMG + "ent/one-to-many-1-dir.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_MANY_TO_ONE_1_DIR, ROOT_FOLDER_FOR_IMG + "ent/many-to-one-1-dir.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_MANY_TO_MANY_1_DIR, ROOT_FOLDER_FOR_IMG + "ent/many-to-many-1-dir.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_ONE_TO_MANY_1_DIR, ROOT_FOLDER_FOR_IMG + "ent/one-to-many-1-dir.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_MANY_TO_ONE_1_DIR, ROOT_FOLDER_FOR_IMG + "ent/many-to-one-1-dir.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_MANY_TO_MANY_1_DIR, ROOT_FOLDER_FOR_IMG + "ent/many-to-many-1-dir.gif"); //$NON-NLS-1$
addImageFilePath(ICON_ONE_TO_ONE_2_DIR, ROOT_FOLDER_FOR_IMG + "ent/one-to-one-2-dir.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_MANY_TO_ONE_2_DIR, ROOT_FOLDER_FOR_IMG + "ent/many-to-one-2-dir.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_MANY_TO_MANY_2_DIR, ROOT_FOLDER_FOR_IMG + "ent/many-to-many-2-dir.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_MANY_TO_ONE_2_DIR, ROOT_FOLDER_FOR_IMG + "ent/many-to-one-2-dir.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_MANY_TO_MANY_2_DIR, ROOT_FOLDER_FOR_IMG + "ent/many-to-many-2-dir.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_SAVE, ROOT_FOLDER_FOR_IMG + "save.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_RESTORE, ROOT_FOLDER_FOR_IMG + "restore.gif"); //$NON-NLS-1$
- addImageFilePath(ICON_SAVE_AND_REMOVE, ROOT_FOLDER_FOR_IMG + "save_and_remove.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_SAVE, ROOT_FOLDER_FOR_IMG + "save.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_RESTORE, ROOT_FOLDER_FOR_IMG + "restore.gif"); //$NON-NLS-1$
+ addImageFilePath(ICON_SAVE_AND_REMOVE, ROOT_FOLDER_FOR_IMG + "save_and_remove.gif"); //$NON-NLS-1$
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java
index d70eed4756..6518f97548 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java
@@ -46,6 +46,7 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.palette.IPaletteCompartmentEntry;
import org.eclipse.graphiti.palette.IToolEntry;
+import org.eclipse.graphiti.palette.impl.ConnectionCreationToolEntry;
import org.eclipse.graphiti.palette.impl.PaletteCompartmentEntry;
import org.eclipse.graphiti.platform.IPlatformImageConstants;
import org.eclipse.graphiti.services.Graphiti;
@@ -68,6 +69,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.ClickRemoveAttribute
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CollapseAllEntitiesFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CollapseCompartmentShapeFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CollapseEntityFeature;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateInheritedEntityFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.DeleteJPAEntityFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.DiscardAndRemoveAllEntitiesFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.ExpandAllEntitiesFeature;
@@ -88,8 +90,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.ui.JPAEdito
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.GraphicsUpdater;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IEclipseFacade;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants.ShapeType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.ui.PartInitException;
@SuppressWarnings("restriction")
@@ -236,6 +238,18 @@ public class JPAEditorToolBehaviorProvider extends DefaultToolBehaviorProvider {
IPaletteCompartmentEntry en = ret.get(0);
ret.set(0, ret.get(1));
ret.set(1, en);
+
+ PaletteCompartmentEntry ent = new PaletteCompartmentEntry(JPAEditorMessages.JPAEditorToolBehaviorProvider_InheritanceCompartmentTitle, superCompartments[1].getIconId());
+ CreateInheritedEntityFeature ft = new CreateInheritedEntityFeature(this.getFeatureProvider());
+ ConnectionCreationToolEntry isARelToolEntry = new ConnectionCreationToolEntry(ft.getCreateName(),
+ ft.getCreateDescription(), ft.getCreateImageId(), ft.getCreateLargeImageId());
+ isARelToolEntry.addCreateConnectionFeature(ft);
+
+ ent.addToolEntry(isARelToolEntry);
+
+
+ ret.add(1, ent);
+
return ret.toArray(new IPaletteCompartmentEntry[ret.size()]);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/BidirectionalRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IBidirectionalRelation.java
index 26fbc1f61a..cf74687f41 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/BidirectionalRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IBidirectionalRelation.java
@@ -17,7 +17,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-public interface BidirectionalRelation extends IRelation {
+public interface IBidirectionalRelation extends IRelation {
public abstract JavaPersistentAttribute getOwnerAnnotatedAttribute();
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IsARelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IsARelation.java
new file mode 100644
index 0000000000..28da316206
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IsARelation.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2005, 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Dimov - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
+
+import org.eclipse.graphiti.mm.pictograms.Anchor;
+import org.eclipse.graphiti.mm.pictograms.Connection;
+import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
+
+public class IsARelation {
+
+ protected final static String SEPARATOR = ";isA;"; //$NON-NLS-1$
+ public final static String IS_A_CONNECTION_PROP_KEY = "is_is_a_connection"; //$NON-NLS-1$
+
+
+ protected JavaPersistentType subclass;
+ protected JavaPersistentType superclass;
+
+ public IsARelation(JavaPersistentType subclass,
+ JavaPersistentType superclass) {
+ this.subclass = subclass;
+ this.superclass = superclass;
+ }
+
+ public IsARelation(IJPAEditorFeatureProvider fp, Connection conn) {
+ Anchor start = conn.getStart();
+ Anchor end = conn.getEnd();
+ Object startObj = fp.getBusinessObjectForPictogramElement((ContainerShape)start.eContainer());
+ Object endObj = fp.getBusinessObjectForPictogramElement((ContainerShape)end.eContainer());
+ if ((startObj == null) || (endObj == null))
+ throw new NullPointerException("Some of the connection ends is null"); //$NON-NLS-1$
+ if (!(startObj instanceof JavaPersistentType) || !(endObj instanceof JavaPersistentType))
+ throw new IllegalArgumentException();
+ this.subclass = (JavaPersistentType)startObj;
+ this.superclass = (JavaPersistentType)endObj;
+ }
+
+
+ public JavaPersistentType getSubclass() {
+ return subclass;
+ }
+
+ public JavaPersistentType getSuperclass() {
+ return superclass;
+ }
+
+ public static boolean isIsAConnection(Connection conn) {
+ String val = JPAEditorUtil.getPeUtil().getPropertyValue(conn, IS_A_CONNECTION_PROP_KEY);
+ return (Boolean.TRUE.toString().equals(val));
+ }
+
+
+ public String getId() {
+ return generateId(subclass, superclass);
+ }
+
+ public static String generateId(IJPAEditorFeatureProvider fp, Connection conn) {
+ Anchor start = conn.getStart();
+ Anchor end = conn.getEnd();
+ Object startObj = fp.getBusinessObjectForPictogramElement((ContainerShape)start.eContainer());
+ Object endObj = fp.getBusinessObjectForPictogramElement((ContainerShape)end.eContainer());
+ if ((startObj == null) || (endObj == null))
+ return null;
+ if (!(startObj instanceof JavaPersistentType) || !(endObj instanceof JavaPersistentType))
+ return null;
+ JavaPersistentType startJpt = (JavaPersistentType)startObj;
+ JavaPersistentType endJpt = (JavaPersistentType)endObj;
+ return generateId(startJpt, endJpt);
+ }
+
+ private static String generateId(JavaPersistentType startJpt, JavaPersistentType endJpt) {
+ return JPAEditorConstants.IS_A_RELATION_ID_PREFIX +
+ startJpt.getName() + SEPARATOR + endJpt.getName();
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == null)
+ return false;
+ if (this.hashCode() != obj.hashCode())
+ return false;
+ if (!(obj instanceof IsARelation))
+ return false;
+ IsARelation rel = (IsARelation)obj;
+ return this.getId().equals(rel.getId());
+ }
+
+ public int hashCode() {
+ return getId().hashCode();
+ }
+
+}
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 41d9e2c234..d57cd9ca74 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
@@ -24,7 +24,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class ManyToManyBiDirRelation extends ManyToManyRelation implements BidirectionalRelation {
+public class ManyToManyBiDirRelation extends ManyToManyRelation implements IBidirectionalRelation {
public ManyToManyBiDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
JavaPersistentType inverse,
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 3442c507f8..dd8ad0f211 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
@@ -24,7 +24,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class ManyToOneBiDirRelation extends ManyToOneRelation implements BidirectionalRelation{
+public class ManyToOneBiDirRelation extends ManyToOneRelation implements IBidirectionalRelation{
public ManyToOneBiDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
JavaPersistentType inverse,
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 eae7ccccc9..0cab59e7fb 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
@@ -23,7 +23,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class OneToOneBiDirRelation extends OneToOneRelation implements BidirectionalRelation{
+public class OneToOneBiDirRelation extends OneToOneRelation implements IBidirectionalRelation{
public OneToOneBiDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
JavaPersistentType inverse,
String ownerAttributeName,
@@ -59,7 +59,6 @@ public class OneToOneBiDirRelation extends OneToOneRelation implements Bidirecti
private void createRelation(IJPAEditorFeatureProvider fp, ICompilationUnit ownerCU, ICompilationUnit inverseCU) {
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 e86867fc6c..ef5c528eae 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
@@ -20,10 +20,9 @@ import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;
+
import org.eclipse.graphiti.features.context.impl.RemoveContext;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
@@ -122,7 +121,7 @@ public class EntityChangeListener extends Thread {
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpt);
PersistentType pt = pu.getPersistentType(jpt.getName());
- if ((pt == null) || !JpaArtifactFactory.instance().hasEntityAnnotation(jpt)) {
+ if ((pt == null) || !JpaArtifactFactory.instance().hasEntityOrMappedSuperclassAnnotation(jpt)) {
JpaArtifactFactory.instance().forceSaveEntityClass(jpt, featureProvider);
@@ -136,21 +135,6 @@ public class EntityChangeListener extends Thread {
RemoveAndSaveEntityFeature ft = new RemoveAndSaveEntityFeature(featureProvider);
ft.remove(ctx);
break;
- } else {
-
- ICompilationUnit cu = featureProvider.getCompilationUnit(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() {
- public void run() {
- GraphicsUpdater.updateHeader(entShape, newHeader);
- }
- });
-
- } catch (JavaModelException e) {
- JPADiagramEditorPlugin.logError("Cannot check compilation unit for unsaved changes", e); //$NON-NLS-1$
- }
}
}
}
@@ -192,7 +176,7 @@ public class EntityChangeListener extends Thread {
}
}
} catch(Exception e) {
- //$NON-NLS-1$
+ //ignore
}
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java
index dbd7c252f4..3596a6f77e 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/GraphicsUpdater.java
@@ -166,9 +166,25 @@ public class GraphicsUpdater {
}
public static void updateHeader(ContainerShape entityShape, final String newHeader) {
- if(entityShape == null)
+ final Text txt = getHeaderText(entityShape);
+ if (txt == null)
return;
-
+ //if (!JPAEditorUtil.areHeadersEqual(txt.getValue(), newHeader)) {
+
+ if (!txt.getValue().equals(newHeader)) {
+ TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(txt);
+ RecordingCommand rc = new RecordingCommand(ted) {
+ protected void doExecute() {
+ txt.setValue(newHeader);
+ }
+ };
+ ted.getCommandStack().execute(rc);
+ }
+ }
+
+ private static Text getHeaderText(ContainerShape entityShape) {
+ if(entityShape == null)
+ return null;
List<Shape> shapes = entityShape.getChildren();
Iterator<Shape> shIt = shapes.iterator();
Shape headerShape = null;;
@@ -180,19 +196,13 @@ public class GraphicsUpdater {
headerShape = null;
}
if (headerShape == null)
- return;
+ return null;
GraphicsAlgorithm ga = headerShape.getGraphicsAlgorithm();
if (ga == null)
- return;
- final Text txt = (Text)ga.getGraphicsAlgorithmChildren().get(0);
- if (!JPAEditorUtil.areHeadersEqual(txt.getValue(), newHeader)) {
- TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(txt);
- RecordingCommand rc = new RecordingCommand(ted) {
- protected void doExecute() {
- txt.setValue(newHeader);
- }
- };
- ted.getCommandStack().execute(rc);
- }
+ return null;
+ if (ga.getGraphicsAlgorithmChildren().size() == 0)
+ return null;
+ Text txt = (Text)ga.getGraphicsAlgorithmChildren().get(0);
+ return txt;
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorPredefinedRenderingStyle.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorPredefinedRenderingStyle.java
new file mode 100644
index 0000000000..9a4538bdab
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorPredefinedRenderingStyle.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2005, 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Dimov - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.util;
+
+import org.eclipse.graphiti.util.IPredefinedRenderingStyle;
+
+public interface IJPAEditorPredefinedRenderingStyle extends IPredefinedRenderingStyle {
+
+ /**
+ * The ID for a green-to-white gradient with a gloss-effect.
+ */
+ public static final String GREEN_WHITE_GLOSS_ID = "green-white-gloss"; //$NON-NLS-1$
+
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java
index 02d2478b46..c781948005 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java
@@ -18,6 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.util;
import java.util.List;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
@@ -64,11 +65,23 @@ public interface IJPAEditorUtil {
boolean isMappedSuperClassChild,
String mappedSuperclassName,
String mappedSuperclassPackage,
+ String idName,
boolean hasPrimaryKey) throws Exception;
+
+ public IFile createEntityInProject(IProject project,
+ String entityName,
+ JavaPersistentType mappedSuperclass) throws Exception;
+
public IFile createEntityFromMappedSuperclassInProject(IProject project,
String mappedSuperclassName, IPreferenceStore jpaPreferenceStore) throws Exception;
+ public IFile createMappedSuperclassInProject(IProject project,
+ IFolder folder, String mappedSuperclassName) throws Exception;
+
+ public IFile createMappedSuperclassInProject(IProject project,
+ String mappedSuperclassName) throws Exception;
+
public boolean isCardinalityDecorator(ConnectionDecorator cd);
public void discardWorkingCopyOnce(ICompilationUnit cu);
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 52e14edfd1..73d627010a 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,15 @@ import org.eclipse.jpt.jpa.core.MappingKeys;
public class JPAEditorConstants {
+ public static enum DIAGRAM_OBJECT_TYPE {
+ Entity,
+ MappedSupeclass
+ };
+
+ public static final String IS_A_RELATION_ID_PREFIX = "is_a_relation:"; //$NON-NLS-1$
+
+ public static final String IS_A = "is-a"; //$NON-NLS-1$
+
public static final String HEADER_PREFIX_DIRTY = "* "; //$NON-NLS-1$
public static Hashtable<String, String> PRIMITIVE_TO_WRAPPER = new Hashtable<String,String>();
@@ -41,16 +50,27 @@ public class JPAEditorConstants {
public static final IColorConstant ENTITY_BACKGROUND =
new ColorConstant(212, 231, 248);
+
+ public static final IColorConstant MAPPED_SUPERCLASS_BACKGROUND =
+ new ColorConstant(212, 248, 231);
public static final IColorConstant CONNECTION_LINE_COLOR =
new ColorConstant(98, 131,167);
+ public static final IColorConstant IS_A_CONNECTION_LINE_COLOR =
+ new ColorConstant(98, 167, 131);
+
public static final IColorConstant ENTITY_BORDER_COLOR =
new ColorConstant(98, 131,167);
+ public static final IColorConstant MAPPED_SUPERCLASS_BORDER_COLOR =
+ new ColorConstant(98, 167, 131);
+
public final static String TRUE_STRING = Boolean.toString(true);
public final static int CONNECTION_LINE_WIDTH = 2;
+ public final static int IS_A_CONNECTION_LINE_WIDTH = 2;
+
public final static int ENTITY_BORDER_WIDTH = 2;
public final static int ENTITY_CORNER_WIDTH = 6;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorPredefinedColoredAreas.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorPredefinedColoredAreas.java
new file mode 100644
index 0000000000..2e903596a4
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorPredefinedColoredAreas.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2005, 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Dimov - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.util;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.graphiti.mm.algorithms.styles.AdaptedGradientColoredAreas;
+import org.eclipse.graphiti.mm.algorithms.styles.GradientColoredArea;
+import org.eclipse.graphiti.mm.algorithms.styles.GradientColoredAreas;
+import org.eclipse.graphiti.mm.algorithms.styles.LocationType;
+import org.eclipse.graphiti.mm.algorithms.styles.StylesFactory;
+import org.eclipse.graphiti.util.IGradientType;
+import org.eclipse.graphiti.util.IPredefinedRenderingStyle;
+import org.eclipse.graphiti.util.PredefinedColoredAreas;
+
+public class JPAEditorPredefinedColoredAreas extends PredefinedColoredAreas
+ implements IJPAEditorPredefinedRenderingStyle {
+
+ /**
+ * The color-areas, which are used for default elements with the ID
+ * {@link #GREEN_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getGreenWhiteGlossDefaultAreas() {
+ final GradientColoredAreas gradientColoredAreas = StylesFactory.eINSTANCE.createGradientColoredAreas();
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "F8FEFB", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "F8FEFB", 1, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "EDFCF5", 1, LocationType.LOCATION_TYPE_ABSOLUTE_START, "EDFCF5", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "DEFAED", 2, LocationType.LOCATION_TYPE_ABSOLUTE_START, "DEFAED", 3, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "D4F8E7", 3, LocationType.LOCATION_TYPE_ABSOLUTE_START, "FAFCFB", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ addGradientColoredArea(gcas, "E2E9E5", 2, LocationType.LOCATION_TYPE_ABSOLUTE_END, "E2E9E5", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for primary selected elements with the ID
+ * {@link #GREEN_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getGreenWhiteGlossPrimarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = StylesFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "EEFDF6", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "EEFDF6", 1, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "D0F9E6", 1, LocationType.LOCATION_TYPE_ABSOLUTE_START, "D0F9E6", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "ACF4D2", 2, LocationType.LOCATION_TYPE_ABSOLUTE_START, "ACF4D2", 3, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "81EAB9", 3, LocationType.LOCATION_TYPE_ABSOLUTE_START, "AAF2D0", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ addGradientColoredArea(gcas, "9AE0BF", 2, LocationType.LOCATION_TYPE_ABSOLUTE_END, "9AE0BF", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for secondary selected elements with the
+ * ID {@link #GREEN_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getGreenWhiteGlossSecondarySelectedAreas() {
+ final GradientColoredAreas gradientColoredAreas = StylesFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "F5FEF9", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "F5FEF9", 1, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "E2FCEF", 1, LocationType.LOCATION_TYPE_ABSOLUTE_START, "E2FCEF", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "CBF9E3", 2, LocationType.LOCATION_TYPE_ABSOLUTE_START, "CBF9E3", 3, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_START);
+ addGradientColoredArea(gcas, "BBF7DA", 3, LocationType.LOCATION_TYPE_ABSOLUTE_START, "C5F7E0", 2, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ addGradientColoredArea(gcas, "B2E5CD", 2, LocationType.LOCATION_TYPE_ABSOLUTE_END, "B2E5CD", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for elements where an action is allowed
+ * with the ID {@link #GREEN_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getGreeenWhiteGlossActionAllowedAreas() {
+ final GradientColoredAreas gradientColoredAreas = StylesFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_ALLOWED);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "9900CC", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "336699", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+ /**
+ * The color-areas, which are used for elements where an action is forbidden
+ * with the ID {@link #GREEN_WHITE_GLOSS_ID}.
+ */
+ private static GradientColoredAreas getGreenWhiteGlossActionForbiddenAreas() {
+ final GradientColoredAreas gradientColoredAreas = StylesFactory.eINSTANCE.createGradientColoredAreas();
+ gradientColoredAreas.setStyleAdaption(IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_FORBIDDEN);
+ final EList<GradientColoredArea> gcas = gradientColoredAreas.getGradientColor();
+
+ addGradientColoredArea(gcas, "FF00CC", 0, LocationType.LOCATION_TYPE_ABSOLUTE_START, "FF0066", 0, //$NON-NLS-1$ //$NON-NLS-2$
+ LocationType.LOCATION_TYPE_ABSOLUTE_END);
+ return gradientColoredAreas;
+ }
+
+
+ public static AdaptedGradientColoredAreas getGreenWhiteGlossAdaptions() {
+ final AdaptedGradientColoredAreas agca = StylesFactory.eINSTANCE.createAdaptedGradientColoredAreas();
+ agca.setDefinedStyleId(GREEN_WHITE_GLOSS_ID);
+ agca.setGradientType(IGradientType.VERTICAL);
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_DEFAULT, getGreenWhiteGlossDefaultAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_PRIMARY_SELECTED,
+ getGreenWhiteGlossPrimarySelectedAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_SECONDARY_SELECTED,
+ getGreenWhiteGlossSecondarySelectedAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_ALLOWED,
+ getGreeenWhiteGlossActionAllowedAreas());
+ agca.getAdaptedGradientColoredAreas().add(IPredefinedRenderingStyle.STYLE_ADAPTATION_ACTION_FORBIDDEN,
+ getGreenWhiteGlossActionForbiddenAreas());
+ return agca;
+ }
+
+ public static AdaptedGradientColoredAreas getAdaptedGradientColoredAreas(String id) {
+ AdaptedGradientColoredAreas res = PredefinedColoredAreas.getAdaptedGradientColoredAreas(id);
+ if (res != null)
+ return res;
+ if (GREEN_WHITE_GLOSS_ID.equals(id))
+ return getGreenWhiteGlossAdaptions();
+ return null;
+ }
+}
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 fe09b1dee6..78bd525ad9 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
@@ -159,7 +159,9 @@ public class JPAEditorUtil {
public static Anchor getAnchor(ContainerShape cs) {
Collection<Anchor> anchors = cs.getAnchors();
- return anchors.iterator().next();
+ if (anchors.iterator().hasNext())
+ return anchors.iterator().next();
+ return null;
}
public static Anchor getAnchor(JavaPersistentType jpt, IFeatureProvider fp) {
@@ -536,7 +538,12 @@ public class JPAEditorUtil {
Iterator<Connection> consIt = cons.iterator();
while (consIt.hasNext()) {
Connection con = consIt.next();
- ContainerShape cs1 = (ContainerShape)con.getStart().getParent();
+ ContainerShape cs1 = null;
+ try {
+ cs1 = (ContainerShape)con.getStart().getParent();
+ } catch (NullPointerException e) {
+ continue;
+ }
if (cs1 != cs)
res.add(cs1);
cs1 = (ContainerShape)con.getEnd().getParent();
@@ -847,7 +854,10 @@ public class JPAEditorUtil {
Iterator<Connection> cIter = set.iterator();
while (cIter.hasNext()) {
Connection c = cIter.next();
- IRelation rel = (IRelation)fp.getBusinessObjectForPictogramElement(c);
+ Object o = fp.getBusinessObjectForPictogramElement(c);
+ if (!(o instanceof IRelation))
+ continue;
+ IRelation rel = (IRelation)o;
rearrangeConnection(c, cnt, setSize, rel.getOwner() == rel.getInverse());
cnt++;
}
@@ -1067,7 +1077,7 @@ public class JPAEditorUtil {
static public String generateUniqueMappedSuperclassName(
JpaProject jpaProject, String pack, IJPAEditorFeatureProvider fp) {
- String NAME = pack + ".MappedSuperclass"; //$NON-NLS-1$
+ String NAME = pack + ".MpdSuprcls"; //$NON-NLS-1$
String name = null;
HashSet<String> JPAProjectEntityNames = getEntityNames(jpaProject);
@@ -1084,17 +1094,26 @@ public class JPAEditorUtil {
return name;
}
-
+ static public IFile createEntityInProject(IProject project,
+ String entityName,
+ JavaPersistentType mappedSuperclass) throws Exception {
+ IFolder folder = getPackageFolder(project);
+ return createEntity(project, folder, entityName,
+ true, mappedSuperclass.getName(),
+ JpaArtifactFactory.instance().getMappedSuperclassPackageDeclaration(mappedSuperclass),
+ JpaArtifactFactory.instance().generateIdName(mappedSuperclass),
+ JpaArtifactFactory.instance().hasOrInheritsPrimaryKey(mappedSuperclass));
+ }
static public IFile createEntityInProject(IProject project,
String entityName, IPreferenceStore jpaPreferenceStore,
boolean isMappedSuperclassChild, String mappedSuperclassName,
- String mappedSuperclassPackage, boolean hasPrimaryKey)
+ String mappedSuperclassPackage, String idName, boolean hasPrimaryKey)
throws Exception {
IFolder folder = getPackageFolder(project);
return createEntity(project, folder, entityName,
isMappedSuperclassChild, mappedSuperclassName,
- mappedSuperclassPackage, hasPrimaryKey);
+ mappedSuperclassPackage, idName, hasPrimaryKey);
}
@@ -1102,8 +1121,7 @@ public class JPAEditorUtil {
IProject project, String mappedSuperclassName,
IPreferenceStore jpaPreferenceStore) throws Exception {
IFolder folder = getPackageFolder(project);
- createMappedSuperclass(project, folder, mappedSuperclassName);
- return createMappedSuperclass(project, folder, mappedSuperclassName);
+ return createMappedSuperclassInProject(project, folder, mappedSuperclassName);
}
@SuppressWarnings("deprecation")
@@ -1130,7 +1148,13 @@ public class JPAEditorUtil {
}
- static private IFile createMappedSuperclass(IProject project,
+ static public IFile createMappedSuperclassInProject(IProject project,
+ String mappedSuperclassName) throws Exception {
+ IFolder folder = getPackageFolder(project);
+ return createMappedSuperclassInProject(project, folder, mappedSuperclassName);
+ }
+
+ static public IFile createMappedSuperclassInProject(IProject project,
IFolder folder, String mappedSuperclassName) throws Exception {
String mappedSuperclassShortName = mappedSuperclassName
@@ -1275,10 +1299,14 @@ public class JPAEditorUtil {
}
}
- static private IFile createEntity(IProject project, IFolder folder, String entityName, boolean isMappedSuperclassChild,
- String mappedSuperclassName, String mappedSuperclassPackage, boolean hasPrimaryKey) throws Exception {
-
-
+ static private IFile createEntity(IProject project,
+ IFolder folder,
+ String entityName,
+ boolean isMappedSuperclassChild,
+ String mappedSuperclassName,
+ String mappedSuperclassPackage,
+ String idName,
+ boolean hasPrimaryKey) throws Exception {
String entityShortName = entityName.substring(entityName.lastIndexOf('.') + 1);
if (!folder.exists()) {
@@ -1306,28 +1334,20 @@ public class JPAEditorUtil {
}
String primaryKeyDeclaration = ""; //$NON-NLS-1$
- if (!hasPrimaryKey) {
- primaryKeyDeclaration = (fieldBasedAccess ? " @Id \n" : "") //$NON-NLS-1$ //$NON-NLS-2$
- + " private long id;\n\n" //$NON-NLS-1$
- + (fieldBasedAccess ? "" : " @Id \n") //$NON-NLS-1$ //$NON-NLS-2$
- + " public long getId() {\n" //$NON-NLS-1$
- + " return id;\n" //$NON-NLS-1$
- + " }\n\n" //$NON-NLS-1$
- + " public void setId(long id) {\n" //$NON-NLS-1$
- + " this.id = id;\n" //$NON-NLS-1$
- + " }\n\n"; //$NON-NLS-1$
- }
-
+ if (!hasPrimaryKey)
+ primaryKeyDeclaration = generatePrimaryKeyDeclaration(fieldBasedAccess, idName);
if (!file.exists()) {
- String content = "package " + JPADiagramPropertyPage.getDefaultPackage(project, props) + ";\n\n" //$NON-NLS-1$ //$NON-NLS-2$
- + "import javax.persistence.*;\n" //$NON-NLS-1$
- + packageImport+"\n\n" //$NON-NLS-1$
- + "@Entity \n" //$NON-NLS-1$
- + ((tableName.length() > 0) ? ("@Table(name=\"" + tableName + "\")\n") : "") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + classDeclarationStringContent
- + primaryKeyDeclaration
- +"}"; //$NON-NLS-1$
+ String content = "package " + JPADiagramPropertyPage.getDefaultPackage(project, props) //$NON-NLS-1$
+ + ";\n\n" //$NON-NLS-1$
+ + "import javax.persistence.*;\n" //$NON-NLS-1$
+ + packageImport+"\n\n" //$NON-NLS-1$
+ + "@Entity \n" //$NON-NLS-1$
+ + ((tableName.length() > 0) ? ("@Table(name=\"" //$NON-NLS-1$
+ + tableName + "\")\n") : "") //$NON-NLS-1$ //$NON-NLS-2$
+ + classDeclarationStringContent
+ + primaryKeyDeclaration
+ +"}"; //$NON-NLS-1$
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
stream.write(content.getBytes());
@@ -1338,7 +1358,21 @@ public class JPAEditorUtil {
}
}
return file;
- }
+ }
+
+ static private String generatePrimaryKeyDeclaration(boolean fieldBasedAccess, String primaryKeyName) {
+ String primaryKeyDeclaration = (fieldBasedAccess ? " @Id \n" : "") //$NON-NLS-1$ //$NON-NLS-2$
+ + " private long " + primaryKeyName + ";\n\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + (fieldBasedAccess ? "" : " @Id \n") //$NON-NLS-1$ //$NON-NLS-2$
+ + " public long get" + capitalizeFirstLetter(primaryKeyName) + "() {\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + " return " + primaryKeyName + ";\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + " }\n\n" //$NON-NLS-1$
+ + " public void set" + capitalizeFirstLetter(primaryKeyName) //$NON-NLS-1$
+ + "(long " + primaryKeyName + ") {\n" //$NON-NLS-1$ //$NON-NLS-2$
+ + " this." + primaryKeyName + " = " + primaryKeyName + ";\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ + " }\n\n"; //$NON-NLS-1$
+ return primaryKeyDeclaration;
+ }
static private HashSet<String> getEntityNames(JpaProject jpaProject) {
HashSet<String> names = new HashSet<String>();
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java
index 861ad0d2c9..c77aaee7ac 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java
@@ -18,6 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.util;
import java.util.List;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.graphiti.mm.pictograms.ConnectionDecorator;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
@@ -78,11 +79,18 @@ public class JPAEditorUtilImpl implements IJPAEditorUtil {
public IFile createEntityInProject(IProject project, String entityName, IPreferenceStore jpaPreferenceStore,
- boolean isMappedSuperclassChild, String mappedSuperclassName, String mappedSuperclassPackage, boolean hasPrimaryKey) throws Exception {
+ boolean isMappedSuperclassChild, String mappedSuperclassName,
+ String mappedSuperclassPackage, String idName,
+ boolean hasPrimaryKey) throws Exception {
return JPAEditorUtil.createEntityInProject(project, entityName, jpaPreferenceStore, isMappedSuperclassChild,
- mappedSuperclassName, mappedSuperclassPackage, hasPrimaryKey);
+ mappedSuperclassName, mappedSuperclassPackage, idName, hasPrimaryKey);
}
+ public IFile createEntityInProject(IProject project,
+ String entityName,
+ JavaPersistentType mappedSuperclass) throws Exception {
+ return JPAEditorUtil.createEntityInProject(project, entityName, mappedSuperclass);
+ }
public ICompilationUnit getCompilationUnit(JavaPersistentType jpt) {
return JPAEditorUtil.getCompilationUnit(jpt);
@@ -100,5 +108,15 @@ public class JPAEditorUtilImpl implements IJPAEditorUtil {
String mappedSuperclassName, IPreferenceStore jpaPreferenceStore) throws Exception {
return JPAEditorUtil.createEntityFromMappedSuperclassInProject(project, mappedSuperclassName, jpaPreferenceStore);
}
+
+ public IFile createMappedSuperclassInProject(IProject project,
+ IFolder folder, String mappedSuperclassName) throws Exception {
+ return JPAEditorUtil.createMappedSuperclassInProject(project, folder, mappedSuperclassName);
+ }
+
+ public IFile createMappedSuperclassInProject(IProject project,
+ String mappedSuperclassName) throws Exception {
+ return JPAEditorUtil.createMappedSuperclassInProject(project, mappedSuperclassName);
+ }
}
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 bb5afb2e22..74032b66ca 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
@@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.WeakHashMap;
+
import org.eclipse.core.internal.resources.File;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
@@ -115,7 +116,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.ModelI
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorDiagramTypeProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.AbstractRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.BidirectionalRelation;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IBidirectionalRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
@@ -143,6 +144,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
private IJPAEditorFeatureProvider featureProvider;
private HashSet<String> removeIgnore = new HashSet<String>();
private HashSet<String> removeRelIgnore = new HashSet<String>();
+ private Collection<JavaPersistentType> persistentTypes = new HashSet<JavaPersistentType>();
private HashSet<String> addIgnore = new HashSet<String>();
private Hashtable<String, IRelation> attribToRel = new Hashtable<String, IRelation>();
@@ -221,7 +223,11 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
eclipseFacade.getDisplay().asyncExec(new Runnable() {
public void run() {
if(featureProvider != null)
- featureProvider.getDiagramTypeProvider().getDiagramEditor().refresh();
+ try {
+ featureProvider.getDiagramTypeProvider().getDiagramEditor().refresh();
+ } catch (Exception e) {
+ // ignore
+ }
}
});
@@ -323,10 +329,11 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
addListenersToEntity(jpt);
PictogramElement pe = featureProvider.getPictogramElementForBusinessObject(jpt);
Graphiti.getPeService().setPropertyValue(pe, JPAEditorConstants.PROP_ENTITY_CLASS_NAME, jpt.getName());
+ persistentTypes.add(jpt);
} else if (bo instanceof AbstractRelation) {
AbstractRelation rel = (AbstractRelation) bo;
attribToRel.put(produceOwnerKeyForRel(rel), rel);
- if (rel instanceof BidirectionalRelation) {
+ if (rel instanceof IBidirectionalRelation) {
attribToRel.put(produceInverseKeyForRel(rel), rel);
}
} else if (bo instanceof JavaPersistentAttribute) {
@@ -344,7 +351,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
String k = getKeyForBusinessObject(at);
remove(k);
}
-
+ persistentTypes.remove(jpt);
removeListenersFromEntity(jpt);
Diagram d = featureProvider.getDiagramTypeProvider().getDiagram();
if (d.getChildren().size() == 1) {
@@ -361,7 +368,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
} else if (o instanceof AbstractRelation) {
AbstractRelation rel = (AbstractRelation) o;
attribToRel.remove(produceOwnerKeyForRel(rel));
- if (rel instanceof BidirectionalRelation)
+ if (rel instanceof IBidirectionalRelation)
attribToRel.remove(produceInverseKeyForRel(rel));
} else if (o instanceof JavaPersistentAttribute) {
removeListenersFromAttribute((JavaPersistentAttribute)o);
@@ -939,8 +946,10 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
util = null;
keyToBO.clear();
attribToRel.clear();
+ persistentTypes.clear();
keyToBO = null;
- attribToRel = null;
+ attribToRel = null;
+ persistentTypes = null;
removeAllListeners();
featureProvider = null;
synchronized (JPASolver.class) {
@@ -977,25 +986,20 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
for (ICompilationUnit cu : affectedCompilationUnits) {
JavaPersistentType jpt = JPAEditorUtil.getJPType(cu);
- for (JPASolver solver : solversSet) {
+ for (final JPASolver solver : solversSet) {
final ContainerShape cs = (ContainerShape)solver.featureProvider.getPictogramElementForBusinessObject(jpt);
if (cs == null)
return;
String entName = JPAEditorUtil.getText(jpt);
try {
final String newHeader = (cu.hasUnsavedChanges() ? "* " : "") + entName; //$NON-NLS-1$ //$NON-NLS-2$
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- GraphicsUpdater.updateHeader(cs, newHeader);
- }
- });
-
+ GraphicsUpdater.updateHeader(cs, newHeader);
+ JpaArtifactFactory.instance().rearrangeIsARelationsInTransaction(solver.featureProvider);
} catch (JavaModelException e) {
JPADiagramEditorPlugin.logError("Cannot check compilation unit for unsaved changes", e); //$NON-NLS-1$
- }
+ }
}
-
- }
+ }
}
private Set<ICompilationUnit> getAffectedCompilationUnits(IJavaElementDelta delta) {
@@ -1470,4 +1474,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
return resources;
}
+ public Collection<JavaPersistentType> getPersistentTypes() {
+ return persistentTypes;
+ }
+
}
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 2a55ae729f..117dd9d068 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
@@ -27,10 +27,13 @@ import java.util.ListIterator;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
@@ -39,10 +42,12 @@ import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.util.IColorConstant;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageDeclaration;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -68,6 +73,7 @@ import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
@@ -77,8 +83,6 @@ import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
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.JoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
@@ -89,16 +93,18 @@ import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotati
import org.eclipse.jpt.jpa.core.resource.java.RelationshipMappingAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.TableAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.AddInheritedEntityFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.AddRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.RemoveRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.UpdateAttributeFeature;
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.relations.BidirectionalRelation;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IBidirectionalRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.RelDir;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.RelType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IsARelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.ManyToManyBiDirRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.ManyToManyUniDirRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.ManyToOneBiDirRelation;
@@ -129,6 +135,44 @@ public class JpaArtifactFactory {
return INSTANCE;
}
+ public void rearrangeIsARelations(IJPAEditorFeatureProvider fp) {
+ Collection<IsARelation> isARels = produceAllMissingIsARelations(fp);
+ addIsARelations(fp, isARels);
+ fp.removeAllRedundantIsARelations();
+ }
+
+ public void rearrangeIsARelationsInTransaction(final IJPAEditorFeatureProvider fp) {
+ final Collection<IsARelation> isARels = produceAllMissingIsARelations(fp);
+ if (!fp.existRedundantIsARelations() && (isARels.size() == 0))
+ return;
+ TransactionalEditingDomain ted = fp.getTransactionalEditingDomain();
+ RecordingCommand rc = new RecordingCommand(ted) {
+ protected void doExecute() {
+ addIsARelations(fp, isARels);
+ fp.removeAllRedundantIsARelations();
+ }
+ };
+ ted.getCommandStack().execute(rc);
+ }
+
+
+ public Collection<IsARelation> produceAllMissingIsARelations(IJPAEditorFeatureProvider fp) {
+ Collection<JavaPersistentType> persistentTypes = fp.getPersistentTypes();
+ Collection<IsARelation> res = new HashSet<IsARelation>();
+ Iterator<JavaPersistentType> it = persistentTypes.iterator();
+ HashSet<IsARelation> allExistingIsARelations = fp.getAllExistingIsARelations();
+ while (it.hasNext()) {
+ JavaPersistentType jpt = it.next();
+ JavaPersistentType superclass = fp.getFirstSuperclassBelongingToTheDiagram(jpt);
+ if (superclass == null)
+ continue;
+ IsARelation newRel = new IsARelation(jpt, superclass);
+ if (!allExistingIsARelations.contains(newRel))
+ res.add(newRel);
+ }
+ return res;
+ }
+
public void addOneToOneUnidirectionalRelation(IFeatureProvider fp, JavaPersistentType jpt,
JavaPersistentAttribute attribute) {
addOneToOneRelation(fp, jpt, attribute, null, null,
@@ -445,7 +489,6 @@ public class JpaArtifactFactory {
IJPAEditorFeatureProvider fp) {
ICompilationUnit cu = fp.getCompilationUnit(jpt);
try {
- JpaProject jpaProject = jpt.getJpaProject();
JPAEditorUtil.discardWorkingCopy(cu);
cu.delete(true, new NullProgressMonitor());
return true;
@@ -514,9 +557,13 @@ public class JpaArtifactFactory {
JavaResourceType jrpt = convertJPTToJRT(jpt);
if (jrpt == null)
return false;
- JavaEntity mapping = (JavaEntity) jpt.getMapping();
- if (mapping != null)
+ JavaTypeMapping jtm = jpt.getMapping();
+ if (jtm == null)
+ return false;
+ if (jtm instanceof JavaEntity) {
+ JavaEntity mapping = (JavaEntity)jtm;
return (mapping.getSpecifiedName() != null);
+ }
return false;
}
@@ -551,19 +598,35 @@ public class JpaArtifactFactory {
}
*/
+ public boolean hasEntityOrMappedSuperclassAnnotation(JavaPersistentType jpt) {
+ return hasEntityAnnotation(jpt) || hasMappedSuperclassAnnotation(jpt);
+ }
+
public boolean hasEntityAnnotation(JavaPersistentType jpt) {
- return (jpt.getMapping() instanceof JavaEntity);
+ return (jpt.getMappingKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY);
}
+ public boolean hasMappedSuperclassAnnotation(JavaPersistentType jpt) {
+ return (jpt.getMappingKey() == MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
+ }
+
public String getSpecifiedEntityName(JavaPersistentType jpt){
- JavaEntity gje = (JavaEntity) jpt.getMapping();
+ JavaTypeMapping jtm = jpt.getMapping();
+ if (jtm instanceof JavaEntity) {
+ JavaEntity gje = (JavaEntity)jtm;
return gje.getSpecifiedName();
}
+ JavaMappedSuperclass jms = (JavaMappedSuperclass)jtm;
+ return jms.getName();
+ }
public void renameEntity(JavaPersistentType jpt, String newName) {
- JavaEntity gje = (JavaEntity)jpt.getMapping();
+ JavaTypeMapping jtm = jpt.getMapping();
+ if (jtm instanceof JavaEntity) {
+ JavaEntity gje = (JavaEntity)jtm;
gje.setSpecifiedName(newName);
}
+ }
public JavaPersistentAttribute addAttribute(IJPAEditorFeatureProvider fp, JavaPersistentType jpt,
JavaPersistentType attributeType, String attributeName,
@@ -1478,7 +1541,7 @@ public class JpaArtifactFactory {
IRelation rel = fp.getRelationRelatedToAttribute(oldAt);
String inverseJPAName = null;
JavaPersistentType inverseJPT = null;
- if (BidirectionalRelation.class.isInstance(rel)) {
+ if (IBidirectionalRelation.class.isInstance(rel)) {
inverseJPT = rel.getInverse();
if (inverseJPT != oldAt.getParent()) {
pu = JpaArtifactFactory.INSTANCE.getPersistenceUnit(jpt);
@@ -1832,7 +1895,7 @@ public class JpaArtifactFactory {
return res;
}
- private BidirectionalRelation produceBiDirRelation(JavaPersistentType jpt,
+ private IBidirectionalRelation produceBiDirRelation(JavaPersistentType jpt,
JavaPersistentAttribute at, Annotation an,
JavaPersistentType relJPT, JavaPersistentAttribute relAt,
Annotation relAn, IJPAEditorFeatureProvider fp) {
@@ -1876,7 +1939,7 @@ public class JpaArtifactFactory {
}
}
- BidirectionalRelation res = null;
+ IBidirectionalRelation res = null;
if (annotationName.equals(JPAEditorConstants.ANNOTATION_ONE_TO_ONE)) {
if (!fp.doesRelationExist(jpt, relJPT, ownerAttrName, RelType.ONE_TO_ONE,
RelDir.BI))
@@ -2167,6 +2230,9 @@ public class JpaArtifactFactory {
Iterator<Connection> iter = Graphiti.getPeService().getAllConnections(cs).iterator();
while (iter.hasNext()) {
Connection conn = iter.next();
+ String v = Graphiti.getPeService().getPropertyValue(conn, IsARelation.IS_A_CONNECTION_PROP_KEY);
+ if (Boolean.TRUE.toString().equals(v))
+ continue;
IRemoveContext ctx = new RemoveContext(conn);
ctxs.add(ctx);
}
@@ -2200,6 +2266,15 @@ public class JpaArtifactFactory {
}
}
+ public void addIsARelations(IJPAEditorFeatureProvider fp,
+ Collection<IsARelation> rels) {
+ Iterator<IsARelation> it = rels.iterator();
+ while (it.hasNext()) {
+ IsARelation rel = it.next();
+ addNewIsARelation(fp, rel);
+ }
+ }
+
private void addNewRelation(IJPAEditorFeatureProvider fp, IRelation rel) {
AddConnectionContext ctx = new AddConnectionContext(JPAEditorUtil
.getAnchor(rel.getOwner(), fp), JPAEditorUtil.getAnchor(rel
@@ -2212,6 +2287,17 @@ public class JpaArtifactFactory {
ft.add(ctx);
}
+ private void addNewIsARelation(IJPAEditorFeatureProvider fp, IsARelation rel) {
+ AddConnectionContext ctx = new AddConnectionContext(JPAEditorUtil
+ .getAnchor(rel.getSubclass(), fp), JPAEditorUtil.getAnchor(rel.getSuperclass(), fp));
+ ctx.setNewObject(rel);
+ ctx.setTargetContainer(fp.getDiagramTypeProvider().getDiagram());
+ refreshEntityModel(fp, rel.getSubclass());
+ refreshEntityModel(fp, rel.getSuperclass());
+ AddInheritedEntityFeature ft = new AddInheritedEntityFeature(fp);
+ ft.add(ctx);
+ }
+
private String getRelTypeName(RelationshipMappingAnnotation an,
JavaResourceAttribute jra) {
String relTypeName = null;
@@ -2252,18 +2338,35 @@ public class JpaArtifactFactory {
return res.toArray(ret);
}
- public boolean isId(JavaPersistentAttribute jpa) {
+ // returns true even if the primary key is inherited
+ public boolean hasOrInheritsPrimaryKey(JavaPersistentType jpt) {
+ Iterable<ReadOnlyPersistentAttribute> attributes = jpt.getAllAttributes();
+ Iterator<ReadOnlyPersistentAttribute> it = attributes.iterator();
+ while (it.hasNext()) {
+ ReadOnlyPersistentAttribute at = it.next();
+ if (isId(at))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean hasPrimaryKey(JavaPersistentType jpt) {
+ for (JavaPersistentAttribute at : jpt.getAttributes())
+ if (isId(at)) return true;
+ return false;
+ }
+
+
+ public boolean isId(ReadOnlyPersistentAttribute jpa) {
return isSimpleId(jpa) || isEmbeddedId(jpa);
}
- public boolean isSimpleId(JavaPersistentAttribute jpa) {
- IdAnnotation an = (IdAnnotation)jpa.getResourceAttribute().getAnnotation(IdAnnotation.ANNOTATION_NAME);
- return (an != null);
+ public boolean isSimpleId(ReadOnlyPersistentAttribute jpa) {
+ return (jpa.getMappingKey() == MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
}
- public boolean isEmbeddedId(JavaPersistentAttribute jpa) {
- EmbeddedIdAnnotation an = (EmbeddedIdAnnotation)jpa.getResourceAttribute().getAnnotation(EmbeddedIdAnnotation.ANNOTATION_NAME);
- return (an != null);
+ public boolean isEmbeddedId(ReadOnlyPersistentAttribute jpa) {
+ return (jpa.getMappingKey() == MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
}
public String getColumnName(JavaPersistentAttribute jpa) {
@@ -2278,5 +2381,69 @@ public class JpaArtifactFactory {
return columnName;
}
+ public IColorConstant getForeground(JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot) {
+ IColorConstant foreground = dot.equals(JPAEditorConstants.DIAGRAM_OBJECT_TYPE.MappedSupeclass) ?
+ JPAEditorConstants.MAPPED_SUPERCLASS_BORDER_COLOR:
+ JPAEditorConstants.ENTITY_BORDER_COLOR;
+ return foreground;
+ }
+ public IColorConstant getBackground(JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot) {
+ IColorConstant background = dot.equals(JPAEditorConstants.DIAGRAM_OBJECT_TYPE.MappedSupeclass) ?
+ JPAEditorConstants.MAPPED_SUPERCLASS_BACKGROUND:
+ JPAEditorConstants.ENTITY_BACKGROUND;
+ return background;
+ }
+
+ public String getRenderingStyle(JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot) {
+ String renderingStyle = dot.equals(JPAEditorConstants.DIAGRAM_OBJECT_TYPE.MappedSupeclass) ?
+ IJPAEditorPredefinedRenderingStyle.GREEN_WHITE_GLOSS_ID :
+ IJPAEditorPredefinedRenderingStyle.BLUE_WHITE_GLOSS_ID;
+ return renderingStyle;
+ }
+
+ public JPAEditorConstants.DIAGRAM_OBJECT_TYPE determineDiagramObjectType(JavaPersistentType jpt) {
+ if (this.hasEntityAnnotation(jpt)) {
+ return JPAEditorConstants.DIAGRAM_OBJECT_TYPE.Entity;
+ } else if (this.hasMappedSuperclassAnnotation(jpt)) {
+ return JPAEditorConstants.DIAGRAM_OBJECT_TYPE.MappedSupeclass;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ public String generateIdName(JavaPersistentType jpt) {
+ String name = "id"; //$NON-NLS-1$
+ String genName = name;
+ for (int i = 0; i < 10000000; i++) {
+ if (!hasAttributeNamed(jpt, genName))
+ return genName;
+ genName = name + "_" + i; //$NON-NLS-1$
+ }
+ return genName;
+ }
+
+
+ private boolean hasAttributeNamed(JavaPersistentType jpt, String name) {
+ Iterable<String> hier = jpt.getAllAttributeNames();
+ Iterator<String> it = hier.iterator();
+ while (it.hasNext()) {
+ String atName = it.next();
+ if (name.equals(atName))
+ return true;
+ }
+ return false;
+ }
+
+ public String getMappedSuperclassPackageDeclaration(JavaPersistentType jpt) throws JavaModelException {
+ String packageName = null;
+ IPackageDeclaration[] packages = JPAEditorUtil.getCompilationUnit(jpt)
+ .getPackageDeclarations();
+ if (packages.length > 0) {
+ IPackageDeclaration packageDecl = packages[0];
+ packageName = packageDecl.getElementName();
+ }
+ return packageName;
+ }
+
+
} \ 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/ResourceChangeListener.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/ResourceChangeListener.java
index 7e3482a80e..50eb3e466b 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/ResourceChangeListener.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/ResourceChangeListener.java
@@ -1,3 +1,18 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2005, 2010 SAP AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stefan Dimov - initial API, implementation and documentation
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.util;
import org.eclipse.core.resources.IFile;
@@ -7,8 +22,10 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.ModelIntegrationUtil;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorDiagramTypeProvider;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
@@ -18,16 +35,23 @@ public class ResourceChangeListener implements IResourceChangeListener {
public void resourceChanged(IResourceChangeEvent event) {
IMarkerDelta[] markerDeltas = event.findMarkerDeltas(null, true);
-
+ IProject pr = null;
for (IMarkerDelta delta : markerDeltas) {
- if (delta.getResource().getType() != IResource.FILE)
+ int resType = delta.getResource().getType();
+ if (resType == IResource.PROJECT) {
+ pr = (IProject)delta.getResource();
continue;
- if (delta.getKind() != IResourceDelta.REMOVED)
+ }
+ if (resType != IResource.FILE)
continue;
final IFile file = (IFile) delta.getResource();
+ pr = file.getProject();
if (file.exists())
continue;
+ if (delta.getKind() != IResourceDelta.REMOVED)
+ continue;
final IProject project = file.getProject();
+ pr = project;
final String name = project.getName();
if (file.getFullPath().equals(ModelIntegrationUtil.getDiagramXMLFullPath(name))) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@@ -49,7 +73,27 @@ public class ResourceChangeListener implements IResourceChangeListener {
});
}
- }
+ }
+
+ if (pr == null)
+ return;
+ rearrangeIsARelations(pr);
+
+ }
+
+ private void rearrangeIsARelations(IProject pr) {
+ if (pr == null) return;
+ final Diagram d = ModelIntegrationUtil.getDiagramByProject(pr);
+ if (d == null) return;
+ final JPAEditorDiagramTypeProvider provider = ModelIntegrationUtil.getProviderByDiagram(d.getName());
+ if (provider == null)
+ return;
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ JpaArtifactFactory.instance().rearrangeIsARelationsInTransaction(provider.getFeatureProvider());
+ }
+ });
+
}
} \ No newline at end of file
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 779e2d6388..2faa1af05a 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
@@ -83,7 +83,7 @@ public class AllJpaEditorTests {
@BeforeClass
public static void verifyRequiredJarsExists() throws NoSuchElementException {
verifyJpaJarExists();
- verifyEclipseLinkJarExists();
+ //verifyEclipseLinkJarExists();
}
private static void verifyJpaJarExists() throws NoSuchElementException {
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddRelationFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddRelationFeatureTest.java
index 242dedead9..63b2e89668 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddRelationFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddRelationFeatureTest.java
@@ -76,7 +76,7 @@ public class AddRelationFeatureTest {
private IAddConnectionContext context;
- private IPeServiceUtil peUtil;
+ private IPeServiceUtil peServiceUtil;
private IGaService gaUtil;
@@ -100,7 +100,7 @@ public class AddRelationFeatureTest {
diagramProvider = EasyMock.createMock(IDiagramTypeProvider.class);
diagram = EasyMock.createMock(Diagram.class);
context = EasyMock.createMock(IAddConnectionContext.class);
- peUtil = EasyMock.createMock(IPeServiceUtil.class);
+ peServiceUtil = EasyMock.createMock(IPeServiceUtil.class);
gaUtil = EasyMock.createMock(IGaService.class);
ft = EasyMock.createMock(IAddBendpointFeature.class);
@@ -191,7 +191,7 @@ public class AddRelationFeatureTest {
Polyline pl = EasyMock.createMock(Polyline.class);
expect(pl.getX()).andReturn(0);
expect(pl.getY()).andReturn(0);
- expect(imageCreator.createArrowConnectionDecorator(isA(Connection.class), eq(location))).andReturn(d);
+ expect(imageCreator.createArrowConnectionDecorator(isA(Connection.class), eq(location), false)).andReturn(d);
expect(d.getGraphicsAlgorithm()).andReturn(pl);
replay(d, pl);
}
@@ -213,7 +213,7 @@ public class AddRelationFeatureTest {
private void configureProvidersForAdd(IRelation relation) {
expect(diagramProvider.getDiagram()).andReturn(diagram);
expect(featureProvider.getDiagramTypeProvider()).andReturn(diagramProvider);
- expect(featureProvider.getPeUtil()).andReturn(peUtil);
+ expect(featureProvider.getPeServiceUtil()).andReturn(peServiceUtil);
expect(featureProvider.getAddBendpointFeature(isA(IAddBendpointContext.class))).andStubReturn(ft);
expect(context.getNewObject()).andReturn(relation);
@@ -255,7 +255,7 @@ public class AddRelationFeatureTest {
gaUtil.setLocation(isA(Polyline.class), EasyMock.anyInt() , EasyMock.anyInt());
FreeFormConnection connection = createConnection(startAnchor, endAnchor);
- expect(peUtil.createFreeFormConnection(diagram)).andReturn(connection);
+ expect(peServiceUtil.createFreeFormConnection(diagram)).andReturn(connection);
expect(imageCreator.createConnectionLine(diagram, connection)).andReturn(null);
ft.addBendpoint(isA(IAddBendpointContext.class));
@@ -320,7 +320,7 @@ public class AddRelationFeatureTest {
replay(diagramProvider);
replay(diagram);
replay(context);
- replay(peUtil);
+ replay(peServiceUtil);
replay(gaUtil);
replay(ft);
return new AddRelationFeature(featureProvider, imageCreator, jpaEditorUtil);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java
index b5548c9fd0..cdcb83c87e 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java
@@ -28,7 +28,7 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.DeleteRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.BidirectionalRelation;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IBidirectionalRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IJPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.util.IEditor;
import org.eclipse.ui.IWorkbenchPartSite;
@@ -45,7 +45,7 @@ public class DeleteRelationFeatureTest {
IDeleteContext ctx = EasyMock.createMock(IDeleteContext.class);
PictogramElement pe = EasyMock.createMock(PictogramElement.class);
expect(ctx.getPictogramElement()).andStubReturn(pe);
- BidirectionalRelation rel = EasyMock.createMock(BidirectionalRelation.class);
+ IBidirectionalRelation rel = EasyMock.createMock(IBidirectionalRelation.class);
ICompilationUnit cu1 = EasyMock.createMock(ICompilationUnit.class);
ICompilationUnit cu2 = EasyMock.createMock(ICompilationUnit.class);
JavaPersistentType jpt1 = EasyMock.createMock(JavaPersistentType.class);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/LayoutEntityFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/LayoutEntityFeatureTest.java
index e9fbe8566b..bbf371f3dd 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/LayoutEntityFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/LayoutEntityFeatureTest.java
@@ -45,7 +45,7 @@ public class LayoutEntityFeatureTest {
EList<Shape> shList = new BasicInternalEList<Shape>(Shape.class);
EasyMock.expect(cs.getChildren()).andStubReturn(shList);
IPeServiceUtil peUtil = EasyMock.createMock(IPeServiceUtil.class);
- EasyMock.expect(fp.getPeUtil()).andStubReturn(peUtil);
+ EasyMock.expect(fp.getPeServiceUtil()).andStubReturn(peUtil);
EasyMock.expect(peUtil.getProperty(cs, JPAEditorConstants.COLLAPSE_FEATURES)).andStubReturn(null);
EasyMock.expect(peUtil.removeProperty(cs, JPAEditorConstants.COLLAPSE_FEATURES)).andStubReturn(false);
IGraphicsUpdater gu = EasyMock.createMock(IGraphicsUpdater.class);

Back to the top