Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortle2008-04-29 22:13:21 +0000
committertle2008-04-29 22:13:21 +0000
commit1eba97849c7970f81b5dd093615ffb684e53cefa (patch)
treefc7edfa6d979599e9e7dc7a479481df3ad7e77d1
parent62193f5f20adb4b3a1a501d3d4c1c69308452fe0 (diff)
downloadwebtools.dali-1eba97849c7970f81b5dd093615ffb684e53cefa.tar.gz
webtools.dali-1eba97849c7970f81b5dd093615ffb684e53cefa.tar.xz
webtools.dali-1eba97849c7970f81b5dd093615ffb684e53cefa.zip
Fix for 228047 and 228038 - patch from Pascal
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/SharedCacheComposite.java104
1 files changed, 78 insertions, 26 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/SharedCacheComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/SharedCacheComposite.java
index cd99900964..9e6febdc88 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/SharedCacheComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/caching/SharedCacheComposite.java
@@ -9,12 +9,18 @@
*******************************************************************************/
package org.eclipse.jpt.eclipselink.ui.internal.caching;
+import java.util.ArrayList;
+
import org.eclipse.jpt.eclipselink.core.internal.context.caching.Caching;
import org.eclipse.jpt.eclipselink.ui.internal.EclipseLinkUiMessages;
import org.eclipse.jpt.ui.internal.widgets.AbstractPane;
import org.eclipse.jpt.ui.internal.widgets.TriStateCheckBox;
+import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel;
+import org.eclipse.jpt.utility.internal.model.value.ListPropertyValueModelAdapter;
import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.PropertyListValueModelAdapter;
import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.osgi.util.NLS;
@@ -39,9 +45,64 @@ public class SharedCacheComposite extends AbstractPane<EntityCacheProperties>
super(parentComposite, parent);
}
+ private PropertyValueModel<Caching> buildCachingHolder() {
+ return new TransformationPropertyValueModel<EntityCacheProperties, Caching>(getSubjectHolder()) {
+ @Override
+ protected Caching transform_(EntityCacheProperties value) {
+ return value.getCaching();
+ }
+ };
+ }
+
+ private PropertyValueModel<Boolean> buildDefaultAndNonDefaultSharedCacheHolder() {
+ return new ListPropertyValueModelAdapter<Boolean>(
+ buildDefaultAndNonDefaultSharedCacheListHolder()
+ ) {
+ @Override
+ protected Boolean buildValue() {
+ // If the number of ListValueModel equals 1, that means the shared
+ // Cache properties is not set (partially selected), which means we
+ // want to see the default value appended to the text
+ if (listHolder.size() == 1) {
+ return (Boolean) listHolder.listIterator().next();
+ }
+ return null;
+ }
+ };
+ };
+
+ private ListValueModel<Boolean> buildDefaultAndNonDefaultSharedCacheListHolder() {
+ ArrayList<ListValueModel<Boolean>> holders = new ArrayList<ListValueModel<Boolean>>(2);
+ holders.add(buildSharedCacheListHolder());
+ holders.add(buildDefaultSharedCacheListHolder());
+
+ return new CompositeListValueModel<ListValueModel<Boolean>, Boolean>(
+ holders
+ );
+ }
+
+ private PropertyValueModel<Boolean> buildDefaultSharedCacheHolder() {
+ return new PropertyAspectAdapter<Caching, Boolean>(buildCachingHolder(), Caching.SHARED_CACHE_DEFAULT_PROPERTY) {
+ @Override
+ protected Boolean buildValue_() {
+ Boolean value = subject.getSharedCacheDefault();
+ if (value == null) {
+ value = subject.getDefaultSharedCacheDefault();
+ }
+ return value;
+ }
+ };
+ }
+
+ private ListValueModel<Boolean> buildDefaultSharedCacheListHolder() {
+ return new PropertyListValueModelAdapter<Boolean>(
+ buildDefaultSharedCacheHolder()
+ );
+ }
+
private WritablePropertyValueModel<Boolean> buildSharedCacheHolder() {
return new PropertyAspectAdapter<EntityCacheProperties, Boolean>(
- getSubjectHolder(), Caching.SHARED_CACHE_PROPERTY) {
+ getSubjectHolder(), EntityCacheProperties.SHARED_CACHE_PROPERTY) {
@Override
protected Boolean buildValue_() {
return this.subject.getSharedCache();
@@ -51,31 +112,22 @@ public class SharedCacheComposite extends AbstractPane<EntityCacheProperties>
protected void setValue_(Boolean value) {
this.subject.setSharedCache(value);
}
-
- @Override
- protected void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
};
}
+ private ListValueModel<Boolean> buildSharedCacheListHolder() {
+ return new PropertyListValueModelAdapter<Boolean>(
+ buildSharedCacheHolder()
+ );
+ }
+
private PropertyValueModel<String> buildSharedCacheStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildSharedCacheHolder()) {
+ return new TransformationPropertyValueModel<Boolean, String>(buildDefaultAndNonDefaultSharedCacheHolder()) {
@Override
protected String transform(Boolean value) {
- if ((subject() != null) && (value == null)) {
- Boolean defaultValue = subject().getDefaultSharedCache();
- if (defaultValue != null) {
- String defaultStringValue = defaultValue ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
- return NLS.bind(EclipseLinkUiMessages.PersistenceXmlCachingTab_defaultSharedCacheLabel, defaultStringValue);
- }
+ if (value != null) {
+ String defaultStringValue = value ? EclipseLinkUiMessages.Boolean_True : EclipseLinkUiMessages.Boolean_False;
+ return NLS.bind(EclipseLinkUiMessages.PersistenceXmlCachingTab_defaultSharedCacheLabel, defaultStringValue);
}
return EclipseLinkUiMessages.PersistenceXmlCachingTab_sharedCacheLabel;
}
@@ -83,6 +135,12 @@ public class SharedCacheComposite extends AbstractPane<EntityCacheProperties>
}
@Override
+ public void enableWidgets(boolean enabled) {
+ super.enableWidgets(enabled);
+ this.sharedCacheCheckBox.setEnabled(enabled);
+ }
+
+ @Override
protected void initializeLayout(Composite container) {
this.sharedCacheCheckBox = this.buildTriStateCheckBoxWithDefault(
@@ -94,10 +152,4 @@ public class SharedCacheComposite extends AbstractPane<EntityCacheProperties>
// EclipseLinkHelpContextIds.CACHING_SHARED_CACHE
);
}
-
- @Override
- public void enableWidgets(boolean enabled) {
- super.enableWidgets(enabled);
- this.sharedCacheCheckBox.setEnabled(enabled);
- }
} \ No newline at end of file

Back to the top