Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2008-04-08 16:55:08 -0400
committerkmoore2008-04-08 16:55:08 -0400
commit76b8cf138857fcb5371fe04c70c6aaca22ca36b7 (patch)
tree68f8e4674c27e8146004f6a697461c596d6bdca6
parentbb23dcdb40c951c7b3cf872ba920c25e27024a0e (diff)
downloadwebtools.dali-76b8cf138857fcb5371fe04c70c6aaca22ca36b7.tar.gz
webtools.dali-76b8cf138857fcb5371fe04c70c6aaca22ca36b7.tar.xz
webtools.dali-76b8cf138857fcb5371fe04c70c6aaca22ca36b7.zip
cleaning up ListValueModels - making them easier to follow
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmXmlItemContentProvider.java29
3 files changed, 39 insertions, 14 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java
index 73ca32e4a5..5f515fb694 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/JavaPersistentTypeItemContentProvider.java
@@ -11,6 +11,7 @@
package org.eclipse.jpt.ui.internal.platform.generic;
import java.util.ListIterator;
+import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.context.java.JavaPersistentType;
import org.eclipse.jpt.ui.internal.jface.AbstractTreeItemContentProvider;
@@ -26,13 +27,17 @@ public class JavaPersistentTypeItemContentProvider extends AbstractTreeItemConte
}
@Override
+ public JavaPersistentType model() {
+ return (JavaPersistentType) super.model();
+ }
+ @Override
public Object getParent() {
- return ((JavaPersistentType) model()).getParent();
+ return model().getParent();
}
@Override
protected ListValueModel<JavaPersistentAttribute> buildChildrenModel() {
- return new ListAspectAdapter<JavaPersistentType, JavaPersistentAttribute>(new String[]{JavaPersistentType.SPECIFIED_ATTRIBUTES_LIST}, (JavaPersistentType) model()) {
+ return new ListAspectAdapter<JavaPersistentType, JavaPersistentAttribute>(PersistentType.SPECIFIED_ATTRIBUTES_LIST, model()) {
@Override
protected ListIterator<JavaPersistentAttribute> listIterator_() {
return subject.attributes();
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java
index 9af56a24a3..0c15789050 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmPersistentTypeItemContentProvider.java
@@ -11,7 +11,9 @@
package org.eclipse.jpt.ui.internal.platform.generic;
import java.util.ArrayList;
+import java.util.List;
import java.util.ListIterator;
+import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.ui.internal.jface.AbstractTreeItemContentProvider;
@@ -28,13 +30,18 @@ public class OrmPersistentTypeItemContentProvider extends AbstractTreeItemConten
}
@Override
+ public OrmPersistentType model() {
+ return (OrmPersistentType) super.model();
+ }
+
+ @Override
public Object getParent() {
- return ((OrmPersistentType) model()).getParent();
+ return model().getParent();
}
@Override
protected ListValueModel<OrmPersistentAttribute> buildChildrenModel() {
- java.util.List<ListValueModel<OrmPersistentAttribute>> list = new ArrayList<ListValueModel<OrmPersistentAttribute>>();
+ List<ListValueModel<OrmPersistentAttribute>> list = new ArrayList<ListValueModel<OrmPersistentAttribute>>(2);
list.add(buildSpecifiedPersistentAttributesListHolder());
list.add(buildVirtualPersistentAttributesListHolder());
return new CompositeListValueModel<ListValueModel<OrmPersistentAttribute>, OrmPersistentAttribute>(list);
@@ -42,7 +49,7 @@ public class OrmPersistentTypeItemContentProvider extends AbstractTreeItemConten
protected ListValueModel<OrmPersistentAttribute> buildSpecifiedPersistentAttributesListHolder() {
- return new ListAspectAdapter<OrmPersistentType, OrmPersistentAttribute>(new String[]{OrmPersistentType.SPECIFIED_ATTRIBUTES_LIST}, (OrmPersistentType) model()) {
+ return new ListAspectAdapter<OrmPersistentType, OrmPersistentAttribute>(PersistentType.SPECIFIED_ATTRIBUTES_LIST, model()) {
@Override
protected ListIterator<OrmPersistentAttribute> listIterator_() {
return subject.specifiedAttributes();
@@ -55,7 +62,7 @@ public class OrmPersistentTypeItemContentProvider extends AbstractTreeItemConten
}
protected ListValueModel<OrmPersistentAttribute> buildVirtualPersistentAttributesListHolder() {
- return new ListAspectAdapter<OrmPersistentType, OrmPersistentAttribute>(new String[]{OrmPersistentType.VIRTUAL_ATTRIBUTES_LIST}, (OrmPersistentType) model()) {
+ return new ListAspectAdapter<OrmPersistentType, OrmPersistentAttribute>(OrmPersistentType.VIRTUAL_ATTRIBUTES_LIST, model()) {
@Override
protected ListIterator<OrmPersistentAttribute> listIterator_() {
return subject.virtualAttributes();
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmXmlItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmXmlItemContentProvider.java
index 85f6ccad21..1013407a20 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmXmlItemContentProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/platform/generic/OrmXmlItemContentProvider.java
@@ -20,6 +20,7 @@ import org.eclipse.jpt.ui.internal.jface.DelegatingTreeContentAndLabelProvider;
import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.utility.model.value.ListValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
public class OrmXmlItemContentProvider
extends AbstractTreeItemContentProvider<OrmPersistentType>
@@ -29,27 +30,39 @@ public class OrmXmlItemContentProvider
super(ormXml, contentProvider);
}
+ @Override
+ public OrmXml model() {
+ return (OrmXml) super.model();
+ }
@Override
public PersistenceUnit getParent() {
- return ((OrmXml) model()).getPersistenceUnit();
+ return model().getPersistenceUnit();
}
@Override
protected ListValueModel<OrmPersistentType> buildChildrenModel() {
return new ListAspectAdapter<EntityMappings, OrmPersistentType>(
- new PropertyAspectAdapter<OrmXml, EntityMappings>(
- OrmXml.ENTITY_MAPPINGS_PROPERTY, (OrmXml) model()) {
- @Override
- protected EntityMappings buildValue_() {
- return subject.getEntityMappings();
- }
- },
+ buildEntityMappingsHolder(),
EntityMappings.PERSISTENT_TYPES_LIST) {
@Override
protected ListIterator<OrmPersistentType> listIterator_() {
return subject.ormPersistentTypes();
}
+ @Override
+ protected int size_() {
+ return subject.ormPersistentTypesSize();
+ }
+ };
+ }
+
+ protected PropertyValueModel<EntityMappings> buildEntityMappingsHolder() {
+ return new PropertyAspectAdapter<OrmXml, EntityMappings>(
+ OrmXml.ENTITY_MAPPINGS_PROPERTY, model()) {
+ @Override
+ protected EntityMappings buildValue_() {
+ return subject.getEntityMappings();
+ }
};
}
}

Back to the top