reducing code duplication with PrivateOwnedComposite and has-a relationship for PrivateOwnable on 1-1 and 1-m mappings
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkOneToManyMapping.java
index 9d7dde9..7b187d6 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkOneToManyMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkOneToManyMapping.java
@@ -23,6 +23,7 @@
* @version 2.1
* @since 2.1
*/
-public interface EclipseLinkOneToManyMapping extends OneToManyMapping, EclipseLinkRelationshipMapping, PrivateOwnable
+public interface EclipseLinkOneToManyMapping extends OneToManyMapping, EclipseLinkRelationshipMapping
{
+ PrivateOwnable getPrivateOwnable();
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkOneToOneMapping.java
index b52746b..2e6b869 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkOneToOneMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/EclipseLinkOneToOneMapping.java
@@ -23,6 +23,7 @@
* @version 2.1
* @since 2.1
*/
-public interface EclipseLinkOneToOneMapping extends OneToOneMapping, EclipseLinkRelationshipMapping, PrivateOwnable
+public interface EclipseLinkOneToOneMapping extends OneToOneMapping, EclipseLinkRelationshipMapping
{
+ PrivateOwnable getPrivateOwnable();
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/JavaPrivateOwnable.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/JavaPrivateOwnable.java
new file mode 100644
index 0000000..e48472e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/context/java/JavaPrivateOwnable.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.eclipselink.core.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
+import org.eclipse.jpt.eclipselink.core.context.PrivateOwnable;
+
+/**
+ *
+ *
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ */
+public interface JavaPrivateOwnable extends JavaJpaContextNode, PrivateOwnable
+{
+
+ /**
+ * Initialize the JavaPrivateOwnable context model object to match the PrivateOwnedAnnotation
+ * resource model object. This should be called immediately after object creation.
+ */
+ void initialize(JavaResourcePersistentAttribute jrpa);
+
+ /**
+ * Update the JavaPrivateOwnable context model object to match the PrivateOwnedAnnotation
+ * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()}
+ */
+ void update(JavaResourcePersistentAttribute jrpa);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaOneToManyMappingImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaOneToManyMappingImpl.java
index 0b83a4c..9a47e2f 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaOneToManyMappingImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaOneToManyMappingImpl.java
@@ -14,19 +14,21 @@
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.eclipselink.core.EclipseLinkJpaFactory;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkOneToManyMapping;
+import org.eclipse.jpt.eclipselink.core.context.PrivateOwnable;
import org.eclipse.jpt.eclipselink.core.context.java.JavaJoinFetchable;
+import org.eclipse.jpt.eclipselink.core.context.java.JavaPrivateOwnable;
import org.eclipse.jpt.eclipselink.core.resource.java.PrivateOwnedAnnotation;
public class EclipseLinkJavaOneToManyMappingImpl extends GenericJavaOneToManyMapping implements EclipseLinkOneToManyMapping
{
- protected boolean privateOwned;
-
protected final JavaJoinFetchable joinFetchable;
+ protected final JavaPrivateOwnable privateOwnable;
public EclipseLinkJavaOneToManyMappingImpl(JavaPersistentAttribute parent) {
super(parent);
- this.joinFetchable = new EclipseLinkJavaJoinFetchable(parent);
+ this.joinFetchable = new EclipseLinkJavaJoinFetchable(parent);//TODO build with jpaFactory
+ this.privateOwnable = new EclipseLinkJavaPrivateOwnable(parent);
}
@Override
@@ -49,55 +51,26 @@
protected void removeResourcePrivateOwned() {
this.resourcePersistentAttribute.removeAnnotation(getPrivateOwnedAnnotationName());
}
-
- public boolean getPrivateOwned() {
- return this.privateOwned;
- }
-
- public void setPrivateOwned(boolean newPrivateOwned) {
- if (this.privateOwned == newPrivateOwned) {
- return;
- }
- boolean oldPrivateOwned = this.privateOwned;
- this.privateOwned = newPrivateOwned;
-
- if (newPrivateOwned) {
- addResourcePrivateOwned();
- }
- else {
- //have to check if annotation exists in case the change is from false to null or vice versa
- if (getResourcePrivateOwned() != null) {
- removeResourcePrivateOwned();
- }
- }
- firePropertyChanged(PRIVATE_OWNED_PROPERTY, oldPrivateOwned, newPrivateOwned);
- }
-
- protected void setPrivateOwned_(boolean newPrivateOwned) {
- boolean oldPrivateOwned = this.privateOwned;
- this.privateOwned = newPrivateOwned;
- firePropertyChanged(PRIVATE_OWNED_PROPERTY, oldPrivateOwned, newPrivateOwned);
- }
public JavaJoinFetchable getJoinFetchable() {
return this.joinFetchable;
}
+
+ public PrivateOwnable getPrivateOwnable() {
+ return this.privateOwnable;
+ }
@Override
public void initialize(JavaResourcePersistentAttribute jrpa) {
super.initialize(jrpa);
- this.privateOwned = privateOwned();
this.joinFetchable.initialize(jrpa);
+ this.privateOwnable.initialize(jrpa);
}
@Override
public void update(JavaResourcePersistentAttribute jrpa) {
super.update(jrpa);
- this.setPrivateOwned_(privateOwned());
this.joinFetchable.update(jrpa);
+ this.privateOwnable.update(jrpa);
}
-
- private boolean privateOwned() {
- return getResourcePrivateOwned() != null;
- }
-}
+}
\ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaOneToOneMappingImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaOneToOneMappingImpl.java
index d9ef31f..c41934c 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaOneToOneMappingImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaOneToOneMappingImpl.java
@@ -14,91 +14,46 @@
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.eclipselink.core.EclipseLinkJpaFactory;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkOneToOneMapping;
+import org.eclipse.jpt.eclipselink.core.context.PrivateOwnable;
import org.eclipse.jpt.eclipselink.core.context.java.JavaJoinFetchable;
-import org.eclipse.jpt.eclipselink.core.resource.java.PrivateOwnedAnnotation;
+import org.eclipse.jpt.eclipselink.core.context.java.JavaPrivateOwnable;
public class EclipseLinkJavaOneToOneMappingImpl extends GenericJavaOneToOneMapping implements EclipseLinkOneToOneMapping
{
- protected boolean privateOwned;
-
protected final JavaJoinFetchable joinFetchable;
+ protected final JavaPrivateOwnable privateOwnable;
public EclipseLinkJavaOneToOneMappingImpl(JavaPersistentAttribute parent) {
super(parent);
this.joinFetchable = new EclipseLinkJavaJoinFetchable(parent);
+ this.privateOwnable = new EclipseLinkJavaPrivateOwnable(parent);
}
@Override
protected EclipseLinkJpaFactory getJpaFactory() {
return (EclipseLinkJpaFactory) super.getJpaFactory();
}
-
- public boolean getPrivateOwned() {
- return this.privateOwned;
- }
-
- protected String getPrivateOwnedAnnotationName() {
- return PrivateOwnedAnnotation.ANNOTATION_NAME;
- }
-
- protected PrivateOwnedAnnotation getResourcePrivateOwned() {
- return (PrivateOwnedAnnotation) this.resourcePersistentAttribute.getAnnotation(getPrivateOwnedAnnotationName());
- }
-
- protected void addResourcePrivateOwned() {
- this.resourcePersistentAttribute.addAnnotation(getPrivateOwnedAnnotationName());
- }
-
- protected void removeResourcePrivateOwned() {
- this.resourcePersistentAttribute.removeAnnotation(getPrivateOwnedAnnotationName());
- }
-
- public void setPrivateOwned(boolean newPrivateOwned) {
- if (this.privateOwned == newPrivateOwned) {
- return;
- }
- boolean oldPrivateOwned = this.privateOwned;
- this.privateOwned = newPrivateOwned;
-
- if (newPrivateOwned) {
- addResourcePrivateOwned();
- }
- else {
- //have to check if annotation exists in case the change is from false to null or vice versa
- if (getResourcePrivateOwned() != null) {
- removeResourcePrivateOwned();
- }
- }
- firePropertyChanged(PRIVATE_OWNED_PROPERTY, oldPrivateOwned, newPrivateOwned);
- }
-
- protected void setPrivateOwned_(boolean newPrivateOwned) {
- boolean oldPrivateOwned = this.privateOwned;
- this.privateOwned = newPrivateOwned;
- firePropertyChanged(PRIVATE_OWNED_PROPERTY, oldPrivateOwned, newPrivateOwned);
- }
public JavaJoinFetchable getJoinFetchable() {
return this.joinFetchable;
}
+ public PrivateOwnable getPrivateOwnable() {
+ return this.privateOwnable;
+ }
@Override
public void initialize(JavaResourcePersistentAttribute jrpa) {
super.initialize(jrpa);
- this.privateOwned = privateOwned();
this.joinFetchable.initialize(jrpa);
+ this.privateOwnable.initialize(jrpa);
}
@Override
public void update(JavaResourcePersistentAttribute jrpa) {
super.update(jrpa);
- setPrivateOwned_(privateOwned());
this.joinFetchable.update(jrpa);
- }
-
- private boolean privateOwned() {
- return getResourcePrivateOwned() != null;
+ this.privateOwnable.update(jrpa);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaPrivateOwnable.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaPrivateOwnable.java
new file mode 100644
index 0000000..8858325
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/EclipseLinkJavaPrivateOwnable.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.eclipselink.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
+import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.eclipselink.core.context.java.JavaPrivateOwnable;
+import org.eclipse.jpt.eclipselink.core.resource.java.PrivateOwnedAnnotation;
+
+public class EclipseLinkJavaPrivateOwnable extends AbstractJavaJpaContextNode implements JavaPrivateOwnable
+{
+
+ protected boolean privateOwned;
+
+ protected JavaResourcePersistentAttribute resourcePersistentAttribute;
+
+ public EclipseLinkJavaPrivateOwnable(JavaPersistentAttribute parent) {
+ super(parent);
+ }
+
+ protected String getPrivateOwnedAnnotationName() {
+ return PrivateOwnedAnnotation.ANNOTATION_NAME;
+ }
+
+ protected PrivateOwnedAnnotation getResourcePrivateOwned() {
+ return (PrivateOwnedAnnotation) this.resourcePersistentAttribute.getAnnotation(getPrivateOwnedAnnotationName());
+ }
+
+ protected void addResourcePrivateOwned() {
+ this.resourcePersistentAttribute.addAnnotation(getPrivateOwnedAnnotationName());
+ }
+
+ protected void removeResourcePrivateOwned() {
+ this.resourcePersistentAttribute.removeAnnotation(getPrivateOwnedAnnotationName());
+ }
+
+ public boolean getPrivateOwned() {
+ return this.privateOwned;
+ }
+
+ public void setPrivateOwned(boolean newPrivateOwned) {
+ if (this.privateOwned == newPrivateOwned) {
+ return;
+ }
+ boolean oldPrivateOwned = this.privateOwned;
+ this.privateOwned = newPrivateOwned;
+
+ if (newPrivateOwned) {
+ addResourcePrivateOwned();
+ }
+ else {
+ //have to check if annotation exists in case the change is from false to null or vice versa
+ if (getResourcePrivateOwned() != null) {
+ removeResourcePrivateOwned();
+ }
+ }
+ firePropertyChanged(PRIVATE_OWNED_PROPERTY, oldPrivateOwned, newPrivateOwned);
+ }
+
+ protected void setPrivateOwned_(boolean newPrivateOwned) {
+ boolean oldPrivateOwned = this.privateOwned;
+ this.privateOwned = newPrivateOwned;
+ firePropertyChanged(PRIVATE_OWNED_PROPERTY, oldPrivateOwned, newPrivateOwned);
+ }
+
+ public void initialize(JavaResourcePersistentAttribute jrpa) {
+ this.resourcePersistentAttribute = jrpa;
+ this.privateOwned = privateOwned();
+ }
+
+ public void update(JavaResourcePersistentAttribute jrpa) {
+ this.resourcePersistentAttribute = jrpa;
+ this.setPrivateOwned_(privateOwned());
+ }
+
+ private boolean privateOwned() {
+ return getResourcePrivateOwned() != null;
+ }
+
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ PrivateOwnedAnnotation resourcePrivateOwned = this.getResourcePrivateOwned();
+ return resourcePrivateOwned == null ? null : resourcePrivateOwned.getTextRange(astRoot);
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/EclipselinkOneToManyMappingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/EclipselinkOneToManyMappingComposite.java
index d3fc06c..5b8b58c 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/EclipselinkOneToManyMappingComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/EclipselinkOneToManyMappingComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -15,7 +15,6 @@
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkOneToManyMapping;
import org.eclipse.jpt.eclipselink.core.context.JoinFetchable;
import org.eclipse.jpt.eclipselink.core.context.PrivateOwnable;
-import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages;
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.details.JpaComposite;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
@@ -123,13 +122,8 @@
// Mapped By widgets
new MappedByComposite(this, subPane);
- // Private Owned widgets
- addCheckBox(
- subPane,
- EclipseLinkUiMappingsMessages.PrivateOwnedComposite_privateOwnedLabel,
- buildPrivateOwnedHolder(),
- null
- );
+ // Private owned widgets
+ new PrivateOwnedComposite(this, buildPrivateOwnableHolder(), subPane);
// Cascade widgets
new CascadeComposite(this, buildCascadeHolder(), addSubPane(container, 4));
@@ -152,6 +146,15 @@
);
}
+ private PropertyValueModel<PrivateOwnable> buildPrivateOwnableHolder() {
+ return new PropertyAspectAdapter<OneToManyMapping, PrivateOwnable>(getSubjectHolder()) {
+ @Override
+ protected PrivateOwnable buildValue_() {
+ return ((EclipseLinkOneToManyMapping) this.subject).getPrivateOwnable();
+ }
+ };
+ }
+
private PropertyValueModel<JoinFetchable> buildJoinFetchableHolder() {
return new PropertyAspectAdapter<OneToManyMapping, JoinFetchable>(getSubjectHolder()) {
@Override
@@ -178,17 +181,4 @@
}
};
}
-
- private PropertyAspectAdapter<OneToManyMapping, Boolean> buildPrivateOwnedHolder() {
- return new PropertyAspectAdapter<OneToManyMapping, Boolean>(getSubjectHolder(), PrivateOwnable.PRIVATE_OWNED_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(((PrivateOwnable) this.subject).getPrivateOwned());
- }
- @Override
- protected void setValue_(Boolean value) {
- ((PrivateOwnable) this.subject).setPrivateOwned(value.booleanValue());
- }
- };
- }
}
\ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/EclipselinkOneToOneMappingComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/EclipselinkOneToOneMappingComposite.java
index ca827a4..e2acfc6 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/EclipselinkOneToOneMappingComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/EclipselinkOneToOneMappingComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -14,7 +14,6 @@
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkOneToOneMapping;
import org.eclipse.jpt.eclipselink.core.context.JoinFetchable;
import org.eclipse.jpt.eclipselink.core.context.PrivateOwnable;
-import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages;
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.details.JpaComposite;
import org.eclipse.jpt.ui.internal.mappings.details.CascadeComposite;
@@ -115,12 +114,8 @@
// Optional check box
new OptionalComposite(this, addSubPane(subPane, 4));
- addCheckBox(
- subPane,
- EclipseLinkUiMappingsMessages.PrivateOwnedComposite_privateOwnedLabel,
- buildPrivateOwnedHolder(),
- null
- );
+ // Private owned check box
+ new PrivateOwnedComposite(this, buildPrivateOwnableHolder(), subPane);
// Cascade widgets
new CascadeComposite(this, buildCascadeHolder(), container);
@@ -138,6 +133,15 @@
};
}
+ private PropertyValueModel<PrivateOwnable> buildPrivateOwnableHolder() {
+ return new PropertyAspectAdapter<OneToOneMapping, PrivateOwnable>(getSubjectHolder()) {
+ @Override
+ protected PrivateOwnable buildValue_() {
+ return ((EclipseLinkOneToOneMapping) this.subject).getPrivateOwnable();
+ }
+ };
+ }
+
private PropertyValueModel<Cascade> buildCascadeHolder() {
return new TransformationPropertyValueModel<OneToOneMapping, Cascade>(getSubjectHolder()) {
@@ -147,18 +151,4 @@
}
};
}
-
- private PropertyAspectAdapter<OneToOneMapping, Boolean> buildPrivateOwnedHolder() {
- return new PropertyAspectAdapter<OneToOneMapping, Boolean>(getSubjectHolder(), PrivateOwnable.PRIVATE_OWNED_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(((PrivateOwnable) this.subject).getPrivateOwned());
- }
- @Override
- protected void setValue_(Boolean value) {
- ((PrivateOwnable) this.subject).setPrivateOwned(value.booleanValue());
- }
- };
- }
-
}
\ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/JoinFetchComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/JoinFetchComposite.java
index 0b42902..5a410f9 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/JoinFetchComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/JoinFetchComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved. This
+ * Copyright (c) 2008 Oracle. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -41,7 +41,7 @@
public class JoinFetchComposite extends FormPane<JoinFetchable> {
/**
- * Creates a new <code>FetchTypeComposite</code>.
+ * Creates a new <code>JoinFetchComposite</code>.
*
* @param parentPane The parent container of this one
* @param parent The parent container
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/PrivateOwnedComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/PrivateOwnedComposite.java
new file mode 100644
index 0000000..d2d93a3
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/mappings/details/PrivateOwnedComposite.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.eclipselink.ui.internal.mappings.details;
+
+import org.eclipse.jpt.eclipselink.core.context.PrivateOwnable;
+import org.eclipse.jpt.eclipselink.ui.internal.mappings.EclipseLinkUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.widgets.FormPane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * This composite simply shows the Lob check box.
+ *
+ * @see BasicMapping
+ *
+ * @version 2.0
+ * @since 1.0
+ */
+public class PrivateOwnedComposite extends FormPane<PrivateOwnable>
+{
+ /**
+ * Creates a new <code>PrivateOwnedComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param parent The parent container
+ */
+ public PrivateOwnedComposite(FormPane<?> parentPane,
+ PropertyValueModel<? extends PrivateOwnable> subjectHolder,
+ Composite parent) {
+
+ super(parentPane, subjectHolder, parent);
+ }
+
+ private PropertyAspectAdapter<PrivateOwnable, Boolean> buildPrivateOwnedHolder() {
+
+ return new PropertyAspectAdapter<PrivateOwnable, Boolean>(getSubjectHolder(), PrivateOwnable.PRIVATE_OWNED_PROPERTY) {
+
+ @Override
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(this.subject.getPrivateOwned());
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ this.subject.setPrivateOwned(value.booleanValue());
+ }
+ };
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+ addCheckBox(
+ container,
+ EclipseLinkUiMappingsMessages.PrivateOwnedComposite_privateOwnedLabel,
+ buildPrivateOwnedHolder(),
+ null
+ );
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java
index d5ca639..e3fdd2c 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToManyMappingTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -18,6 +18,7 @@
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkOneToManyMapping;
import org.eclipse.jpt.eclipselink.core.context.JoinFetchType;
import org.eclipse.jpt.eclipselink.core.context.JoinFetchable;
+import org.eclipse.jpt.eclipselink.core.context.PrivateOwnable;
import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA;
import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchAnnotation;
import org.eclipse.jpt.eclipselink.core.resource.java.PrivateOwnedAnnotation;
@@ -92,7 +93,8 @@
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getSpecifiedMapping();
- assertEquals(true, oneToManyMapping.getPrivateOwned());
+ PrivateOwnable privateOwnable = oneToManyMapping.getPrivateOwnable();
+ assertEquals(true, privateOwnable.getPrivateOwned());
}
public void testSetPrivateOwned() throws Exception {
@@ -101,18 +103,19 @@
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getSpecifiedMapping();
- assertEquals(true, oneToManyMapping.getPrivateOwned());
+ PrivateOwnable privateOwnable = oneToManyMapping.getPrivateOwnable();
+ assertEquals(true, privateOwnable.getPrivateOwned());
- oneToManyMapping.setPrivateOwned(false);
+ privateOwnable.setPrivateOwned(false);
JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
assertNull(attributeResource.getAnnotation(PrivateOwnedAnnotation.ANNOTATION_NAME));
- assertEquals(false, oneToManyMapping.getPrivateOwned());
+ assertEquals(false, privateOwnable.getPrivateOwned());
- oneToManyMapping.setPrivateOwned(true);
+ privateOwnable.setPrivateOwned(true);
assertNotNull(attributeResource.getAnnotation(PrivateOwnedAnnotation.ANNOTATION_NAME));
- assertEquals(true, oneToManyMapping.getPrivateOwned());
+ assertEquals(true, privateOwnable.getPrivateOwned());
}
public void testPrivateOwnedUpdatesFromResourceModelChange() throws Exception {
@@ -121,17 +124,18 @@
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
EclipseLinkOneToManyMapping oneToManyMapping = (EclipseLinkOneToManyMapping) persistentAttribute.getSpecifiedMapping();
- assertEquals(true, oneToManyMapping.getPrivateOwned());
+ PrivateOwnable privateOwnable = oneToManyMapping.getPrivateOwnable();
+ assertEquals(true, privateOwnable.getPrivateOwned());
JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
attributeResource.removeAnnotation(PrivateOwnedAnnotation.ANNOTATION_NAME);
- assertEquals(false, oneToManyMapping.getPrivateOwned());
+ assertEquals(false, privateOwnable.getPrivateOwned());
attributeResource.addAnnotation(PrivateOwnedAnnotation.ANNOTATION_NAME);
- assertEquals(true, oneToManyMapping.getPrivateOwned());
+ assertEquals(true, privateOwnable.getPrivateOwned());
}
public void testHasJoinFetch() throws Exception {
diff --git a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java
index 2f3aa89..67e1172 100644
--- a/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java
+++ b/jpa/tests/org.eclipse.jpt.eclipselink.core.tests/src/org/eclipse/jpt/eclipselink/core/tests/internal/context/java/EclipseLinkJavaOneToOneMappingTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2008 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -19,6 +19,7 @@
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkOneToOneMapping;
import org.eclipse.jpt.eclipselink.core.context.JoinFetchType;
import org.eclipse.jpt.eclipselink.core.context.JoinFetchable;
+import org.eclipse.jpt.eclipselink.core.context.PrivateOwnable;
import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkJPA;
import org.eclipse.jpt.eclipselink.core.resource.java.JoinFetchAnnotation;
import org.eclipse.jpt.eclipselink.core.resource.java.PrivateOwnedAnnotation;
@@ -94,7 +95,8 @@
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getSpecifiedMapping();
- assertEquals(true, oneToOneMapping.getPrivateOwned());
+ PrivateOwnable privateOwnable = oneToOneMapping.getPrivateOwnable();
+ assertEquals(true, privateOwnable.getPrivateOwned());
}
public void testSetPrivateOwned() throws Exception {
@@ -103,18 +105,19 @@
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getSpecifiedMapping();
- assertEquals(true, oneToOneMapping.getPrivateOwned());
+ PrivateOwnable privateOwnable = oneToOneMapping.getPrivateOwnable();
+ assertEquals(true, privateOwnable.getPrivateOwned());
- oneToOneMapping.setPrivateOwned(false);
+ privateOwnable.setPrivateOwned(false);
JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
assertNull(attributeResource.getAnnotation(PrivateOwnedAnnotation.ANNOTATION_NAME));
- assertEquals(false, oneToOneMapping.getPrivateOwned());
+ assertEquals(false, privateOwnable.getPrivateOwned());
- oneToOneMapping.setPrivateOwned(true);
+ privateOwnable.setPrivateOwned(true);
assertNotNull(attributeResource.getAnnotation(PrivateOwnedAnnotation.ANNOTATION_NAME));
- assertEquals(true, oneToOneMapping.getPrivateOwned());
+ assertEquals(true, privateOwnable.getPrivateOwned());
}
public void testPrivateOwnedUpdatesFromResourceModelChange() throws Exception {
@@ -123,17 +126,18 @@
PersistentAttribute persistentAttribute = javaPersistentType().attributes().next();
EclipseLinkOneToOneMapping oneToOneMapping = (EclipseLinkOneToOneMapping) persistentAttribute.getSpecifiedMapping();
- assertEquals(true, oneToOneMapping.getPrivateOwned());
+ PrivateOwnable privateOwnable = oneToOneMapping.getPrivateOwnable();
+ assertEquals(true, privateOwnable.getPrivateOwned());
JavaResourcePersistentType typeResource = jpaProject().getJavaResourcePersistentType(FULLY_QUALIFIED_TYPE_NAME);
JavaResourcePersistentAttribute attributeResource = typeResource.attributes().next();
attributeResource.removeAnnotation(PrivateOwnedAnnotation.ANNOTATION_NAME);
- assertEquals(false, oneToOneMapping.getPrivateOwned());
+ assertEquals(false, privateOwnable.getPrivateOwned());
attributeResource.addAnnotation(PrivateOwnedAnnotation.ANNOTATION_NAME);
- assertEquals(true, oneToOneMapping.getPrivateOwned());
+ assertEquals(true, privateOwnable.getPrivateOwned());
}
public void testHasJoinFetch() throws Exception {