Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2009-04-03 21:40:11 +0000
committerpfullbright2009-04-03 21:40:11 +0000
commitade32cc190613ad38040020998f53d1d8bc223b6 (patch)
treee560aabda94c926a86b00edb696377036bf0fe2c
parent90b521c75922006473ac410564c0f9c81d79510d (diff)
downloadwebtools.dali-ade32cc190613ad38040020998f53d1d8bc223b6.tar.gz
webtools.dali-ade32cc190613ad38040020998f53d1d8bc223b6.tar.xz
webtools.dali-ade32cc190613ad38040020998f53d1d8bc223b6.zip
fixed npe when switching between relationship mapping and non-relationship mapping
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnComposite.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java112
2 files changed, 151 insertions, 20 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnComposite.java
index 922b0b9060..23913acf17 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinColumnComposite.java
@@ -26,14 +26,19 @@ import org.eclipse.jpt.ui.internal.widgets.AddRemovePane;
import org.eclipse.jpt.ui.internal.widgets.FormPane;
import org.eclipse.jpt.ui.internal.widgets.PostExecution;
import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter;
+import org.eclipse.jpt.utility.internal.model.value.CachingTransformationPropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel;
import org.eclipse.jpt.utility.internal.model.value.ItemPropertyListValueModelAdapter;
import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
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.ReadOnlyWritablePropertyValueModelWrapper;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.ValueListAdapter;
import org.eclipse.jpt.utility.internal.model.value.swing.ObjectListSelectionModel;
+import org.eclipse.jpt.utility.model.event.StateChangeEvent;
+import org.eclipse.jpt.utility.model.listener.StateChangeListener;
import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
@@ -351,18 +356,58 @@ public class JoinColumnComposite
private class JoinColumnPaneEnablerHolder
- extends ListPropertyValueModelAdapter<Boolean>
- implements PropertyValueModel<Boolean>
+ extends CachingTransformationPropertyValueModel<JoinColumnJoiningStrategy, Boolean>
{
+ private StateChangeListener stateChangeListener;
+
+
public JoinColumnPaneEnablerHolder() {
- super(buildSpecifiedJoinColumnsListHolder());
+ super(
+ new ValueListAdapter<JoinColumnJoiningStrategy>(
+ new ReadOnlyWritablePropertyValueModelWrapper(getSubjectHolder()),
+ JoinColumnJoiningStrategy.SPECIFIED_JOIN_COLUMNS_LIST));
+ this.stateChangeListener = buildStateChangeListener();
+ }
+
+
+ private StateChangeListener buildStateChangeListener() {
+ return new StateChangeListener() {
+ public void stateChanged(StateChangeEvent event) {
+ valueStateChanged(event);
+ }
+ };
+ }
+
+ private void valueStateChanged(StateChangeEvent event) {
+ Object oldValue = this.cachedValue;
+ Object newValue = transformNew(this.valueHolder.getValue());
+ firePropertyChanged(VALUE, oldValue, newValue);
}
@Override
- protected Boolean buildValue() {
- boolean virtual = getSubject().getRelationshipReference().getRelationshipMapping().getPersistentAttribute().isVirtual();
- return Boolean.valueOf(!virtual && this.listHolder.size() > 0);
+ protected Boolean transform(JoinColumnJoiningStrategy value) {
+ if (value == null) {
+ return false;
+ }
+ return super.transform(value);
+ }
+
+ @Override
+ protected Boolean transform_(JoinColumnJoiningStrategy value) {
+ boolean virtual = value.getRelationshipReference().getRelationshipMapping().getPersistentAttribute().isVirtual();
+ return Boolean.valueOf(! virtual && value.specifiedJoinColumnsSize() > 0);
+ }
+
+ @Override
+ protected void engageValueHolder() {
+ super.engageValueHolder();
+ this.valueHolder.addStateChangeListener(this.stateChangeListener);
+ }
+
+ @Override
+ protected void disengageValueHolder() {
+ this.valueHolder.removeStateChangeListener(this.stateChangeListener);
+ super.disengageValueHolder();
}
-
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java
index 651b27775a..e75a8fbdd3 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/JoinTableComposite.java
@@ -25,9 +25,14 @@ import org.eclipse.jpt.ui.internal.mappings.db.TableCombo;
import org.eclipse.jpt.ui.internal.mappings.details.JoinColumnsComposite.IJoinColumnsEditor;
import org.eclipse.jpt.ui.internal.widgets.FormPane;
import org.eclipse.jpt.ui.internal.widgets.PostExecution;
+import org.eclipse.jpt.utility.internal.model.value.CachingTransformationPropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
import org.eclipse.jpt.utility.internal.model.value.ListPropertyValueModelAdapter;
+import org.eclipse.jpt.utility.internal.model.value.ReadOnlyWritablePropertyValueModelWrapper;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.ValueListAdapter;
+import org.eclipse.jpt.utility.model.event.StateChangeEvent;
+import org.eclipse.jpt.utility.model.listener.StateChangeListener;
import org.eclipse.jpt.utility.model.value.ListValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
@@ -699,34 +704,115 @@ public class JoinTableComposite extends FormPane<JoinTable>
private class JoinColumnPaneEnablerHolder
- extends ListPropertyValueModelAdapter<Boolean>
- implements PropertyValueModel<Boolean>
+ extends CachingTransformationPropertyValueModel<JoinTable, Boolean>
{
+ private StateChangeListener stateChangeListener;
+
+
public JoinColumnPaneEnablerHolder() {
- super(buildSpecifiedJoinColumnsListHolder());
+ super(
+ new ValueListAdapter<JoinTable>(
+ new ReadOnlyWritablePropertyValueModelWrapper(getSubjectHolder()),
+ JoinTable.SPECIFIED_JOIN_COLUMNS_LIST));
+ this.stateChangeListener = buildStateChangeListener();
+ }
+
+
+ private StateChangeListener buildStateChangeListener() {
+ return new StateChangeListener() {
+ public void stateChanged(StateChangeEvent event) {
+ valueStateChanged(event);
+ }
+ };
+ }
+
+ private void valueStateChanged(StateChangeEvent event) {
+ Object oldValue = this.cachedValue;
+ Object newValue = transformNew(this.valueHolder.getValue());
+ firePropertyChanged(VALUE, oldValue, newValue);
}
@Override
- protected Boolean buildValue() {
- boolean virtual = getSubject().getRelationshipMapping().getPersistentAttribute().isVirtual();
- return Boolean.valueOf(!virtual && this.listHolder.size() > 0);
+ protected Boolean transform(JoinTable value) {
+ if (value == null) {
+ return false;
+ }
+ return super.transform(value);
+ }
+
+ @Override
+ protected Boolean transform_(JoinTable value) {
+ boolean virtual = value.getRelationshipMapping().getPersistentAttribute().isVirtual();
+ return Boolean.valueOf(! virtual && value.specifiedJoinColumnsSize() > 0);
+ }
+
+ @Override
+ protected void engageValueHolder() {
+ super.engageValueHolder();
+ this.valueHolder.addStateChangeListener(this.stateChangeListener);
+ }
+
+ @Override
+ protected void disengageValueHolder() {
+ this.valueHolder.removeStateChangeListener(this.stateChangeListener);
+ super.disengageValueHolder();
}
}
private class InverseJoinColumnPaneEnablerHolder
- extends ListPropertyValueModelAdapter<Boolean>
- implements PropertyValueModel<Boolean>
+ extends CachingTransformationPropertyValueModel<JoinTable, Boolean>
{
+ private StateChangeListener stateChangeListener;
+
+
public InverseJoinColumnPaneEnablerHolder() {
- super(buildSpecifiedInverseJoinColumnsListHolder());
+ super(
+ new ValueListAdapter<JoinTable>(
+ new ReadOnlyWritablePropertyValueModelWrapper(getSubjectHolder()),
+ JoinTable.SPECIFIED_INVERSE_JOIN_COLUMNS_LIST));
+ this.stateChangeListener = buildStateChangeListener();
+ }
+
+
+ private StateChangeListener buildStateChangeListener() {
+ return new StateChangeListener() {
+ public void stateChanged(StateChangeEvent event) {
+ valueStateChanged(event);
+ }
+ };
+ }
+
+ private void valueStateChanged(StateChangeEvent event) {
+ Object oldValue = this.cachedValue;
+ Object newValue = transformNew(this.valueHolder.getValue());
+ firePropertyChanged(VALUE, oldValue, newValue);
}
@Override
- protected Boolean buildValue() {
- boolean virtual = getSubject().getRelationshipMapping().getPersistentAttribute().isVirtual();
- return Boolean.valueOf(!virtual && this.listHolder.size() > 0);
+ protected Boolean transform(JoinTable value) {
+ if (value == null) {
+ return false;
+ }
+ return super.transform(value);
+ }
+
+ @Override
+ protected Boolean transform_(JoinTable value) {
+ boolean virtual = value.getRelationshipMapping().getPersistentAttribute().isVirtual();
+ return Boolean.valueOf(! virtual && value.specifiedInverseJoinColumnsSize() > 0);
+ }
+
+ @Override
+ protected void engageValueHolder() {
+ super.engageValueHolder();
+ this.valueHolder.addStateChangeListener(this.stateChangeListener);
+ }
+
+ @Override
+ protected void disengageValueHolder() {
+ this.valueHolder.removeStateChangeListener(this.stateChangeListener);
+ super.disengageValueHolder();
}
-
}
} \ No newline at end of file

Back to the top