Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 241318
Collapse All | Expand All

(-)src/org/eclipse/core/internal/databinding/observable/masterdetail/DetailObservableSet.java (-1 / +3 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Matthew Hall - bug 221351
10
 *     Matthew Hall - bug 221351
11
 *     Ovidio Mallo - bug 241318
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.core.internal.databinding.observable.masterdetail;
13
package org.eclipse.core.internal.databinding.observable.masterdetail;
13
14
Lines 136-147 Link Here
136
137
137
		if (outerObservableValue != null) {
138
		if (outerObservableValue != null) {
138
			outerObservableValue.removeValueChangeListener(outerChangeListener);
139
			outerObservableValue.removeValueChangeListener(outerChangeListener);
139
			outerObservableValue.dispose();
140
		}
140
		}
141
		if (innerObservableSet != null) {
141
		if (innerObservableSet != null) {
142
			innerObservableSet.removeSetChangeListener(innerChangeListener);
142
			innerObservableSet.removeSetChangeListener(innerChangeListener);
143
			innerObservableSet.dispose();
143
			innerObservableSet.dispose();
144
		}
144
		}
145
		outerObservableValue = null;
146
		outerChangeListener = null;
145
		currentOuterValue = null;
147
		currentOuterValue = null;
146
		factory = null;
148
		factory = null;
147
		innerObservableSet = null;
149
		innerObservableSet = null;
(-)src/org/eclipse/core/internal/databinding/observable/masterdetail/DetailObservableValue.java (-1 / +3 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Brad Reynolds - bug 164653
10
 *     Brad Reynolds - bug 164653
11
 *     Brad Reynolds - bug 147515
11
 *     Brad Reynolds - bug 147515
12
 *     Ovidio Mallo - bug 241318
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.core.internal.databinding.observable.masterdetail;
14
package org.eclipse.core.internal.databinding.observable.masterdetail;
14
15
Lines 114-125 Link Here
114
115
115
		if (outerObservableValue != null) {
116
		if (outerObservableValue != null) {
116
			outerObservableValue.removeValueChangeListener(outerChangeListener);
117
			outerObservableValue.removeValueChangeListener(outerChangeListener);
117
			outerObservableValue.dispose();
118
		}
118
		}
119
		if (innerObservableValue != null) {
119
		if (innerObservableValue != null) {
120
			innerObservableValue.removeValueChangeListener(innerChangeListener);
120
			innerObservableValue.removeValueChangeListener(innerChangeListener);
121
			innerObservableValue.dispose();
121
			innerObservableValue.dispose();
122
		}
122
		}
123
		outerObservableValue = null;
124
		outerChangeListener = null;
123
		currentOuterValue = null;
125
		currentOuterValue = null;
124
		factory = null;
126
		factory = null;
125
		innerObservableValue = null;
127
		innerObservableValue = null;
(-)src/org/eclipse/core/internal/databinding/observable/masterdetail/DetailObservableList.java (-1 / +3 lines)
Lines 9-14 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Brad Reynolds - bug 147515
10
 *     Brad Reynolds - bug 147515
11
 *     Matthew Hall - bug 221351
11
 *     Matthew Hall - bug 221351
12
 *     Ovidio Mallo - bug 241318
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.core.internal.databinding.observable.masterdetail;
14
package org.eclipse.core.internal.databinding.observable.masterdetail;
14
15
Lines 154-165 Link Here
154
155
155
		if (outerObservableValue != null) {
156
		if (outerObservableValue != null) {
156
			outerObservableValue.removeValueChangeListener(outerChangeListener);
157
			outerObservableValue.removeValueChangeListener(outerChangeListener);
157
			outerObservableValue.dispose();
158
		}
158
		}
159
		if (innerObservableList != null) {
159
		if (innerObservableList != null) {
160
			innerObservableList.removeListChangeListener(innerChangeListener);
160
			innerObservableList.removeListChangeListener(innerChangeListener);
161
			innerObservableList.dispose();
161
			innerObservableList.dispose();
162
		}
162
		}
163
		outerObservableValue = null;
164
		outerChangeListener = null;
163
		currentOuterValue = null;
165
		currentOuterValue = null;
164
		factory = null;
166
		factory = null;
165
		innerObservableList = null;
167
		innerObservableList = null;
(-)src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableListTest.java (-18 / +36 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Brad Reynolds - initial API and implementation
9
 *     Brad Reynolds - initial API and implementation
10
 *     Matthew Hall - bugs 208858, 221351, 213145
10
 *     Matthew Hall - bugs 208858, 221351, 213145
11
 *     Ovidio Mallo - bug 241318
11
 ******************************************************************************/
12
 ******************************************************************************/
12
13
13
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
14
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
Lines 44-58 Link Here
44
	public void testElementTypeNull() throws Exception {
45
	public void testElementTypeNull() throws Exception {
45
		WritableValue observableValue = new WritableValue(new WritableList(new ArrayList(), Object.class), null);
46
		WritableValue observableValue = new WritableValue(new WritableList(new ArrayList(), Object.class), null);
46
47
47
		class Factory implements IObservableFactory {
48
		WritableListFactory factory = new WritableListFactory();
48
			Object type = Object.class;
49
50
			public IObservable createObservable(Object target) {
51
				return new WritableList(new ArrayList(), type);
52
			}
53
		}
54
55
		Factory factory = new Factory();
56
		DetailObservableList detailObservable = new DetailObservableList(
49
		DetailObservableList detailObservable = new DetailObservableList(
57
				factory, observableValue, null);
50
				factory, observableValue, null);
58
		assertNull(detailObservable.getElementType());
51
		assertNull(detailObservable.getElementType());
Lines 72-86 Link Here
72
		WritableValue observableValue = new WritableValue(new WritableList(new ArrayList(), Object.class),
65
		WritableValue observableValue = new WritableValue(new WritableList(new ArrayList(), Object.class),
73
				null);
66
				null);
74
67
75
		class Factory implements IObservableFactory {
68
		WritableListFactory factory = new WritableListFactory();
76
			Object type = Object.class;
77
78
			public IObservable createObservable(Object target) {
79
				return new WritableList(new ArrayList(), type);
80
			}
81
		}
82
83
		Factory factory = new Factory();
84
		DetailObservableList detailObservable = new DetailObservableList(factory,
69
		DetailObservableList detailObservable = new DetailObservableList(factory,
85
				observableValue, Object.class);
70
				observableValue, Object.class);
86
		assertEquals(factory.type, detailObservable.getElementType());
71
		assertEquals(factory.type, detailObservable.getElementType());
Lines 94-99 Link Here
94
		}
79
		}
95
	}
80
	}
96
81
82
	/**
83
	 * Asserts that the master observable value is not disposed upon disposing
84
	 * its detail observable value (bug 241318).
85
	 */
86
	public void testMasterNotDisposedWhenDetailDisposed() {
87
		class OuterObservable extends WritableValue {
88
			boolean disposed = false;
89
90
			public synchronized void dispose() {
91
				disposed = true;
92
				super.dispose();
93
			}
94
		}
95
96
		OuterObservable outerObservable = new OuterObservable();
97
		WritableListFactory factory = new WritableListFactory();
98
		DetailObservableList detailObservable = new DetailObservableList(
99
				factory, outerObservable, null);
100
101
		assertFalse(outerObservable.disposed);
102
103
		detailObservable.dispose();
104
		assertFalse(outerObservable.disposed);
105
	}
106
107
	private static class WritableListFactory implements IObservableFactory {
108
		Object type = Object.class;
109
110
		public IObservable createObservable(Object target) {
111
			return new WritableList(new ArrayList(), type);
112
		}
113
	}
114
97
	public static Test suite() {
115
	public static Test suite() {
98
		TestSuite suite = new TestSuite(DetailObservableListTest.class.getName());
116
		TestSuite suite = new TestSuite(DetailObservableListTest.class.getName());
99
		suite.addTestSuite(DetailObservableListTest.class);
117
		suite.addTestSuite(DetailObservableListTest.class);
(-)src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableSetTest.java (-18 / +36 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     Brad Reynolds - initial API and implementation
9
 *     Brad Reynolds - initial API and implementation
10
 *     Matthew Hall - bugs 221351, 213145
10
 *     Matthew Hall - bugs 221351, 213145
11
 *     Ovidio Mallo - bug 241318
11
 ******************************************************************************/
12
 ******************************************************************************/
12
13
13
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
14
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
Lines 47-61 Link Here
47
		WritableValue observableValue = new WritableValue(new WritableSet(new HashSet(), Object.class),
48
		WritableValue observableValue = new WritableValue(new WritableSet(new HashSet(), Object.class),
48
				null);
49
				null);
49
50
50
		class Factory implements IObservableFactory {
51
		WritableSetFactory factory = new WritableSetFactory();
51
			Object type;
52
53
			public IObservable createObservable(Object target) {
54
				return new WritableSet(new HashSet(), type);
55
			}
56
		}
57
58
		Factory factory = new Factory();
59
		DetailObservableSet detailObservable = new DetailObservableSet(factory,
52
		DetailObservableSet detailObservable = new DetailObservableSet(factory,
60
				observableValue, null);
53
				observableValue, null);
61
		assertNull(detailObservable.getElementType());
54
		assertNull(detailObservable.getElementType());
Lines 82-96 Link Here
82
		WritableValue observableValue = new WritableValue(new WritableSet(new HashSet(), Object.class),
75
		WritableValue observableValue = new WritableValue(new WritableSet(new HashSet(), Object.class),
83
				null);
76
				null);
84
77
85
		class Factory implements IObservableFactory {
78
		WritableSetFactory factory = new WritableSetFactory();
86
			Object type = Object.class;
87
88
			public IObservable createObservable(Object target) {
89
				return new WritableSet(new HashSet(), type);
90
			}
91
		}
92
93
		Factory factory = new Factory();
94
		DetailObservableSet detailObservable = new DetailObservableSet(factory,
79
		DetailObservableSet detailObservable = new DetailObservableSet(factory,
95
				observableValue, Object.class);
80
				observableValue, Object.class);
96
		assertEquals(factory.type, detailObservable.getElementType());
81
		assertEquals(factory.type, detailObservable.getElementType());
Lines 104-109 Link Here
104
		}
89
		}
105
	}
90
	}
