Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortle2008-05-01 01:11:24 +0000
committertle2008-05-01 01:11:24 +0000
commit65af2a3bd0d5e41f89ac67fccdfef2b9ad4cfb2c (patch)
tree4cd08302e827cce1f8d03890a787dcc5e7677888
parentdde0076e66906c515d8c8312dc1f16e8259da8f0 (diff)
downloadwebtools.dali-65af2a3bd0d5e41f89ac67fccdfef2b9ad4cfb2c.tar.gz
webtools.dali-65af2a3bd0d5e41f89ac67fccdfef2b9ad4cfb2c.tar.xz
webtools.dali-65af2a3bd0d5e41f89ac67fccdfef2b9ad4cfb2c.zip
228047 Defaults for entity level caching ... - patch from Pascal
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java157
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/TableItemModelAdapter.java6
3 files changed, 119 insertions, 48 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java
index 0fe159e179..3eddefcb19 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/CacheTypeComposite.java
@@ -10,11 +10,17 @@
package org.eclipse.jpt.eclipselink.ui.internal.caching;
import java.util.Collection;
-
import org.eclipse.jpt.eclipselink.core.internal.context.caching.CacheType;
+import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
/**
@@ -36,54 +42,119 @@ public class CacheTypeComposite extends AbstractPane<EntityCacheProperties>
super(parentComposite, parent);
}
- private EnumFormComboViewer<EntityCacheProperties, CacheType> buildCacheTypeCombo(Composite container) {
- return new EnumFormComboViewer<EntityCacheProperties, CacheType>(this, container) {
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(EntityCacheProperties.CACHE_TYPE_PROPERTY);
- }
-
- @Override
- protected CacheType[] choices() {
- return CacheType.values();
- }
-
- @Override
- protected boolean sortChoices() {
- return false;
- }
-
- @Override
- protected CacheType defaultValue() {
- return this.subject().getDefaultCacheType();
- }
-
- @Override
- protected String displayString(CacheType value) {
- return buildDisplayString(EclipseLinkUiMessages.class, CacheTypeComposite.this, value);
- }
-
- @Override
- protected CacheType getValue() {
- return this.subject().getCacheType();
- }
-
- @Override
- protected void setValue(CacheType value) {
- this.subject().setCacheType(value);
- }
- };
- }
-
@Override
protected void initializeLayout(Composite container) {
this.buildLabeledComposite(
container,
EclipseLinkUiMessages.PersistenceXmlCachingTab_cacheTypeLabel,
- this.buildCacheTypeCombo(container),
+ new CacheTypeCombo(container),
null // TODO IJpaHelpContextIds.
);
}
-}
+
+ private class CacheTypeCombo extends EnumFormComboViewer<EntityCacheProperties, CacheType> {
+
+ private CacheTypeCombo(Composite parent) {
+ super(CacheTypeComposite.this, parent);
+ }
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(EntityCacheProperties.CACHE_TYPE_PROPERTY);
+ }
+
+ private PropertyValueModel<Caching> buildCachingHolder() {
+ return new TransformationPropertyValueModel<EntityCacheProperties, Caching>(getSubjectHolder()) {
+ @Override
+ protected Caching transform_(EntityCacheProperties value) {
+ return value.getCaching();
+ }
+ };
+ }
+
+ private PropertyValueModel<CacheType> buildDefaultCacheTypeHolder() {
+ return new PropertyAspectAdapter<Caching, CacheType>(buildCachingHolder(), Caching.CACHE_TYPE_DEFAULT_PROPERTY) {
+ @Override
+ protected CacheType buildValue_() {
+ CacheType cacheType = subject.getCacheTypeDefault();
+ if (cacheType == null) {
+ cacheType = subject.getDefaultCacheTypeDefault();
+ }
+ return cacheType;
+ }
+ };
+ }
+
+ private PropertyChangeListener buildDefaultCachingTypePropertyChangeListener() {
+ return new SWTPropertyChangeListenerWrapper(
+ buildDefaultCachingTypePropertyChangeListener_()
+ );
+ }
+
+ private PropertyChangeListener buildDefaultCachingTypePropertyChangeListener_() {
+ return new PropertyChangeListener() {
+ public void propertyChanged(PropertyChangeEvent e) {
+ if ((e.getNewValue() != null) && !getCombo().isDisposed()) {
+ CacheTypeCombo.this.doPopulate();
+ }
+ }
+ };
+ }
+
+ @Override
+ protected CacheType[] choices() {
+ return CacheType.values();
+ }
+
+ @Override
+ protected CacheType defaultValue() {
+ return this.subject().getDefaultCacheType();
+ }
+
+ @Override
+ protected String displayString(CacheType value) {
+ return buildDisplayString(
+ EclipseLinkUiMessages.class,
+ CacheTypeComposite.this,
+ value
+ );
+ }
+
+ @Override
+ protected void doPopulate() {
+ // This is required to allow the class loader to let the listener
+ // written above to access this method
+ super.doPopulate();
+ }
+
+ @Override
+ protected CacheType getValue() {
+ return this.subject().getCacheType();
+ }
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+
+ PropertyValueModel<CacheType> defaultCacheTypeHolder =
+ buildDefaultCacheTypeHolder();
+
+ defaultCacheTypeHolder.addPropertyChangeListener(
+ PropertyValueModel.VALUE,
+ buildDefaultCachingTypePropertyChangeListener()
+ );
+ }
+
+ @Override
+ protected void setValue(CacheType value) {
+ this.subject().setCacheType(value);
+ }
+
+ @Override
+ protected boolean sortChoices() {
+ return false;
+ }
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java
index 07520792d3..68f42de3e1 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/EntityListComposite.java
@@ -10,7 +10,6 @@
package org.eclipse.jpt.eclipselink.ui.internal.caching;
import java.util.ListIterator;
-
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
@@ -134,8 +133,7 @@ public class EntityListComposite extends AbstractPane<Caching>
}
private JpaProject jpaProject() {
- // TODO
- return null;
+ return subject().getJpaProject();
}
private ListValueModel<EntityCacheProperties> buildEntityCachingListHolder() {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/TableItemModelAdapter.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/TableItemModelAdapter.java
index 3bf9fd28d7..12675863ce 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/TableItemModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/TableItemModelAdapter.java
@@ -199,8 +199,10 @@ public class TableItemModelAdapter {
}
public void propertyChanged(PropertyChangeEvent event) {
- Table table = tableItem.getParent();
- tableItemChanged(index, tableItem.getData(), table.getColumnCount() == 0);
+ if (!tableItem.isDisposed()) {
+ Table table = tableItem.getParent();
+ tableItemChanged(index, tableItem.getData(), table.getColumnCount() == 0);
+ }
}
}
} \ No newline at end of file

Back to the top