use of org.eclipse.core.internal.databinding.observable.masterdetail.ListDetailValueObservableList in project eclipse.platform.ui by eclipse-platform.
the class ListDetailValueObservableListTest method testUnmodifiability.
@Test
public void testUnmodifiability() {
WritableList masterObservableList = new WritableList();
masterObservableList.add(new SimplePerson());
masterObservableList.add(new SimplePerson());
ListDetailValueObservableList ldol = new ListDetailValueObservableList(masterObservableList, BeansObservables.valueFactory("name"), null);
try {
ldol.add("name");
fail("ListDetailValueObservableList must not be modifiable.");
} catch (UnsupportedOperationException e) {
// expected exception
}
try {
ldol.remove(masterObservableList.get(0));
fail("ListDetailValueObservableList must not be modifiable.");
} catch (UnsupportedOperationException e) {
// expected exception
}
try {
ldol.removeAll(Collections.singleton(masterObservableList.get(0)));
fail("ListDetailValueObservableList must not be modifiable.");
} catch (UnsupportedOperationException e) {
// expected exception
}
try {
ldol.retainAll(Collections.EMPTY_LIST);
fail("ListDetailValueObservableList must not be modifiable.");
} catch (UnsupportedOperationException e) {
// expected exception
}
try {
ldol.move(0, 1);
fail("ListDetailValueObservableList must not be modifiable.");
} catch (UnsupportedOperationException e) {
// expected exception
}
}
use of org.eclipse.core.internal.databinding.observable.masterdetail.ListDetailValueObservableList in project eclipse.platform.ui by eclipse-platform.
the class ListDetailValueObservableListTest method testDuplicateMasterElements.
@Test
public void testDuplicateMasterElements() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(masterList, BeansObservables.valueFactory("name"), String.class);
SimplePerson master = new SimplePerson();
master.setName("name1");
// Add the same master twice.
masterList.add(master);
masterList.add(master);
// Attach the change listener to the detail list.
ListChangeEventTracker changeTracker = ListChangeEventTracker.observe(ldol);
// Setting the name on master should trigger an event on both
// occurrences of in the master list.
master.setName("name2");
// We should have 2 replace diffs, i.e. 4 diff entries.
assertEquals(1, changeTracker.count);
assertEquals(4, changeTracker.event.diff.getDifferences().length);
assertReplaceDiffAt(changeTracker.event.diff, 0, 0, "name1", "name2");
assertReplaceDiffAt(changeTracker.event.diff, 2, 0, "name1", "name2");
// Remove one instance of the master (one will remain).
masterList.remove(master);
// It should still be possible to work on the remaining master instance.
ldol.set(0, "name3");
assertEquals("name3", master.getName());
}
use of org.eclipse.core.internal.databinding.observable.masterdetail.ListDetailValueObservableList in project eclipse.platform.ui by eclipse-platform.
the class ListDetailValueObservableListTest method testGetElementType.
@Test
public void testGetElementType() {
ListDetailValueObservableList ldol = new ListDetailValueObservableList(new WritableList(), BeansObservables.valueFactory("name"), String.class);
assertSame(String.class, ldol.getElementType());
}
use of org.eclipse.core.internal.databinding.observable.masterdetail.ListDetailValueObservableList in project eclipse.platform.ui by eclipse-platform.
the class ListDetailValueObservableListTest method testGetObserved.
@Test
public void testGetObserved() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(masterList, BeansObservables.valueFactory("name"), String.class);
// The observed object is the master list.
assertSame(masterList, ldol.getObserved());
}
use of org.eclipse.core.internal.databinding.observable.masterdetail.ListDetailValueObservableList in project eclipse.platform.ui by eclipse-platform.
the class ListDetailValueObservableListTest method testDisposeOnMasterDisposed.
@Test
public void testDisposeOnMasterDisposed() {
WritableList masterList = new WritableList();
ListDetailValueObservableList ldol = new ListDetailValueObservableList(masterList, BeansObservables.valueFactory("name"), String.class);
// Initially, nothing should be disposed.
assertFalse(masterList.isDisposed());
assertFalse(ldol.isDisposed());
// Upon disposing the master list, the detail list should be disposed as
// well.
masterList.dispose();
assertTrue(masterList.isDisposed());
assertTrue(ldol.isDisposed());
}
Aggregations