106
91
92
	/**
93
	 * Asserts that the master observable value is not disposed upon disposing
94
	 * its detail observable value (bug 241318).
95
	 */
96
	public void testMasterNotDisposedWhenDetailDisposed() {
97
		class OuterObservable extends WritableValue {
98
			boolean disposed = false;
99
100
			public synchronized void dispose() {
101
				disposed = true;
102
				super.dispose();
103
			}
104
		}
105
106
		OuterObservable outerObservable = new OuterObservable();
107
		WritableSetFactory factory = new WritableSetFactory();
108
		DetailObservableSet detailObservable = new DetailObservableSet(factory,
109
				outerObservable, null);
110
111
		assertFalse(outerObservable.disposed);
112
113
		detailObservable.dispose();
114
		assertFalse(outerObservable.disposed);
115
	}
116
117
	private static class WritableSetFactory implements IObservableFactory {
118
		Object type = Object.class;
119
120
		public IObservable createObservable(Object target) {
121
			return new WritableSet(new HashSet(), type);
122
		}
123
	}
124
107
	public static Test suite() {
125
	public static Test suite() {
108
		TestSuite suite = new TestSuite(DetailObservableSetTest.class.getName());
126
		TestSuite suite = new TestSuite(DetailObservableSetTest.class.getName());
109
		suite.addTestSuite(DetailObservableSetTest.class);
127
		suite.addTestSuite(DetailObservableSetTest.class);
(-)src/org/eclipse/core/tests/internal/databinding/observable/masterdetail/DetailObservableValueTest.java (-1 / +27 lines)
Lines 9-14 Link Here
9
 *     Brad Reynolds - initial API and implementation
9
 *     Brad Reynolds - initial API and implementation
10
 *     Brad Reynolds - bug 147515
10
 *     Brad Reynolds - bug 147515
11
 *     Matthew Hall - bugs 221351, 213145
11
 *     Matthew Hall - bugs 221351, 213145
12
 *     Ovidio Mallo - bug 241318
12
 ******************************************************************************/
13
 ******************************************************************************/
13
14
14
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
15
package org.eclipse.core.tests.internal.databinding.observable.masterdetail;
Lines 80-86 Link Here
80
		outerObservable.setValue("2");
81
		outerObservable.setValue("2");
81
		assertNull("value type should be ignored", detailObservable.getValueType());
82
		assertNull("value type should be ignored", detailObservable.getValueType());
82
	}
83
	}
83
	
84
85
	/**
86
	 * Asserts that the master observable value is not disposed upon disposing
87
	 * its detail observable value (bug 241318).
88
	 */
89
	public void testMasterNotDisposedWhenDetailDisposed() {
90
		class OuterObservable extends WritableValue {
91
			boolean disposed = false;
92
93
			public synchronized void dispose() {
94
				disposed = true;
95
				super.dispose();
96
			}
97
		}
98
99
		OuterObservable outerObservable = new OuterObservable();
100
		WritableValueFactory factory = new WritableValueFactory();
101
		DetailObservableValue detailObservable = new DetailObservableValue(
102
				outerObservable, factory, null);
103
104
		assertFalse(outerObservable.disposed);
105
106
		detailObservable.dispose();
107
		assertFalse(outerObservable.disposed);
108
	}
109
84
	/**
110
	/**
85
	 * Factory that creates WritableValues with the target as the value.
111
	 * Factory that creates WritableValues with the target as the value.
86
	 */
112
	 */

Return to bug 241318