Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Pazderski2019-05-18 22:03:52 +0000
committerPaul Pazderski2019-06-14 12:39:45 +0000
commit4e5b4450176cf71c5f3620377ec4d7ef39392c0c (patch)
tree2f248a44fd5072a873c92f9fc18f748b3aad39c0 /org.eclipse.debug.tests
parenta27187cb1a408caaadf5eca6909bbe03a8b297a4 (diff)
downloadeclipse.platform.debug-4e5b4450176cf71c5f3620377ec4d7ef39392c0c.tar.gz
eclipse.platform.debug-4e5b4450176cf71c5f3620377ec4d7ef39392c0c.tar.xz
eclipse.platform.debug-4e5b4450176cf71c5f3620377ec4d7ef39392c0c.zip
Bug 547304 - [cleanup] Fix wrong space/tab indentationI20190616-1800I20190615-1800I20190614-1800
This change fixes space or mixed tab/space indentations in all Java files. This also includes two or three space indentations and even fix most stray single spaces in indentations. The change includes only whitespace formatting and no code changes. Change-Id: I95f385f1587b72776aee5d955b66e82539dedc3c
Diffstat (limited to 'org.eclipse.debug.tests')
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java12
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/LocalSuite.java8
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java34
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java2
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java934
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/DynamicRenderingBindings.java36
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/MemoryRenderingTests.java68
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java80
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ChildrenUpdateTests.java74
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ColumnPresentationTests.java94
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java330
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/DeltaTests.java842
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTests.java376
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java54
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerCheckTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerContentTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerDeltaTests.java20
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerFilterTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerLazyTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPerformanceTests.java16
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPopupTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerSelectionTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerStateTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerTopIndexTests.java576
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerUpdateTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/LazyTests.java262
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PerformanceTests.java390
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PopupTests.java204
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java22
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/SelectionTests.java292
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/StateTests.java1266
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModel.java1668
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java114
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreePathWrapper.java68
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/UpdateTests.java796
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerContentTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerDeltaTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerFilterTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerLazyModeTests.java14
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPerformanceTests.java16
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPopupTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerSelectionTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerStateTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerUpdateTests.java10
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VisibleVirtualItemValidator.java124
45 files changed, 4471 insertions, 4471 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java
index d1858f09e..317599be1 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java
@@ -51,7 +51,7 @@ import junit.framework.Test;
import junit.framework.TestSuite;
/**
- * Tests for integration and nightly builds.
+ * Tests for integration and nightly builds.
*
* @since 3.6
*/
@@ -74,18 +74,18 @@ public class AutomatedSuite extends TestSuite {
addTest(new TestSuite(SourceLookupFacilityTests.class));
// BP tests
addTest(new TestSuite(BreakpointOrderingTests.class));
- // Note: jface viewer tests were moved out of nightly tests
- // due to frequent problems on nightly build machines.
- // (Bug 343308).
+ // Note: jface viewer tests were moved out of nightly tests
+ // due to frequent problems on nightly build machines.
+ // (Bug 343308).
// Virtual viewer tests
addTest(new TestSuite(VirtualViewerDeltaTests.class));
- addTest(new TestSuite(VirtualViewerContentTests.class));
+ addTest(new TestSuite(VirtualViewerContentTests.class));
addTest(new TestSuite(VirtualViewerLazyModeTests.class));
addTest(new TestSuite(VirtualViewerSelectionTests.class));
addTest(new TestSuite(VirtualViewerStateTests.class));
addTest(new TestSuite(VirtualViewerUpdateTests.class));
- addTest(new TestSuite(VirtualViewerFilterTests.class));
+ addTest(new TestSuite(VirtualViewerFilterTests.class));
// Viewer neutral tests
addTest(new TestSuite(FilterTransformTests.class));
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/LocalSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/LocalSuite.java
index 4475e9fd1..58ef4f76a 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/LocalSuite.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/LocalSuite.java
@@ -55,9 +55,9 @@ public class LocalSuite extends TestSuite {
addTest(new TestSuite(JFaceViewerSelectionTests.class));
addTest(new TestSuite(JFaceViewerStateTests.class));
addTest(new TestSuite(JFaceViewerUpdateTests.class));
- addTest(new TestSuite(JFaceViewerLazyTests.class));
- addTest(new TestSuite(JFaceViewerTopIndexTests.class));
- addTest(new TestSuite(JFaceViewerFilterTests.class));
- addTest(new TestSuite(ColumnPresentationTests.class));
+ addTest(new TestSuite(JFaceViewerLazyTests.class));
+ addTest(new TestSuite(JFaceViewerTopIndexTests.class));
+ addTest(new TestSuite(JFaceViewerFilterTests.class));
+ addTest(new TestSuite(ColumnPresentationTests.class));
}
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java
index a18468823..4d44939fd 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/PerformanceSuite.java
@@ -26,24 +26,24 @@ import org.eclipse.debug.tests.viewer.model.VirtualViewerPerformanceTests;
*/
public class PerformanceSuite extends TestSuite {
- /**
- * Returns the suite. This is required to use the JUnit Launcher.
- *
- * @return the test suite
- */
- public static Test suite() {
- return new PerformanceSuite();
- }
+ /**
+ * Returns the suite. This is required to use the JUnit Launcher.
+ *
+ * @return the test suite
+ */
+ public static Test suite() {
+ return new PerformanceSuite();
+ }
- /**
- * Constructs the automated test suite. Adds all tests.
- */
- public PerformanceSuite() {
- // JFace viewer tests
- addTest(new TestSuite(JFaceViewerPerformanceTests.class));
+ /**
+ * Constructs the automated test suite. Adds all tests.
+ */
+ public PerformanceSuite() {
+ // JFace viewer tests
+ addTest(new TestSuite(JFaceViewerPerformanceTests.class));
- // Virtual viewer tests
- addTest(new TestSuite(VirtualViewerPerformanceTests.class));
- }
+ // Virtual viewer tests
+ addTest(new TestSuite(VirtualViewerPerformanceTests.class));
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java
index 95ef799ea..11c32f86c 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java
@@ -61,7 +61,7 @@ public class TestsPlugin extends AbstractUIPlugin {
}
/**
- * Returns the shared instance
+ * Returns the shared instance
*
* @return the shared instance
*/
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
index 6e89c9859..af364ea97 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java
@@ -227,16 +227,16 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* - Boolean2 = false
*/
protected ILaunchConfigurationWorkingCopy newConfiguration(IContainer container, String name) throws CoreException {
- ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
- assertTrue("Should support debug mode", type.supportsMode(ILaunchManager.DEBUG_MODE)); //$NON-NLS-1$
- assertTrue("Should support run mode", type.supportsMode(ILaunchManager.RUN_MODE)); //$NON-NLS-1$
- ILaunchConfigurationWorkingCopy wc = type.newInstance(container, name);
- wc.setAttribute("String1", "String1"); //$NON-NLS-1$ //$NON-NLS-2$
- wc.setAttribute("Int1", 1); //$NON-NLS-1$
- wc.setAttribute("Boolean1", true); //$NON-NLS-1$
- wc.setAttribute("Boolean2", false); //$NON-NLS-1$
- assertTrue("Should need saving", wc.isDirty()); //$NON-NLS-1$
- return wc;
+ ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
+ assertTrue("Should support debug mode", type.supportsMode(ILaunchManager.DEBUG_MODE)); //$NON-NLS-1$
+ assertTrue("Should support run mode", type.supportsMode(ILaunchManager.RUN_MODE)); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = type.newInstance(container, name);
+ wc.setAttribute("String1", "String1"); //$NON-NLS-1$ //$NON-NLS-2$
+ wc.setAttribute("Int1", 1); //$NON-NLS-1$
+ wc.setAttribute("Boolean1", true); //$NON-NLS-1$
+ wc.setAttribute("Boolean2", false); //$NON-NLS-1$
+ assertTrue("Should need saving", wc.isDirty()); //$NON-NLS-1$
+ return wc;
}
/**
@@ -244,10 +244,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* or shared, with no attributes
*/
protected ILaunchConfigurationWorkingCopy newEmptyConfiguration(IContainer container, String name) throws CoreException {
- ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
- ILaunchConfigurationWorkingCopy wc = type.newInstance(container, name);
+ ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
+ ILaunchConfigurationWorkingCopy wc = type.newInstance(container, name);
assertEquals("Should have no attributes", 0, wc.getAttributes().size()); //$NON-NLS-1$
- return wc;
+ return wc;
}
/**
@@ -259,16 +259,16 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* - Boolean2 = false
*/
protected ILaunchConfigurationWorkingCopy newPrototype(IContainer container, String name) throws CoreException {
- ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
- assertTrue("Should support debug mode", type.supportsMode(ILaunchManager.DEBUG_MODE)); //$NON-NLS-1$
- assertTrue("Should support run mode", type.supportsMode(ILaunchManager.RUN_MODE)); //$NON-NLS-1$
- ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, name);
- wc.setAttribute("String1", "String1"); //$NON-NLS-1$ //$NON-NLS-2$
- wc.setAttribute("Int1", 1); //$NON-NLS-1$
- wc.setAttribute("Boolean1", true); //$NON-NLS-1$
- wc.setAttribute("Boolean2", false); //$NON-NLS-1$
- assertTrue("Should need saving", wc.isDirty()); //$NON-NLS-1$
- return wc;
+ ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
+ assertTrue("Should support debug mode", type.supportsMode(ILaunchManager.DEBUG_MODE)); //$NON-NLS-1$
+ assertTrue("Should support run mode", type.supportsMode(ILaunchManager.RUN_MODE)); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, name);
+ wc.setAttribute("String1", "String1"); //$NON-NLS-1$ //$NON-NLS-2$
+ wc.setAttribute("Int1", 1); //$NON-NLS-1$
+ wc.setAttribute("Boolean1", true); //$NON-NLS-1$
+ wc.setAttribute("Boolean2", false); //$NON-NLS-1$
+ assertTrue("Should need saving", wc.isDirty()); //$NON-NLS-1$
+ return wc;
}
/**
@@ -276,10 +276,10 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* or shared, with no attributes
*/
protected ILaunchConfigurationWorkingCopy newEmptyPrototype(IContainer container, String name) throws CoreException {
- ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
- ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, name);
- assertEquals("Should have no attributes", 0, wc.getAttributes().size()); //$NON-NLS-1$
- return wc;
+ ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(ID_TEST_LAUNCH_TYPE);
+ ILaunchConfigurationWorkingCopy wc = type.newPrototypeInstance(container, name);
+ assertEquals("Should have no attributes", 0, wc.getAttributes().size()); //$NON-NLS-1$
+ return wc;
}
/**
@@ -302,25 +302,25 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testCreateLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertEquals("String1 should be String1", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Int1 should be 1", handle.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$//$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$//$NON-NLS-2$
+ // retrieve attributes
+ assertEquals("String1 should be String1", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertEquals("Int1 should be 1", handle.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$//$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$//$NON-NLS-2$
- // ensure new handle is the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
+ // ensure new handle is the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
}
/**
@@ -329,32 +329,32 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testLocalName() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "localName"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "localName"); //$NON-NLS-1$
+ ILaunchConfiguration handle = wc.doSave();
+ assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertEquals("Wrong name", handle.getName(), "localName"); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertEquals("Wrong name", handle.getName(), "localName"); //$NON-NLS-1$ //$NON-NLS-2$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
}
/**
* Creates a shared working copy configuration and tests is name.
*/
public void testSharedName() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "sharedName"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "sharedName"); //$NON-NLS-1$
+ ILaunchConfiguration handle = wc.doSave();
+ assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertEquals("Wrong name", handle.getName(), "sharedName"); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertEquals("Wrong name", handle.getName(), "sharedName"); //$NON-NLS-1$ //$NON-NLS-2$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
}
/**
@@ -362,22 +362,22 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testGetAttributes() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
Map<?, ?> attributes = handle.getAttributes();
- // retrieve attributes
- assertEquals("String1 should be String1", "String1", attributes.get("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Int1 should be 1", Integer.valueOf(1), attributes.get("Int1")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Boolean1 should be true", Boolean.TRUE, attributes.get("Boolean1")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Boolean2 should be false", Boolean.FALSE, attributes.get("Boolean2")); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertEquals("String1 should be String1", "String1", attributes.get("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Int1 should be 1", Integer.valueOf(1), attributes.get("Int1")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Boolean1 should be true", Boolean.TRUE, attributes.get("Boolean1")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Boolean2 should be false", Boolean.FALSE, attributes.get("Boolean2")); //$NON-NLS-1$ //$NON-NLS-2$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
}
/**
@@ -385,25 +385,25 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testSetAttributes() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
Map<String, Object> map = new HashMap<>();
- map.put("ATTR1", "ONE"); //$NON-NLS-1$ //$NON-NLS-2$
- map.put("ATTR2", "TWO"); //$NON-NLS-1$ //$NON-NLS-2$
- wc.setAttributes(map);
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+ map.put("ATTR1", "ONE"); //$NON-NLS-1$ //$NON-NLS-2$
+ map.put("ATTR2", "TWO"); //$NON-NLS-1$ //$NON-NLS-2$
+ wc.setAttributes(map);
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
Map<?, ?> attributes = handle.getAttributes();
- assertEquals("should have two attributes", 2, attributes.size()); //$NON-NLS-1$
- // retrieve attributes
- assertEquals("ATTR1 should be ONE", "ONE", attributes.get("ATTR1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("ATTR2 should be TWO", "TWO", attributes.get("ATTR2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("should have two attributes", 2, attributes.size()); //$NON-NLS-1$
+ // retrieve attributes
+ assertEquals("ATTR1 should be ONE", "ONE", attributes.get("ATTR1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("ATTR2 should be TWO", "TWO", attributes.get("ATTR2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
}
/**
@@ -411,18 +411,18 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testSetNullAttributes() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
- wc.setAttributes(null);
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config1"); //$NON-NLS-1$
+ wc.setAttributes(null);
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
Map<?, ?> attributes = handle.getAttributes();
- assertEquals("should have no attributes", 0, attributes.size()); //$NON-NLS-1$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ assertEquals("should have no attributes", 0, attributes.size()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
}
/**
@@ -432,39 +432,39 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testLocalCopy() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "configToCopy"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "configToCopy"); //$NON-NLS-1$
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
- // ensure new handle is the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
+ // ensure new handle is the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
- ILaunchConfigurationWorkingCopy softCopy = handle.copy("CopyOf" + handle.getName()); //$NON-NLS-1$
- assertNull("Original in copy should be null", softCopy.getOriginal()); //$NON-NLS-1$
- ILaunchConfiguration hardCopy = softCopy.doSave();
+ ILaunchConfigurationWorkingCopy softCopy = handle.copy("CopyOf" + handle.getName()); //$NON-NLS-1$
+ assertNull("Original in copy should be null", softCopy.getOriginal()); //$NON-NLS-1$
+ ILaunchConfiguration hardCopy = softCopy.doSave();
- // retrieve attributes
- assertTrue("String1 should be String1", hardCopy.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", hardCopy.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", hardCopy.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !hardCopy.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertTrue("String1 should be String1", hardCopy.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", hardCopy.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", hardCopy.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !hardCopy.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Original should still exist", handle.exists()); //$NON-NLS-1$
+ assertTrue("Original should still exist", handle.exists()); //$NON-NLS-1$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- hardCopy.delete();
- assertTrue("Config should not exist after deletion", !hardCopy.exists()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ hardCopy.delete();
+ assertTrue("Config should not exist after deletion", !hardCopy.exists()); //$NON-NLS-1$
}
/**
@@ -473,21 +473,21 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testDoubleSave() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "configDoubleSave"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "configDoubleSave"); //$NON-NLS-1$
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // ensure new handle is the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
String name = wc.getName();
wc.rename("newName"); //$NON-NLS-1$
@@ -498,9 +498,9 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
ILaunchConfiguration[] newConfigs = getLaunchManager().getLaunchConfigurations();
assertTrue("Should be the same number of configs", newConfigs.length == configs.length); //$NON-NLS-1$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
}
@@ -511,24 +511,24 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testDeleteLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2delete"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- File file = wc.getLocation().toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2delete"); //$NON-NLS-1$
+ ILaunchConfiguration handle = wc.doSave();
+ File file = wc.getLocation().toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
- // delete
- handle.delete();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
+ // delete
+ handle.delete();
+ assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- // ensure handle is not in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should not exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
+ // ensure handle is not in the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Configuration should not exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
}
/**
@@ -539,42 +539,42 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testRenameLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2rename"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // rename
- wc = handle.getWorkingCopy();
- wc.rename("config-2-rename"); //$NON-NLS-1$
- addConfigListener();
- ILaunchConfiguration newHandle = wc.doSave();
- removeConfigListener();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
- assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
-
- // retrieve new attributes
- assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$//$NON-NLS-2$
- assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
- assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- newHandle.delete();
- assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2rename"); //$NON-NLS-1$
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // rename
+ wc = handle.getWorkingCopy();
+ wc.rename("config-2-rename"); //$NON-NLS-1$
+ addConfigListener();
+ ILaunchConfiguration newHandle = wc.doSave();
+ removeConfigListener();
+ assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
+ assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
+ assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
+
+ // retrieve new attributes
+ assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$//$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // ensure new handle is in the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
+ assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
+
+ // cleanup
+ newHandle.delete();
+ assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
}
/**
@@ -582,42 +582,42 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testMoveLocalToSharedConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2share"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // move
- wc = handle.getWorkingCopy();
- wc.setContainer(getProject());
- addConfigListener();
- ILaunchConfiguration newHandle = wc.doSave();
- removeConfigListener();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
- assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
-
- // retrieve new attributes
- assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
- assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- newHandle.delete();
- assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config2share"); //$NON-NLS-1$
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // move
+ wc = handle.getWorkingCopy();
+ wc.setContainer(getProject());
+ addConfigListener();
+ ILaunchConfiguration newHandle = wc.doSave();
+ removeConfigListener();
+ assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
+ assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
+ assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
+
+ // retrieve new attributes
+ assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // ensure new handle is in the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
+ assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
+
+ // cleanup
+ newHandle.delete();
+ assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
}
/**
@@ -625,42 +625,42 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testMoveSharedToLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2local"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // move
- wc = handle.getWorkingCopy();
- wc.setContainer(null);
- addConfigListener();
- ILaunchConfiguration newHandle = wc.doSave();
- removeConfigListener();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
- assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
-
- // retrieve new attributes
- assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
- assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- newHandle.delete();
- assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2local"); //$NON-NLS-1$
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // move
+ wc = handle.getWorkingCopy();
+ wc.setContainer(null);
+ addConfigListener();
+ ILaunchConfiguration newHandle = wc.doSave();
+ removeConfigListener();
+ assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
+ assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
+ assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
+
+ // retrieve new attributes
+ assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // ensure new handle is in the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
+ assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
+
+ // cleanup
+ newHandle.delete();
+ assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
}
/**
@@ -669,23 +669,23 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testCreateSharedConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2"); //$NON-NLS-1$
+ ILaunchConfiguration handle = wc.doSave();
+ assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
+ // ensure new handle is in the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
}
/**
@@ -695,37 +695,37 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testSharedCopy() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2Copy"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "config2Copy"); //$NON-NLS-1$
+ ILaunchConfiguration handle = wc.doSave();
+ assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
+ // ensure new handle is in the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
- // copy
- ILaunchConfigurationWorkingCopy softCopy = handle.copy("CopyOf" + handle.getName()); //$NON-NLS-1$
- ILaunchConfiguration hardCopy = softCopy.doSave();
+ // copy
+ ILaunchConfigurationWorkingCopy softCopy = handle.copy("CopyOf" + handle.getName()); //$NON-NLS-1$
+ ILaunchConfiguration hardCopy = softCopy.doSave();
- // retrieve attributes
- assertTrue("String1 should be String1", hardCopy.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", hardCopy.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", hardCopy.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !hardCopy.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertTrue("String1 should be String1", hardCopy.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", hardCopy.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", hardCopy.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !hardCopy.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Original should still exist", handle.exists()); //$NON-NLS-1$
+ assertTrue("Original should still exist", handle.exists()); //$NON-NLS-1$
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
- hardCopy.delete();
- assertTrue("Config should not exist after deletion", !hardCopy.exists()); //$NON-NLS-1$
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ hardCopy.delete();
+ assertTrue("Config should not exist after deletion", !hardCopy.exists()); //$NON-NLS-1$
}
@@ -736,23 +736,23 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testDeleteSharedConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2delete"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2delete"); //$NON-NLS-1$
+ ILaunchConfiguration handle = wc.doSave();
+ assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
- // delete
- handle.delete();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
+ // delete
+ handle.delete();
+ assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- // ensure handle is not in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should not exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
+ // ensure handle is not in the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Configuration should not exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
}
/**
@@ -763,40 +763,40 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testRenameSharedConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2rename"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // rename
- wc = handle.getWorkingCopy();
- wc.rename("shared-2-rename"); //$NON-NLS-1$
- addConfigListener();
- ILaunchConfiguration newHandle = wc.doSave();
- removeConfigListener();
- assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
- assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
- assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
-
- // retrieve new attributes
- assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is in the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
- assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
-
- // cleanup
- newHandle.delete();
- assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "shared2rename"); //$NON-NLS-1$
+ ILaunchConfiguration handle = wc.doSave();
+ assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
+
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // rename
+ wc = handle.getWorkingCopy();
+ wc.rename("shared-2-rename"); //$NON-NLS-1$
+ addConfigListener();
+ ILaunchConfiguration newHandle = wc.doSave();
+ removeConfigListener();
+ assertTrue("Config should no longer exist", !handle.exists()); //$NON-NLS-1$
+ assertEquals("From should be original", handle, fFrom); //$NON-NLS-1$
+ assertEquals("To should be new handle", newHandle, fTo); //$NON-NLS-1$
+
+ // retrieve new attributes
+ assertTrue("String1 should be String1", newHandle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", newHandle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", newHandle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !newHandle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // ensure new handle is in the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Renamed configuration should exist in project index", existsIn(configs, newHandle)); //$NON-NLS-1$
+ assertTrue("Original configuration should NOT exist in project index", !existsIn(configs, handle)); //$NON-NLS-1$
+
+ // cleanup
+ newHandle.delete();
+ assertTrue("Config should not exist after deletion", !newHandle.exists()); //$NON-NLS-1$
}
/**
@@ -841,11 +841,11 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
assertTrue("Config should exist after openning", existsIn(after, before[i])); //$NON-NLS-1$
}
- // cleanup
- lc1.delete();
- assertTrue("Config should not exist after deletion", !lc1.exists()); //$NON-NLS-1$
- lc2.delete();
- assertTrue("Config should not exist after deletion", !lc2.exists()); //$NON-NLS-1$
+ // cleanup
+ lc1.delete();
+ assertTrue("Config should not exist after deletion", !lc1.exists()); //$NON-NLS-1$
+ lc2.delete();
+ assertTrue("Config should not exist after deletion", !lc2.exists()); //$NON-NLS-1$
}
@@ -858,9 +858,9 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
public void launchConfigurationAdded(ILaunchConfiguration configuration) {
fFrom = getLaunchManager().getMovedFrom(configuration);
synchronized (fLock) {
- fAdded = configuration;
- fLock.notifyAll();
- }
+ fAdded = configuration;
+ fLock.notifyAll();
+ }
}
/**
@@ -877,9 +877,9 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
fTo = getLaunchManager().getMovedTo(configuration);
synchronized (fLock) {
- fRemoved = configuration;
- fLock.notifyAll();
- }
+ fRemoved = configuration;
+ fLock.notifyAll();
+ }
}
protected void addConfigListener() {
@@ -897,33 +897,33 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws Exception
*/
public void testDeleteProjectWithSharedConfig() throws Exception {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("DeleteSharedConfig"); //$NON-NLS-1$
- try {
- assertFalse("project should not exist yet", project.exists()); //$NON-NLS-1$
- project.create(null);
- assertTrue("project should now exist", project.exists()); //$NON-NLS-1$
- project.open(null);
- assertTrue("project should be open", project.isOpen()); //$NON-NLS-1$
- ILaunchConfigurationWorkingCopy wc = newConfiguration(project, "ToBeDeleted"); //$NON-NLS-1$
-
- addConfigListener();
- ILaunchConfiguration configuration = wc.doSave();
- assertEquals(configuration, fAdded);
-
- synchronized (fLock) {
- fRemoved = null;
- project.delete(true, false, null);
- if (fRemoved == null) {
- fLock.wait(10000);
- }
- }
- assertEquals(configuration, fRemoved);
- } finally {
- if (project.exists()) {
- project.delete(true, false, null);
- }
- removeConfigListener();
- }
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("DeleteSharedConfig"); //$NON-NLS-1$
+ try {
+ assertFalse("project should not exist yet", project.exists()); //$NON-NLS-1$
+ project.create(null);
+ assertTrue("project should now exist", project.exists()); //$NON-NLS-1$
+ project.open(null);
+ assertTrue("project should be open", project.isOpen()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(project, "ToBeDeleted"); //$NON-NLS-1$
+
+ addConfigListener();
+ ILaunchConfiguration configuration = wc.doSave();
+ assertEquals(configuration, fAdded);
+
+ synchronized (fLock) {
+ fRemoved = null;
+ project.delete(true, false, null);
+ if (fRemoved == null) {
+ fLock.wait(10000);
+ }
+ }
+ assertEquals(configuration, fRemoved);
+ } finally {
+ if (project.exists()) {
+ project.delete(true, false, null);
+ }
+ removeConfigListener();
+ }
}
/**
@@ -932,53 +932,53 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws CoreException
*/
public void testNestedWorkingCopyLocalConfiguration() throws CoreException {
- ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config123"); //$NON-NLS-1$
- IPath location = wc.getLocation();
- ILaunchConfiguration handle = wc.doSave();
- File file = location.toFile();
- assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
-
- // retrieve attributes
- assertEquals("String1 should be String1", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Int1 should be 1", handle.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ensure new handle is the index
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
- assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
-
- // get a working copy
- wc = handle.getWorkingCopy();
- ILaunchConfigurationWorkingCopy nested = wc.getWorkingCopy();
-
- // verify nested is same as original
- assertEquals("String1 should be String1", nested.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Int1 should be 1", nested.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", nested.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !nested.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
-
- // change an attribute in the nested working copy
- nested.setAttribute("String1", "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Wrong attribute value", nested.getAttribute("String1", "Missing"), "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Wrong attribute value", wc.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Wrong attribute value", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // save back to parent
- ILaunchConfigurationWorkingCopy parent = nested.getParent();
- assertEquals("Wrong parent", wc, parent); //$NON-NLS-1$
- assertNull("Should have no parent", wc.getParent()); //$NON-NLS-1$
- nested.doSave();
- assertEquals("Wrong attribute value", wc.getAttribute("String1", "Missing"), "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
- assertEquals("Wrong attribute value", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // check originals
- assertEquals("Wrong original config" , handle, wc.getOriginal()); //$NON-NLS-1$
- assertEquals("Wrong original config" , handle, nested.getOriginal()); //$NON-NLS-1$
-
- // cleanup
- handle.delete();
- assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(null, "config123"); //$NON-NLS-1$
+ IPath location = wc.getLocation();
+ ILaunchConfiguration handle = wc.doSave();
+ File file = location.toFile();
+ assertTrue("Configuration file should exist", file.exists()); //$NON-NLS-1$
+
+ // retrieve attributes
+ assertEquals("String1 should be String1", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertEquals("Int1 should be 1", handle.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // ensure new handle is the index
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ assertTrue("Configuration should exist in project index", existsIn(configs, handle)); //$NON-NLS-1$
+
+ // get a working copy
+ wc = handle.getWorkingCopy();
+ ILaunchConfigurationWorkingCopy nested = wc.getWorkingCopy();
+
+ // verify nested is same as original
+ assertEquals("String1 should be String1", nested.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertEquals("Int1 should be 1", nested.getAttribute("Int1", 0), 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", nested.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !nested.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // change an attribute in the nested working copy
+ nested.setAttribute("String1", "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Wrong attribute value", nested.getAttribute("String1", "Missing"), "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertEquals("Wrong attribute value", wc.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertEquals("Wrong attribute value", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ // save back to parent
+ ILaunchConfigurationWorkingCopy parent = nested.getParent();
+ assertEquals("Wrong parent", wc, parent); //$NON-NLS-1$
+ assertNull("Should have no parent", wc.getParent()); //$NON-NLS-1$
+ nested.doSave();
+ assertEquals("Wrong attribute value", wc.getAttribute("String1", "Missing"), "StringOne"); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
+ assertEquals("Wrong attribute value", handle.getAttribute("String1", "Missing"), "String1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ // check originals
+ assertEquals("Wrong original config" , handle, wc.getOriginal()); //$NON-NLS-1$
+ assertEquals("Wrong original config" , handle, nested.getOriginal()); //$NON-NLS-1$
+
+ // cleanup
+ handle.delete();
+ assertTrue("Config should not exist after deletion", !handle.exists()); //$NON-NLS-1$
}
/**
@@ -1000,11 +1000,11 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
ILaunchConfiguration handle = wc.doSave();
assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
// delete configuration
handle.delete();
@@ -1034,11 +1034,11 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
ILaunchConfiguration handle = wc.doSave();
assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
- // retrieve attributes
- assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
+ // retrieve attributes
+ assertTrue("String1 should be String1", handle.getAttribute("String1", "Missing").equals("String1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ assertTrue("Int1 should be 1", handle.getAttribute("Int1", 0) == 1); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean1 should be true", handle.getAttribute("Boolean1", false)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Boolean2 should be false", !handle.getAttribute("Boolean2", true)); //$NON-NLS-1$ //$NON-NLS-2$
// cleanup
folder.delete(IResource.NONE, null);
@@ -1052,12 +1052,12 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
* @throws Exception
*/
public void testEFSProjectRename() throws Exception {
- // create test project
+ // create test project
IProject pro = ResourcesPlugin.getWorkspace().getRoot().getProject("RenameEFS"); //$NON-NLS-1$
- if (pro.exists()) {
- pro.delete(true, true, null);
- }
- // create project
+ if (pro.exists()) {
+ pro.delete(true, true, null);
+ }
+ // create project
IProject project = TestsPlugin.createProject("RenameEFS"); //$NON-NLS-1$
IFileSystem fileSystem = EFS.getFileSystem("debug"); //$NON-NLS-1$
@@ -1116,19 +1116,19 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
*/
public void testImport() throws Exception {
// create a shared configuration "Import4" in the workspace to be overwritten on import
- ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "Import4"); //$NON-NLS-1$
- ILaunchConfiguration handle = wc.doSave();
- assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
+ ILaunchConfigurationWorkingCopy wc = newConfiguration(getProject(), "Import4"); //$NON-NLS-1$
+ ILaunchConfiguration handle = wc.doSave();
+ assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
File dir = TestsPlugin.getDefault().getFileInPlugin(new Path("test-import")); //$NON-NLS-1$
assertTrue("Import directory does not exist", dir.exists()); //$NON-NLS-1$
- LaunchManager manager = (LaunchManager) getLaunchManager();
+ LaunchManager manager = (LaunchManager) getLaunchManager();
- Listener listener = new Listener();
- try {
- getLaunchManager().addLaunchConfigurationListener(listener);
- // import
- manager.importConfigurations(dir.listFiles(
+ Listener listener = new Listener();
+ try {
+ getLaunchManager().addLaunchConfigurationListener(listener);
+ // import
+ manager.importConfigurations(dir.listFiles(
new FileFilter() {
@Override
public boolean accept(File file) {
@@ -1139,17 +1139,17 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
}),
null);
- // should be one removed
+ // should be one removed
List<ILaunchConfiguration> removed = listener.getRemoved();
assertEquals("Should be one removed config", 1, removed.size()); //$NON-NLS-1$
assertTrue("Import4 should be removed", removed.contains(handle)); //$NON-NLS-1$
- // should be 5 added
+ // should be 5 added
List<?> added = listener.getAdded();
assertEquals("Should be 5 added configs", 5, added.size()); //$NON-NLS-1$
Set<String> names = new HashSet<>();
Iterator<?> iterator = added.iterator();
- while (iterator.hasNext()) {
+ while (iterator.hasNext()) {
ILaunchConfiguration lc = (ILaunchConfiguration) iterator.next();
names.add(lc.getName());
}
@@ -1163,9 +1163,9 @@ public class LaunchConfigurationTests extends AbstractLaunchTest implements ILau
List<ILaunchConfiguration> changed = listener.getChanged();
assertEquals("Should be 1 changed config", 1, changed.size()); //$NON-NLS-1$
assertEquals("Wrong changed config", "Import4", changed.get(0).getName()); //$NON-NLS-1$ //$NON-NLS-2$
- } finally {
- manager.removeLaunchConfigurationListener(listener);
- }
+ } finally {
+ manager.removeLaunchConfigurationListener(listener);
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/DynamicRenderingBindings.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/DynamicRenderingBindings.java
index 2767477c1..a4e53f4ff 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/DynamicRenderingBindings.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/DynamicRenderingBindings.java
@@ -37,29 +37,29 @@ public class DynamicRenderingBindings extends AbstractMemoryRenderingBindingsPro
fgSingleton = this;
}
- /**
- * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getRenderingTypes(org.eclipse.debug.core.model.IMemoryBlock)
- */
- @Override
+ /**
+ * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getRenderingTypes(org.eclipse.debug.core.model.IMemoryBlock)
+ */
+ @Override
public IMemoryRenderingType[] getRenderingTypes(IMemoryBlock block) {
- return new IMemoryRenderingType[]{getPrimaryRenderingType(block)};
- }
+ return new IMemoryRenderingType[]{getPrimaryRenderingType(block)};
+ }
- /**
- * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getDefaultRenderingTypes(org.eclipse.debug.core.model.IMemoryBlock)
- */
- @Override
+ /**
+ * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getDefaultRenderingTypes(org.eclipse.debug.core.model.IMemoryBlock)
+ */
+ @Override
public IMemoryRenderingType[] getDefaultRenderingTypes(IMemoryBlock block) {
- return new IMemoryRenderingType[]{getPrimaryRenderingType(block)};
- }
+ return new IMemoryRenderingType[]{getPrimaryRenderingType(block)};
+ }
- /**
- * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getPrimaryRenderingType(org.eclipse.debug.core.model.IMemoryBlock)
- */
- @Override
+ /**
+ * @see org.eclipse.debug.ui.memory.IMemoryRenderingBindingsProvider#getPrimaryRenderingType(org.eclipse.debug.core.model.IMemoryBlock)
+ */
+ @Override
public IMemoryRenderingType getPrimaryRenderingType(IMemoryBlock block) {
- return DebugUITools.getMemoryRenderingManager().getRenderingType(fId);
- }
+ return DebugUITools.getMemoryRenderingManager().getRenderingType(fId);
+ }
/**
* Sets the current rendering bound to this provider, and notifies
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/MemoryRenderingTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/MemoryRenderingTests.java
index 98baa47a2..0fe5c99f6 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/MemoryRenderingTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/view/memory/MemoryRenderingTests.java
@@ -67,55 +67,55 @@ public class MemoryRenderingTests extends AbstractDebugTest {
assertTrue("Missing binding", indexOf(manager.getRenderingType("rendering_type_2"), types) >= 0); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testDefaultBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockOne();
- IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
+ public void testDefaultBinding() {
+ IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
+ IMemoryBlock block = new MemoryBlockOne();
+ IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
assertEquals("Wrong number of bindings", 1, types.length); //$NON-NLS-1$
assertEquals("Wrong binding", "rendering_type_1", types[0].getId()); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
- public void testNoDefaultBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockTwo();
- IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
+ public void testNoDefaultBinding() {
+ IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
+ IMemoryBlock block = new MemoryBlockTwo();
+ IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
assertEquals("Wrong number of bindings", 0, types.length); //$NON-NLS-1$
- }
+ }
- public void testPrimaryBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockOne();
- IMemoryRenderingType type = manager.getPrimaryRenderingType(block);
+ public void testPrimaryBinding() {
+ IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
+ IMemoryBlock block = new MemoryBlockOne();
+ IMemoryRenderingType type = manager.getPrimaryRenderingType(block);
assertEquals("Wrong binding", "rendering_type_1", type.getId()); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
- public void testNoPrimaryBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockTwo();
- IMemoryRenderingType type = manager.getPrimaryRenderingType(block);
+ public void testNoPrimaryBinding() {
+ IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
+ IMemoryBlock block = new MemoryBlockTwo();
+ IMemoryRenderingType type = manager.getPrimaryRenderingType(block);
assertNull("Wrong binding", type); //$NON-NLS-1$
- }
+ }
- public void testDefaultWithoutPrimaryBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockThree();
- IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
+ public void testDefaultWithoutPrimaryBinding() {
+ IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
+ IMemoryBlock block = new MemoryBlockThree();
+ IMemoryRenderingType[] types = manager.getDefaultRenderingTypes(block);
assertEquals("Wrong number of bindings", 1, types.length); //$NON-NLS-1$
assertEquals("Wrong binding", "rendering_type_3", types[0].getId()); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
- public void testDynamicBinding() {
- IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
- IMemoryBlock block = new MemoryBlockDynamic();
- IMemoryRenderingType[] types = manager.getRenderingTypes(block);
+ public void testDynamicBinding() {
+ IMemoryRenderingManager manager = DebugUITools.getMemoryRenderingManager();
+ IMemoryBlock block = new MemoryBlockDynamic();
+ IMemoryRenderingType[] types = manager.getRenderingTypes(block);
assertEquals("Wrong number of bindings", 1, types.length); //$NON-NLS-1$
assertEquals("Wrong binding", "rendering_type_1", types[0].getId()); //$NON-NLS-1$ //$NON-NLS-2$
- types = manager.getDefaultRenderingTypes(block);
+ types = manager.getDefaultRenderingTypes(block);
assertEquals("Wrong number of bindings", 1, types.length); //$NON-NLS-1$
assertEquals("Wrong binding", "rendering_type_1", types[0].getId()); //$NON-NLS-1$ //$NON-NLS-2$
- IMemoryRenderingType type = manager.getPrimaryRenderingType(block);
+ IMemoryRenderingType type = manager.getPrimaryRenderingType(block);
assertEquals("Wrong bindings", manager.getRenderingType("rendering_type_1"), type); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
public void testBindingChangeNotification() {
final boolean[] changed = new boolean[1];
@@ -130,14 +130,14 @@ public class MemoryRenderingTests extends AbstractDebugTest {
// bug 374447 - Need to make sure that DynamicRenderingBindings singleton
// is initialized
IMemoryBlock block = new MemoryBlockDynamic();
- IMemoryRenderingType[] types = manager.getRenderingTypes(block);
+ IMemoryRenderingType[] types = manager.getRenderingTypes(block);
try {
manager.addListener(listener);
assertFalse("Renderings should not have changed yet", changed[0]); //$NON-NLS-1$
DynamicRenderingBindings.setBinding("rendering_type_2"); //$NON-NLS-1$
assertTrue("Renderings should have changed", changed[0]); //$NON-NLS-1$
- types = manager.getRenderingTypes(block);
+ types = manager.getRenderingTypes(block);
assertEquals("Wrong number of bindings", 1, types.length); //$NON-NLS-1$
assertEquals("Wrong binding", "rendering_type_2", types[0].getId()); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java
index 07a142007..287a72393 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/CheckTests.java
@@ -29,9 +29,9 @@ import org.eclipse.jface.viewers.TreePath;
*/
abstract public class CheckTests extends AbstractViewerModelTest {
- public CheckTests(String name) {
- super(name);
- }
+ public CheckTests(String name) {
+ super(name);
+ }
@Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
@@ -39,43 +39,43 @@ abstract public class CheckTests extends AbstractViewerModelTest {
}
public void testSimpleSingleLevel() throws Exception {
- // Create the model with test data
- TestModel model = TestModel.simpleSingleLevel();
+ // Create the model with test data
+ TestModel model = TestModel.simpleSingleLevel();
- // Make sure that all elements are expanded
- fViewer.setAutoExpandLevel(-1);
+ // Make sure that all elements are expanded
+ fViewer.setAutoExpandLevel(-1);
- // Create the agent which forces the tree to populate
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ // Create the agent which forces the tree to populate
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- // Create the listener which determines when the view is finished updating.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener which determines when the view is finished updating.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the viewer input (and trigger updates).
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input (and trigger updates).
+ fViewer.setInput(model.getRootElement());
- // Wait for the updates to complete.
+ // Wait for the updates to complete.
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
public void testSimpleMultiLevel() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleMultiLevel();
+ fViewer.setAutoExpandLevel(-1);
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- fViewer.setInput(model.getRootElement());
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
- // TODO: no idea how to trigger a toggle event on an item
+ // TODO: no idea how to trigger a toggle event on an item
// public void testCheckReceiver() {
// // Initial setup
// TestModel model = TestModel.simpleSingleLevel();
@@ -106,28 +106,28 @@ abstract public class CheckTests extends AbstractViewerModelTest {
// }
public void testUpdateCheck() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- TestElement element = model.getRootElement().getChildren()[0];
+ // Update the model
+ TestElement element = model.getRootElement().getChildren()[0];
- TreePath elementPath = new TreePath(new Object[] { element });
- ModelDelta delta = model.setElementChecked(elementPath, false, false);
+ TreePath elementPath = new TreePath(new Object[] { element });
+ ModelDelta delta = model.setElementChecked(elementPath, false, false);
- fListener.reset(elementPath, element, -1, true, false);
- model.postDelta(delta);
+ fListener.reset(elementPath, element, -1, true, false);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(ITestModelUpdatesListenerConstants.LABEL_COMPLETE | ITestModelUpdatesListenerConstants.MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ChildrenUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ChildrenUpdateTests.java
index b7e310b3c..fb293ebfa 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ChildrenUpdateTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ChildrenUpdateTests.java
@@ -76,33 +76,33 @@ public class ChildrenUpdateTests extends AbstractDebugTest {
public void removeModelChangedListener(IModelChangedListener listener) {}
@Override
public void removeLabelUpdateListener(ILabelUpdateListener listener) {}
- @Override
+ @Override
public void addViewerUpdateListener(IViewerUpdateListener listener) {}
- @Override
+ @Override
public void addStateUpdateListener(IStateUpdateListener listener) {}
- @Override
+ @Override
public void addModelChangedListener(IModelChangedListener listener) {}
- @Override
+ @Override
public void addLabelUpdateListener(ILabelUpdateListener listener) {}
- @Override
+ @Override
public void update(Object element) {}
- @Override
+ @Override
public void setHasChildren(Object elementOrTreePath, boolean hasChildren) {}
- @Override
+ @Override
public void setExpandedState(Object elementOrTreePath, boolean expanded) {}
- @Override
+ @Override
public void setChildCount(Object elementOrTreePath, int count) {}
- @Override
+ @Override
public void reveal(TreePath path, int index) {}
- @Override
+ @Override
public void replace(Object parentOrTreePath, int index, Object element) {}
- @Override
+ @Override
public void remove(Object parentOrTreePath, int index) {}
- @Override
+ @Override
public void remove(Object elementOrTreePath) {}
- @Override
+ @Override
public void refresh() {}
- @Override
+ @Override
public void refresh(Object element) {}
@Override
@@ -171,10 +171,10 @@ public class ChildrenUpdateTests extends AbstractDebugTest {
return null;
}
- @Override
+ @Override
public boolean getHasChildren(Object elementOrTreePath) {
- return false;
- }
+ return false;
+ }
@Override
public int getChildCount(TreePath path) {
@@ -194,37 +194,37 @@ public class ChildrenUpdateTests extends AbstractDebugTest {
public void autoExpand(TreePath elementPath) {
}
- @Override
+ @Override
public boolean getElementChildrenRealized(TreePath parentPath) {
- return false;
- }
+ return false;
+ }
- @Override
+ @Override
public boolean getElementChecked(TreePath path) {
- return false;
- }
+ return false;
+ }
- @Override
+ @Override
public boolean getElementGrayed(TreePath path) {
- return false;
- }
+ return false;
+ }
- @Override
+ @Override
public void setElementChecked(TreePath path, boolean checked, boolean grayed) {
- }
+ }
- @Override
+ @Override
public TreePath[] getElementPaths(Object element) {
- return null;
- }
- @Override
+ return null;
+ }
+ @Override
public void setElementData(TreePath path, int numColumns, String[] labels, ImageDescriptor[] images,
- FontData[] fontDatas, RGB[] foregrounds, RGB[] backgrounds) {
- }
- @Override
+ FontData[] fontDatas, RGB[] foregrounds, RGB[] backgrounds) {
+ }
+ @Override
public String[] getVisibleColumns() {
- return null;
- }
+ return null;
+ }
};
}
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ColumnPresentationTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ColumnPresentationTests.java
index b202e5838..92d3c131b 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ColumnPresentationTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ColumnPresentationTests.java
@@ -67,20 +67,20 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM
void createViewer() {
fDisplay = PlatformUI.getWorkbench().getDisplay();
- fShell = new Shell(fDisplay);
- fShell.setSize(800, 600);
+ fShell = new Shell(fDisplay);
+ fShell.setSize(800, 600);
fShell.setLayout(new FillLayout());
fViewer = new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$
- fViewer.getTree().addControlListener(new ControlListener() {
- @Override
+ fViewer.getTree().addControlListener(new ControlListener() {
+ @Override
public void controlResized(ControlEvent e) {
- fResized = true;
- }
+ fResized = true;
+ }
- @Override
+ @Override
public void controlMoved(ControlEvent e) {
- }
- });
+ }
+ });
fListener = new TestModelUpdatesListener(fViewer, false, false);
fShell.open();
TestUtil.processUIEvents();
@@ -104,15 +104,15 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM
protected String[] columnIds;
MyColumnPresentation() {
- this (makeDefaultColumnIds());
- }
+ this (makeDefaultColumnIds());
+ }
static String[] makeDefaultColumnIds() {
- String[] columnIds = new String[5];
- for (int i = 0; i < columnIds.length; i++) {
+ String[] columnIds = new String[5];
+ for (int i = 0; i < columnIds.length; i++) {
columnIds[i] = "ColumnId_" + i; //$NON-NLS-1$
- }
- return columnIds;
+ }
+ return columnIds;
}
MyColumnPresentation(String[] columnIds) {
@@ -150,10 +150,10 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM
@Override
public String getHeader(String id) {
- if (Arrays.asList(columnIds).indexOf(id) != -1) {
- return id;
- }
- return null;
+ if (Arrays.asList(columnIds).indexOf(id) != -1) {
+ return id;
+ }
+ return null;
}
@Override
@@ -262,7 +262,7 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM
* in InternalTreeModelViewer.
*/
public void testInitialColumnAverageWidth() throws Exception {
- fResized = false;
+ fResized = false;
MyColumnPresentation colPre = new MyColumnPresentation();
makeModel(colPre, "m1"); //$NON-NLS-1$
@@ -271,9 +271,9 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM
int treeWidth = tree.getSize().x;
int avgWidth = treeWidth / columns.length;
- // Resizing the tree invalidates the test.
+ // Resizing the tree invalidates the test.
if (fResized) {
- return;
+ return;
}
for (int i = 0; i < columns.length - 1; i++) {
@@ -281,8 +281,8 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM
}
// Checking of the width of the last column is not reliable.
// I.e. it's handled differenty on different platforms.
- //int remainder = treeWidth % columns.length;
- //assertEquals(avgWidth + remainder, columns[columns.length - 1].getWidth());
+ //int remainder = treeWidth % columns.length;
+ //assertEquals(avgWidth + remainder, columns[columns.length - 1].getWidth());
}
/**
@@ -291,22 +291,22 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM
* the IColumnPresentation2 implementation.
*/
public void testInitialColumnWidth() throws Exception {
- fResized = false;
+ fResized = false;
- MyColumnPresentation2 colPre = new MyColumnPresentation2();
+ MyColumnPresentation2 colPre = new MyColumnPresentation2();
makeModel(colPre, "m2"); //$NON-NLS-1$
Tree tree = fViewer.getTree();
TreeColumn[] columns = tree.getColumns();
- // Resizing the tree invalidates the test.
+ // Resizing the tree invalidates the test.
if (fResized) {
- return;
+ return;
}
for (int i = 0; i < columns.length; i++) {
int width = colPre.repliedWidths[i];
if (width != -1) {
- assertEquals(width, columns[i].getWidth());
+ assertEquals(width, columns[i].getWidth());
}
}
}
@@ -392,36 +392,36 @@ public class ColumnPresentationTests extends AbstractDebugTest implements ITestM
}
/**
- * In this test: verify that tree viewer can handle the column presentation changing
- * its available column IDs between runs (bug 360015).
- */
+ * In this test: verify that tree viewer can handle the column presentation changing
+ * its available column IDs between runs (bug 360015).
+ */
public void testChangedColumnIds() throws Exception {
- MyColumnPresentation colPre = new MyColumnPresentation();
+ MyColumnPresentation colPre = new MyColumnPresentation();
makeModel(colPre, "m1"); //$NON-NLS-1$
- TreeColumn[] columns = fViewer.getTree().getColumns();
- // Select visible columns
- fViewer.setVisibleColumns(new String[] { colPre.columnIds[0] });
+ TreeColumn[] columns = fViewer.getTree().getColumns();
+ // Select visible columns
+ fViewer.setVisibleColumns(new String[] { colPre.columnIds[0] });
TestUtil.processUIEvents();
waitWhile(t -> fViewer.getTree().getColumns().length != 1, createColumnsErrorMessage());
- // get InternalTreeModelViewer to rebuild columns due to change of
- // model and presentation - first set to another model and column
- // presentation, then switch to a model with original presentation.
+ // get InternalTreeModelViewer to rebuild columns due to change of
+ // model and presentation - first set to another model and column
+ // presentation, then switch to a model with original presentation.
makeModel(new MyColumnPresentation2(), "m2"); //$NON-NLS-1$
- String[] newColumnIds = MyColumnPresentation.makeDefaultColumnIds();
+ String[] newColumnIds = MyColumnPresentation.makeDefaultColumnIds();
newColumnIds[0] = "new_column_id"; //$NON-NLS-1$
- colPre = new MyColumnPresentation(newColumnIds);
+ colPre = new MyColumnPresentation(newColumnIds);
makeModel(colPre, "m3"); //$NON-NLS-1$
- // verify user resized widths are used instead of the initial widths from IColumnPresentation2
- columns = fViewer.getTree().getColumns();
- for (int i = 0; i < columns.length; i++) {
- assertEquals(newColumnIds[i], columns[i].getText());
- }
- }
+ // verify user resized widths are used instead of the initial widths from IColumnPresentation2
+ columns = fViewer.getTree().getColumns();
+ for (int i = 0; i < columns.length; i++) {
+ assertEquals(newColumnIds[i], columns[i].getText());
+ }
+ }
private Function<AbstractDebugTest, String> createColumnsErrorMessage() {
return t -> "Unexpected columns number: " + fViewer.getTree().getColumns().length;
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java
index 01f93cbdc..64a38b7fa 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ContentTests.java
@@ -50,111 +50,111 @@ abstract public class ContentTests extends AbstractViewerModelTest implements IT
}
public void testSimpleSingleLevel() throws Exception {
- // Create the model with test data
- TestModel model = TestModel.simpleSingleLevel();
+ // Create the model with test data
+ TestModel model = TestModel.simpleSingleLevel();
- // Make sure that all elements are expanded
- fViewer.setAutoExpandLevel(-1);
+ // Make sure that all elements are expanded
+ fViewer.setAutoExpandLevel(-1);
- // Create the agent which forces the tree to populate
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ // Create the agent which forces the tree to populate
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- // Create the listener which determines when the view is finished updating.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true);
+ // Create the listener which determines when the view is finished updating.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true);
- // Set the viewer input (and trigger updates).
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input (and trigger updates).
+ fViewer.setInput(model.getRootElement());
- // Wait for the updates to complete.
+ // Wait for the updates to complete.
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) );
- }
+ assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) );
+ }
public void testSimpleMultiLevel() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleMultiLevel();
+ fViewer.setAutoExpandLevel(-1);
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true);
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true);
- fViewer.setInput(model.getRootElement());
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 3) );
- }
+ assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 3) );
+ }
- /**
- * Modified test model that optionally captures (i.e. doesn't compete)
- * udpates after filling in their data.
- */
- class TestModelWithCapturedUpdates extends TestModel {
+ /**
+ * Modified test model that optionally captures (i.e. doesn't compete)
+ * udpates after filling in their data.
+ */
+ class TestModelWithCapturedUpdates extends TestModel {
- boolean fCaptureLabelUpdates = false;
- boolean fCaptureChildrenUpdates = false;
+ boolean fCaptureLabelUpdates = false;
+ boolean fCaptureChildrenUpdates = false;
List<IViewerUpdate> fCapturedUpdates = Collections.synchronizedList(new ArrayList<IViewerUpdate>());
- @Override
+ @Override
public void update(IChildrenUpdate[] updates) {
- for (int i = 0; i < updates.length; i++) {
- TestElement element = (TestElement)updates[i].getElement();
- int endOffset = updates[i].getOffset() + updates[i].getLength();
- for (int j = updates[i].getOffset(); j < endOffset; j++) {
- if (j < element.getChildren().length) {
- updates[i].setChild(element.getChildren()[j], j);
- }
- }
- if (fCaptureChildrenUpdates) {
- fCapturedUpdates.add(updates[i]);
- } else {
- updates[i].done();
- }
- }
- }
-
- @Override
+ for (int i = 0; i < updates.length; i++) {
+ TestElement element = (TestElement)updates[i].getElement();
+ int endOffset = updates[i].getOffset() + updates[i].getLength();
+ for (int j = updates[i].getOffset(); j < endOffset; j++) {
+ if (j < element.getChildren().length) {
+ updates[i].setChild(element.getChildren()[j], j);
+ }
+ }
+ if (fCaptureChildrenUpdates) {
+ fCapturedUpdates.add(updates[i]);
+ } else {
+ updates[i].done();
+ }
+ }
+ }
+
+ @Override
public void update(ILabelUpdate[] updates) {
- for (int i = 0; i < updates.length; i++) {
- TestElement element = (TestElement)updates[i].getElement();
- updates[i].setLabel(element.getLabel(), 0);
- if (updates[i] instanceof ICheckUpdate &&
- Boolean.TRUE.equals(updates[i].getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)))
- {
- ((ICheckUpdate)updates[i]).setChecked(element.getChecked(), element.getGrayed());
- }
- if (fCaptureLabelUpdates) {
- fCapturedUpdates.add(updates[i]);
- } else {
- updates[i].done();
- }
- }
- }
- }
-
- /**
- * Test to make sure that label provider cancels stale updates and doesn't
- * use data from stale updates to populate the viewer.<br>
- * See bug 210027
- */
+ for (int i = 0; i < updates.length; i++) {
+ TestElement element = (TestElement)updates[i].getElement();
+ updates[i].setLabel(element.getLabel(), 0);
+ if (updates[i] instanceof ICheckUpdate &&
+ Boolean.TRUE.equals(updates[i].getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)))
+ {
+ ((ICheckUpdate)updates[i]).setChecked(element.getChecked(), element.getGrayed());
+ }
+ if (fCaptureLabelUpdates) {
+ fCapturedUpdates.add(updates[i]);
+ } else {
+ updates[i].done();
+ }
+ }
+ }
+ }
+
+ /**
+ * Test to make sure that label provider cancels stale updates and doesn't
+ * use data from stale updates to populate the viewer.<br>
+ * See bug 210027
+ */
public void testLabelUpdatesCompletedOutOfSequence1() throws Exception {
- TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates();
- model.fCaptureLabelUpdates = true;
+ TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates();
+ model.fCaptureLabelUpdates = true;
model.setRoot(new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$
new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "2", new TestElement[0]), //$NON-NLS-1$
- }) );
+ }) );
- // Set input into the view to update it, but block children updates.
- // Wait for view to start retrieving content.
- fViewer.setInput(model.getRootElement());
+ // Set input into the view to update it, but block children updates.
+ // Wait for view to start retrieving content.
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> model.fCapturedUpdates.size() < model.getRootElement().fChildren.length, createModelErrorMessage(model));
@@ -164,145 +164,145 @@ abstract public class ContentTests extends AbstractViewerModelTest implements IT
// // Change the model and run another update set.
model.getElement(model.findElement("1")).setLabelAppendix(" - changed"); //$NON-NLS-1$ //$NON-NLS-2$
model.getElement(model.findElement("2")).setLabelAppendix(" - changed"); //$NON-NLS-1$ //$NON-NLS-2$
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> model.fCapturedUpdates.size() < model.getRootElement().fChildren.length, createModelErrorMessage(model));
- // Complete the second set of children updates
- for (int i = 0; i < model.fCapturedUpdates.size(); i++) {
- ((ILabelUpdate)model.fCapturedUpdates.get(i)).done();
- }
+ // Complete the second set of children updates
+ for (int i = 0; i < model.fCapturedUpdates.size(); i++) {
+ ((ILabelUpdate)model.fCapturedUpdates.get(i)).done();
+ }
- // Then complete the first set.
- for (int i = 0; i < firstUpdates.size(); i++) {
- ILabelUpdate capturedUpdate = (ILabelUpdate)firstUpdates.get(i);
- assertTrue(capturedUpdate.isCanceled());
- capturedUpdate.done();
- }
+ // Then complete the first set.
+ for (int i = 0; i < firstUpdates.size(); i++) {
+ ILabelUpdate capturedUpdate = (ILabelUpdate)firstUpdates.get(i);
+ assertTrue(capturedUpdate.isCanceled());
+ capturedUpdate.done();
+ }
waitWhile(t -> !fListener.isFinished(CHILDREN_UPDATES), createListenerErrorMessage());
- // Check viewer data
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ // Check viewer data
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
private Function<AbstractDebugTest, String> createModelErrorMessage(TestModelWithCapturedUpdates model) {
return t -> "Unxexpected model state: captured updates: " + model.fCapturedUpdates + ", root children: " + Arrays.toString(model.getRootElement().fChildren);
}
- /**
- * Test to make sure that label provider cancels stale updates and doesn't
- * use data from stale updates to populate the viewer.<br>
- * This version of the test changes the elements in the view, and not just
- * the elements' labels. In this case, the view should still cancel stale
- * updates.<br>
- * See bug 210027
- */
+ /**
+ * Test to make sure that label provider cancels stale updates and doesn't
+ * use data from stale updates to populate the viewer.<br>
+ * This version of the test changes the elements in the view, and not just
+ * the elements' labels. In this case, the view should still cancel stale
+ * updates.<br>
+ * See bug 210027
+ */
public void testLabelUpdatesCompletedOutOfSequence2() throws Exception {
- TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates();
- model.fCaptureLabelUpdates = true;
+ TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates();
+ model.fCaptureLabelUpdates = true;
model.setRoot(new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$
new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "2", new TestElement[0]), //$NON-NLS-1$
- }) );
+ }) );
- // Set input into the view to update it, but block children updates.
- // Wait for view to start retrieving content.
- fViewer.setInput(model.getRootElement());
+ // Set input into the view to update it, but block children updates.
+ // Wait for view to start retrieving content.
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> model.fCapturedUpdates.size() < model.getRootElement().fChildren.length, createModelErrorMessage(model));
List<IViewerUpdate> firstUpdates = model.fCapturedUpdates;
model.fCapturedUpdates = Collections.synchronizedList(new ArrayList<IViewerUpdate>(2));
- // Change the model and run another update set.
+ // Change the model and run another update set.
model.setElementChildren(TreePath.EMPTY, new TestElement[] {
new TestElement(model, "1-new", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "2-new", new TestElement[0]), //$NON-NLS-1$
- });
+ });
fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> model.fCapturedUpdates.size() < model.getRootElement().fChildren.length, createModelErrorMessage(model));
- // Complete the second set of children updates
- for (int i = 0; i < model.fCapturedUpdates.size(); i++) {
- ((ILabelUpdate)model.fCapturedUpdates.get(i)).done();
- }
+ // Complete the second set of children updates
+ for (int i = 0; i < model.fCapturedUpdates.size(); i++) {
+ ((ILabelUpdate)model.fCapturedUpdates.get(i)).done();
+ }
- // Then complete the first set.
- for (int i = 0; i < firstUpdates.size(); i++) {
- ILabelUpdate capturedUpdate = (ILabelUpdate)firstUpdates.get(i);
- assertTrue(capturedUpdate.isCanceled());
- capturedUpdate.done();
- }
+ // Then complete the first set.
+ for (int i = 0; i < firstUpdates.size(); i++) {
+ ILabelUpdate capturedUpdate = (ILabelUpdate)firstUpdates.get(i);
+ assertTrue(capturedUpdate.isCanceled());
+ capturedUpdate.done();
+ }
waitWhile(t -> !fListener.isFinished(CHILDREN_UPDATES), createListenerErrorMessage());
- // Check viewer data
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- /**
- * Test to make sure that content provider cancels stale updates and doesn't
- * use data from stale updates to populate the viewer.<br>
- * Note: this test is disabled because currently the viewer will not issue
- * a new update for an until the previous update is completed. This is even
- * if the previous update is canceled. If this behavior is changed at some
- * point, then this test should be re-enabled.<br>
- * See bug 210027
- */
+ // Check viewer data
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
+
+ /**
+ * Test to make sure that content provider cancels stale updates and doesn't
+ * use data from stale updates to populate the viewer.<br>
+ * Note: this test is disabled because currently the viewer will not issue
+ * a new update for an until the previous update is completed. This is even
+ * if the previous update is canceled. If this behavior is changed at some
+ * point, then this test should be re-enabled.<br>
+ * See bug 210027
+ */
public void _x_testChildrenUpdatesCompletedOutOfSequence() throws Exception {
- TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates();
- model.fCaptureChildrenUpdates = true;
+ TestModelWithCapturedUpdates model = new TestModelWithCapturedUpdates();
+ model.fCaptureChildrenUpdates = true;
model.setRoot(new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$
new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "2", new TestElement[0]), //$NON-NLS-1$
- }) );
+ }) );
- // Set input into the view to update it, but block children updates.
- // Wait for view to start retrieving content.
- fViewer.setInput(model.getRootElement());
+ // Set input into the view to update it, but block children updates.
+ // Wait for view to start retrieving content.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !areCapturedChildrenUpdatesComplete(model.fCapturedUpdates, model.getRootElement().fChildren.length), createModelErrorMessage(model));
- IChildrenUpdate[] firstUpdates = model.fCapturedUpdates.toArray(new IChildrenUpdate[0]);
- model.fCapturedUpdates.clear();
+ IChildrenUpdate[] firstUpdates = model.fCapturedUpdates.toArray(new IChildrenUpdate[0]);
+ model.fCapturedUpdates.clear();
- // Change the model and run another update set.
- model.setElementChildren(TreePath.EMPTY, new TestElement[] {
+ // Change the model and run another update set.
+ model.setElementChildren(TreePath.EMPTY, new TestElement[] {
new TestElement(model, "1-new", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "2-new", new TestElement[0]), //$NON-NLS-1$
- });
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ });
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !areCapturedChildrenUpdatesComplete(model.fCapturedUpdates, model.getRootElement().fChildren.length), createModelErrorMessage(model));
- // Complete the second set of children updates
- for (int i = 0; i < model.fCapturedUpdates.size(); i++) {
- ((IChildrenUpdate)model.fCapturedUpdates.get(i)).done();
- }
+ // Complete the second set of children updates
+ for (int i = 0; i < model.fCapturedUpdates.size(); i++) {
+ ((IChildrenUpdate)model.fCapturedUpdates.get(i)).done();
+ }
- // Then complete the first set.
- for (int i = 0; i < firstUpdates.length; i++) {
- firstUpdates[i].done();
- }
+ // Then complete the first set.
+ for (int i = 0; i < firstUpdates.length; i++) {
+ firstUpdates[i].done();
+ }
waitWhile(t -> !fListener.isFinished(CHILDREN_UPDATES), createListenerErrorMessage());
- // Check viewer data
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ // Check viewer data
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
private boolean areCapturedChildrenUpdatesComplete(List<IViewerUpdate> capturedUpdates, int childCount) {
List<Integer> expectedChildren = new ArrayList<>();
- for (int i = 0; i < childCount; i++) {
- expectedChildren.add(Integer.valueOf(i));
- }
- IChildrenUpdate[] updates = capturedUpdates.toArray(new IChildrenUpdate[0]);
- for (int i = 0; i < updates.length; i++) {
- for (int j = 0; j < updates[i].getLength(); j++) {
- expectedChildren.remove( Integer.valueOf(updates[i].getOffset() + j) );
- }
- }
- return expectedChildren.isEmpty();
- }
+ for (int i = 0; i < childCount; i++) {
+ expectedChildren.add(Integer.valueOf(i));
+ }
+ IChildrenUpdate[] updates = capturedUpdates.toArray(new IChildrenUpdate[0]);
+ for (int i = 0; i < updates.length; i++) {
+ for (int j = 0; j < updates[i].getLength(); j++) {
+ expectedChildren.remove( Integer.valueOf(updates[i].getOffset() + j) );
+ }
+ }
+ return expectedChildren.isEmpty();
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/DeltaTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/DeltaTests.java
index 63b9d8860..e6c25d01e 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/DeltaTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/DeltaTests.java
@@ -31,9 +31,9 @@ import org.eclipse.jface.viewers.TreePath;
*/
abstract public class DeltaTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants {
- public DeltaTests(String name) {
- super(name);
- }
+ public DeltaTests(String name) {
+ super(name);
+ }
@Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
@@ -41,656 +41,656 @@ abstract public class DeltaTests extends AbstractViewerModelTest implements ITes
}
public void testUpdateLabel() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- TestElement element = model.getRootElement().getChildren()[0];
- TreePath elementPath = new TreePath(new Object[] { element });
+ // Update the model
+ TestElement element = model.getRootElement().getChildren()[0];
+ TreePath elementPath = new TreePath(new Object[] { element });
ModelDelta delta = model.appendElementLabel(elementPath, "-modified"); //$NON-NLS-1$
- fListener.reset(elementPath, element, -1, true, false);
- model.postDelta(delta);
+ fListener.reset(elementPath, element, -1, true, false);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(LABEL_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
public void testRefreshStruct() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- TestElement element = model.getRootElement().getChildren()[0];
- TreePath elementPath = new TreePath(new Object[] { element });
- TestElement[] newChildren = new TestElement[] {
+ // Update the model
+ TestElement element = model.getRootElement().getChildren()[0];
+ TreePath elementPath = new TreePath(new Object[] { element });
+ TestElement[] newChildren = new TestElement[] {
new TestElement(model, "1.1 - new", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "1.2 - new", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "1.3 - new", new TestElement[0]), //$NON-NLS-1$
- };
- ModelDelta delta = model.setElementChildren(elementPath, newChildren);
+ };
+ ModelDelta delta = model.setElementChildren(elementPath, newChildren);
- fListener.reset(elementPath, element, -1, true, false);
- model.postDelta(delta);
+ fListener.reset(elementPath, element, -1, true, false);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
public void testRefreshStruct2() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleMultiLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
String prefix = "new - "; //$NON-NLS-1$
- model.setElementChildren(TreePath.EMPTY, new TestElement[] {
+ model.setElementChildren(TreePath.EMPTY, new TestElement[] {
new TestElement(model, prefix + "1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, prefix + "2", true, false, new TestElement[] { //$NON-NLS-1$
new TestElement(model, prefix + "2.1", true, true, new TestElement[0]), //$NON-NLS-1$
new TestElement(model, prefix + "2.2", false, true, new TestElement[0]), //$NON-NLS-1$
new TestElement(model, prefix + "2.3", true, false, new TestElement[0]), //$NON-NLS-1$
- }),
+ }),
new TestElement(model, prefix + "3", new TestElement[] { //$NON-NLS-1$
new TestElement(model, prefix + "3.1", new TestElement[] { //$NON-NLS-1$
new TestElement(model, prefix + "3.1.1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, prefix + "3.1.2", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, prefix + "3.1.3", new TestElement[0]), //$NON-NLS-1$
- }),
+ }),
new TestElement(model, prefix + "3.2", new TestElement[] { //$NON-NLS-1$
new TestElement(model, prefix + "3.2.1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, prefix + "3.2.2", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, prefix + "3.2.3", new TestElement[0]), //$NON-NLS-1$
- }),
+ }),
new TestElement(model, prefix + "3.3", new TestElement[] { //$NON-NLS-1$
new TestElement(model, prefix + "3.3.1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, prefix + "3.3.2", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, prefix + "3.3.3", new TestElement[0]), //$NON-NLS-1$
- }),
- })
- });
+ }),
+ })
+ });
- TestElement element = model.getRootElement();
- fListener.reset(TreePath.EMPTY, element, -1, false, false);
+ TestElement element = model.getRootElement();
+ fListener.reset(TreePath.EMPTY, element, -1, false, false);
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
+ model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
public void testRefreshCoalesceStruct() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
-
- // Create a single level model and add a single child to each element.
- TestModel model = TestModel.simpleSingleLevel();
- TestElement[] rootChildren = model.getRootElement().getChildren();
- for (int i = 0; i < rootChildren.length; i++) {
- model.setElementChildren(
- new TreePath(new Object[] { rootChildren[i]} ),
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+
+ // Create a single level model and add a single child to each element.
+ TestModel model = TestModel.simpleSingleLevel();
+ TestElement[] rootChildren = model.getRootElement().getChildren();
+ for (int i = 0; i < rootChildren.length; i++) {
+ model.setElementChildren(
+ new TreePath(new Object[] { rootChildren[i]} ),
new TestElement[] { new TestElement(model, i + ".1", new TestElement[0]) }); //$NON-NLS-1$
- }
+ }
- fViewer.setAutoExpandLevel(-1);
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) );
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) );
+ }
public void testInsert() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
+ // Update the model
TestElement element = new TestElement(model, "7", new TestElement[0]); //$NON-NLS-1$
- TreePath elementPath = new TreePath(new Object[] { element });
- ModelDelta delta = model.insertElementChild(TreePath.EMPTY, 6, element);
-
- // Insert causes the update of element's data, label and children.
- // TODO: update of element's data after insert seems redundant
- // but it's probably not a big inefficiency
- fListener.reset();
- fListener.addChildreUpdate(TreePath.EMPTY, 6);
- fListener.addHasChildrenUpdate(elementPath);
- fListener.addLabelUpdate(elementPath);
- // TODO: redundant label updates on insert!
- fListener.setFailOnRedundantUpdates(false);
- model.postDelta(delta);
+ TreePath elementPath = new TreePath(new Object[] { element });
+ ModelDelta delta = model.insertElementChild(TreePath.EMPTY, 6, element);
+
+ // Insert causes the update of element's data, label and children.
+ // TODO: update of element's data after insert seems redundant
+ // but it's probably not a big inefficiency
+ fListener.reset();
+ fListener.addChildreUpdate(TreePath.EMPTY, 6);
+ fListener.addHasChildrenUpdate(elementPath);
+ fListener.addLabelUpdate(elementPath);
+ // TODO: redundant label updates on insert!
+ fListener.setFailOnRedundantUpdates(false);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
- /**
- * This test checks that insert and select delta flags are processed in correct order:
- * insert then select.
- */
+ /**
+ * This test checks that insert and select delta flags are processed in correct order:
+ * insert then select.
+ */
public void testInsertAndSelect() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- // Insert two new elements at once
+ // Update the model
+ // Insert two new elements at once
TestElement element0 = new TestElement(model, "00", new TestElement[] {}); //$NON-NLS-1$
TestElement element1 = new TestElement(model, "01", new TestElement[] {}); //$NON-NLS-1$
- TreePath elementPath0 = new TreePath(new Object[] { element0 });
- TreePath elementPath1 = new TreePath(new Object[] { element1 });
- ModelDelta rootDelta = model.insertElementChild(TreePath.EMPTY, 0, element0);
- rootDelta = model.insertElementChild(rootDelta, TreePath.EMPTY, 1, element1);
+ TreePath elementPath0 = new TreePath(new Object[] { element0 });
+ TreePath elementPath1 = new TreePath(new Object[] { element1 });
+ ModelDelta rootDelta = model.insertElementChild(TreePath.EMPTY, 0, element0);
+ rootDelta = model.insertElementChild(rootDelta, TreePath.EMPTY, 1, element1);
- // Set the select flag on the first added node.
- ModelDelta delta0 = rootDelta.getChildDelta(element0);
- delta0.setFlags(delta0.getFlags() | IModelDelta.SELECT);
+ // Set the select flag on the first added node.
+ ModelDelta delta0 = rootDelta.getChildDelta(element0);
+ delta0.setFlags(delta0.getFlags() | IModelDelta.SELECT);
- fListener.reset();
- fListener.addHasChildrenUpdate(elementPath0);
- fListener.addHasChildrenUpdate(elementPath1);
- fListener.addLabelUpdate(elementPath0);
- fListener.addLabelUpdate(elementPath1);
+ fListener.reset();
+ fListener.addHasChildrenUpdate(elementPath0);
+ fListener.addHasChildrenUpdate(elementPath1);
+ fListener.addLabelUpdate(elementPath0);
+ fListener.addLabelUpdate(elementPath1);
- // TODO: list full set of expected updates.
- fListener.setFailOnRedundantUpdates(false);
+ // TODO: list full set of expected updates.
+ fListener.setFailOnRedundantUpdates(false);
- model.postDelta(rootDelta);
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
- /**
- * This test checks that insert and remove deltas are processed in correct order:
- * remove deltas are processed first then insert deltas.
- */
+ /**
+ * This test checks that insert and remove deltas are processed in correct order:
+ * remove deltas are processed first then insert deltas.
+ */
public void testInsertAndRemove() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- fViewer.setInput(model.getRootElement());
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- // Remove one element then insert a new one
- IModelDelta removeDelta = model.removeElementChild(TreePath.EMPTY, 3).getChildDeltas()[0];
+ // Update the model
+ // Remove one element then insert a new one
+ IModelDelta removeDelta = model.removeElementChild(TreePath.EMPTY, 3).getChildDeltas()[0];
- // Insert new elements at once
+ // Insert new elements at once
TestElement element = new TestElement(model, "00", new TestElement[] {}); //$NON-NLS-1$
- TreePath elementPath = new TreePath(new Object[] { element });
- IModelDelta insertDelta = model.insertElementChild(TreePath.EMPTY, 1, element).getChildDeltas()[0];
+ TreePath elementPath = new TreePath(new Object[] { element });
+ IModelDelta insertDelta = model.insertElementChild(TreePath.EMPTY, 1, element).getChildDeltas()[0];
- // Create a combined delta where the insert child delta is first and the remove child delta is second.
- ModelDelta combinedDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE, 0, model.getRootElement().getChildren().length);
- combinedDelta.addNode(insertDelta.getElement(), insertDelta.getIndex(), insertDelta.getFlags(), insertDelta.getChildCount());
- combinedDelta.addNode(removeDelta.getElement(), removeDelta.getIndex(), removeDelta.getFlags(), removeDelta.getChildCount());
+ // Create a combined delta where the insert child delta is first and the remove child delta is second.
+ ModelDelta combinedDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE, 0, model.getRootElement().getChildren().length);
+ combinedDelta.addNode(insertDelta.getElement(), insertDelta.getIndex(), insertDelta.getFlags(), insertDelta.getChildCount());
+ combinedDelta.addNode(removeDelta.getElement(), removeDelta.getIndex(), removeDelta.getFlags(), removeDelta.getChildCount());
- // Set the select flag on the first added node.
- fListener.reset();
- fListener.addHasChildrenUpdate(elementPath);
- fListener.addLabelUpdate(elementPath);
+ // Set the select flag on the first added node.
+ fListener.reset();
+ fListener.addHasChildrenUpdate(elementPath);
+ fListener.addLabelUpdate(elementPath);
- // TODO: list full set of expected updates.
- fListener.setFailOnRedundantUpdates(false);
+ // TODO: list full set of expected updates.
+ fListener.setFailOnRedundantUpdates(false);
- model.postDelta(combinedDelta);
+ model.postDelta(combinedDelta);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
public void testAddElement() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
+ // Update the model
TestElement element = new TestElement(model, "7", new TestElement[0]); //$NON-NLS-1$
- TreePath elementPath = new TreePath(new Object[] { element });
- ModelDelta delta = model.addElementChild(TreePath.EMPTY, null, 6, element);
-
- // Add causes the update of parent child count and element's children.
- fListener.reset(elementPath, element, -1, true, false);
- fListener.addChildreUpdate(TreePath.EMPTY, 6);
- // TODO: redundant updates on add!
- fListener.setFailOnRedundantUpdates(false);
- model.postDelta(delta);
+ TreePath elementPath = new TreePath(new Object[] { element });
+ ModelDelta delta = model.addElementChild(TreePath.EMPTY, null, 6, element);
+
+ // Add causes the update of parent child count and element's children.
+ fListener.reset(elementPath, element, -1, true, false);
+ fListener.addChildreUpdate(TreePath.EMPTY, 6);
+ // TODO: redundant updates on add!
+ fListener.setFailOnRedundantUpdates(false);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
- // This test currently fails. When (if) bug 311442 gets address we should re-enable it.
+ // This test currently fails. When (if) bug 311442 gets address we should re-enable it.
public void _x_testAddUnexpandedElement() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
- // Turn off auto-expansion
- fViewer.setAutoExpandLevel(0);
+ // Turn off auto-expansion
+ fViewer.setAutoExpandLevel(0);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- // Update the model
+ // Update the model
TreePath parentPath = model.findElement("1"); //$NON-NLS-1$
ModelDelta rootDelta = model.addElementChild(parentPath, null, 0, new TestElement(model, "1.1", new TestElement[0])); //$NON-NLS-1$
model.addElementChild(parentPath, rootDelta, 1, new TestElement(model, "1.2", new TestElement[0])); //$NON-NLS-1$
model.addElementChild(parentPath, rootDelta, 2, new TestElement(model, "1.3", new TestElement[0])); //$NON-NLS-1$
model.addElementChild(parentPath, rootDelta, 3, new TestElement(model, "1.4", new TestElement[0])); //$NON-NLS-1$
- // Add causes the update of parent child count and element's children.
- fListener.reset();
- fListener.setFailOnRedundantUpdates(false);
- model.postDelta(rootDelta);
+ // Add causes the update of parent child count and element's children.
+ fListener.reset();
+ fListener.setFailOnRedundantUpdates(false);
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- // Update the elements that were added.
- fListener.reset();
- fListener.addUpdates(fViewer, TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
- rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.CONTENT);
+ // Update the elements that were added.
+ fListener.reset();
+ fListener.addUpdates(fViewer, TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
+ rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.CONTENT);
model.getElementDelta(rootDelta, model.findElement("1.1"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$
model.getElementDelta(rootDelta, model.findElement("1.2"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$
model.getElementDelta(rootDelta, model.findElement("1.3"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$
model.getElementDelta(rootDelta, model.findElement("1.4"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$
- model.postDelta(rootDelta);
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- fListener.reset(parentPath, model.getElement(parentPath), 1, false, true);
- fViewer.expandToLevel(parentPath, 1);
+ fListener.reset(parentPath, model.getElement(parentPath), 1, false, true);
+ fViewer.expandToLevel(parentPath, 1);
waitWhile(t -> fListener.isFinished(CONTENT_SEQUENCE_STARTED) && !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, parentPath);
- }
+ model.validateData(fViewer, parentPath);
+ }
public void _x_testRefreshUnexpandedElementsChildren() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
- // Turn off auto-expansion
- fViewer.setAutoExpandLevel(0);
+ // Turn off auto-expansion
+ fViewer.setAutoExpandLevel(0);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- // Expand elment "2"
+ // Expand elment "2"
TreePath parentPath = model.findElement("2"); //$NON-NLS-1$
- fListener.reset(parentPath, model.getElement(parentPath), 1, false, true);
- fViewer.expandToLevel(parentPath, 1);
+ fListener.reset(parentPath, model.getElement(parentPath), 1, false, true);
+ fViewer.expandToLevel(parentPath, 1);
waitWhile(t -> fListener.isFinished(CONTENT_SEQUENCE_STARTED) && !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- // Collapse back element "2"
- fViewer.setExpandedState(parentPath, false);
+ // Collapse back element "2"
+ fViewer.setExpandedState(parentPath, false);
- // Update the children of element "2".
- fListener.reset();
- fListener.addUpdates(fViewer, TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
- ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.CONTENT);
+ // Update the children of element "2".
+ fListener.reset();
+ fListener.addUpdates(fViewer, TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
+ ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.CONTENT);
model.getElementDelta(rootDelta, model.findElement("2.1"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$
model.getElementDelta(rootDelta, model.findElement("2.2"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$
model.getElementDelta(rootDelta, model.findElement("2.3"), true).setFlags(IModelDelta.CONTENT); //$NON-NLS-1$
- model.postDelta(rootDelta);
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Expand back element "2"
- fListener.reset(parentPath, model.getElement(parentPath), 1, false, true);
- fViewer.expandToLevel(parentPath, 1);
+ // Expand back element "2"
+ fListener.reset(parentPath, model.getElement(parentPath), 1, false, true);
+ fViewer.expandToLevel(parentPath, 1);
waitWhile(t -> fListener.isFinished(CONTENT_SEQUENCE_STARTED) && !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, parentPath, true);
- }
+ model.validateData(fViewer, parentPath, true);
+ }
public void testRemove() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- ModelDelta delta = model.removeElementChild(TreePath.EMPTY, 5);
+ // Update the model
+ ModelDelta delta = model.removeElementChild(TreePath.EMPTY, 5);
- // Remove delta should generate no new updates, but we still need to wait for the event to
- // be processed.
- fListener.reset();
- model.postDelta(delta);
+ // Remove delta should generate no new updates, but we still need to wait for the event to
+ // be processed.
+ fListener.reset();
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
public void testExpandAndSelect() throws Exception {
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Create the delta
- fListener.reset();
- // TODO Investigate: there seem to be unnecessary updates being issued
- // by the viewer. These include the updates that are commented out:
- // For now disable checking for extra updates.
- fListener.setFailOnRedundantUpdates(false);
- TestElement element = model.getRootElement();
- TreePath path_root = TreePath.EMPTY;
- ModelDelta delta= new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
- ModelDelta deltaRoot = delta;
- element = element.getChildren()[2];
- TreePath path_root_3 = path_root.createChildPath(element);
- delta = delta.addNode(element, 2, IModelDelta.EXPAND, element.fChildren.length);
- fListener.addChildreUpdate(path_root_3, 0);
- TreePath path_root_3_1 = path_root_3.createChildPath(element.getChildren()[0]);
- fListener.addHasChildrenUpdate(path_root_3_1);
- fListener.addLabelUpdate(path_root_3_1);
- TreePath path_root_3_3 = path_root_3.createChildPath(element.getChildren()[2]);
- fListener.addHasChildrenUpdate(path_root_3_3);
- fListener.addLabelUpdate(path_root_3_3);
- //TODO unnecessary update: fListener.addChildreUpdate(path1, 1);
- fListener.addChildreUpdate(path_root_3, 2);
- element = element.getChildren()[1];
- TreePath path_root_3_2 = path_root_3.createChildPath(element);
- delta = delta.addNode(element, 1, IModelDelta.EXPAND, element.fChildren.length);
- fListener.addLabelUpdate(path_root_3_2);
- TreePath path_root_3_2_1 = path_root_3_2.createChildPath(element.getChildren()[0]);
- fListener.addHasChildrenUpdate(path_root_3_2_1);
- fListener.addLabelUpdate(path_root_3_2_1);
- TreePath path_root_3_2_3 = path_root_3_2.createChildPath(element.getChildren()[2]);
- fListener.addHasChildrenUpdate(path_root_3_2_3);
- fListener.addLabelUpdate(path_root_3_2_3);
- // TODO unnecessary update: fListener.addChildreCountUpdate(path2);
- fListener.addChildreUpdate(path_root_3_2, 0);
- // TODO unnecessary update: fListener.addChildreUpdate(path2, 1);
- fListener.addChildreUpdate(path_root_3_2, 2);
- element = element.getChildren()[1];
- TreePath path_root_3_2_2 = path_root_3_2.createChildPath(element);
- delta = delta.addNode(element, 1, IModelDelta.SELECT, element.fChildren.length);
- fListener.addLabelUpdate(path_root_3_2_2);
- fListener.addHasChildrenUpdate(path_root_3_2_2);
-
- // Validate the expansion state BEFORE posting the delta.
-
- IInternalTreeModelViewer contentProviderViewer = fViewer;
- assertFalse(contentProviderViewer.getExpandedState(path_root_3));
- assertFalse(contentProviderViewer.getExpandedState(path_root_3_2));
- assertFalse(contentProviderViewer.getExpandedState(path_root_3_2_2));
-
- model.postDelta(deltaRoot);
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Create the delta
+ fListener.reset();
+ // TODO Investigate: there seem to be unnecessary updates being issued
+ // by the viewer. These include the updates that are commented out:
+ // For now disable checking for extra updates.
+ fListener.setFailOnRedundantUpdates(false);
+ TestElement element = model.getRootElement();
+ TreePath path_root = TreePath.EMPTY;
+ ModelDelta delta= new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
+ ModelDelta deltaRoot = delta;
+ element = element.getChildren()[2];
+ TreePath path_root_3 = path_root.createChildPath(element);
+ delta = delta.addNode(element, 2, IModelDelta.EXPAND, element.fChildren.length);
+ fListener.addChildreUpdate(path_root_3, 0);
+ TreePath path_root_3_1 = path_root_3.createChildPath(element.getChildren()[0]);
+ fListener.addHasChildrenUpdate(path_root_3_1);
+ fListener.addLabelUpdate(path_root_3_1);
+ TreePath path_root_3_3 = path_root_3.createChildPath(element.getChildren()[2]);
+ fListener.addHasChildrenUpdate(path_root_3_3);
+ fListener.addLabelUpdate(path_root_3_3);
+ //TODO unnecessary update: fListener.addChildreUpdate(path1, 1);
+ fListener.addChildreUpdate(path_root_3, 2);
+ element = element.getChildren()[1];
+ TreePath path_root_3_2 = path_root_3.createChildPath(element);
+ delta = delta.addNode(element, 1, IModelDelta.EXPAND, element.fChildren.length);
+ fListener.addLabelUpdate(path_root_3_2);
+ TreePath path_root_3_2_1 = path_root_3_2.createChildPath(element.getChildren()[0]);
+ fListener.addHasChildrenUpdate(path_root_3_2_1);
+ fListener.addLabelUpdate(path_root_3_2_1);
+ TreePath path_root_3_2_3 = path_root_3_2.createChildPath(element.getChildren()[2]);
+ fListener.addHasChildrenUpdate(path_root_3_2_3);
+ fListener.addLabelUpdate(path_root_3_2_3);
+ // TODO unnecessary update: fListener.addChildreCountUpdate(path2);
+ fListener.addChildreUpdate(path_root_3_2, 0);
+ // TODO unnecessary update: fListener.addChildreUpdate(path2, 1);
+ fListener.addChildreUpdate(path_root_3_2, 2);
+ element = element.getChildren()[1];
+ TreePath path_root_3_2_2 = path_root_3_2.createChildPath(element);
+ delta = delta.addNode(element, 1, IModelDelta.SELECT, element.fChildren.length);
+ fListener.addLabelUpdate(path_root_3_2_2);
+ fListener.addHasChildrenUpdate(path_root_3_2_2);
+
+ // Validate the expansion state BEFORE posting the delta.
+
+ IInternalTreeModelViewer contentProviderViewer = fViewer;
+ assertFalse(contentProviderViewer.getExpandedState(path_root_3));
+ assertFalse(contentProviderViewer.getExpandedState(path_root_3_2));
+ assertFalse(contentProviderViewer.getExpandedState(path_root_3_2_2));
+
+ model.postDelta(deltaRoot);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Validate the expansion state AFTER posting the delta.
- assertTrue(contentProviderViewer.getExpandedState(path_root_3));
- assertTrue(contentProviderViewer.getExpandedState(path_root_3_2));
- assertFalse(contentProviderViewer.getExpandedState(path_root_3_2_2));
+ // Validate the expansion state AFTER posting the delta.
+ assertTrue(contentProviderViewer.getExpandedState(path_root_3));
+ assertTrue(contentProviderViewer.getExpandedState(path_root_3_2));
+ assertFalse(contentProviderViewer.getExpandedState(path_root_3_2_2));
- // Verify selection
- ISelection selection = fViewer.getSelection();
- if (selection instanceof ITreeSelection) {
+ // Verify selection
+ ISelection selection = fViewer.getSelection();
+ if (selection instanceof ITreeSelection) {
List<TreePath> selectionPathsList = Arrays.asList(((ITreeSelection) selection).getPaths());
- assertTrue(selectionPathsList.contains(path_root_3_2_2));
- } else {
+ assertTrue(selectionPathsList.contains(path_root_3_2_2));
+ } else {
fail("Not a tree selection"); //$NON-NLS-1$
- }
- }
+ }
+ }
- /**
- * This test verifies that expand and select updates are being ignored.
- */
+ /**
+ * This test verifies that expand and select updates are being ignored.
+ */
public void testExpandAndSelect_simple() throws Exception {
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Create the delta
- fListener.reset();
- // TODO Investigate: there seem to be unnecessary updates being issued
- // by the viewer. These include the updates that are commented out:
- // For now disable checking for extra updates.
- fListener.setFailOnRedundantUpdates(false);
- TestElement element = model.getRootElement();
- TreePath path_root = TreePath.EMPTY;
- ModelDelta delta= new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
- ModelDelta deltaRoot = delta;
- element = element.getChildren()[2];
- TreePath path_root_3 = path_root.createChildPath(element);
- delta.addNode(element, 2, IModelDelta.SELECT | IModelDelta.EXPAND, element.fChildren.length);
-
- // Validate the expansion state BEFORE posting the delta.
-
- IInternalTreeModelViewer contentProviderViewer = fViewer;
- assertFalse(contentProviderViewer.getExpandedState(path_root_3));
-
- model.postDelta(deltaRoot);
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Create the delta
+ fListener.reset();
+ // TODO Investigate: there seem to be unnecessary updates being issued
+ // by the viewer. These include the updates that are commented out:
+ // For now disable checking for extra updates.
+ fListener.setFailOnRedundantUpdates(false);
+ TestElement element = model.getRootElement();
+ TreePath path_root = TreePath.EMPTY;
+ ModelDelta delta= new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
+ ModelDelta deltaRoot = delta;
+ element = element.getChildren()[2];
+ TreePath path_root_3 = path_root.createChildPath(element);
+ delta.addNode(element, 2, IModelDelta.SELECT | IModelDelta.EXPAND, element.fChildren.length);
+
+ // Validate the expansion state BEFORE posting the delta.
+
+ IInternalTreeModelViewer contentProviderViewer = fViewer;
+ assertFalse(contentProviderViewer.getExpandedState(path_root_3));
+
+ model.postDelta(deltaRoot);
TestUtil.processUIEvents();
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE) && !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Validate the expansion state AFTER posting the delta.
- assertTrue(contentProviderViewer.getExpandedState(path_root_3));
+ // Validate the expansion state AFTER posting the delta.
+ assertTrue(contentProviderViewer.getExpandedState(path_root_3));
- // Verify selection
- ISelection selection = fViewer.getSelection();
- if (selection instanceof ITreeSelection) {
+ // Verify selection
+ ISelection selection = fViewer.getSelection();
+ if (selection instanceof ITreeSelection) {
List<TreePath> selectionPathsList = Arrays.asList(((ITreeSelection) selection).getPaths());
- assertTrue(selectionPathsList.contains(path_root_3));
- } else {
+ assertTrue(selectionPathsList.contains(path_root_3));
+ } else {
fail("Not a tree selection"); //$NON-NLS-1$
- }
- }
+ }
+ }
public void testCompositeModelRefreshStruct() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.compositeMultiLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.compositeMultiLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- // TODO: redundant updates on install deltas
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ // TODO: redundant updates on install deltas
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Update the model
+ // Update the model
TreePath m4_2_1Path = model.findElement("m4.2.1"); //$NON-NLS-1$
- TestElement m4_2_1 = model.getElement(m4_2_1Path);
- TestModel m4 = m4_2_1.getModel();
- TestElement[] newChildren = new TestElement[] {
+ TestElement m4_2_1 = model.getElement(m4_2_1Path);
+ TestModel m4 = m4_2_1.getModel();
+ TestElement[] newChildren = new TestElement[] {
new TestElement(m4, "4.2.1.new-1", new TestElement[0]), //$NON-NLS-1$
new TestElement(m4, "4.2.1.new-2", new TestElement[0]), //$NON-NLS-1$
new TestElement(m4, "4.2.1.new-3", new TestElement[0]), //$NON-NLS-1$
- };
+ };
- ModelDelta delta = m4.setElementChildren(m4_2_1Path, newChildren);
+ ModelDelta delta = m4.setElementChildren(m4_2_1Path, newChildren);
- fListener.reset(m4_2_1Path, m4_2_1, -1, true, false);
- model.postDelta(delta);
+ fListener.reset(m4_2_1Path, m4_2_1, -1, true, false);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
public void testCompositeModelAddElement() throws Exception {
- TestModel model = TestModel.compositeMultiLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.compositeMultiLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- // TODO: redundant updates on install deltas
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ // TODO: redundant updates on install deltas
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
TreePath m3_1Path = model.findElement("m3.1"); //$NON-NLS-1$
- TestElement m3_1 = model.getElement(m3_1Path);
- TestModel m3 = m3_1.getModel();
+ TestElement m3_1 = model.getElement(m3_1Path);
+ TestModel m3 = m3_1.getModel();
TestElement m3_1_new = new TestElement(m3, "m3.1-new", new TestElement[0]); //$NON-NLS-1$
- TreePath m3_1_newPath = m3_1Path.createChildPath(m3_1_new);
- ModelDelta delta = m3.addElementChild(m3_1Path, null, 0, m3_1_new);
+ TreePath m3_1_newPath = m3_1Path.createChildPath(m3_1_new);
+ ModelDelta delta = m3.addElementChild(m3_1Path, null, 0, m3_1_new);
- fListener.reset(m3_1_newPath, m3_1_new, -1, true, false);
- fListener.addChildreUpdate(m3_1Path, 0);
- fListener.setFailOnRedundantUpdates(false);
+ fListener.reset(m3_1_newPath, m3_1_new, -1, true, false);
+ fListener.addChildreUpdate(m3_1Path, 0);
+ fListener.setFailOnRedundantUpdates(false);
- m3.postDelta(delta);
+ m3.postDelta(delta);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
public void testBug292322() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Update the model: remove one child of an un-expanded element, then
- // make sure that the number of children is correct.
+ // Update the model: remove one child of an un-expanded element, then
+ // make sure that the number of children is correct.
TreePath parentPath = model.findElement("2"); //$NON-NLS-1$
- TestElement parentElement = model.getElement(parentPath);
- ModelDelta delta = model.removeElementChild(parentPath, 0);
+ TestElement parentElement = model.getElement(parentPath);
+ ModelDelta delta = model.removeElementChild(parentPath, 0);
- // Update the viewer
- fListener.reset(parentPath, parentElement, 0, false, false);
- //fListener.addChildreCountUpdate(parentPath);
- model.postDelta(delta);
+ // Update the viewer
+ fListener.reset(parentPath, parentElement, 0, false, false);
+ //fListener.addChildreCountUpdate(parentPath);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_COMPLETE), createListenerErrorMessage());
- // Validate the viewer data.
- model.validateData(fViewer, TreePath.EMPTY, true);
+ // Validate the viewer data.
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Update the model: remove the remaining children and make sure that
- // the element children are updated to false.
- model.removeElementChild(parentPath, 0);
+ // Update the model: remove the remaining children and make sure that
+ // the element children are updated to false.
+ model.removeElementChild(parentPath, 0);
- // Update the viewer
- fListener.reset(parentPath, parentElement, 0, false, false);
- model.postDelta(delta);
+ // Update the viewer
+ fListener.reset(parentPath, parentElement, 0, false, false);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_COMPLETE), createListenerErrorMessage());
- // Validate the viewer data.
- model.validateData(fViewer, TreePath.EMPTY, true);
+ // Validate the viewer data.
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Update the model: remove the remaining children and make sure that
- // the element children are updated to false.
- model.removeElementChild(parentPath, 0);
+ // Update the model: remove the remaining children and make sure that
+ // the element children are updated to false.
+ model.removeElementChild(parentPath, 0);
- // Update the viewer
- fListener.reset(parentPath, parentElement, 0, false, false);
- model.postDelta(delta);
+ // Update the viewer
+ fListener.reset(parentPath, parentElement, 0, false, false);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_COMPLETE), createListenerErrorMessage());
- // Validate the viewer data.
- model.validateData(fViewer, TreePath.EMPTY, true);
- }
+ // Validate the viewer data.
+ model.validateData(fViewer, TreePath.EMPTY, true);
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTests.java
index b4928569c..fb958178a 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/FilterTests.java
@@ -37,326 +37,326 @@ import org.eclipse.jface.viewers.ViewerFilter;
*/
abstract public class FilterTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants {
- public FilterTests(String name) {
- super(name);
- }
+ public FilterTests(String name) {
+ super(name);
+ }
@Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
return new TestModelUpdatesListener(viewer, true, true);
}
- protected IInternalTreeModelViewer getInternalViewer() {
- return fViewer;
- }
+ protected IInternalTreeModelViewer getInternalViewer() {
+ return fViewer;
+ }
- class TestViewerFilter extends ViewerFilter {
+ class TestViewerFilter extends ViewerFilter {
- Pattern fPattern;
- TestViewerFilter(String pattern) {
- fPattern = Pattern.compile(pattern);
- }
+ Pattern fPattern;
+ TestViewerFilter(String pattern) {
+ fPattern = Pattern.compile(pattern);
+ }
- @Override
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof TestElement) {
- TestElement te = (TestElement)element;
- return !fPattern.matcher(te.getLabel()).find();
- }
-
- return true;
- }
- }
-
- class TestTMVFilter extends TreeModelViewerFilter {
- Pattern fPattern;
- Object fParentElement;
- TestTMVFilter(String pattern, Object parentElement) {
- fPattern = Pattern.compile(pattern);
- fParentElement = parentElement;
- }
-
- @Override
+ if (element instanceof TestElement) {
+ TestElement te = (TestElement)element;
+ return !fPattern.matcher(te.getLabel()).find();
+ }
+
+ return true;
+ }
+ }
+
+ class TestTMVFilter extends TreeModelViewerFilter {
+ Pattern fPattern;
+ Object fParentElement;
+ TestTMVFilter(String pattern, Object parentElement) {
+ fPattern = Pattern.compile(pattern);
+ fParentElement = parentElement;
+ }
+
+ @Override
public boolean isApplicable(ITreeModelViewer viewer, Object parentElement) {
- if (fParentElement != null) {
- return fParentElement.equals(parentElement);
- }
+ if (fParentElement != null) {
+ return fParentElement.equals(parentElement);
+ }
- return true;
- }
+ return true;
+ }
- @Override
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof TestElement) {
- TestElement te = (TestElement)element;
- return !fPattern.matcher(te.getLabel()).find();
- }
+ if (element instanceof TestElement) {
+ TestElement te = (TestElement)element;
+ return !fPattern.matcher(te.getLabel()).find();
+ }
- return true;
- }
- }
+ return true;
+ }
+ }
public void testSimpleSingleLevel() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
+ TestModel model = TestModel.simpleSingleLevel();
doTestSimpleLevel(model, new ViewerFilter[] { new TestViewerFilter("2") }); //$NON-NLS-1$
- }
+ }
public void testSimpleSingleLevelWithTMVFilter() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
+ TestModel model = TestModel.simpleSingleLevel();
doTestSimpleLevel(model, new ViewerFilter[] { new TestTMVFilter("2", model.getRootElement()) }); //$NON-NLS-1$
- }
+ }
public void testSimpleSingleLevelWithMixedFilters() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
+ TestModel model = TestModel.simpleSingleLevel();
doTestSimpleLevel(model, new ViewerFilter[] { new TestTMVFilter("2", model.getRootElement()), new TestViewerFilter("1") }); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
public void testSimpleMultiLevel() throws Exception {
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
doTestSimpleLevel(model, new ViewerFilter[] { new TestViewerFilter(".1"), new TestViewerFilter(".2") }); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
public void testSimpleMultiLevelWithTMVFilter() throws Exception {
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
doTestSimpleLevel(model, new ViewerFilter[] { new TestTMVFilter(".1", null), new TestTMVFilter(".2", null) }); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
public void testSimpleMultiLevelWithMixedFilters() throws Exception {
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
doTestSimpleLevel(model, new ViewerFilter[] { new TestViewerFilter(".1"), new TestTMVFilter(".2", null) }); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
private void doTestSimpleLevel(TestModel model, ViewerFilter[] filters) throws Exception {
- // Make sure that all elements are expanded
- fViewer.setAutoExpandLevel(-1);
+ // Make sure that all elements are expanded
+ fViewer.setAutoExpandLevel(-1);
- fViewer.setFilters(filters);
+ fViewer.setFilters(filters);
- // Create the listener which determines when the view is finished updating.
- // fListener.reset(TreePath.EMPTY, model.getRootElement(), filters, -1, false, false);
- fListener.reset(TreePath.EMPTY, model.getRootElement(), filters, -1, true, true);
+ // Create the listener which determines when the view is finished updating.
+ // fListener.reset(TreePath.EMPTY, model.getRootElement(), filters, -1, false, false);
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), filters, -1, true, true);
- // Set the viewer input (and trigger updates).
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input (and trigger updates).
+ fViewer.setInput(model.getRootElement());
- // Wait for the updates to complete.
+ // Wait for the updates to complete.
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, false, filters);
- }
+ model.validateData(fViewer, TreePath.EMPTY, false, filters);
+ }
public void testLargeSingleLevel() throws Exception {
doTestLargeSingleLevel(new ViewerFilter[] { new TestViewerFilter("2") }); //$NON-NLS-1$
- }
+ }
public void testLargeSingleLevelWithTMVFilter() throws Exception {
doTestLargeSingleLevel(new ViewerFilter[] { new TestTMVFilter("2", null) }); //$NON-NLS-1$
- }
+ }
private void doTestLargeSingleLevel(ViewerFilter[] filters) throws Exception {
- TestModel model = new TestModel();
+ TestModel model = new TestModel();
model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$
model.setElementChildren(TreePath.EMPTY, TestModel.makeSingleLevelModelElements(model, 3000, "model.")); //$NON-NLS-1$
- // Set filters
- fViewer.setFilters(filters);
+ // Set filters
+ fViewer.setFilters(filters);
- fListener.setFailOnRedundantUpdates(false);
- //fListener.setFailOnMultipleLabelUpdateSequences(false);
- fListener.reset();
+ fListener.setFailOnRedundantUpdates(false);
+ //fListener.setFailOnMultipleLabelUpdateSequences(false);
+ fListener.reset();
- fViewer.setInput(model.getRootElement());
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- }
+ }
- /**
- * Replace an element that is not visible but filtered out. With an element that is NOT filtered out.
- * Fire REPLACE delta.
- */
+ /**
+ * Replace an element that is not visible but filtered out. With an element that is NOT filtered out.
+ * Fire REPLACE delta.
+ */
public void testReplacedUnrealizedFilteredElement() throws Exception {
doTestReplacedUnrealizedFilteredElement(new ViewerFilter[] { new TestViewerFilter("2") }); //$NON-NLS-1$
- }
+ }
- /**
- * Replace an element that is not visible but filtered out. With an element that is NOT filtered out.
- * Fire REPLACE delta.
- */
+ /**
+ * Replace an element that is not visible but filtered out. With an element that is NOT filtered out.
+ * Fire REPLACE delta.
+ */
public void testReplacedUnrealizedFilteredElementWithTMVFilter() throws Exception {
doTestReplacedUnrealizedFilteredElement(new ViewerFilter[] { new TestTMVFilter("2", null) }); //$NON-NLS-1$
- }
+ }
private void doTestReplacedUnrealizedFilteredElement(ViewerFilter[] filters) throws Exception {
- // Populate a view with a large model (only first 100 elements will be visible in virtual viewer).
- TestModel model = new TestModel();
+ // Populate a view with a large model (only first 100 elements will be visible in virtual viewer).
+ TestModel model = new TestModel();
model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$
model.setElementChildren(TreePath.EMPTY, TestModel.makeSingleLevelModelElements(model, 300, "model.")); //$NON-NLS-1$
- fViewer.setFilters(filters);
+ fViewer.setFilters(filters);
- fListener.setFailOnRedundantUpdates(false);
- fListener.reset();
+ fListener.setFailOnRedundantUpdates(false);
+ fListener.reset();
- // Populate the view (all elements containing a "2" will be filtered out.
- fViewer.setInput(model.getRootElement());
+ // Populate the view (all elements containing a "2" will be filtered out.
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Switch out element "201" which is filtered out, with a "replaced element" which should NOT be
- // filtered out.
+ // Switch out element "201" which is filtered out, with a "replaced element" which should NOT be
+ // filtered out.
TestElement replacedElement = new TestElement(model, "replaced element", new TestElement[0]); //$NON-NLS-1$
- IModelDelta replaceDelta = model.replaceElementChild(TreePath.EMPTY, 200, replacedElement);
- fListener.reset();
- model.postDelta(replaceDelta);
+ IModelDelta replaceDelta = model.replaceElementChild(TreePath.EMPTY, 200, replacedElement);
+ fListener.reset();
+ model.postDelta(replaceDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Reposition the viewer to make element 100 the top element, making the replaced element visible.
- fListener.reset();
- fViewer.reveal(TreePath.EMPTY, 150);
+ // Reposition the viewer to make element 100 the top element, making the replaced element visible.
+ fListener.reset();
+ fViewer.reveal(TreePath.EMPTY, 150);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Verify that the replaced element is in viewer now (i.e. it's not filtered out.
- TreePath[] replacedElementPaths = fViewer.getElementPaths(replacedElement);
- assertTrue(replacedElementPaths.length != 0);
- }
+ // Verify that the replaced element is in viewer now (i.e. it's not filtered out.
+ TreePath[] replacedElementPaths = fViewer.getElementPaths(replacedElement);
+ assertTrue(replacedElementPaths.length != 0);
+ }
public void testRefreshUnrealizedFilteredElement() throws Exception {
doTestRefreshUnrealizedFilteredElement(new ViewerFilter[] { new TestViewerFilter("2") }); //$NON-NLS-1$
- }
+ }
public void testRefreshUnrealizedFilteredElementWithTMVFilter() throws Exception {
doTestRefreshUnrealizedFilteredElement(new ViewerFilter[] { new TestTMVFilter("2", null) }); //$NON-NLS-1$
- }
+ }
- /**
- * Replace an element that is not visible but filtered out. With an element that is NOT filtered out.
- * Fire CONTENT delta on parent.
- */
+ /**
+ * Replace an element that is not visible but filtered out. With an element that is NOT filtered out.
+ * Fire CONTENT delta on parent.
+ */
private void doTestRefreshUnrealizedFilteredElement(ViewerFilter[] filters) throws Exception {
- // Populate a view with a large model (only first 100 elements will be visible in virtual viewer).
- TestModel model = new TestModel();
+ // Populate a view with a large model (only first 100 elements will be visible in virtual viewer).
+ TestModel model = new TestModel();
model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$
model.setElementChildren(TreePath.EMPTY, TestModel.makeSingleLevelModelElements(model, 300, "model.")); //$NON-NLS-1$
- fViewer.setFilters(filters);
+ fViewer.setFilters(filters);
- fListener.setFailOnRedundantUpdates(false);
- fListener.reset();
+ fListener.setFailOnRedundantUpdates(false);
+ fListener.reset();
- // Populate the view (all elements containing a "2" will be filtered out.
- fViewer.setInput(model.getRootElement());
+ // Populate the view (all elements containing a "2" will be filtered out.
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Switch out element "201" which is filtered out, with a "replaced element" which should NOT be
- // filtered out.
+ // Switch out element "201" which is filtered out, with a "replaced element" which should NOT be
+ // filtered out.
TestElement replacedElement = new TestElement(model, "replaced element", new TestElement[0]); //$NON-NLS-1$
- model.replaceElementChild(TreePath.EMPTY, 200, replacedElement);
- fListener.reset();
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ model.replaceElementChild(TreePath.EMPTY, 200, replacedElement);
+ fListener.reset();
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Reposition the viewer to make element 100 the top element, making the replaced element visible.
- fListener.reset();
- fViewer.reveal(TreePath.EMPTY, 150);
+ // Reposition the viewer to make element 100 the top element, making the replaced element visible.
+ fListener.reset();
+ fViewer.reveal(TreePath.EMPTY, 150);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Verify that the replaced element is in viewer now (i.e. it's not filtered out.
- TreePath[] replacedElementPaths = fViewer.getElementPaths(replacedElement);
- assertTrue(replacedElementPaths.length != 0);
- }
+ // Verify that the replaced element is in viewer now (i.e. it's not filtered out.
+ TreePath[] replacedElementPaths = fViewer.getElementPaths(replacedElement);
+ assertTrue(replacedElementPaths.length != 0);
+ }
public void testRefreshToUnfilterElements() throws Exception {
doTestRefreshToUnfilterElements(new ViewerFilter[] { new TestViewerFilter(".1"), new TestViewerFilter(".2") }); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
public void testRefreshToUnfilterElementsWithTMVFilter() throws Exception {
doTestRefreshToUnfilterElements(new ViewerFilter[] { new TestTMVFilter(".1", null), new TestTMVFilter(".2", null) }); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
public void testRefreshToUnfilterElementsWithMixedFilters() throws Exception {
doTestRefreshToUnfilterElements(new ViewerFilter[] { new TestViewerFilter(".1"), new TestTMVFilter(".2", null) }); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ }
- /**
- * Replace an element that is not visible but filtered out. With an element that is NOT filtered out.
- * Fire CONTENT delta on parent.
- */
+ /**
+ * Replace an element that is not visible but filtered out. With an element that is NOT filtered out.
+ * Fire CONTENT delta on parent.
+ */
private void doTestRefreshToUnfilterElements(ViewerFilter[] filters) throws Exception {
ViewerFilter[] filters1 = filters;
- // Populate a view with a large model (only first 100 elements will be visible in virtual viewer).
- TestModel model = TestModel.simpleMultiLevel();
+ // Populate a view with a large model (only first 100 elements will be visible in virtual viewer).
+ TestModel model = TestModel.simpleMultiLevel();
- fViewer.setFilters(filters);
+ fViewer.setFilters(filters);
- fListener.setFailOnRedundantUpdates(false);
- fListener.reset();
+ fListener.setFailOnRedundantUpdates(false);
+ fListener.reset();
- // Make sure that all elements are expanded
- fViewer.setAutoExpandLevel(-1);
+ // Make sure that all elements are expanded
+ fViewer.setAutoExpandLevel(-1);
- // Populate the view (all elements containing a "2" will be filtered out.
- fViewer.setInput(model.getRootElement());
+ // Populate the view (all elements containing a "2" will be filtered out.
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Turn off filters and refresh.
+ // Turn off filters and refresh.
filters1 = new ViewerFilter[0];
fViewer.setFilters(filters1);
- fListener.reset();
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ fListener.reset();
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
model.validateData(fViewer, TreePath.EMPTY, false, filters1);
- }
+ }
public void testPreserveExpandedOnMultLevelContent() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = StateTests.alternatingSubsreesModel(6);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = StateTests.alternatingSubsreesModel(6);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- StateTests.expandAlternateElements(fListener, model, true);
+ StateTests.expandAlternateElements(fListener, model, true);
- // Set a selection in view
- // Set a selection in view
- TreeSelection originalSelection = new TreeSelection(
+ // Set a selection in view
+ // Set a selection in view
+ TreeSelection originalSelection = new TreeSelection(
new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findElement("6") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- fViewer.setSelection(originalSelection);
- assertTrue( StateTests.areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ fViewer.setSelection(originalSelection);
+ assertTrue( StateTests.areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- // Set a filter to remove element "1"
+ // Set a filter to remove element "1"
ViewerFilter[] filters = new ViewerFilter[] { new TestViewerFilter("^1$") }; //$NON-NLS-1$
- fViewer.setFilters(filters);
+ fViewer.setFilters(filters);
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), filters, -1, ALL_UPDATES_COMPLETE);
+ // Note: Re-expanding nodes causes redundant updates.
+ fListener.reset(false, false);
+ fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), filters, -1, ALL_UPDATES_COMPLETE);
- // Post the refresh delta
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Post the refresh delta
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true, filters);
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true, filters);
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
@@ -364,24 +364,24 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( StateTests.areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ assertTrue( StateTests.areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- // Note: in past it was observed sub-optimal coalescing in this test due
- // to scattered update requests from viewer.
- assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) );
+ // Note: in past it was observed sub-optimal coalescing in this test due
+ // to scattered update requests from viewer.
+ assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 6) );
- // Clear the filter, to re-add the element
- filters = new ViewerFilter[0];
- fViewer.setFilters(filters);
+ // Clear the filter, to re-add the element
+ filters = new ViewerFilter[0];
+ fViewer.setFilters(filters);
- // Refresh again to get the filtered element back
- fListener.reset();
- fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), filters, -1, ALL_UPDATES_COMPLETE);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Refresh again to get the filtered element back
+ fListener.reset();
+ fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), filters, -1, ALL_UPDATES_COMPLETE);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true, filters);
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true, filters);
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
@@ -389,8 +389,8 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( StateTests.areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ assertTrue( StateTests.areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java
index d195e59fd..332723b61 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java
@@ -20,35 +20,35 @@ package org.eclipse.debug.tests.viewer.model;
*/
public interface ITestModelUpdatesListenerConstants {
- int LABEL_SEQUENCE_COMPLETE = 0X00000001;
- int CONTENT_SEQUENCE_COMPLETE = 0X00000002;
- int CONTENT_SEQUENCE_STARTED = 0X00020000;
- int LABEL_UPDATES = 0X00000004;
- int LABEL_SEQUENCE_STARTED = 0X00040000;
- int HAS_CHILDREN_UPDATES = 0X00000008;
- int HAS_CHILDREN_UPDATES_STARTED = 0X00080000;
- int CHILD_COUNT_UPDATES = 0X00000010;
- int CHILD_COUNT_UPDATES_STARTED = 0X00100000;
- int CHILDREN_UPDATES = 0X00000020;
- int CHILDREN_UPDATES_STARTED = 0X00200000;
- int CHILDREN_UPDATES_RUNNING = 0X00400000;
- int MODEL_CHANGED_COMPLETE = 0X00000040;
- int MODEL_PROXIES_INSTALLED = 0X00000080;
- int STATE_SAVE_COMPLETE = 0X00000100;
- int STATE_SAVE_STARTED = 0X01000000;
- int STATE_RESTORE_COMPLETE = 0X00000200;
- int STATE_RESTORE_STARTED = 0X02000000;
- int STATE_UPDATES = 0X00000400;
- int STATE_UPDATES_STARTED = 0X04000000;
+ int LABEL_SEQUENCE_COMPLETE = 0X00000001;
+ int CONTENT_SEQUENCE_COMPLETE = 0X00000002;
+ int CONTENT_SEQUENCE_STARTED = 0X00020000;
+ int LABEL_UPDATES = 0X00000004;
+ int LABEL_SEQUENCE_STARTED = 0X00040000;
+ int HAS_CHILDREN_UPDATES = 0X00000008;
+ int HAS_CHILDREN_UPDATES_STARTED = 0X00080000;
+ int CHILD_COUNT_UPDATES = 0X00000010;
+ int CHILD_COUNT_UPDATES_STARTED = 0X00100000;
+ int CHILDREN_UPDATES = 0X00000020;
+ int CHILDREN_UPDATES_STARTED = 0X00200000;
+ int CHILDREN_UPDATES_RUNNING = 0X00400000;
+ int MODEL_CHANGED_COMPLETE = 0X00000040;
+ int MODEL_PROXIES_INSTALLED = 0X00000080;
+ int STATE_SAVE_COMPLETE = 0X00000100;
+ int STATE_SAVE_STARTED = 0X01000000;
+ int STATE_RESTORE_COMPLETE = 0X00000200;
+ int STATE_RESTORE_STARTED = 0X02000000;
+ int STATE_UPDATES = 0X00000400;
+ int STATE_UPDATES_STARTED = 0X04000000;
- int VIEWER_UPDATES_RUNNING = 0X00001000;
- int LABEL_UPDATES_RUNNING = 0X00002000;
+ int VIEWER_UPDATES_RUNNING = 0X00001000;
+ int LABEL_UPDATES_RUNNING = 0X00002000;
- int ALL_VIEWER_UPDATES_STARTED = HAS_CHILDREN_UPDATES_STARTED | CHILD_COUNT_UPDATES_STARTED | CHILDREN_UPDATES_STARTED;
+ int ALL_VIEWER_UPDATES_STARTED = HAS_CHILDREN_UPDATES_STARTED | CHILD_COUNT_UPDATES_STARTED | CHILDREN_UPDATES_STARTED;
- int LABEL_COMPLETE = LABEL_SEQUENCE_COMPLETE | LABEL_UPDATES | LABEL_UPDATES_RUNNING;
- int CONTENT_COMPLETE =
- CONTENT_SEQUENCE_COMPLETE | HAS_CHILDREN_UPDATES | CHILD_COUNT_UPDATES | CHILDREN_UPDATES | VIEWER_UPDATES_RUNNING;
+ int LABEL_COMPLETE = LABEL_SEQUENCE_COMPLETE | LABEL_UPDATES | LABEL_UPDATES_RUNNING;
+ int CONTENT_COMPLETE =
+ CONTENT_SEQUENCE_COMPLETE | HAS_CHILDREN_UPDATES | CHILD_COUNT_UPDATES | CHILDREN_UPDATES | VIEWER_UPDATES_RUNNING;
- int ALL_UPDATES_COMPLETE = LABEL_COMPLETE | CONTENT_COMPLETE | MODEL_PROXIES_INSTALLED | LABEL_UPDATES_RUNNING | VIEWER_UPDATES_RUNNING;
+ int ALL_UPDATES_COMPLETE = LABEL_COMPLETE | CONTENT_COMPLETE | MODEL_PROXIES_INSTALLED | LABEL_UPDATES_RUNNING | VIEWER_UPDATES_RUNNING;
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerCheckTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerCheckTests.java
index c596da581..21e849d19 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerCheckTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerCheckTests.java
@@ -26,12 +26,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerCheckTests extends CheckTests {
- public JFaceViewerCheckTests(String name) {
- super(name);
- }
+ public JFaceViewerCheckTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.CHECK, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerContentTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerContentTests.java
index 85b8f32ca..53feebda2 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerContentTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerContentTests.java
@@ -26,12 +26,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerContentTests extends ContentTests {
- public JFaceViewerContentTests(String name) {
- super(name);
- }
+ public JFaceViewerContentTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerDeltaTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerDeltaTests.java
index 356c20a46..5bfa72a37 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerDeltaTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerDeltaTests.java
@@ -26,19 +26,19 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerDeltaTests extends DeltaTests {
- public JFaceViewerDeltaTests(String name) {
- super(name);
- }
+ public JFaceViewerDeltaTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
- /**
- * TODO: remove this method when bug 292322 gets fixed in TreeViewer
- */
- @Override
+ /**
+ * TODO: remove this method when bug 292322 gets fixed in TreeViewer
+ */
+ @Override
public void testBug292322() {
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerFilterTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerFilterTests.java
index e4d8d8d6a..e120aa4c9 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerFilterTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerFilterTests.java
@@ -26,12 +26,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerFilterTests extends FilterTests {
- public JFaceViewerFilterTests(String name) {
- super(name);
- }
+ public JFaceViewerFilterTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.MULTI, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerLazyTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerLazyTests.java
index 271c9f2a3..9d042f74b 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerLazyTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerLazyTests.java
@@ -25,12 +25,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerLazyTests extends LazyTests {
- public JFaceViewerLazyTests(String name) {
- super(name);
- }
+ public JFaceViewerLazyTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPerformanceTests.java
index 9a855265d..ed4b6815f 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPerformanceTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPerformanceTests.java
@@ -25,17 +25,17 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerPerformanceTests extends PerformanceTests {
- public JFaceViewerPerformanceTests(String name) {
- super(name);
- }
+ public JFaceViewerPerformanceTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
- @Override
+ @Override
protected int getTestModelDepth() {
- return 5;
- }
+ return 5;
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPopupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPopupTests.java
index 221e68def..eda0e22a3 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPopupTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerPopupTests.java
@@ -26,12 +26,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerPopupTests extends PopupTests {
- public JFaceViewerPopupTests(String name) {
- super(name);
- }
+ public JFaceViewerPopupTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell, int style) {
return new TreeModelViewer(fShell, SWT.VIRTUAL | style, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerSelectionTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerSelectionTests.java
index e60f5cadb..b520b9b31 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerSelectionTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerSelectionTests.java
@@ -26,12 +26,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerSelectionTests extends SelectionTests {
- public JFaceViewerSelectionTests(String name) {
- super(name);
- }
+ public JFaceViewerSelectionTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerStateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerStateTests.java
index 46e1fd6b2..ef8b08746 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerStateTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerStateTests.java
@@ -26,12 +26,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerStateTests extends StateTests {
- public JFaceViewerStateTests(String name) {
- super(name);
- }
+ public JFaceViewerStateTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.MULTI, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerTopIndexTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerTopIndexTests.java
index 05415e6c2..d0ffc8645 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerTopIndexTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerTopIndexTests.java
@@ -35,9 +35,9 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants {
- public JFaceViewerTopIndexTests(String name) {
- super(name);
- }
+ public JFaceViewerTopIndexTests(String name) {
+ super(name);
+ }
@Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
@@ -46,445 +46,445 @@ public class JFaceViewerTopIndexTests extends AbstractViewerModelTest implements
protected final TreeModelViewer getCTargetViewer() {
return (TreeModelViewer) fViewer;
- }
-
- /**
- * @param display the display
- * @param shell the shell
- * @return the new viewer
- */
- @Override
+ }
+
+ /**
+ * @param display the display
+ * @param shell the shell
+ * @return the new viewer
+ */
+ @Override
protected TreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL | SWT.MULTI, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
- /**
- * Restore REVEAL on simple model with elements without children.
- *
- */
+ /**
+ * Restore REVEAL on simple model with elements without children.
+ *
+ */
public void testRestoreTopIndex() throws Exception {
TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer());
- TestModel model = new TestModel();
+ TestModel model = new TestModel();
- TestElement[] elements = new TestElement[8];
- for (int i = 0; i < elements.length; i++) {
- String text = Integer.toString(i + 1);
- // elements don't have children
- elements[i] =
- new TestElement(model, text, new TestElement[0] );
+ TestElement[] elements = new TestElement[8];
+ for (int i = 0; i < elements.length; i++) {
+ String text = Integer.toString(i + 1);
+ // elements don't have children
+ elements[i] =
+ new TestElement(model, text, new TestElement[0] );
- }
+ }
model.setRoot(new TestElement(model, "root", elements)); //$NON-NLS-1$
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Stop forcing view updates.
- autopopulateAgent.dispose();
+ // Stop forcing view updates.
+ autopopulateAgent.dispose();
- // scroll to the 5th element
- int indexRevealElem = 4;
- getCTargetViewer().reveal(TreePath.EMPTY, indexRevealElem);
+ // scroll to the 5th element
+ int indexRevealElem = 4;
+ getCTargetViewer().reveal(TreePath.EMPTY, indexRevealElem);
TestUtil.processUIEvents();
- final TreePath originalTopPath = getCTargetViewer().getTopElementPath();
+ final TreePath originalTopPath = getCTargetViewer().getTopElementPath();
assertNotNull("Top item should not be null!", originalTopPath); //$NON-NLS-1$
- // Bug 116105: On a Mac the reveal call is not reliable. Use the viewer returned path instead.
- // assertEquals(elements[indexRevealElem], originalTopPath.getLastSegment());
+ // Bug 116105: On a Mac the reveal call is not reliable. Use the viewer returned path instead.
+ // assertEquals(elements[indexRevealElem], originalTopPath.getLastSegment());
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(true, false);
- fListener.addStateUpdates(getCTargetViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset(true, false);
+ fListener.addStateUpdates(getCTargetViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
- fViewer.setInput(null);
+ fViewer.setInput(null);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE | STATE_UPDATES), createListenerErrorMessage());
- // Set the viewer input back to the model to trigger RESTORE operation.
- fListener.reset(false, false);
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model to trigger RESTORE operation.
+ fListener.reset(false, false);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
TestUtil.processUIEvents();
- // check if REVEAL was restored OK
- final TreePath topPath = getCTargetViewer().getTopElementPath();
+ // check if REVEAL was restored OK
+ final TreePath topPath = getCTargetViewer().getTopElementPath();
assertNotNull("Top item should not be null!", topPath); //$NON-NLS-1$
- TreePathWrapper.assertEqual(originalTopPath, topPath);
- }
-
- /**
- * Restore REVEAL when having also to restore an expanded element
- * that is just above the REVEAL element.
- *
- * See bug 324100
- */
+ TreePathWrapper.assertEqual(originalTopPath, topPath);
+ }
+
+ /**
+ * Restore REVEAL when having also to restore an expanded element
+ * that is just above the REVEAL element.
+ *
+ * See bug 324100
+ */
public void testRestoreTopAndExpand() throws Exception {
TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer());
- TestModel model = new TestModel();
+ TestModel model = new TestModel();
- TestElement[] elements = new TestElement[10];
- for (int i = 0; i < elements.length; i++) {
- String text = Integer.toString(i + 1);
- // first element has 2 children
- if (i == 0) {
- elements[i] =
- new TestElement(model, text, new TestElement[] {
+ TestElement[] elements = new TestElement[10];
+ for (int i = 0; i < elements.length; i++) {
+ String text = Integer.toString(i + 1);
+ // first element has 2 children
+ if (i == 0) {
+ elements[i] =
+ new TestElement(model, text, new TestElement[] {
new TestElement(model, text + ".1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, text + ".2", new TestElement[0]) //$NON-NLS-1$
- });
- } else {
- // rest of elements don't have children
- elements[i] =
- new TestElement(model, text, new TestElement[0] );
- }
-
- }
+ });
+ } else {
+ // rest of elements don't have children
+ elements[i] =
+ new TestElement(model, text, new TestElement[0] );
+ }
+
+ }
model.setRoot(new TestElement(model, "root", elements)); //$NON-NLS-1$
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Expand first element
- fListener.reset();
- fListener.setFailOnRedundantUpdates(false);
- int indexFirstElem = 0;
- TestElement firstElem = elements[indexFirstElem];
- ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- ModelDelta delta = model.getBaseDelta(rootDelta);
- TreePath firstElemPath = model.findElement(firstElem.getLabel());
- fListener.addUpdates(
- firstElemPath, firstElem, 1,
- CHILD_COUNT_UPDATES | CHILDREN_UPDATES );
- delta.addNode(firstElem, indexFirstElem, IModelDelta.EXPAND, firstElem.getChildren().length);
-
- model.postDelta(rootDelta);
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Expand first element
+ fListener.reset();
+ fListener.setFailOnRedundantUpdates(false);
+ int indexFirstElem = 0;
+ TestElement firstElem = elements[indexFirstElem];
+ ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ ModelDelta delta = model.getBaseDelta(rootDelta);
+ TreePath firstElemPath = model.findElement(firstElem.getLabel());
+ fListener.addUpdates(
+ firstElemPath, firstElem, 1,
+ CHILD_COUNT_UPDATES | CHILDREN_UPDATES );
+ delta.addNode(firstElem, indexFirstElem, IModelDelta.EXPAND, firstElem.getChildren().length);
+
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Validate that the first node is expanded
- assertTrue(getCTargetViewer().getExpandedState(firstElemPath) == true);
+ // Validate that the first node is expanded
+ assertTrue(getCTargetViewer().getExpandedState(firstElemPath) == true);
- // Stop forcing view updates.
- autopopulateAgent.dispose();
+ // Stop forcing view updates.
+ autopopulateAgent.dispose();
- // scroll to the 2nd element
- getCTargetViewer().reveal(TreePath.EMPTY, 1);
+ // scroll to the 2nd element
+ getCTargetViewer().reveal(TreePath.EMPTY, 1);
TestUtil.processUIEvents();
- final TreePath originalTopPath = getCTargetViewer().getTopElementPath();
+ final TreePath originalTopPath = getCTargetViewer().getTopElementPath();
assertNotNull("Top item should not be null!", originalTopPath); //$NON-NLS-1$
- // Bug 116105: On a Mac the reveal call is not reliable. Use the viewer returned path instead.
- //assertEquals(elements[1], originalTopPath.getLastSegment());
+ // Bug 116105: On a Mac the reveal call is not reliable. Use the viewer returned path instead.
+ //assertEquals(elements[1], originalTopPath.getLastSegment());
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(true, false);
- fListener.addStateUpdates(getCTargetViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
- fViewer.setInput(null);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset(true, false);
+ fListener.addStateUpdates(getCTargetViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
+ fViewer.setInput(null);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE), createListenerErrorMessage());
- // Set the viewer input back to the model
- fListener.reset(false, false);
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model
+ fListener.reset(false, false);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
TestUtil.processUIEvents();
- // check if REVEAL was restored OK
- final TreePath topPath = getCTargetViewer().getTopElementPath();
+ // check if REVEAL was restored OK
+ final TreePath topPath = getCTargetViewer().getTopElementPath();
assertNotNull("Top item should not be null!", topPath); //$NON-NLS-1$
- TreePathWrapper.assertEqual(originalTopPath, topPath);
- }
-
- /**
- * Restore REVEAL when this operation triggers restoring of an expanded
- * element.
- *
- * See bug 324100
- */
+ TreePathWrapper.assertEqual(originalTopPath, topPath);
+ }
+
+ /**
+ * Restore REVEAL when this operation triggers restoring of an expanded
+ * element.
+ *
+ * See bug 324100
+ */
public void testRestoreTopTriggersExpand() throws Exception {
TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer());
- TestModel model = new TestModel();
+ TestModel model = new TestModel();
- TestElement[] elements = new TestElement[10];
- for (int i = 0; i < elements.length; i++) {
- String text = Integer.toString(i + 1);
- // last element has 2 children
- if (i == elements.length - 1) {
- elements[i] =
- new TestElement(model, text, new TestElement[] {
+ TestElement[] elements = new TestElement[10];
+ for (int i = 0; i < elements.length; i++) {
+ String text = Integer.toString(i + 1);
+ // last element has 2 children
+ if (i == elements.length - 1) {
+ elements[i] =
+ new TestElement(model, text, new TestElement[] {
new TestElement(model, text + ".1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, text + ".2", new TestElement[0]) //$NON-NLS-1$
- });
- } else {
- // rest of elements don't have children
- elements[i] =
- new TestElement(model, text, new TestElement[0] );
- }
+ });
+ } else {
+ // rest of elements don't have children
+ elements[i] =
+ new TestElement(model, text, new TestElement[0] );
+ }
- }
+ }
- fViewer.setAutoExpandLevel(-1);
+ fViewer.setAutoExpandLevel(-1);
model.setRoot(new TestElement(model, "root", elements)); //$NON-NLS-1$
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- int indexLastElem = elements.length-1;
- TestElement lastElem = elements[indexLastElem];
- TreePath lastElemePath = model.findElement(lastElem.getLabel());
+ int indexLastElem = elements.length-1;
+ TestElement lastElem = elements[indexLastElem];
+ TreePath lastElemePath = model.findElement(lastElem.getLabel());
- // Validate that the last node is expanded
- assertTrue(getCTargetViewer().getExpandedState(lastElemePath) == true);
+ // Validate that the last node is expanded
+ assertTrue(getCTargetViewer().getExpandedState(lastElemePath) == true);
- // Stop forcing view updates.
- fViewer.setAutoExpandLevel(0);
- autopopulateAgent.dispose();
+ // Stop forcing view updates.
+ fViewer.setAutoExpandLevel(0);
+ autopopulateAgent.dispose();
- // scroll to the element before last element
- getCTargetViewer().reveal(TreePath.EMPTY, indexLastElem-1);
+ // scroll to the element before last element
+ getCTargetViewer().reveal(TreePath.EMPTY, indexLastElem-1);
TestUtil.processUIEvents();
- final TreePath originalTopPath = getCTargetViewer().getTopElementPath();
+ final TreePath originalTopPath = getCTargetViewer().getTopElementPath();
assertNotNull("Top item should not be null!", originalTopPath); //$NON-NLS-1$
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(true, false);
- fListener.addStateUpdates(getCTargetViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset(true, false);
+ fListener.addStateUpdates(getCTargetViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
- fViewer.setInput(null);
+ fViewer.setInput(null);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE | STATE_UPDATES), createListenerErrorMessage());
- // Set the viewer input back to the model.
- fListener.reset(false, false);
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model.
+ fListener.reset(false, false);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
TestUtil.processUIEvents();
- // check if REVEAL was restored OK
- final TreePath topPath = getCTargetViewer().getTopElementPath();
+ // check if REVEAL was restored OK
+ final TreePath topPath = getCTargetViewer().getTopElementPath();
assertNotNull("Top item should not be null!", topPath); //$NON-NLS-1$
- TreePathWrapper.assertEqual(originalTopPath, topPath);
- }
-
- /**
- * Test for bug 326965.<br>
- * This test verifies that canceling a reveal pending state delta is
- * properly handled when a new reveal delta is received from the model.
- */
+ TreePathWrapper.assertEqual(originalTopPath, topPath);
+ }
+
+ /**
+ * Test for bug 326965.<br>
+ * This test verifies that canceling a reveal pending state delta is
+ * properly handled when a new reveal delta is received from the model.
+ */
public void testRestoreRevealAfterRevealCancel() throws Exception {
TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer());
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
- // Expand all
- fViewer.setAutoExpandLevel(-1);
+ // Expand all
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Stop autopopulating the view.
- autopopulateAgent.dispose();
+ // Stop autopopulating the view.
+ autopopulateAgent.dispose();
- // Set top index of view to element "3" and wait for view to repaint.
- getCTargetViewer().reveal(TreePath.EMPTY, 2);
+ // Set top index of view to element "3" and wait for view to repaint.
+ getCTargetViewer().reveal(TreePath.EMPTY, 2);
TestUtil.processUIEvents();
- // Trigger save of state.
- fListener.reset();
- fViewer.setInput(null);
- while (!fListener.isFinished(STATE_SAVE_COMPLETE)) {
+ // Trigger save of state.
+ fListener.reset();
+ fViewer.setInput(null);
+ while (!fListener.isFinished(STATE_SAVE_COMPLETE)) {
Thread.sleep(0);
}
- // Set input back to root element.
- // Note: Wait only for the processing of the delta and the start of state restore, not for all updates
- fListener.reset();
+ // Set input back to root element.
+ // Note: Wait only for the processing of the delta and the start of state restore, not for all updates
+ fListener.reset();
TreePath elementPath = model.findElement("3"); //$NON-NLS-1$
- fListener.addUpdates(fViewer, elementPath, model.getElement(elementPath), 1, STATE_UPDATES);
- fViewer.setInput(model.getRootElement());
+ fListener.addUpdates(fViewer, elementPath, model.getElement(elementPath), 1, STATE_UPDATES);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | STATE_UPDATES), createListenerErrorMessage());
- // Update the viewer with new selection delta to something new in the view
+ // Update the viewer with new selection delta to something new in the view
ModelDelta revealDelta = model.makeElementDelta(model.findElement("2.1"), IModelDelta.REVEAL); //$NON-NLS-1$
- // Wait for the second model delta to process
- fListener.reset();
- model.postDelta(revealDelta);
+ // Wait for the second model delta to process
+ fListener.reset();
+ model.postDelta(revealDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- // Clear view then reset it again.
- fListener.reset();
- fViewer.setInput(null);
- while (!fListener.isFinished(STATE_SAVE_COMPLETE)) {
+ // Clear view then reset it again.
+ fListener.reset();
+ fViewer.setInput(null);
+ while (!fListener.isFinished(STATE_SAVE_COMPLETE)) {
Thread.sleep(0);
}
autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer());
- fViewer.setInput(model.getRootElement());
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- autopopulateAgent.dispose();
- }
-
- /**
- * Test for bug 326965.<br>
- * This test verifies that canceling a reveal pending state delta is
- * properly handled when a new reveal delta is received from the model.
- */
+ autopopulateAgent.dispose();
+ }
+
+ /**
+ * Test for bug 326965.<br>
+ * This test verifies that canceling a reveal pending state delta is
+ * properly handled when a new reveal delta is received from the model.
+ */
public void testRestoreRevealAfterRevealCancel2() throws Exception {
- if (Platform.getOS().equals(Platform.OS_MACOSX)) {
- // skip this test on Mac - see bug 327557
- return;
- }
+ if (Platform.getOS().equals(Platform.OS_MACOSX)) {
+ // skip this test on Mac - see bug 327557
+ return;
+ }
TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer());
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
- // Expand all
- fViewer.setAutoExpandLevel(-1);
+ // Expand all
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Stop auto-populating and auto-expanding the view.
- fViewer.setAutoExpandLevel(0);
- autopopulateAgent.dispose();
+ // Stop auto-populating and auto-expanding the view.
+ fViewer.setAutoExpandLevel(0);
+ autopopulateAgent.dispose();
- // Set top index of view to element "3" and wait for view to repaint.
- getCTargetViewer().reveal(TreePath.EMPTY, 2);
+ // Set top index of view to element "3" and wait for view to repaint.
+ getCTargetViewer().reveal(TreePath.EMPTY, 2);
TestUtil.processUIEvents();
- // Trigger save of state.
- fListener.reset();
- fViewer.setInput(null);
- while (!fListener.isFinished(STATE_SAVE_COMPLETE)) {
+ // Trigger save of state.
+ fListener.reset();
+ fViewer.setInput(null);
+ while (!fListener.isFinished(STATE_SAVE_COMPLETE)) {
Thread.sleep(0);
}
- // Set input back to root element.
- // Note: Wait only for the processing of the delta and the start of state restore, not for all updates
- fListener.reset();
+ // Set input back to root element.
+ // Note: Wait only for the processing of the delta and the start of state restore, not for all updates
+ fListener.reset();
TreePath elementPath = model.findElement("2"); //$NON-NLS-1$
- fListener.addUpdates(fViewer, elementPath, model.getElement(elementPath), 1, STATE_UPDATES | CHILDREN_UPDATES | LABEL_UPDATES);
+ fListener.addUpdates(fViewer, elementPath, model.getElement(elementPath), 1, STATE_UPDATES | CHILDREN_UPDATES | LABEL_UPDATES);
elementPath = model.findElement("3"); //$NON-NLS-1$
- fListener.addUpdates(fViewer, elementPath, model.getElement(elementPath), 0, STATE_UPDATES);
- fViewer.setInput(model.getRootElement());
+ fListener.addUpdates(fViewer, elementPath, model.getElement(elementPath), 0, STATE_UPDATES);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(STATE_UPDATES), createListenerErrorMessage());
- // Update the viewer with new selection delta to something new in the view
+ // Update the viewer with new selection delta to something new in the view
TreePath pathToBeRevealed = model.findElement("2.1"); //$NON-NLS-1$
- ModelDelta revealDelta = model.makeElementDelta(pathToBeRevealed, IModelDelta.REVEAL);
- revealDelta.accept(new IModelDeltaVisitor() {
+ ModelDelta revealDelta = model.makeElementDelta(pathToBeRevealed, IModelDelta.REVEAL);
+ revealDelta.accept(new IModelDeltaVisitor() {
- @Override
+ @Override
public boolean visit(IModelDelta delta, int depth) {
- ((ModelDelta)delta).setFlags(delta.getFlags() | IModelDelta.EXPAND);
- return true;
- }
- });
+ ((ModelDelta)delta).setFlags(delta.getFlags() | IModelDelta.EXPAND);
+ return true;
+ }
+ });
- // Wait for the second model delta to process
- model.postDelta(revealDelta);
+ // Wait for the second model delta to process
+ model.postDelta(revealDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILDREN_UPDATES | LABEL_UPDATES), createListenerErrorMessage());
- // check if REVEAL was triggered by the delta and not by the
- // state restore operation
- TreePath topPath = getCTargetViewer().getTopElementPath();
+ // check if REVEAL was triggered by the delta and not by the
+ // state restore operation
+ TreePath topPath = getCTargetViewer().getTopElementPath();
assertNotNull("Top item should not be null!", topPath); //$NON-NLS-1$
- TreePathWrapper.assertEqual(pathToBeRevealed, topPath);
- }
+ TreePathWrapper.assertEqual(pathToBeRevealed, topPath);
+ }
- /**
- * Restore REVEAL when having also to restore an expanded element
- * that is just above the REVEAL element.
- *
- * See bug 324100
- */
+ /**
+ * Restore REVEAL when having also to restore an expanded element
+ * that is just above the REVEAL element.
+ *
+ * See bug 324100
+ */
public void testRestoreDeepTreeAndReveal() throws Exception {
TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(getCTargetViewer());
- TestModel model = TestModel.simpleDeepMultiLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleDeepMultiLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Stop forcing view updates.
- autopopulateAgent.dispose();
+ // Stop forcing view updates.
+ autopopulateAgent.dispose();
- // Scroll down to the last part of the tree.
+ // Scroll down to the last part of the tree.
getCTargetViewer().reveal(model.findElement("3.6.3.16.16.16.16.16"), 1); //$NON-NLS-1$
TestUtil.processUIEvents();
- final TreePath originalTopPath = getCTargetViewer().getTopElementPath();
+ final TreePath originalTopPath = getCTargetViewer().getTopElementPath();
assertNotNull("Top item should not be null!", originalTopPath); //$NON-NLS-1$
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(true, false);
- fListener.addStateUpdates(getCTargetViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
- fViewer.setInput(null);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset(true, false);
+ fListener.addStateUpdates(getCTargetViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
+ fViewer.setInput(null);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE), createListenerErrorMessage());
- // Set the viewer input back to the model
- fListener.reset(false, false);
- fListener.addUpdates(getCTargetViewer(), originalTopPath, (TestElement)originalTopPath.getLastSegment(), 0, STATE_UPDATES);
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model
+ fListener.reset(false, false);
+ fListener.addUpdates(getCTargetViewer(), originalTopPath, (TestElement)originalTopPath.getLastSegment(), 0, STATE_UPDATES);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(STATE_UPDATES | CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
TestUtil.processUIEvents();
- // check if REVEAL was restored OK
- final TreePath topPath = getCTargetViewer().getTopElementPath();
+ // check if REVEAL was restored OK
+ final TreePath topPath = getCTargetViewer().getTopElementPath();
assertNotNull("Top item should not be null!", topPath); //$NON-NLS-1$
- TreePathWrapper.assertEqual(originalTopPath, topPath);
+ TreePathWrapper.assertEqual(originalTopPath, topPath);
- }
+ }
/**
* This test verifies that a revealed node does not get scrolled away due to
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerUpdateTests.java
index 67193e40d..4a1d39f9e 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerUpdateTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/JFaceViewerUpdateTests.java
@@ -26,12 +26,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class JFaceViewerUpdateTests extends UpdateTests {
- public JFaceViewerUpdateTests(String name) {
- super(name);
- }
+ public JFaceViewerUpdateTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new TreeModelViewer(fShell, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/LazyTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/LazyTests.java
index d874b6625..2819182c2 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/LazyTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/LazyTests.java
@@ -30,187 +30,187 @@ import org.eclipse.jface.viewers.TreeSelection;
*/
abstract public class LazyTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants {
- public LazyTests(String name) {
- super(name);
- }
+ public LazyTests(String name) {
+ super(name);
+ }
@Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
return new TestModelUpdatesListener(viewer, true, true);
}
- /**
- * Creates a model in the pattern of:
- *
- * root
- * 1
- * 1.1
- * 1.2
- * 1.3
- * ...
- * 1.(size)
- */
- private TestModel largeSubtreeModel(int size) {
- TestModel model = new TestModel();
- TestElement[] children = new TestElement[size];
- for (int i = 0; i < size; i++) {
+ /**
+ * Creates a model in the pattern of:
+ *
+ * root
+ * 1
+ * 1.1
+ * 1.2
+ * 1.3
+ * ...
+ * 1.(size)
+ */
+ private TestModel largeSubtreeModel(int size) {
+ TestModel model = new TestModel();
+ TestElement[] children = new TestElement[size];
+ for (int i = 0; i < size; i++) {
children[i] = new TestElement(model, "1." + i, new TestElement[0]); //$NON-NLS-1$
- }
+ }
TestElement element = new TestElement(model, "1", children); //$NON-NLS-1$
model.setRoot(new TestElement(model, "root", new TestElement[] { element })); //$NON-NLS-1$
- return model;
- }
+ return model;
+ }
- /**
- * Test to make sure that if an element is expanded its children are
- * not automatically materialized.
- * (bug 305739 and bug 304277)
- */
+ /**
+ * Test to make sure that if an element is expanded its children are
+ * not automatically materialized.
+ * (bug 305739 and bug 304277)
+ */
public void testExpandLargeSubTree() throws Exception {
- // Create test model with lots of children.
- TestModel model = largeSubtreeModel(1000);
+ // Create test model with lots of children.
+ TestModel model = largeSubtreeModel(1000);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Populate initial view content
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, true);
- fViewer.setInput(model.getRootElement());
+ // Populate initial view content
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, true);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Create delta to expand the "1" element.
- TestElement rootElement = model.getRootElement();
- ModelDelta rootDelta = new ModelDelta(rootElement, IModelDelta.NO_CHANGE);
- ModelDelta expandDelta = model.getBaseDelta(rootDelta);
- TestElement expandElement = rootElement.getChildren()[0];
- expandDelta.addNode(expandElement, 0, IModelDelta.EXPAND, expandElement.getChildren().length);
+ // Create delta to expand the "1" element.
+ TestElement rootElement = model.getRootElement();
+ ModelDelta rootDelta = new ModelDelta(rootElement, IModelDelta.NO_CHANGE);
+ ModelDelta expandDelta = model.getBaseDelta(rootDelta);
+ TestElement expandElement = rootElement.getChildren()[0];
+ expandDelta.addNode(expandElement, 0, IModelDelta.EXPAND, expandElement.getChildren().length);
- // Add first 250 elements as acceptable to materialize
- fListener.reset();
- fListener.setFailOnRedundantUpdates(true);
+ // Add first 250 elements as acceptable to materialize
+ fListener.reset();
+ fListener.setFailOnRedundantUpdates(true);
TreePath expandElementPath = model.findElement("1"); //$NON-NLS-1$
- fListener.addChildreCountUpdate(expandElementPath);
- fListener.addLabelUpdate(expandElementPath); // TODO: not sure why label is updated upon expand?
- for (int i = 0; i < 250; i++) {
- fListener.addChildreUpdate(expandElementPath, i);
- TreePath childPath = expandElementPath.createChildPath(expandElement.getChildren()[i]);
- fListener.addLabelUpdate(childPath);
- fListener.addHasChildrenUpdate(childPath);
- }
- model.postDelta(rootDelta);
+ fListener.addChildreCountUpdate(expandElementPath);
+ fListener.addLabelUpdate(expandElementPath); // TODO: not sure why label is updated upon expand?
+ for (int i = 0; i < 250; i++) {
+ fListener.addChildreUpdate(expandElementPath, i);
+ TreePath childPath = expandElementPath.createChildPath(expandElement.getChildren()[i]);
+ fListener.addLabelUpdate(childPath);
+ fListener.addHasChildrenUpdate(childPath);
+ }
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | MODEL_CHANGED_COMPLETE | LABEL_SEQUENCE_COMPLETE), createListenerErrorMessage());
- }
+ }
- /**
- * Test to make sure that if an element that is previously selected, is
- * then selected and replaced, that no extra elements are retrieved.
- * (bug 304277 comment #24, and bug 305739 comment #9).
- */
+ /**
+ * Test to make sure that if an element that is previously selected, is
+ * then selected and replaced, that no extra elements are retrieved.
+ * (bug 304277 comment #24, and bug 305739 comment #9).
+ */
public void testReplaceAndSelectInSubTreeTree() throws Exception {
- // Create test model with lots of children.
- TestModel model = largeSubtreeModel(1000);
-
- // Expand all children
- fViewer.setAutoExpandLevel(-1);
-
- // Populate initial view content, watch for all updates but only wait
- // for the content update sequence to finish (elements off screen will
- // not be updated).
- // TODO: child count for element 1 is updated multiple times.
- fListener.reset();
- fListener.setFailOnMultipleModelUpdateSequences(true);
- fListener.setFailOnRedundantUpdates(false);
- fViewer.setInput(model.getRootElement());
+ // Create test model with lots of children.
+ TestModel model = largeSubtreeModel(1000);
+
+ // Expand all children
+ fViewer.setAutoExpandLevel(-1);
+
+ // Populate initial view content, watch for all updates but only wait
+ // for the content update sequence to finish (elements off screen will
+ // not be updated).
+ // TODO: child count for element 1 is updated multiple times.
+ fListener.reset();
+ fListener.setFailOnMultipleModelUpdateSequences(true);
+ fListener.setFailOnRedundantUpdates(false);
+ fViewer.setInput(model.getRootElement());
fListener.addLabelUpdate(model.findElement("1.0")); //$NON-NLS-1$
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_COMPLETE), createListenerErrorMessage());
- // Set selection so that the initial selection is not empty
+ // Set selection so that the initial selection is not empty
fViewer.setSelection(new TreeSelection(new TreePath[] { model.findElement("1.0") })); //$NON-NLS-1$
- // Create delta to select the "1" element.
- TestElement rootElement = model.getRootElement();
- ModelDelta rootDelta = new ModelDelta(rootElement, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = model.getBaseDelta(rootDelta);
- TestElement _1Element = rootElement.getChildren()[0];
- ModelDelta _1Delta = baseDelta.addNode(_1Element, 0, IModelDelta.NO_CHANGE, _1Element.getChildren().length);
+ // Create delta to select the "1" element.
+ TestElement rootElement = model.getRootElement();
+ ModelDelta rootDelta = new ModelDelta(rootElement, IModelDelta.NO_CHANGE);
+ ModelDelta baseDelta = model.getBaseDelta(rootDelta);
+ TestElement _1Element = rootElement.getChildren()[0];
+ ModelDelta _1Delta = baseDelta.addNode(_1Element, 0, IModelDelta.NO_CHANGE, _1Element.getChildren().length);
- // Add the delta to select the "1.1" element.
+ // Add the delta to select the "1.1" element.
TestElement _1_0_newElement = new TestElement(model, "1.0 - new", new TestElement[0]); //$NON-NLS-1$
TreePath _1ElementPath = model.findElement("1"); //$NON-NLS-1$
- model.replaceElementChild(_1ElementPath, 0, _1_0_newElement);
- _1Delta.addNode(_1_0_newElement, 0, IModelDelta.SELECT);
+ model.replaceElementChild(_1ElementPath, 0, _1_0_newElement);
+ _1Delta.addNode(_1_0_newElement, 0, IModelDelta.SELECT);
- // Add element label update and post the delta
- fListener.reset();
- fListener.setFailOnRedundantUpdates(true);
+ // Add element label update and post the delta
+ fListener.reset();
+ fListener.setFailOnRedundantUpdates(true);
TreePath _1_0_newElementPath = model.findElement("1.0 - new"); //$NON-NLS-1$
- fListener.addLabelUpdate(_1_0_newElementPath);
- model.postDelta(rootDelta);
+ fListener.addLabelUpdate(_1_0_newElementPath);
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | LABEL_COMPLETE), createListenerErrorMessage());
- assertEquals(((IStructuredSelection)fViewer.getSelection()).getFirstElement(), _1_0_newElement);
- }
+ assertEquals(((IStructuredSelection)fViewer.getSelection()).getFirstElement(), _1_0_newElement);
+ }
- /**
- */
+ /**
+ */
public void testContentRefresh() throws Exception {
- // Create test model with lots of children.
- TestModel model = largeSubtreeModel(1000);
+ // Create test model with lots of children.
+ TestModel model = largeSubtreeModel(1000);
- // Expand children all
- fViewer.setAutoExpandLevel(-1);
+ // Expand children all
+ fViewer.setAutoExpandLevel(-1);
- // Populate initial view content
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true);
- fViewer.setInput(model.getRootElement());
+ // Populate initial view content
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, true);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE), createListenerErrorMessage());
- // Turn off autoexpand
- fViewer.setAutoExpandLevel(0);
+ // Turn off autoexpand
+ fViewer.setAutoExpandLevel(0);
- // Reposition the viewer to middle of list
- fListener.reset();
- fListener.setFailOnRedundantUpdates(false);
+ // Reposition the viewer to middle of list
+ fListener.reset();
+ fListener.setFailOnRedundantUpdates(false);
fViewer.reveal(model.findElement("1"), 500); //$NON-NLS-1$
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- // Create delta to refresh the "1" element.
- TestElement rootElement = model.getRootElement();
- ModelDelta rootDelta = new ModelDelta(rootElement, IModelDelta.NO_CHANGE);
- ModelDelta expandDelta = model.getBaseDelta(rootDelta);
- TestElement expandElement = rootElement.getChildren()[0];
- expandDelta.addNode(expandElement, 0, IModelDelta.CONTENT, expandElement.getChildren().length);
-
- // Rinse and repeast. The refresh in bug 335734 is only triggered
- // only on the second time.
- for (int repeatCount = 0; repeatCount < 3; repeatCount++) {
- // Add first 250 elements (after element 500) as acceptable to materialize
- fListener.reset();
- fListener.setFailOnRedundantUpdates(true);
+ // Create delta to refresh the "1" element.
+ TestElement rootElement = model.getRootElement();
+ ModelDelta rootDelta = new ModelDelta(rootElement, IModelDelta.NO_CHANGE);
+ ModelDelta expandDelta = model.getBaseDelta(rootDelta);
+ TestElement expandElement = rootElement.getChildren()[0];
+ expandDelta.addNode(expandElement, 0, IModelDelta.CONTENT, expandElement.getChildren().length);
+
+ // Rinse and repeast. The refresh in bug 335734 is only triggered
+ // only on the second time.
+ for (int repeatCount = 0; repeatCount < 3; repeatCount++) {
+ // Add first 250 elements (after element 500) as acceptable to materialize
+ fListener.reset();
+ fListener.setFailOnRedundantUpdates(true);
TreePath refreshElementPath = model.findElement("1"); //$NON-NLS-1$
- fListener.addRedundantExceptionChildCount(refreshElementPath);
- fListener.addRedundantExceptionLabel(refreshElementPath);
- fListener.addChildreUpdate(TreePath.EMPTY, 0);
- fListener.addHasChildrenUpdate(refreshElementPath);
- fListener.addChildreCountUpdate(refreshElementPath);
- fListener.addLabelUpdate(refreshElementPath); // TODO: not sure why label is updated upon expand?
- for (int i = 499; i < 750; i++) {
- fListener.addChildreUpdate(refreshElementPath, i);
- TreePath childPath = refreshElementPath.createChildPath(expandElement.getChildren()[i]);
- fListener.addLabelUpdate(childPath);
- fListener.addHasChildrenUpdate(childPath);
- }
- model.postDelta(rootDelta);
-
- while (!fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | MODEL_CHANGED_COMPLETE)) {
+ fListener.addRedundantExceptionChildCount(refreshElementPath);
+ fListener.addRedundantExceptionLabel(refreshElementPath);
+ fListener.addChildreUpdate(TreePath.EMPTY, 0);
+ fListener.addHasChildrenUpdate(refreshElementPath);
+ fListener.addChildreCountUpdate(refreshElementPath);
+ fListener.addLabelUpdate(refreshElementPath); // TODO: not sure why label is updated upon expand?
+ for (int i = 499; i < 750; i++) {
+ fListener.addChildreUpdate(refreshElementPath, i);
+ TreePath childPath = refreshElementPath.createChildPath(expandElement.getChildren()[i]);
+ fListener.addLabelUpdate(childPath);
+ fListener.addHasChildrenUpdate(childPath);
+ }
+ model.postDelta(rootDelta);
+
+ while (!fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | MODEL_CHANGED_COMPLETE)) {
if (!fDisplay.readAndDispatch ()) {
Thread.sleep(0);
}
}
- }
- }
+ }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PerformanceTests.java
index df7de31e3..148291e7e 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PerformanceTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PerformanceTests.java
@@ -32,11 +32,11 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement
protected VisibleVirtualItemValidator fVirtualItemValidator;
- public PerformanceTests(String name) {
- super(name);
- }
+ public PerformanceTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
return new TestModelUpdatesListener(viewer, false, false);
}
@@ -45,287 +45,287 @@ abstract public class PerformanceTests extends AbstractViewerModelTest implement
protected void setUp() throws Exception {
super.setUp();
fVirtualItemValidator = new VisibleVirtualItemValidator(0, Integer.MAX_VALUE);
- }
+ }
- /**
- * Depth (size) of the test model to be used in the tests. This number allows
- * the jface based tests to use a small enough model to fit on the screen, and
- * for the virtual viewer to exercise the content provider to a greater extent.
- */
- abstract protected int getTestModelDepth();
+ /**
+ * Depth (size) of the test model to be used in the tests. This number allows
+ * the jface based tests to use a small enough model to fit on the screen, and
+ * for the virtual viewer to exercise the content provider to a greater extent.
+ */
+ abstract protected int getTestModelDepth();
public void testRefreshStruct() throws Exception {
- TestModel model = new TestModel();
+ TestModel model = new TestModel();
model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$
model.setElementChildren(TreePath.EMPTY, TestModel.makeMultiLevelElements(model, getTestModelDepth(), "model.")); //$NON-NLS-1$
- fViewer.setAutoExpandLevel(-1);
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- Performance perf = Performance.getDefault();
- PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
- try {
- for (int i = 0; i < 10; i++) {
- // Update the model
+ Performance perf = Performance.getDefault();
+ PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
+ try {
+ for (int i = 0; i < 10; i++) {
+ // Update the model
model.setAllAppendix(" - pass " + i); //$NON-NLS-1$
- TestElement element = model.getRootElement();
- fListener.reset(TreePath.EMPTY, element, -1, false, false);
+ TestElement element = model.getRootElement();
+ fListener.reset(TreePath.EMPTY, element, -1, false, false);
- meter.start();
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
+ meter.start();
+ model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- meter.stop();
- System.gc();
- }
-
- meter.commit();
- perf.assertPerformance(meter);
- } finally {
- meter.dispose();
- }
- }
+ meter.stop();
+ System.gc();
+ }
+
+ meter.commit();
+ perf.assertPerformance(meter);
+ } finally {
+ meter.dispose();
+ }
+ }
public void testRefreshStruct2() throws Exception {
- TestModel model = new TestModel();
+ TestModel model = new TestModel();
model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$
model.setElementChildren(TreePath.EMPTY, TestModel.makeMultiLevelElements2(model, new int[] { 2, 3000, 1 }, "model.")); //$NON-NLS-1$
- fViewer.setAutoExpandLevel(2);
- // Create the listener
- //fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- fListener.reset();
+ fViewer.setAutoExpandLevel(2);
+ // Create the listener
+ //fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ fListener.reset();
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- fVirtualItemValidator.setVisibleRange(0, 50);
+ fVirtualItemValidator.setVisibleRange(0, 50);
- Performance perf = Performance.getDefault();
- PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
- try {
- for (int i = 0; i < 100; i++) {
- // Update the model
+ Performance perf = Performance.getDefault();
+ PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
+ try {
+ for (int i = 0; i < 100; i++) {
+ // Update the model
model.setAllAppendix(" - pass " + i); //$NON-NLS-1$
- TestElement element = model.getRootElement();
- //fListener.reset(TreePath.EMPTY, element, -1, false, false);
- fListener.reset();
+ TestElement element = model.getRootElement();
+ //fListener.reset(TreePath.EMPTY, element, -1, false, false);
+ fListener.reset();
- meter.start();
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
+ meter.start();
+ model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
+ model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- meter.stop();
- System.gc();
- }
-
- meter.commit();
- perf.assertPerformance(meter);
- } finally {
- meter.dispose();
- }
- }
+ meter.stop();
+ System.gc();
+ }
+
+ meter.commit();
+ perf.assertPerformance(meter);
+ } finally {
+ meter.dispose();
+ }
+ }
public void testRefreshStructReplaceElements() throws Exception {
- TestModel model = new TestModel();
+ TestModel model = new TestModel();
model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$
model.setElementChildren(TreePath.EMPTY, TestModel.makeMultiLevelElements(model, getTestModelDepth(), "model.")); //$NON-NLS-1$
- fViewer.setAutoExpandLevel(-1);
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- Performance perf = Performance.getDefault();
- PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
- try {
- for (int i = 0; i < 100; i++) {
- // Update the model
+ Performance perf = Performance.getDefault();
+ PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
+ try {
+ for (int i = 0; i < 100; i++) {
+ // Update the model
model.setElementChildren(TreePath.EMPTY, TestModel.makeMultiLevelElements(model, getTestModelDepth(), "pass " + i + ".")); //$NON-NLS-1$ //$NON-NLS-2$
- TestElement element = model.getRootElement();
- fListener.reset(TreePath.EMPTY, element, -1, false, false);
+ TestElement element = model.getRootElement();
+ fListener.reset(TreePath.EMPTY, element, -1, false, false);
- meter.start();
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
+ meter.start();
+ model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- meter.stop();
- System.gc();
- }
-
- meter.commit();
- perf.assertPerformance(meter);
- } finally {
- meter.dispose();
- }
- }
+ meter.stop();
+ System.gc();
+ }
+
+ meter.commit();
+ perf.assertPerformance(meter);
+ } finally {
+ meter.dispose();
+ }
+ }
public void testRefreshList() throws Exception {
- TestModel model = new TestModel();
+ TestModel model = new TestModel();
model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$
- int numElements = (int)Math.pow(2, getTestModelDepth());
+ int numElements = (int)Math.pow(2, getTestModelDepth());
model.setElementChildren(TreePath.EMPTY, TestModel.makeSingleLevelModelElements(model, numElements, "model.")); //$NON-NLS-1$
- fViewer.setAutoExpandLevel(-1);
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- Performance perf = Performance.getDefault();
- PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
- try {
- for (int i = 0; i < 100; i++) {
- // Update the model
+ Performance perf = Performance.getDefault();
+ PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
+ try {
+ for (int i = 0; i < 100; i++) {
+ // Update the model
model.setAllAppendix(" - pass " + i); //$NON-NLS-1$
- TestElement element = model.getRootElement();
- fListener.reset(TreePath.EMPTY, element, -1, false, false);
+ TestElement element = model.getRootElement();
+ fListener.reset(TreePath.EMPTY, element, -1, false, false);
- meter.start();
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
+ meter.start();
+ model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- meter.stop();
- System.gc();
- }
-
- meter.commit();
- perf.assertPerformance(meter);
- } finally {
- meter.dispose();
- }
- }
+ meter.stop();
+ System.gc();
+ }
+
+ meter.commit();
+ perf.assertPerformance(meter);
+ } finally {
+ meter.dispose();
+ }
+ }
public void testSaveAndRestore() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
- // expand all elements
- fViewer.setAutoExpandLevel(-1);
+ // expand all elements
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Set a selection in view
+ // Set a selection in view
fViewer.setSelection(new TreeSelection(model.findElement("3.2.3"))); //$NON-NLS-1$
- // Turn off the auto-expand now since we want to text the auto-expand logic
- fViewer.setAutoExpandLevel(-1);
+ // Turn off the auto-expand now since we want to text the auto-expand logic
+ fViewer.setAutoExpandLevel(-1);
- Performance perf = Performance.getDefault();
- PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
- try {
- for (int i = 0; i < 100; i++) {
- // Update the model
+ Performance perf = Performance.getDefault();
+ PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
+ try {
+ for (int i = 0; i < 100; i++) {
+ // Update the model
model.setAllAppendix(" - pass " + i); //$NON-NLS-1$
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(true, false);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset(true, false);
- meter.start();
- fViewer.setInput(null);
+ meter.start();
+ fViewer.setInput(null);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE), createListenerErrorMessage());
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- // TODO: add state updates somehow?
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model. When view updates are complete
+ // the viewer
+ // Note: disable redundant updates because the reveal delta triggers one.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
+ // TODO: add state updates somehow?
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- meter.stop();
- System.gc();
- }
+ meter.stop();
+ System.gc();
+ }
- meter.commit();
- perf.assertPerformance(meter);
- } finally {
- meter.dispose();
- }
+ meter.commit();
+ perf.assertPerformance(meter);
+ } finally {
+ meter.dispose();
+ }
- }
+ }
public void testRefreshListFiltered() throws Exception {
- TestModel model = new TestModel();
+ TestModel model = new TestModel();
model.setRoot(new TestElement(model, "root", new TestElement[0])); //$NON-NLS-1$
- int numElements = (int)Math.pow(2, getTestModelDepth());
+ int numElements = (int)Math.pow(2, getTestModelDepth());
model.setElementChildren(TreePath.EMPTY, TestModel.makeSingleLevelModelElements(model, numElements, "model.")); //$NON-NLS-1$
- fViewer.setAutoExpandLevel(-1);
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- fViewer.addFilter(new ViewerFilter() {
- @Override
+ fViewer.addFilter(new ViewerFilter() {
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof TestElement) {
- String id = ((TestElement)element).getID();
+ if (element instanceof TestElement) {
+ String id = ((TestElement)element).getID();
if (id.startsWith("model.")) { //$NON-NLS-1$
id = id.substring("model.".length()); //$NON-NLS-1$
- }
- if (id.length() >= 2 && (id.charAt(1) == '1' || id.charAt(1) == '3' || id.charAt(1) == '5' || id.charAt(1) == '7' || id.charAt(1) == '9')) {
- return false;
- }
- }
- return true;
- }
- });
-
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ }
+ if (id.length() >= 2 && (id.charAt(1) == '1' || id.charAt(1) == '3' || id.charAt(1) == '5' || id.charAt(1) == '7' || id.charAt(1) == '9')) {
+ return false;
+ }
+ }
+ return true;
+ }
+ });
+
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- Performance perf = Performance.getDefault();
- PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
- try {
- for (int i = 0; i < 100; i++) {
- // Update the model
+ Performance perf = Performance.getDefault();
+ PerformanceMeter meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this));
+ try {
+ for (int i = 0; i < 100; i++) {
+ // Update the model
model.setAllAppendix(" - pass " + i); //$NON-NLS-1$
- TestElement element = model.getRootElement();
- fListener.reset(TreePath.EMPTY, element, -1, false, false);
+ TestElement element = model.getRootElement();
+ fListener.reset(TreePath.EMPTY, element, -1, false, false);
- meter.start();
- model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
+ meter.start();
+ model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- meter.stop();
- System.gc();
- }
-
- meter.commit();
- perf.assertPerformance(meter);
- } finally {
- meter.dispose();
- }
- }
+ meter.stop();
+ System.gc();
+ }
+
+ meter.commit();
+ perf.assertPerformance(meter);
+ } finally {
+ meter.dispose();
+ }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PopupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PopupTests.java
index 08a44ebcb..d37b2f8b3 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PopupTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PopupTests.java
@@ -40,18 +40,18 @@ import org.eclipse.swt.widgets.Shell;
*/
abstract public class PopupTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants {
- public PopupTests(String name) {
- super(name);
- }
+ public PopupTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
return new TestModelUpdatesListener(viewer, false, false);
}
- protected IInternalTreeModelViewer getCTargetViewer() {
- return fViewer;
- }
+ protected IInternalTreeModelViewer getCTargetViewer() {
+ return fViewer;
+ }
@Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
@@ -60,152 +60,152 @@ abstract public class PopupTests extends AbstractViewerModelTest implements ITes
abstract protected IInternalTreeModelViewer createViewer(Display display, Shell shell, int style);
- /**
- * This test verifies that content updates are still being performed.
- */
+ /**
+ * This test verifies that content updates are still being performed.
+ */
public void testRefreshStruct() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- TestElement element = model.getRootElement().getChildren()[0];
- TreePath elementPath = new TreePath(new Object[] { element });
- TestElement[] newChildren = new TestElement[] {
+ // Update the model
+ TestElement element = model.getRootElement().getChildren()[0];
+ TreePath elementPath = new TreePath(new Object[] { element });
+ TestElement[] newChildren = new TestElement[] {
new TestElement(model, "1.1 - new", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "1.2 - new", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "1.3 - new", new TestElement[0]), //$NON-NLS-1$
- };
- ModelDelta delta = model.setElementChildren(elementPath, newChildren);
+ };
+ ModelDelta delta = model.setElementChildren(elementPath, newChildren);
- fListener.reset(elementPath, element, -1, true, false);
- model.postDelta(delta);
+ fListener.reset(elementPath, element, -1, true, false);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
- /**
- * This test verifies that expand and select updates are being ignored.
- */
+ /**
+ * This test verifies that expand and select updates are being ignored.
+ */
public void testExpandAndSelect() throws Exception {
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Create the delta
- fListener.reset();
- // TODO Investigate: there seem to be unnecessary updates being issued
- // by the viewer. These include the updates that are commented out:
- // For now disable checking for extra updates.
- fListener.setFailOnRedundantUpdates(false);
- TestElement element = model.getRootElement();
- TreePath path_root = TreePath.EMPTY;
- ModelDelta delta= new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
- ModelDelta deltaRoot = delta;
- element = element.getChildren()[2];
- TreePath path_root_3 = path_root.createChildPath(element);
- delta.addNode(element, 2, IModelDelta.SELECT | IModelDelta.EXPAND, element.fChildren.length);
-
- // Validate the expansion state BEFORE posting the delta.
-
- IInternalTreeModelViewer contentProviderViewer = fViewer;
- assertFalse(contentProviderViewer.getExpandedState(path_root_3));
-
- model.postDelta(deltaRoot);
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Create the delta
+ fListener.reset();
+ // TODO Investigate: there seem to be unnecessary updates being issued
+ // by the viewer. These include the updates that are commented out:
+ // For now disable checking for extra updates.
+ fListener.setFailOnRedundantUpdates(false);
+ TestElement element = model.getRootElement();
+ TreePath path_root = TreePath.EMPTY;
+ ModelDelta delta= new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
+ ModelDelta deltaRoot = delta;
+ element = element.getChildren()[2];
+ TreePath path_root_3 = path_root.createChildPath(element);
+ delta.addNode(element, 2, IModelDelta.SELECT | IModelDelta.EXPAND, element.fChildren.length);
+
+ // Validate the expansion state BEFORE posting the delta.
+
+ IInternalTreeModelViewer contentProviderViewer = fViewer;
+ assertFalse(contentProviderViewer.getExpandedState(path_root_3));
+
+ model.postDelta(deltaRoot);
TestUtil.processUIEvents();
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE)
&& (fListener.isFinished(CONTENT_SEQUENCE_STARTED)
|| !fListener.isFinished(CONTENT_SEQUENCE_STARTED) && !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE)),
createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Validate the expansion state AFTER posting the delta.
- assertFalse(contentProviderViewer.getExpandedState(path_root_3));
+ // Validate the expansion state AFTER posting the delta.
+ assertFalse(contentProviderViewer.getExpandedState(path_root_3));
- // Verify selection
- ISelection selection = fViewer.getSelection();
- if (selection instanceof ITreeSelection) {
+ // Verify selection
+ ISelection selection = fViewer.getSelection();
+ if (selection instanceof ITreeSelection) {
List<TreePath> selectionPathsList = Arrays.asList(((ITreeSelection) selection).getPaths());
- assertFalse(selectionPathsList.contains(path_root_3));
- } else {
+ assertFalse(selectionPathsList.contains(path_root_3));
+ } else {
fail("Not a tree selection"); //$NON-NLS-1$
- }
- }
+ }
+ }
public void testPreserveExpandedOnSubTreeContent() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
- // Expand all
- fViewer.setAutoExpandLevel(-1);
+ // Expand all
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener,
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener,
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Turn off auto-expansion
- fViewer.setAutoExpandLevel(0);
+ // Turn off auto-expansion
+ fViewer.setAutoExpandLevel(0);
- // Set a selection in view
+ // Set a selection in view
TreeSelection originalSelection = new TreeSelection(model.findElement("3.3.1")); //$NON-NLS-1$
- fViewer.setSelection(originalSelection);
+ fViewer.setSelection(originalSelection);
- // Update the model
+ // Update the model
model.addElementChild(model.findElement("3"), null, 0, new TestElement(model, "3.0 - new", new TestElement[0])); //$NON-NLS-1$ //$NON-NLS-2$
- // Create the delta for element "3" with content update.
+ // Create the delta for element "3" with content update.
TreePath elementPath = model.findElement("3"); //$NON-NLS-1$
- ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- ModelDelta elementDelta = model.getElementDelta(rootDelta, elementPath, true);
- elementDelta.setFlags(IModelDelta.CONTENT);
+ ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ ModelDelta elementDelta = model.getElementDelta(rootDelta, elementPath, true);
+ elementDelta.setFlags(IModelDelta.CONTENT);
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- fListener.addUpdates(getCTargetViewer(), elementPath, model.getElement(elementPath), -1, ALL_UPDATES_COMPLETE);
+ // Note: Re-expanding nodes causes redundant updates.
+ fListener.reset(false, false);
+ fListener.addUpdates(getCTargetViewer(), elementPath, model.getElement(elementPath), -1, ALL_UPDATES_COMPLETE);
- // Post the sub-tree update
- model.postDelta(rootDelta);
+ // Post the sub-tree update
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true);
assertTrue(getCTargetViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
- // On windows, getExpandedState() may return true for an element with no children:
- // assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.0 - new")) == false);
+ // On windows, getExpandedState() may return true for an element with no children:
+ // assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.0 - new")) == false);
assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.2")) == true); //$NON-NLS-1$
assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.3")) == true); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- }
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ }
- private boolean areTreeSelectionsEqual(ITreeSelection sel1, ITreeSelection sel2) {
+ private boolean areTreeSelectionsEqual(ITreeSelection sel1, ITreeSelection sel2) {
Set<TreePath> sel1Set = new HashSet<>();
- sel1Set.addAll( Arrays.asList(sel1.getPaths()) );
+ sel1Set.addAll( Arrays.asList(sel1.getPaths()) );
Set<TreePath> sel2Set = new HashSet<>();
- sel2Set.addAll( Arrays.asList(sel2.getPaths()) );
+ sel2Set.addAll( Arrays.asList(sel2.getPaths()) );
- return sel1Set.equals(sel2Set);
- }
+ return sel1Set.equals(sel2Set);
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java
index fa6f7f15d..901d62105 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/PresentationContextTests.java
@@ -27,14 +27,14 @@ import org.eclipse.ui.XMLMemento;
*/
public class PresentationContextTests extends AbstractDebugTest {
- public PresentationContextTests(String name) {
- super(name);
- }
+ public PresentationContextTests(String name) {
+ super(name);
+ }
- /**
- * Tests saving and restoring presentation context properties.
- */
- public void testSaveRestore () {
+ /**
+ * Tests saving and restoring presentation context properties.
+ */
+ public void testSaveRestore () {
PresentationContext context = new PresentationContext("test"); //$NON-NLS-1$
context.setProperty("string", "string"); //$NON-NLS-1$ //$NON-NLS-2$
context.setProperty("integer", Integer.valueOf(1)); //$NON-NLS-1$
@@ -42,15 +42,15 @@ public class PresentationContextTests extends AbstractDebugTest {
context.setProperty("persistable", ResourcesPlugin.getWorkspace().getRoot().getAdapter(IPersistableElement.class)); //$NON-NLS-1$
final XMLMemento memento = XMLMemento.createWriteRoot("TEST"); //$NON-NLS-1$
- context.saveProperites(memento);
+ context.saveProperites(memento);
context = new PresentationContext("test"); //$NON-NLS-1$
- context.initProperties(memento);
+ context.initProperties(memento);
assertEquals("Wrong value restored", "string", context.getProperty("string")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertEquals("Wrong value restored", Integer.valueOf(1), context.getProperty("integer")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong value restored", Boolean.TRUE, context.getProperty("boolean")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Wrong value restored", ResourcesPlugin.getWorkspace().getRoot(), context.getProperty("persistable")); //$NON-NLS-1$ //$NON-NLS-2$
- context.dispose();
- }
+ context.dispose();
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/SelectionTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/SelectionTests.java
index 56230cc4c..e73e9c96f 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/SelectionTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/SelectionTests.java
@@ -33,212 +33,212 @@ import org.eclipse.jface.viewers.TreeSelection;
*/
abstract public class SelectionTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants {
- public SelectionTests(String name) {
- super(name);
- }
+ public SelectionTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
return new TestModelUpdatesListener(viewer, false, false);
}
- private static class SelectionListener implements ISelectionChangedListener {
+ private static class SelectionListener implements ISelectionChangedListener {
private final List<SelectionChangedEvent> fEvents = new ArrayList<>(1);
- @Override
+ @Override
public void selectionChanged(SelectionChangedEvent event) {
- fEvents.add(event);
- }
- }
+ fEvents.add(event);
+ }
+ }
private TestModel makeMultiLevelModel() throws Exception {
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- fViewer.setInput(model.getRootElement());
+ TestModel model = TestModel.simpleMultiLevel();
+ fViewer.setAutoExpandLevel(-1);
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- return model;
- }
-
- /**
- * In this test:
- * - set selection to an element deep in the model
- * - verify that selection chagned listener is called
- * - verify that the selection is in the viewer is correct
- */
+ model.validateData(fViewer, TreePath.EMPTY);
+ return model;
+ }
+
+ /**
+ * In this test:
+ * - set selection to an element deep in the model
+ * - verify that selection chagned listener is called
+ * - verify that the selection is in the viewer is correct
+ */
public void testSimpleSetSelection() throws Exception {
- // Create the model and populate the view.
- TestModel model = makeMultiLevelModel();
+ // Create the model and populate the view.
+ TestModel model = makeMultiLevelModel();
- // Create a selection object to the deepest part of the tree.
- SelectionListener listener = new SelectionListener();
- fViewer.addSelectionChangedListener(listener);
+ // Create a selection object to the deepest part of the tree.
+ SelectionListener listener = new SelectionListener();
+ fViewer.addSelectionChangedListener(listener);
- // Set the selection and verify that the listener is called.
+ // Set the selection and verify that the listener is called.
TreeSelection selection = new TreeSelection(model.findElement("3.3.3")); //$NON-NLS-1$
- fViewer.setSelection(selection, true, false);
- assertTrue(listener.fEvents.size() == 1);
-
- // Check that the new selection is what was requested.
- ISelection viewerSelection = fViewer.getSelection();
- assertEquals(selection, viewerSelection);
- }
-
- /**
- * In this test verify that selection policy can prevent selection
- * from being set and verify that a FORCE flag can override the selection
- * policy.
- */
+ fViewer.setSelection(selection, true, false);
+ assertTrue(listener.fEvents.size() == 1);
+
+ // Check that the new selection is what was requested.
+ ISelection viewerSelection = fViewer.getSelection();
+ assertEquals(selection, viewerSelection);
+ }
+
+ /**
+ * In this test verify that selection policy can prevent selection
+ * from being set and verify that a FORCE flag can override the selection
+ * policy.
+ */
public void testSelectionPolicy() throws Exception {
- // Create the model and populate the view.
- final TestModel model = makeMultiLevelModel();
+ // Create the model and populate the view.
+ final TestModel model = makeMultiLevelModel();
- // Set the selection and verify it.
+ // Set the selection and verify it.
TreeSelection selection_3_3_3 = new TreeSelection(model.findElement("3.3.3")); //$NON-NLS-1$
- fViewer.setSelection(selection_3_3_3, true, false);
- assertEquals(selection_3_3_3, fViewer.getSelection());
+ fViewer.setSelection(selection_3_3_3, true, false);
+ assertEquals(selection_3_3_3, fViewer.getSelection());
- model.setSelectionPolicy(new IModelSelectionPolicy() {
+ model.setSelectionPolicy(new IModelSelectionPolicy() {
- @Override
+ @Override
public ISelection replaceInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
- return null;
- }
+ return null;
+ }
- @Override
+ @Override
public boolean overrides(ISelection existing, ISelection candidate, IPresentationContext context) {
- return false;
- }
+ return false;
+ }
- @Override
+ @Override
public boolean isSticky(ISelection selection, IPresentationContext context) {
- return true;
- }
+ return true;
+ }
- @Override
+ @Override
public boolean contains(ISelection selection, IPresentationContext context) {
- return true;
- }
- });
+ return true;
+ }
+ });
- // Attempt to change selection and verify that old selection is still valid.
+ // Attempt to change selection and verify that old selection is still valid.
TreeSelection selection_3_3_1 = new TreeSelection(model.findElement("3.3.1")); //$NON-NLS-1$
- fViewer.setSelection(selection_3_3_1, true, false);
- assertEquals(selection_3_3_3, fViewer.getSelection());
+ fViewer.setSelection(selection_3_3_1, true, false);
+ assertEquals(selection_3_3_3, fViewer.getSelection());
- // Now attempt to *force* selection and verify that new selection was set.
- fViewer.setSelection(selection_3_3_1, true, true);
- assertEquals(selection_3_3_1, fViewer.getSelection());
+ // Now attempt to *force* selection and verify that new selection was set.
+ fViewer.setSelection(selection_3_3_1, true, true);
+ assertEquals(selection_3_3_1, fViewer.getSelection());
- // Create the an update delta to attempt to change selection back to
- // 3.3.3 and verify that selection did not get overriden.
+ // Create the an update delta to attempt to change selection back to
+ // 3.3.3 and verify that selection did not get overriden.
TreePath path_3_3_3 = model.findElement("3.3.3"); //$NON-NLS-1$
- ModelDelta baseDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- ModelDelta delta_3_3_3 = model.getElementDelta(baseDelta, path_3_3_3, false);
- delta_3_3_3.setFlags(IModelDelta.SELECT);
- fViewer.updateViewer(baseDelta);
+ ModelDelta baseDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ ModelDelta delta_3_3_3 = model.getElementDelta(baseDelta, path_3_3_3, false);
+ delta_3_3_3.setFlags(IModelDelta.SELECT);
+ fViewer.updateViewer(baseDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- assertEquals(selection_3_3_1, fViewer.getSelection());
+ assertEquals(selection_3_3_1, fViewer.getSelection());
- // Add the *force* flag to the selection delta and update viewer again.
- // Verify that selection did change.
- delta_3_3_3.setFlags(IModelDelta.SELECT | IModelDelta.FORCE);
- fViewer.updateViewer(baseDelta);
+ // Add the *force* flag to the selection delta and update viewer again.
+ // Verify that selection did change.
+ delta_3_3_3.setFlags(IModelDelta.SELECT | IModelDelta.FORCE);
+ fViewer.updateViewer(baseDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- assertEquals(selection_3_3_3, fViewer.getSelection());
- }
+ assertEquals(selection_3_3_3, fViewer.getSelection());
+ }
- /**
- * In this test:
- * - set a seleciton to an element
- * - then remove that element
- * - update the view with remove delta
- * -> The selection should be re-set to empty.
- */
+ /**
+ * In this test:
+ * - set a seleciton to an element
+ * - then remove that element
+ * - update the view with remove delta
+ * -> The selection should be re-set to empty.
+ */
public void testSelectRemove() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- // Create the model and populate the view.
- TestModel model = makeMultiLevelModel();
+ // Create the model and populate the view.
+ TestModel model = makeMultiLevelModel();
- // Create a selection object to the deepest part of the tree.
+ // Create a selection object to the deepest part of the tree.
TreePath elementPath = model.findElement("3.3.3"); //$NON-NLS-1$
- TreeSelection selection = new TreeSelection(elementPath);
+ TreeSelection selection = new TreeSelection(elementPath);
- // Set the selection.
- fViewer.setSelection(selection, true, false);
+ // Set the selection.
+ fViewer.setSelection(selection, true, false);
- // Remove the element
+ // Remove the element
TreePath removePath = model.findElement("3"); //$NON-NLS-1$
- TreePath parentPath = removePath.getParentPath();
- int removeIndex = model.getElement(parentPath).indexOf( model.getElement(removePath) );
- ModelDelta delta = model.removeElementChild(removePath.getParentPath(), removeIndex);
-
- // Configure a selection listener
- SelectionListener listener = new SelectionListener();
- fViewer.addSelectionChangedListener(listener);
-
- // Reset the listener and update the viewer. With a remove
- // delta only wait for the delta to be processed.
- fListener.reset();
- model.postDelta(delta);
+ TreePath parentPath = removePath.getParentPath();
+ int removeIndex = model.getElement(parentPath).indexOf( model.getElement(removePath) );
+ ModelDelta delta = model.removeElementChild(removePath.getParentPath(), removeIndex);
+
+ // Configure a selection listener
+ SelectionListener listener = new SelectionListener();
+ fViewer.addSelectionChangedListener(listener);
+
+ // Reset the listener and update the viewer. With a remove
+ // delta only wait for the delta to be processed.
+ fListener.reset();
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(ITestModelUpdatesListenerConstants.MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Check to make sure the selection was made
- //assertTrue(listener.fEvents.size() == 1);
+ // Check to make sure the selection was made
+ //assertTrue(listener.fEvents.size() == 1);
- // Check that the new selection is empty
- ISelection viewerSelection = fViewer.getSelection();
- assertTrue(viewerSelection.isEmpty());
- }
+ // Check that the new selection is empty
+ ISelection viewerSelection = fViewer.getSelection();
+ assertTrue(viewerSelection.isEmpty());
+ }
- /**
- * In this test:
- * - set a selection to an element
- * - then remove that element
- * - then refresh the view.
- * -> The selection should be re-set to empty.
- */
+ /**
+ * In this test:
+ * - set a selection to an element
+ * - then remove that element
+ * - then refresh the view.
+ * -> The selection should be re-set to empty.
+ */
public void testSelectRemoveRefreshStruct() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- // Create the model and populate the view.
- TestModel model = makeMultiLevelModel();
+ // Create the model and populate the view.
+ TestModel model = makeMultiLevelModel();
- // Create a selection object to the deepest part of the tree.
+ // Create a selection object to the deepest part of the tree.
TreePath elementPath = model.findElement("3.3.3"); //$NON-NLS-1$
- TreeSelection selection = new TreeSelection(elementPath);
+ TreeSelection selection = new TreeSelection(elementPath);
- // Set the selection.
- fViewer.setSelection(selection, true, false);
+ // Set the selection.
+ fViewer.setSelection(selection, true, false);
- // Remove the element
+ // Remove the element
TreePath removePath = model.findElement("3"); //$NON-NLS-1$
- TreePath parentPath = removePath.getParentPath();
- int removeIndex = model.getElement(parentPath).indexOf( model.getElement(removePath) );
- model.removeElementChild(removePath.getParentPath(), removeIndex);
+ TreePath parentPath = removePath.getParentPath();
+ int removeIndex = model.getElement(parentPath).indexOf( model.getElement(removePath) );
+ model.removeElementChild(removePath.getParentPath(), removeIndex);
- // Configure a selection listener
- SelectionListener listener = new SelectionListener();
- fViewer.addSelectionChangedListener(listener);
+ // Configure a selection listener
+ SelectionListener listener = new SelectionListener();
+ fViewer.addSelectionChangedListener(listener);
- // Reset the listener to ignore redundant updates. When elements are removed
- // the viewer may still request updates for those elements.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Reset the listener to ignore redundant updates. When elements are removed
+ // the viewer may still request updates for those elements.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Refresh the viewer
- model.postDelta( new ModelDelta(model.getRootElement(), IModelDelta.CONTENT) );
+ // Refresh the viewer
+ model.postDelta( new ModelDelta(model.getRootElement(), IModelDelta.CONTENT) );
waitWhile(t -> !fListener.isFinished(ITestModelUpdatesListenerConstants.ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Check to make sure the selection was made
- // Commented out until JFace bug 219887 is fixed.
- //assertTrue(listener.fEvents.size() == 1);
+ // Check to make sure the selection was made
+ // Commented out until JFace bug 219887 is fixed.
+ //assertTrue(listener.fEvents.size() == 1);
- // Check that the new selection is empty
- ISelection viewerSelection = fViewer.getSelection();
- assertTrue(viewerSelection.isEmpty());
- }
+ // Check that the new selection is empty
+ ISelection viewerSelection = fViewer.getSelection();
+ assertTrue(viewerSelection.isEmpty());
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/StateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/StateTests.java
index aed68f6ad..5e858848f 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/StateTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/StateTests.java
@@ -35,208 +35,208 @@ import org.eclipse.jface.viewers.TreeSelection;
*/
abstract public class StateTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants {
- public StateTests(String name) {
- super(name);
- }
+ public StateTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
return new TestModelUpdatesListener(viewer, false, false);
}
- protected IInternalTreeModelViewer getInternalViewer() {
- return fViewer;
- }
+ protected IInternalTreeModelViewer getInternalViewer() {
+ return fViewer;
+ }
public void testUpdateViewer() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ TestModel model = TestModel.simpleMultiLevel();
- // Create the listener
- fListener.reset();
- fListener.addChildreUpdate(TreePath.EMPTY, 0);
- fListener.addChildreUpdate(TreePath.EMPTY, 1);
- fListener.addChildreUpdate(TreePath.EMPTY, 2);
+ // Create the listener
+ fListener.reset();
+ fListener.addChildreUpdate(TreePath.EMPTY, 0);
+ fListener.addChildreUpdate(TreePath.EMPTY, 1);
+ fListener.addChildreUpdate(TreePath.EMPTY, 2);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
-
- // Create the update delta
- TestElement element = model.getRootElement();
- TreePath path0 = TreePath.EMPTY;
- ModelDelta delta = new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
- ModelDelta updateDelta = delta;
- element = element.getChildren()[2];
- TreePath path1 = path0.createChildPath(element);
- delta = delta.addNode(element, 2, IModelDelta.EXPAND, element.fChildren.length);
- element = element.getChildren()[1];
- TreePath path2 = path1.createChildPath(element);
- delta = delta.addNode(element, 1, IModelDelta.EXPAND, element.fChildren.length);
- element = element.getChildren()[1];
- TreePath path3 = path2.createChildPath(element);
- delta = delta.addNode(element, 1, IModelDelta.SELECT);
-
- fListener.reset(false, false);
-
- fListener.addChildreUpdate(path0, 2);
- fListener.addHasChildrenUpdate(path1);
- fListener.addChildreCountUpdate(path1);
- fListener.addLabelUpdate(path1);
- fListener.addChildreUpdate(path1, 1);
- fListener.addHasChildrenUpdate(path2);
- fListener.addChildreCountUpdate(path2);
- fListener.addLabelUpdate(path2);
- fListener.addHasChildrenUpdate(path2);
- fListener.addChildreCountUpdate(path2);
- fListener.addChildreUpdate(path2, 1);
- fListener.addHasChildrenUpdate(path3);
- fListener.addLabelUpdate(path3);
-
- fViewer.updateViewer(updateDelta);
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Create the update delta
+ TestElement element = model.getRootElement();
+ TreePath path0 = TreePath.EMPTY;
+ ModelDelta delta = new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
+ ModelDelta updateDelta = delta;
+ element = element.getChildren()[2];
+ TreePath path1 = path0.createChildPath(element);
+ delta = delta.addNode(element, 2, IModelDelta.EXPAND, element.fChildren.length);
+ element = element.getChildren()[1];
+ TreePath path2 = path1.createChildPath(element);
+ delta = delta.addNode(element, 1, IModelDelta.EXPAND, element.fChildren.length);
+ element = element.getChildren()[1];
+ TreePath path3 = path2.createChildPath(element);
+ delta = delta.addNode(element, 1, IModelDelta.SELECT);
+
+ fListener.reset(false, false);
+
+ fListener.addChildreUpdate(path0, 2);
+ fListener.addHasChildrenUpdate(path1);
+ fListener.addChildreCountUpdate(path1);
+ fListener.addLabelUpdate(path1);
+ fListener.addChildreUpdate(path1, 1);
+ fListener.addHasChildrenUpdate(path2);
+ fListener.addChildreCountUpdate(path2);
+ fListener.addLabelUpdate(path2);
+ fListener.addHasChildrenUpdate(path2);
+ fListener.addChildreCountUpdate(path2);
+ fListener.addChildreUpdate(path2, 1);
+ fListener.addHasChildrenUpdate(path3);
+ fListener.addLabelUpdate(path3);
+
+ fViewer.updateViewer(updateDelta);
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | LABEL_UPDATES), createListenerErrorMessage());
- // Extract the new state from viewer
- ModelDelta savedDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(path0, savedDelta, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the new state from viewer
+ ModelDelta savedDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(path0, savedDelta, IModelDelta.EXPAND | IModelDelta.SELECT);
- if (!deltaMatches(updateDelta, savedDelta) ) {
+ if (!deltaMatches(updateDelta, savedDelta) ) {
fail("Expected:\n" + updateDelta.toString() + "\nGot:\n" + savedDelta); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- boolean deltaMatches(ModelDelta requested, ModelDelta received) {
- if ( requested.getElement().equals(received.getElement()) &&
- requested.getFlags() == received.getFlags() &&
- ( requested.getChildCount() == -1 || requested.getChildCount() == received.getChildCount() )&&
- ( requested.getIndex() == -1 || requested.getIndex() == received.getIndex()) &&
- ((requested.getReplacementElement() != null && requested.getReplacementElement().equals(received.getReplacementElement())) ||
- (requested.getReplacementElement() == null && received.getReplacementElement() == null)) &&
- requested.getChildDeltas().length == received.getChildDeltas().length)
- {
- for (int i = 0; i < requested.getChildDeltas().length; i++) {
- ModelDelta requestedChildDelta = (ModelDelta)requested.getChildDeltas()[i];
- ModelDelta receivedChildDelta = received.getChildDelta(requestedChildDelta.getElement());
- if ( receivedChildDelta == null || !deltaMatches(requestedChildDelta, receivedChildDelta) ) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- /**
- * Creates a model in the pattern of:
- *
- * root
- * 1
- * 1.1
- * 1.1.1
- * 2
- * 2.1
- * 2.1.1
- * 3
- * 3.1
- * 3.1.1
- * ...
- * (size)
- * (size).1
- * (size).1.1
- */
- static TestModel alternatingSubsreesModel(int size) {
- TestModel model = new TestModel();
-
- TestElement[] elements = new TestElement[size];
- for (int i = 0; i < size; i++) {
- String text = Integer.toString(i + 1);
- elements[i] =
- new TestElement(model, text, new TestElement[] {
+ }
+ }
+
+ boolean deltaMatches(ModelDelta requested, ModelDelta received) {
+ if ( requested.getElement().equals(received.getElement()) &&
+ requested.getFlags() == received.getFlags() &&
+ ( requested.getChildCount() == -1 || requested.getChildCount() == received.getChildCount() )&&
+ ( requested.getIndex() == -1 || requested.getIndex() == received.getIndex()) &&
+ ((requested.getReplacementElement() != null && requested.getReplacementElement().equals(received.getReplacementElement())) ||
+ (requested.getReplacementElement() == null && received.getReplacementElement() == null)) &&
+ requested.getChildDeltas().length == received.getChildDeltas().length)
+ {
+ for (int i = 0; i < requested.getChildDeltas().length; i++) {
+ ModelDelta requestedChildDelta = (ModelDelta)requested.getChildDeltas()[i];
+ ModelDelta receivedChildDelta = received.getChildDelta(requestedChildDelta.getElement());
+ if ( receivedChildDelta == null || !deltaMatches(requestedChildDelta, receivedChildDelta) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Creates a model in the pattern of:
+ *
+ * root
+ * 1
+ * 1.1
+ * 1.1.1
+ * 2
+ * 2.1
+ * 2.1.1
+ * 3
+ * 3.1
+ * 3.1.1
+ * ...
+ * (size)
+ * (size).1
+ * (size).1.1
+ */
+ static TestModel alternatingSubsreesModel(int size) {
+ TestModel model = new TestModel();
+
+ TestElement[] elements = new TestElement[size];
+ for (int i = 0; i < size; i++) {
+ String text = Integer.toString(i + 1);
+ elements[i] =
+ new TestElement(model, text, new TestElement[] {
new TestElement(model, text + ".1", new TestElement[] { //$NON-NLS-1$
new TestElement(model, text + ".1.1", new TestElement[0]) //$NON-NLS-1$
- })
- });
- }
+ })
+ });
+ }
model.setRoot(new TestElement(model, "root", elements)); //$NON-NLS-1$
- return model;
- }
+ return model;
+ }
- static boolean areTreeSelectionsEqual(ITreeSelection sel1, ITreeSelection sel2) {
+ static boolean areTreeSelectionsEqual(ITreeSelection sel1, ITreeSelection sel2) {
Set<TreePath> sel1Set = new HashSet<>();
- sel1Set.addAll( Arrays.asList(sel1.getPaths()) );
+ sel1Set.addAll( Arrays.asList(sel1.getPaths()) );
Set<TreePath> sel2Set = new HashSet<>();
- sel2Set.addAll( Arrays.asList(sel2.getPaths()) );
+ sel2Set.addAll( Arrays.asList(sel2.getPaths()) );
- return sel1Set.equals(sel2Set);
- }
+ return sel1Set.equals(sel2Set);
+ }
static void expandAlternateElements(TestModelUpdatesListener listener, TestModel model, boolean waitForAllUpdates) throws Exception {
- listener.reset();
- listener.setFailOnRedundantUpdates(false);
-
- TestElement rootElement = model.getRootElement();
- TestElement[] children = rootElement.getChildren();
- ModelDelta rootDelta = new ModelDelta(rootElement, IModelDelta.NO_CHANGE);
- ModelDelta expandDelta = model.getBaseDelta(rootDelta);
- for (int i = 0; i < children.length; i++) {
- // Expand only odd children
- if (i % 2 == 1) {
- continue;
- }
-
- // Expand the element and the first child of each sub-element
- TestElement element = children[i];
- ModelDelta delta = expandDelta;
- int index = i;
- while (element.getChildren().length != 0) {
- TreePath elementPath = model.findElement(element.getLabel());
- listener.addUpdates(
- elementPath, element, 1,
- CHILD_COUNT_UPDATES | (waitForAllUpdates ? CHILDREN_UPDATES : 0) );
- delta = delta.addNode(element, index, IModelDelta.EXPAND, element.getChildren().length);
- element = element.getChildren()[0];
- index = 0;
- }
- }
- model.postDelta(rootDelta);
+ listener.reset();
+ listener.setFailOnRedundantUpdates(false);
+
+ TestElement rootElement = model.getRootElement();
+ TestElement[] children = rootElement.getChildren();
+ ModelDelta rootDelta = new ModelDelta(rootElement, IModelDelta.NO_CHANGE);
+ ModelDelta expandDelta = model.getBaseDelta(rootDelta);
+ for (int i = 0; i < children.length; i++) {
+ // Expand only odd children
+ if (i % 2 == 1) {
+ continue;
+ }
+
+ // Expand the element and the first child of each sub-element
+ TestElement element = children[i];
+ ModelDelta delta = expandDelta;
+ int index = i;
+ while (element.getChildren().length != 0) {
+ TreePath elementPath = model.findElement(element.getLabel());
+ listener.addUpdates(
+ elementPath, element, 1,
+ CHILD_COUNT_UPDATES | (waitForAllUpdates ? CHILDREN_UPDATES : 0) );
+ delta = delta.addNode(element, index, IModelDelta.EXPAND, element.getChildren().length);
+ element = element.getChildren()[0];
+ index = 0;
+ }
+ }
+ model.postDelta(rootDelta);
TestUtil.waitWhile(t -> !listener.isFinished(CONTENT_SEQUENCE_COMPLETE | MODEL_CHANGED_COMPLETE), null, 30000, t -> "Listener not finished: " + listener);
- }
+ }
public void testPreserveExpandedOnRemove() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(6);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(6);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- expandAlternateElements(fListener, model, true);
+ expandAlternateElements(fListener, model, true);
- // Set a selection in view
+ // Set a selection in view
TreeSelection originalSelection = new TreeSelection(model.findElement("5.1")); //$NON-NLS-1$
- fViewer.setSelection(originalSelection);
+ fViewer.setSelection(originalSelection);
- // Update the model
- ModelDelta delta = model.removeElementChild(TreePath.EMPTY, 0);
+ // Update the model
+ ModelDelta delta = model.removeElementChild(TreePath.EMPTY, 0);
- // Remove delta should not generate any new updates
- fListener.reset();
- model.postDelta(delta);
+ // Remove delta should not generate any new updates
+ fListener.reset();
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true);
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
@@ -244,42 +244,42 @@ abstract public class StateTests extends AbstractViewerModelTest implements ITes
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- }
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ }
public void testPreserveExpandedOnInsert() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(6);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(6);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- expandAlternateElements(fListener, model, true);
+ expandAlternateElements(fListener, model, true);
- // Set a selection in view
+ // Set a selection in view
TreeSelection originalSelection = new TreeSelection(model.findElement("5.1")); //$NON-NLS-1$
- fViewer.setSelection(originalSelection);
+ fViewer.setSelection(originalSelection);
- // Update the model
+ // Update the model
ModelDelta delta = model.insertElementChild(TreePath.EMPTY, 0, new TestElement(model, "0 - new", new TestElement[0])); //$NON-NLS-1$
- // Insert delta should generate updates only for the new element
+ // Insert delta should generate updates only for the new element
TreePath path = model.findElement("0 - new"); //$NON-NLS-1$
- // Note: redundant label updates on insert.
- fListener.reset(path, (TestElement)path.getLastSegment(), 0, false, false);
- fListener.addChildreUpdate(TreePath.EMPTY, 0);
- model.postDelta(delta);
+ // Note: redundant label updates on insert.
+ fListener.reset(path, (TestElement)path.getLastSegment(), 0, false, false);
+ fListener.addChildreUpdate(TreePath.EMPTY, 0);
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true);
assertTrue(getInternalViewer().getExpandedState(model.findElement("1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("1.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
@@ -289,50 +289,50 @@ abstract public class StateTests extends AbstractViewerModelTest implements ITes
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- }
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ }
public void testPreserveExpandedOnMultLevelContent() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(6);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(6);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- expandAlternateElements(fListener, model, true);
+ expandAlternateElements(fListener, model, true);
- // Set a selection in view
- // Set a selection in view
- TreeSelection originalSelection = new TreeSelection(
+ // Set a selection in view
+ // Set a selection in view
+ TreeSelection originalSelection = new TreeSelection(
new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findElement("6") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- fViewer.setSelection(originalSelection);
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ fViewer.setSelection(originalSelection);
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- // Update the model
- model.removeElementChild(TreePath.EMPTY, 0);
+ // Update the model
+ model.removeElementChild(TreePath.EMPTY, 0);
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
+ // Note: Re-expanding nodes causes redundant updates.
+ fListener.reset(false, false);
+ fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
- // Create the delta which has nodes with CONTENT flag set at multiple levels.
- ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.CONTENT);
+ // Create the delta which has nodes with CONTENT flag set at multiple levels.
+ ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.CONTENT);
ModelDelta elementDelta = model.getElementDelta(rootDelta, model.findElement("3.1.1"), true); //$NON-NLS-1$
- elementDelta.setFlags(IModelDelta.CONTENT);
+ elementDelta.setFlags(IModelDelta.CONTENT);
- // Post the multi-content update delta
- model.postDelta(rootDelta);
+ // Post the multi-content update delta
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true);
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
@@ -340,101 +340,101 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- // Note: in past it was observed sub-optimal coalescing in this test due
- // to scattered update requests from viewer.
- assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 5) );
- }
+ // Note: in past it was observed sub-optimal coalescing in this test due
+ // to scattered update requests from viewer.
+ assertTrue( fListener.checkCoalesced(TreePath.EMPTY, 0, 5) );
+ }
public void testPreserveExpandedOnSubTreeContent() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
- // Expand all
- fViewer.setAutoExpandLevel(-1);
+ // Expand all
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener,
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener,
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Turn off auto-expansion
- fViewer.setAutoExpandLevel(0);
+ // Turn off auto-expansion
+ fViewer.setAutoExpandLevel(0);
- // Set a selection in view
+ // Set a selection in view
TreeSelection originalSelection = new TreeSelection(model.findElement("3.3.1")); //$NON-NLS-1$
- fViewer.setSelection(originalSelection);
+ fViewer.setSelection(originalSelection);
- // Update the model
+ // Update the model
model.addElementChild(model.findElement("3"), null, 0, new TestElement(model, "3.0 - new", new TestElement[0])); //$NON-NLS-1$ //$NON-NLS-2$
- // Create the delta for element "3" with content update.
+ // Create the delta for element "3" with content update.
TreePath elementPath = model.findElement("3"); //$NON-NLS-1$
- ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- ModelDelta elementDelta = model.getElementDelta(rootDelta, elementPath, true);
- elementDelta.setFlags(IModelDelta.CONTENT);
+ ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ ModelDelta elementDelta = model.getElementDelta(rootDelta, elementPath, true);
+ elementDelta.setFlags(IModelDelta.CONTENT);
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- fListener.addUpdates(getInternalViewer(), elementPath, model.getElement(elementPath), -1, ALL_UPDATES_COMPLETE);
+ // Note: Re-expanding nodes causes redundant updates.
+ fListener.reset(false, false);
+ fListener.addUpdates(getInternalViewer(), elementPath, model.getElement(elementPath), -1, ALL_UPDATES_COMPLETE);
- // Post the sub-tree update
- model.postDelta(rootDelta);
+ // Post the sub-tree update
+ model.postDelta(rootDelta);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true);
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
- // On windows, getExpandedState() may return true for an element with no children:
- // assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.0 - new")) == false);
+ // On windows, getExpandedState() may return true for an element with no children:
+ // assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.0 - new")) == false);
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.2")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.3")) == true); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- }
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ }
public void testPreserveExpandedOnContentStress() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(6);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(6);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- expandAlternateElements(fListener, model, true);
+ expandAlternateElements(fListener, model, true);
- // Set a selection in view
+ // Set a selection in view
// TreeSelection originalSelection = new TreeSelection(
// new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findElement("6") });
TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1")); //$NON-NLS-1$
- fViewer.setSelection(originalSelection);
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
-
- // Run this test ten times as we've seen intermittent failures related
- // to timing in it.
- for (int i = 0; i < 10; i++) {
- // Update the model
- model.removeElementChild(TreePath.EMPTY, 0);
-
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ fViewer.setSelection(originalSelection);
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+
+ // Run this test ten times as we've seen intermittent failures related
+ // to timing in it.
+ for (int i = 0; i < 10; i++) {
+ // Update the model
+ model.removeElementChild(TreePath.EMPTY, 0);
+
+ // Note: Re-expanding nodes causes redundant updates.
+ fListener.reset(false, false);
+ fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true);
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
@@ -442,19 +442,19 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- // Update the model again
+ // Update the model again
model.addElementChild(TreePath.EMPTY, null, 0, new TestElement(model, "1", new TestElement[0])); //$NON-NLS-1$
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Note: Re-expanding nodes causes redundant updates.
+ fListener.reset(false, false);
+ fListener.addUpdates(getInternalViewer(), TreePath.EMPTY, model.getRootElement(), -1, ALL_UPDATES_COMPLETE);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Validate data
- model.validateData(fViewer, TreePath.EMPTY, true);
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true);
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
@@ -462,40 +462,40 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- }
- }
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ }
+ }
public void testPreserveLargeModelOnContent() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(100);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(100);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset();
+ // Create the listener, only check the first level
+ fListener.reset();
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- expandAlternateElements(fListener, model, false);
+ expandAlternateElements(fListener, model, false);
- // Set a selection in view
+ // Set a selection in view
TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1")); //$NON-NLS-1$
- fViewer.setSelection(originalSelection);
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ fViewer.setSelection(originalSelection);
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- // Update the model
- model.removeElementChild(TreePath.EMPTY, 0);
+ // Update the model
+ model.removeElementChild(TreePath.EMPTY, 0);
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Note: Re-expanding nodes causes redundant updates.
+ fListener.reset(false, false);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- // Validate data
+ // Validate data
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
@@ -503,17 +503,17 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- // Update the model again
+ // Update the model again
model.addElementChild(TreePath.EMPTY, null, 0, new TestElement(model, "1", new TestElement[0])); //$NON-NLS-1$
- // Note: Re-expanding nodes causes redundant updates.
- fListener.reset(false, false);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Note: Re-expanding nodes causes redundant updates.
+ fListener.reset(false, false);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- // Validate data
+ // Validate data
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
@@ -521,88 +521,88 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- }
-
- /**
- * This test verifies that if the model selects a new element
- * following a content refresh, the state restore logic will
- * not override the selection requested by the model.
- */
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ }
+
+ /**
+ * This test verifies that if the model selects a new element
+ * following a content refresh, the state restore logic will
+ * not override the selection requested by the model.
+ */
public void testPreserveSelectionDeltaAfterContent() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
- // Expand all
- fViewer.setAutoExpandLevel(-1);
+ // Expand all
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Set a selection in view
+ // Set a selection in view
fViewer.setSelection(new TreeSelection(model.findElement("3.1.1"))); //$NON-NLS-1$
- // Reset the listener (ignore redundant updates)
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Reset the listener (ignore redundant updates)
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Refresh content.
- // Note: Wait only for the processing of the delta, not for all updates
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Refresh content.
+ // Note: Wait only for the processing of the delta, not for all updates
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Update the viewer with new selection delta to something new in the view
+ // Update the viewer with new selection delta to something new in the view
ModelDelta selectDelta = model.makeElementDelta(model.findElement("2.1"), IModelDelta.SELECT); //$NON-NLS-1$
- // Wait for the second model delta to process
- fListener.resetModelChanged();
- model.postDelta(selectDelta);
+ // Wait for the second model delta to process
+ fListener.resetModelChanged();
+ model.postDelta(selectDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Wait for all the updates to complete (note: we're not resetting the listener.
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Wait for all the updates to complete (note: we're not resetting the listener.
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Check to make sure that the state restore didn't change the selection.
+ // Check to make sure that the state restore didn't change the selection.
assertEquals(new TreeSelection(model.findElement("2.1")), fViewer.getSelection()); //$NON-NLS-1$
- }
+ }
public void testPreserveCollapseDeltaAfterContent() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
- // Expand all
- fViewer.setAutoExpandLevel(-1);
+ // Expand all
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Turn off auto-expand
- fViewer.setAutoExpandLevel(0);
+ // Turn off auto-expand
+ fViewer.setAutoExpandLevel(0);
- // Reset the listener (ignore redundant updates)
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Reset the listener (ignore redundant updates)
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Refresh content.
- // Note: Wait only for the processing of the delta, not for all updates
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Refresh content.
+ // Note: Wait only for the processing of the delta, not for all updates
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Update the viewer to collapse an element
+ // Update the viewer to collapse an element
ModelDelta collapseDelta = model.makeElementDelta(model.findElement("3.1"), IModelDelta.COLLAPSE); //$NON-NLS-1$
- // Remove updates for the collapsed element from listener, because they
- // will never happen if the element remains collapsed.
- fListener.resetModelChanged();
+ // Remove updates for the collapsed element from listener, because they
+ // will never happen if the element remains collapsed.
+ fListener.resetModelChanged();
fListener.removeLabelUpdate(model.findElement("3.1.1")); //$NON-NLS-1$
fListener.removeLabelUpdate(model.findElement("3.1.2")); //$NON-NLS-1$
fListener.removeLabelUpdate(model.findElement("3.1.3")); //$NON-NLS-1$
@@ -614,284 +614,284 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
fListener.removeChildrenUpdate(model.findElement("3.1"), 1); //$NON-NLS-1$
fListener.removeChildrenUpdate(model.findElement("3.1"), 2); //$NON-NLS-1$
- // Wait for the second model delta to process
- model.postDelta(collapseDelta);
+ // Wait for the second model delta to process
+ model.postDelta(collapseDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Wait for all the updates to complete (note: we're not resetting the listener.
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Wait for all the updates to complete (note: we're not resetting the listener.
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Check to make sure that the state restore didn't change the selection.
+ // Check to make sure that the state restore didn't change the selection.
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == false); //$NON-NLS-1$
- }
+ }
public void testPreserveExpandDeltaAfterContent() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
- // Note: Do not auto-expand!
+ // Note: Do not auto-expand!
- // Create the listener.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Reset the listener (ignore redundant updates)
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
+ // Reset the listener (ignore redundant updates)
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- // Refresh content.
- // Note: Wait only for the processing of the delta, not for all updates
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Refresh content.
+ // Note: Wait only for the processing of the delta, not for all updates
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Update the viewer to expand an element
+ // Update the viewer to expand an element
ModelDelta expandDelta = model.makeElementDelta(model.findElement("3.1"), IModelDelta.EXPAND); //$NON-NLS-1$
- // Wait for the second model delta to process
- fListener.resetModelChanged();
- model.postDelta(expandDelta);
+ // Wait for the second model delta to process
+ fListener.resetModelChanged();
+ model.postDelta(expandDelta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Wait for all the updates to complete (note: we're not resetting the listener.
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Wait for all the updates to complete (note: we're not resetting the listener.
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Check to make sure that the state restore didn't change the selection.
+ // Check to make sure that the state restore didn't change the selection.
assertTrue(getInternalViewer().getExpandedState(model.findElement("3.1")) == true); //$NON-NLS-1$
- }
+ }
public void testSaveAndRestore1() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(6);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(6);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Expand some, but not all elements
- expandAlternateElements(fListener, model, true);
+ // Expand some, but not all elements
+ expandAlternateElements(fListener, model, true);
- // Set a selection in view
+ // Set a selection in view
fViewer.setSelection(new TreeSelection(new TreePath[] { model.findElement("5.1"), model.findElement("5.1.1"), model.findElement("6.1.1") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(false, false);
- fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
- fViewer.setInput(null);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset(false, false);
+ fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
+ fViewer.setInput(null);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE | STATE_UPDATES), createListenerErrorMessage());
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- // TODO: add state updates somehow?
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model. When view updates are complete
+ // the viewer
+ // Note: disable redundant updates because the reveal delta triggers one.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
+ // TODO: add state updates somehow?
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- // Extract the restored state from viewer
- ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the restored state from viewer
+ ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
- if (!deltaMatches(originalState, restoredState)) {
+ if (!deltaMatches(originalState, restoredState)) {
fail("Expected:\n" + originalState.toString() + "\nGot:\n" + restoredState); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ }
+ }
public void testSaveAndRestore2() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
- // expand all elements
- fViewer.setAutoExpandLevel(-1);
+ // expand all elements
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Set a selection in view
+ // Set a selection in view
fViewer.setSelection(new TreeSelection(new TreePath[] { model.findElement("3.2"), model.findElement("3.2.1"), model.findElement("2") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
fViewer.setSelection(new TreeSelection(model.findElement("3.2.3"))); //$NON-NLS-1$
- // Turn off the auto-expand now since we want to text the auto-expand logic
- fViewer.setAutoExpandLevel(-1);
+ // Turn off the auto-expand now since we want to text the auto-expand logic
+ fViewer.setAutoExpandLevel(-1);
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(true, false);
- fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset(true, false);
+ fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
- fViewer.setInput(null);
+ fViewer.setInput(null);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE | STATE_UPDATES), createListenerErrorMessage());
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- // TODO: add state updates somehow?
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model. When view updates are complete
+ // the viewer
+ // Note: disable redundant updates because the reveal delta triggers one.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
+ // TODO: add state updates somehow?
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- // Extract the restored state from viewer
- ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the restored state from viewer
+ ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
- if (!deltaMatches(originalState, restoredState)) {
+ if (!deltaMatches(originalState, restoredState)) {
fail("Expected:\n" + originalState.toString() + "\nGot:\n" + restoredState); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ }
+ }
public void testSaveAndRestoreInputInstance() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(6);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(6);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Expand some, but not all elements
- expandAlternateElements(fListener, model, true);
+ // Expand some, but not all elements
+ expandAlternateElements(fListener, model, true);
- // Set a selection in view
+ // Set a selection in view
fViewer.setSelection(new TreeSelection(new TreePath[] { model.findElement("5.1"), model.findElement("5.1.1"), model.findElement("6.1.1") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Do not reset to null, just reset input to the same object.
+ // Do not reset to null, just reset input to the same object.
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model. When view updates are complete
+ // the viewer
+ // Note: disable redundant updates because the reveal delta triggers one.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- // Extract the restored state from viewer
- ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the restored state from viewer
+ ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
- if (!deltaMatches(originalState, restoredState)) {
+ if (!deltaMatches(originalState, restoredState)) {
fail("Expected:\n" + originalState.toString() + "\nGot:\n" + restoredState); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ }
+ }
public void testSaveAndRestoreInputInstanceEquals() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(6);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(6);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+ // Create the listener, only check the first level
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // Expand some, but not all elements
- expandAlternateElements(fListener, model, true);
+ // Expand some, but not all elements
+ expandAlternateElements(fListener, model, true);
- // Set a selection in view
+ // Set a selection in view
fViewer.setSelection(new TreeSelection(new TreePath[] { model.findElement("5.1"), model.findElement("5.1.1"), model.findElement("6.1.1") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Create a copy of the input object and set it to model.
- TestElement newRoot = new TestElement(model, model.getRootElement().getID(), model.getRootElement().getChildren());
- model.setRoot(newRoot);
+ // Create a copy of the input object and set it to model.
+ TestElement newRoot = new TestElement(model, model.getRootElement().getID(), model.getRootElement().getChildren());
+ model.setRoot(newRoot);
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
+ // Set the viewer input back to the model. When view updates are complete
+ // the viewer
+ // Note: disable redundant updates because the reveal delta triggers one.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- fViewer.setInput(model.getRootElement());
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- // Extract the restored state from viewer
- ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the restored state from viewer
+ ModelDelta restoredState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, restoredState, IModelDelta.EXPAND | IModelDelta.SELECT);
- if (!deltaMatches(originalState, restoredState)) {
+ if (!deltaMatches(originalState, restoredState)) {
fail("Expected:\n" + originalState.toString() + "\nGot:\n" + restoredState); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ }
+ }
public void testSaveAndRestoreLarge() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(100);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(100);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset();
+ // Create the listener, only check the first level
+ fListener.reset();
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- expandAlternateElements(fListener, model, false);
+ expandAlternateElements(fListener, model, false);
- // Set a selection in view
+ // Set a selection in view
TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1")); //$NON-NLS-1$
- fViewer.setSelection(originalSelection);
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ fViewer.setSelection(originalSelection);
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset();
- fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset();
+ fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
- fViewer.setInput(null);
+ fViewer.setInput(null);
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE | STATE_UPDATES), createListenerErrorMessage());
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset();
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model. When view updates are complete
+ // the viewer
+ // Note: disable redundant updates because the reveal delta triggers one.
+ fListener.reset();
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- // Validate data (only select visible elements).
+ // Validate data (only select visible elements).
assertTrue(getInternalViewer().getExpandedState(model.findElement("1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("1.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
@@ -901,64 +901,64 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- }
-
- /**
- * This test saves state of a large tree. Then the tree is modified
- * to contain much fewer elements. The restore logic should discard the
- * rest of the saved state delta once all the elements are visible.
- */
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ }
+
+ /**
+ * This test saves state of a large tree. Then the tree is modified
+ * to contain much fewer elements. The restore logic should discard the
+ * rest of the saved state delta once all the elements are visible.
+ */
public void testSaveAndRestorePartialStateLarge() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = alternatingSubsreesModel(100);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = alternatingSubsreesModel(100);
- // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
+ // NOTE: WE ARE NOT EXPANDING ANY CHILDREN
- // Create the listener, only check the first level
- fListener.reset();
+ // Create the listener, only check the first level
+ fListener.reset();
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE), createListenerErrorMessage());
- expandAlternateElements(fListener, model, false);
+ expandAlternateElements(fListener, model, false);
- // Set a selection in view
+ // Set a selection in view
TreeSelection originalSelection = new TreeSelection(model.findElement("5.1.1")); //$NON-NLS-1$
- fViewer.setSelection(originalSelection);
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ fViewer.setSelection(originalSelection);
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- // Extract the original state from viewer
- ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
+ // Extract the original state from viewer
+ ModelDelta originalState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, originalState, IModelDelta.EXPAND | IModelDelta.SELECT);
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset();
- fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset();
+ fListener.addStateUpdates(getInternalViewer(), originalState, IModelDelta.EXPAND | IModelDelta.SELECT | IModelDelta.REVEAL);
- fViewer.setInput(null);
+ fViewer.setInput(null);
TestUtil.waitForJobs(getName(), 300, 5000);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE | STATE_UPDATES), createListenerErrorMessage());
- TestElement[] elements = model.getRootElement().getChildren();
- TestElement[] newElements = new TestElement[10];
- System.arraycopy(elements, 0, newElements, 0, newElements.length);
- model.setElementChildren(TreePath.EMPTY, newElements);
+ TestElement[] elements = model.getRootElement().getChildren();
+ TestElement[] newElements = new TestElement[10];
+ System.arraycopy(elements, 0, newElements, 0, newElements.length);
+ model.setElementChildren(TreePath.EMPTY, newElements);
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset();
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model. When view updates are complete
+ // the viewer
+ // Note: disable redundant updates because the reveal delta triggers one.
+ fListener.reset();
+ fViewer.setInput(model.getRootElement());
TestUtil.waitForJobs(getName(), 300, 5000);
- // MONITOR FOR THE STATE RESTORE TO COMPLETE
+ // MONITOR FOR THE STATE RESTORE TO COMPLETE
waitWhile(t -> !fListener.isFinished(CONTENT_SEQUENCE_COMPLETE | STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Validate data
+ // Validate data
assertTrue(getInternalViewer().getExpandedState(model.findElement("1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("1.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
@@ -968,134 +968,134 @@ new TreePath[] { model.findElement("5"), model.findElement("5.1"), model.findEle
assertTrue(getInternalViewer().getExpandedState(model.findElement("5")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("5.1")) == true); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("6")) == false); //$NON-NLS-1$
- assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
- }
+ assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ }
public void testPreserveCollapseAndSelectDeltaAfterSaveAndRestore() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
- // Expand all
- fViewer.setAutoExpandLevel(-1);
+ // Expand all
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
fViewer.setSelection(new TreeSelection(model.findElement("3"))); //$NON-NLS-1$
- // Turn off auto-expand
- fViewer.setAutoExpandLevel(0);
+ // Turn off auto-expand
+ fViewer.setAutoExpandLevel(0);
- // Set the viewer input to null. This will trigger the view to save the viewer state.
- fListener.reset(false, false);
- fViewer.setInput(null);
+ // Set the viewer input to null. This will trigger the view to save the viewer state.
+ fListener.reset(false, false);
+ fViewer.setInput(null);
waitWhile(t -> !fListener.isFinished(STATE_SAVE_COMPLETE), createListenerErrorMessage());
- // Set the viewer input back to the model. When view updates are complete
- // the viewer
- // Note: disable redundant updates because the reveal delta triggers one.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
- fViewer.setInput(model.getRootElement());
+ // Set the viewer input back to the model. When view updates are complete
+ // the viewer
+ // Note: disable redundant updates because the reveal delta triggers one.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, false, false);
+ fViewer.setInput(model.getRootElement());
TreePath path = model.findElement("2"); //$NON-NLS-1$
- fListener.addUpdates(null, path, (TestElement)path.getLastSegment(), 0, STATE_UPDATES);
+ fListener.addUpdates(null, path, (TestElement)path.getLastSegment(), 0, STATE_UPDATES);
path = model.findElement("3"); //$NON-NLS-1$
- fListener.addUpdates(null, path, (TestElement)path.getLastSegment(), 0, STATE_UPDATES);
+ fListener.addUpdates(null, path, (TestElement)path.getLastSegment(), 0, STATE_UPDATES);
- // Wait till we restore state of elements we want to collapse and select
- // Bug 372619 - Need to wait until proxy installed delta is processed before
- // posting the next delta.
+ // Wait till we restore state of elements we want to collapse and select
+ // Bug 372619 - Need to wait until proxy installed delta is processed before
+ // posting the next delta.
waitWhile(t -> !fListener.isFinished(STATE_RESTORE_STARTED | STATE_UPDATES | CHILDREN_UPDATES | MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Post first collapse delta
- fListener.resetModelChanged();
+ // Post first collapse delta
+ fListener.resetModelChanged();
model.postDelta(model.makeElementDelta(model.findElement("2"), IModelDelta.COLLAPSE)); //$NON-NLS-1$
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Post second collapse delta
- fListener.resetModelChanged();
+ // Post second collapse delta
+ fListener.resetModelChanged();
model.postDelta(model.makeElementDelta(model.findElement("3"), IModelDelta.COLLAPSE)); //$NON-NLS-1$
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Post select delta
+ // Post select delta
model.postDelta(model.makeElementDelta(model.findElement("1"), IModelDelta.SELECT)); //$NON-NLS-1$
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- // Wait for all the updates to complete (note: we're not resetting the listener).
+ // Wait for all the updates to complete (note: we're not resetting the listener).
waitWhile(t -> !fListener.isFinished(STATE_RESTORE_COMPLETE), createListenerErrorMessage());
- // Check to make sure that the state restore didn't change the selection.
+ // Check to make sure that the state restore didn't change the selection.
assertTrue(getInternalViewer().getExpandedState(model.findElement("2")) == false); //$NON-NLS-1$
assertTrue(getInternalViewer().getExpandedState(model.findElement("3")) == false); //$NON-NLS-1$
assertEquals(new TreeSelection(model.findElement("1")), fViewer.getSelection()); //$NON-NLS-1$
- }
+ }
- /**
- * Test for bug 359859.<br>
- * This test verifies that RESTORE state is handled after SAVE previous state was completed
- */
+ /**
+ * Test for bug 359859.<br>
+ * This test verifies that RESTORE state is handled after SAVE previous state was completed
+ */
public void testSaveRestoreOrder() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleMultiLevel();
- model.setDelayUpdates(true);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
+ model.setDelayUpdates(true);
- // Expand all
- fViewer.setAutoExpandLevel(-1);
+ // Expand all
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener.
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener.
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY, true);
+ model.validateData(fViewer, TreePath.EMPTY, true);
- // a new similar model
- TestModel copyModel = TestModel.simpleMultiLevel();
+ // a new similar model
+ TestModel copyModel = TestModel.simpleMultiLevel();
- // Trigger save - restore sequence.
- fListener.reset();
- fListener.expectRestoreAfterSaveComplete();
- fViewer.setInput(copyModel.getRootElement());
+ // Trigger save - restore sequence.
+ fListener.reset();
+ fListener.expectRestoreAfterSaveComplete();
+ fViewer.setInput(copyModel.getRootElement());
waitWhile(t -> !fListener.isFinished(STATE_RESTORE_STARTED), createListenerErrorMessage());
assertTrue("RESTORE started before SAVE to complete", fListener.isFinished(STATE_SAVE_COMPLETE)); //$NON-NLS-1$
- }
+ }
- /**
- * This test tries to restore a viewer state while input == null.
- * See: Bug 380288 - NPE switching to the Breakpoints View
- */
+ /**
+ * This test tries to restore a viewer state while input == null.
+ * See: Bug 380288 - NPE switching to the Breakpoints View
+ */
public void testUpdateWithNullInput() throws Exception {
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleMultiLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- ModelDelta expandedState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
- fViewer.saveElementState(TreePath.EMPTY, expandedState, IModelDelta.EXPAND);
+ ModelDelta expandedState = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ fViewer.saveElementState(TreePath.EMPTY, expandedState, IModelDelta.EXPAND);
- // Refresh the viewer so that updates are generated.
- fListener.reset();
- fListener.addChildreCountUpdate(TreePath.EMPTY);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Refresh the viewer so that updates are generated.
+ fListener.reset();
+ fListener.addChildreCountUpdate(TreePath.EMPTY);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- // Wait for the delta to be processed.
+ // Wait for the delta to be processed.
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES), createListenerErrorMessage());
- fViewer.setInput(null);
- fViewer.updateViewer(expandedState);
+ fViewer.setInput(null);
+ fViewer.updateViewer(expandedState);
waitWhile(t -> !fListener.isFinished(CONTENT_COMPLETE | VIEWER_UPDATES_RUNNING), createListenerErrorMessage());
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModel.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModel.java
index 572a92ea2..cb4da5b01 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModel.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TestModel.java
@@ -60,891 +60,891 @@ import org.junit.Assert;
*/
public class TestModel implements IElementContentProvider, IElementLabelProvider, IModelProxyFactory2 , IElementMementoProvider, IModelSelectionPolicyFactory {
- public static class TestElement extends PlatformObject {
- private final TestModel fModel;
- private final String fID;
- TestElement[] fChildren;
- String fLabelAppendix = ""; //$NON-NLS-1$
- boolean fExpanded;
- boolean fChecked;
- boolean fGrayed;
-
- public TestElement(TestModel model, String text, TestElement[] children) {
- this (model, text, false, false, children);
- }
-
- public TestElement(TestModel model, String text, boolean checked, boolean grayed, TestElement[] children) {
- fModel = model;
- fID = text;
- fChildren = children;
- fChecked = checked;
- fGrayed = grayed;
- }
-
- public TestModel getModel() {
- return fModel;
- }
+ public static class TestElement extends PlatformObject {
+ private final TestModel fModel;
+ private final String fID;
+ TestElement[] fChildren;
+ String fLabelAppendix = ""; //$NON-NLS-1$
+ boolean fExpanded;
+ boolean fChecked;
+ boolean fGrayed;
+
+ public TestElement(TestModel model, String text, TestElement[] children) {
+ this (model, text, false, false, children);
+ }
+
+ public TestElement(TestModel model, String text, boolean checked, boolean grayed, TestElement[] children) {
+ fModel = model;
+ fID = text;
+ fChildren = children;
+ fChecked = checked;
+ fGrayed = grayed;
+ }
+
+ public TestModel getModel() {
+ return fModel;
+ }
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
- if (adapter.isInstance(fModel)) {
+ if (adapter.isInstance(fModel)) {
return (T) fModel;
- }
- return null;
- }
+ }
+ return null;
+ }
- public String getID() {
- return fID;
- }
+ public String getID() {
+ return fID;
+ }
- public void setLabelAppendix(String appendix) {
- fLabelAppendix = appendix;
- }
+ public void setLabelAppendix(String appendix) {
+ fLabelAppendix = appendix;
+ }
- public String getLabel() {
- return fID + fLabelAppendix;
- }
+ public String getLabel() {
+ return fID + fLabelAppendix;
+ }
- public TestElement[] getChildren() {
- return fChildren;
- }
+ public TestElement[] getChildren() {
+ return fChildren;
+ }
- public boolean isExpanded() {
- return fExpanded;
- }
+ public boolean isExpanded() {
+ return fExpanded;
+ }
- public boolean getGrayed() {
- return fGrayed;
- }
+ public boolean getGrayed() {
+ return fGrayed;
+ }
- public boolean getChecked() {
- return fChecked;
- }
+ public boolean getChecked() {
+ return fChecked;
+ }
- public void setChecked(boolean checked, boolean grayed) {
- fChecked = checked;
- fGrayed = grayed;
- }
+ public void setChecked(boolean checked, boolean grayed) {
+ fChecked = checked;
+ fGrayed = grayed;
+ }
- @Override
+ @Override
public boolean equals(Object obj) {
- return obj instanceof TestElement && fID.equals(((TestElement)obj).fID);
- }
+ return obj instanceof TestElement && fID.equals(((TestElement)obj).fID);
+ }
- @Override
+ @Override
public int hashCode() {
- return fID.hashCode();
- }
+ return fID.hashCode();
+ }
- @Override
+ @Override
public String toString() {
- return getLabel();
- }
+ return getLabel();
+ }
- public int indexOf(TestElement child) {
- return Arrays.asList(fChildren).indexOf(child);
- }
- }
+ public int indexOf(TestElement child) {
+ return Arrays.asList(fChildren).indexOf(child);
+ }
+ }
- private class ModelProxy extends AbstractModelProxy {
- @Override
+ private class ModelProxy extends AbstractModelProxy {
+ @Override
public void installed(Viewer viewer) {
- super.installed(viewer);
- ModelDelta rootDelta = TestModel.this.getBaseDelta(new ModelDelta(fInput, IModelDelta.NO_CHANGE));
- installSubModelProxies(fRootPath, rootDelta);
- fireModelChanged(rootDelta);
- }
-
- private void installSubModelProxies(TreePath path, ModelDelta delta) {
- TestElement element = getElement(path);
- if (element.fModel != TestModel.this) {
- // Found an element from a different model. Install its proxy and return.
- delta.setFlags(delta.getFlags() | IModelDelta.INSTALL);
- } else {
- TestElement[] children = element.getChildren();
-
- for (int i = 0; i < children.length; i++) {
- installSubModelProxies(path.createChildPath(children[i]), delta.addNode(children[i], IModelDelta.NO_CHANGE));
- }
- }
- }
- }
-
- private TestElement fRoot;
- private Object fInput = null;
- private TreePath fRootPath = TreePath.EMPTY;
- private ModelProxy fModelProxy;
- private IModelSelectionPolicy fModelSelectionPolicy;
- private boolean fQueueingUpdates = false;
- private boolean fDelayUpdates = false;
+ super.installed(viewer);
+ ModelDelta rootDelta = TestModel.this.getBaseDelta(new ModelDelta(fInput, IModelDelta.NO_CHANGE));
+ installSubModelProxies(fRootPath, rootDelta);
+ fireModelChanged(rootDelta);
+ }
+
+ private void installSubModelProxies(TreePath path, ModelDelta delta) {
+ TestElement element = getElement(path);
+ if (element.fModel != TestModel.this) {
+ // Found an element from a different model. Install its proxy and return.
+ delta.setFlags(delta.getFlags() | IModelDelta.INSTALL);
+ } else {
+ TestElement[] children = element.getChildren();
+
+ for (int i = 0; i < children.length; i++) {
+ installSubModelProxies(path.createChildPath(children[i]), delta.addNode(children[i], IModelDelta.NO_CHANGE));
+ }
+ }
+ }
+ }
+
+ private TestElement fRoot;
+ private Object fInput = null;
+ private TreePath fRootPath = TreePath.EMPTY;
+ private ModelProxy fModelProxy;
+ private IModelSelectionPolicy fModelSelectionPolicy;
+ private boolean fQueueingUpdates = false;
+ private boolean fDelayUpdates = false;
private List<IViewerUpdate> fQueuedUpdates = new LinkedList<>();
- /**
- * Constructor private. Use static factory methods instead.
- */
- public TestModel() {}
+ /**
+ * Constructor private. Use static factory methods instead.
+ */
+ public TestModel() {}
- public TestElement getRootElement() {
- return fRoot;
- }
+ public TestElement getRootElement() {
+ return fRoot;
+ }
- public void setSelectionPolicy(IModelSelectionPolicy modelSelectionPolicy) {
- fModelSelectionPolicy = modelSelectionPolicy;
- }
+ public void setSelectionPolicy(IModelSelectionPolicy modelSelectionPolicy) {
+ fModelSelectionPolicy = modelSelectionPolicy;
+ }
- @Override
+ @Override
public IModelSelectionPolicy createModelSelectionPolicyAdapter(Object element, IPresentationContext context) {
- return fModelSelectionPolicy;
- }
-
- public ModelDelta getBaseDelta(ModelDelta rootDelta) {
- ModelDelta delta = rootDelta;
- for (int i = 0; i < fRootPath.getSegmentCount(); i++) {
- ModelDelta subDelta = delta.getChildDelta(fRootPath.getSegment(i));
- if (subDelta == null) {
- subDelta = delta.addNode(fRootPath.getSegment(i), IModelDelta.NO_CHANGE);
- }
- delta = subDelta;
- }
- delta.setChildCount(getRootElement().getChildren().length);
- return delta;
- }
-
- public int getModelDepth() {
- return getDepth(getRootElement(), 0);
- }
-
- private int getDepth(TestElement element, int atDepth) {
- TestElement[] children = element.getChildren();
- if (children.length == 0) {
- return atDepth;
- }
- int depth = atDepth + 1;
- for (int i = 0; i < children.length; i++) {
- depth = Math.max(depth, getDepth(children[i], atDepth + 1));
- }
-
- return depth;
- }
-
- public void setQeueueingUpdate(boolean queueingUpdates) {
- fQueueingUpdates = queueingUpdates;
- if (!fQueueingUpdates) {
- processQueuedUpdates();
- }
- }
-
- public void setDelayUpdates(boolean delayUpdates) {
- fDelayUpdates = delayUpdates;
- }
+ return fModelSelectionPolicy;
+ }
+
+ public ModelDelta getBaseDelta(ModelDelta rootDelta) {
+ ModelDelta delta = rootDelta;
+ for (int i = 0; i < fRootPath.getSegmentCount(); i++) {
+ ModelDelta subDelta = delta.getChildDelta(fRootPath.getSegment(i));
+ if (subDelta == null) {
+ subDelta = delta.addNode(fRootPath.getSegment(i), IModelDelta.NO_CHANGE);
+ }
+ delta = subDelta;
+ }
+ delta.setChildCount(getRootElement().getChildren().length);
+ return delta;
+ }
+
+ public int getModelDepth() {
+ return getDepth(getRootElement(), 0);
+ }
+
+ private int getDepth(TestElement element, int atDepth) {
+ TestElement[] children = element.getChildren();
+ if (children.length == 0) {
+ return atDepth;
+ }
+ int depth = atDepth + 1;
+ for (int i = 0; i < children.length; i++) {
+ depth = Math.max(depth, getDepth(children[i], atDepth + 1));
+ }
+
+ return depth;
+ }
+
+ public void setQeueueingUpdate(boolean queueingUpdates) {
+ fQueueingUpdates = queueingUpdates;
+ if (!fQueueingUpdates) {
+ processQueuedUpdates();
+ }
+ }
+
+ public void setDelayUpdates(boolean delayUpdates) {
+ fDelayUpdates = delayUpdates;
+ }
public List<IViewerUpdate> getQueuedUpdates() {
- return fQueuedUpdates;
- }
+ return fQueuedUpdates;
+ }
- public void processQueuedUpdates() {
+ public void processQueuedUpdates() {
List<IViewerUpdate> updates = new ArrayList<>(fQueuedUpdates);
- fQueuedUpdates.clear();
- for (int i = 0; i < updates.size(); i++) {
- processUpdate(updates.get(i));
- }
- }
-
- public void processUpdate(IViewerUpdate update) {
- if (update instanceof IHasChildrenUpdate) {
- doHasChildrenUpdate((IHasChildrenUpdate)update);
- } else if (update instanceof IChildrenCountUpdate) {
- doChildrenCountUpdate((IChildrenCountUpdate)update);
- } else if (update instanceof IChildrenUpdate) {
- doChildrenUpdate((IChildrenUpdate)update);
- } else if (update instanceof ILabelUpdate) {
- doLabelUpdate((ILabelUpdate)update);
- } else if (update instanceof IElementCompareRequest) {
- doCompareElements((IElementCompareRequest)update);
- } else if (update instanceof IElementMementoRequest) {
- doEncodeElements((IElementMementoRequest)update);
- }
- }
-
- private void processUpdates(IViewerUpdate[] updates) {
- for (int i = 0; i < updates.length; i++) {
- processUpdate(updates[i]);
- }
- }
-
- private void doUpdate(final IViewerUpdate[] updates) {
- if (fQueueingUpdates) {
- fQueuedUpdates.addAll(Arrays.asList(updates));
- } else if (fDelayUpdates) {
+ fQueuedUpdates.clear();
+ for (int i = 0; i < updates.size(); i++) {
+ processUpdate(updates.get(i));
+ }
+ }
+
+ public void processUpdate(IViewerUpdate update) {
+ if (update instanceof IHasChildrenUpdate) {
+ doHasChildrenUpdate((IHasChildrenUpdate)update);
+ } else if (update instanceof IChildrenCountUpdate) {
+ doChildrenCountUpdate((IChildrenCountUpdate)update);
+ } else if (update instanceof IChildrenUpdate) {
+ doChildrenUpdate((IChildrenUpdate)update);
+ } else if (update instanceof ILabelUpdate) {
+ doLabelUpdate((ILabelUpdate)update);
+ } else if (update instanceof IElementCompareRequest) {
+ doCompareElements((IElementCompareRequest)update);
+ } else if (update instanceof IElementMementoRequest) {
+ doEncodeElements((IElementMementoRequest)update);
+ }
+ }
+
+ private void processUpdates(IViewerUpdate[] updates) {
+ for (int i = 0; i < updates.length; i++) {
+ processUpdate(updates[i]);
+ }
+ }
+
+ private void doUpdate(final IViewerUpdate[] updates) {
+ if (fQueueingUpdates) {
+ fQueuedUpdates.addAll(Arrays.asList(updates));
+ } else if (fDelayUpdates) {
Display.getDefault().asyncExec(() -> processUpdates(updates));
- } else {
+ } else {
processUpdates(updates);
- }
- }
+ }
+ }
- @Override
+ @Override
public void update(IHasChildrenUpdate[] updates) {
- doUpdate(updates);
- }
+ doUpdate(updates);
+ }
- private void doHasChildrenUpdate(IHasChildrenUpdate update) {
- TestElement element = (TestElement)update.getElement();
- update.setHasChilren(element.getChildren().length > 0);
- update.done();
- }
+ private void doHasChildrenUpdate(IHasChildrenUpdate update) {
+ TestElement element = (TestElement)update.getElement();
+ update.setHasChilren(element.getChildren().length > 0);
+ update.done();
+ }
- @Override
+ @Override
public void update(IChildrenCountUpdate[] updates) {
- doUpdate(updates);
- }
+ doUpdate(updates);
+ }
- private void doChildrenCountUpdate(IChildrenCountUpdate update) {
- TestElement element = (TestElement)update.getElement();
- update.setChildCount(element.getChildren().length);
- update.done();
- }
+ private void doChildrenCountUpdate(IChildrenCountUpdate update) {
+ TestElement element = (TestElement)update.getElement();
+ update.setChildCount(element.getChildren().length);
+ update.done();
+ }
- @Override
+ @Override
public void update(IChildrenUpdate[] updates) {
- doUpdate(updates);
- }
-
- private void doChildrenUpdate(IChildrenUpdate update) {
- TestElement element = (TestElement)update.getElement();
- int endOffset = update.getOffset() + update.getLength();
- for (int j = update.getOffset(); j < endOffset; j++) {
- if (j < element.getChildren().length) {
- update.setChild(element.getChildren()[j], j);
- }
- }
- update.done();
- }
-
- @Override
+ doUpdate(updates);
+ }
+
+ private void doChildrenUpdate(IChildrenUpdate update) {
+ TestElement element = (TestElement)update.getElement();
+ int endOffset = update.getOffset() + update.getLength();
+ for (int j = update.getOffset(); j < endOffset; j++) {
+ if (j < element.getChildren().length) {
+ update.setChild(element.getChildren()[j], j);
+ }
+ }
+ update.done();
+ }
+
+ @Override
public void update(ILabelUpdate[] updates) {
- doUpdate(updates);
- }
-
- private void doLabelUpdate(ILabelUpdate update) {
- TestElement element = (TestElement)update.getElement();
- update.setLabel(element.getLabel(), 0);
- if (update instanceof ICheckUpdate &&
- Boolean.TRUE.equals(update.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)))
- {
- ((ICheckUpdate)update).setChecked(element.getChecked(), element.getGrayed());
- }
- update.done();
- }
-
- public final static String ELEMENT_MEMENTO_ID = "id"; //$NON-NLS-1$
-
- @Override
+ doUpdate(updates);
+ }
+
+ private void doLabelUpdate(ILabelUpdate update) {
+ TestElement element = (TestElement)update.getElement();
+ update.setLabel(element.getLabel(), 0);
+ if (update instanceof ICheckUpdate &&
+ Boolean.TRUE.equals(update.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)))
+ {
+ ((ICheckUpdate)update).setChecked(element.getChecked(), element.getGrayed());
+ }
+ update.done();
+ }
+
+ public final static String ELEMENT_MEMENTO_ID = "id"; //$NON-NLS-1$
+
+ @Override
public void compareElements(final IElementCompareRequest[] updates) {
- doUpdate(updates);
- }
+ doUpdate(updates);
+ }
- private void doCompareElements(IElementCompareRequest update) {
- String elementID = ((TestElement)update.getElement()).getID();
- String mementoID = update.getMemento().getString(ELEMENT_MEMENTO_ID);
- update.setEqual( elementID.equals(mementoID) );
- update.done();
- }
+ private void doCompareElements(IElementCompareRequest update) {
+ String elementID = ((TestElement)update.getElement()).getID();
+ String mementoID = update.getMemento().getString(ELEMENT_MEMENTO_ID);
+ update.setEqual( elementID.equals(mementoID) );
+ update.done();
+ }
- @Override
+ @Override
public void encodeElements(IElementMementoRequest[] updates) {
- doUpdate(updates);
- }
-
- private void doEncodeElements(IElementMementoRequest update) {
- String elementID = ((TestElement)update.getElement()).getID();
- update.getMemento().putString(ELEMENT_MEMENTO_ID, elementID);
- update.done();
- }
-
- /**
- * @param context the context
- * @param viewerInput the input
- * @param path the path
- * @param checked the checked state
- */
- public void elementChecked(IPresentationContext context, Object viewerInput, TreePath path, boolean checked) {
- TestElement element = getElement(path);
- Assert.assertFalse(element.getGrayed());
- element.setChecked(checked, false);
- }
-
- @Override
+ doUpdate(updates);
+ }
+
+ private void doEncodeElements(IElementMementoRequest update) {
+ String elementID = ((TestElement)update.getElement()).getID();
+ update.getMemento().putString(ELEMENT_MEMENTO_ID, elementID);
+ update.done();
+ }
+
+ /**
+ * @param context the context
+ * @param viewerInput the input
+ * @param path the path
+ * @param checked the checked state
+ */
+ public void elementChecked(IPresentationContext context, Object viewerInput, TreePath path, boolean checked) {
+ TestElement element = getElement(path);
+ Assert.assertFalse(element.getGrayed());
+ element.setChecked(checked, false);
+ }
+
+ @Override
public IModelProxy createTreeModelProxy(Object input, TreePath path, IPresentationContext context) {
- fModelProxy = new ModelProxy();
- fInput = input;
- fRootPath = path;
- return fModelProxy;
- }
-
- public IModelProxy getModelProxy() {
- return fModelProxy;
- }
-
- public TestElement getElement(TreePath path) {
- if (path.getSegmentCount() == 0) {
- return getRootElement();
- } else {
- return (TestElement)path.getLastSegment();
- }
- }
-
- public void setAllExpanded() {
- doSetExpanded(fRoot);
- }
-
- private void doSetExpanded(TestElement element) {
- element.fExpanded = true;
- for (int i = 0; i < element.fChildren.length; i++) {
- doSetExpanded(element.fChildren[i]);
- }
- }
-
- public void setAllAppendix(String appendix) {
- doSetAllAppendix(fRoot, appendix);
- }
-
- private void doSetAllAppendix(TestElement element, String appendix) {
- element.setLabelAppendix(appendix);
- for (int i = 0; i < element.fChildren.length; i++) {
- doSetAllAppendix(element.fChildren[i], appendix);
- }
- }
-
- public void validateData(ITreeModelViewer viewer, TreePath path) {
- validateData(viewer, path, false);
- }
-
- public void validateData(ITreeModelViewer _viewer, TreePath path, boolean expandedElementsOnly) {
- validateData(_viewer, path, expandedElementsOnly, TestModelUpdatesListener.EMPTY_FILTER_ARRAY);
- }
-
- public void validateData(ITreeModelViewer _viewer, TreePath path, boolean expandedElementsOnly, ViewerFilter[] filters) {
- IInternalTreeModelViewer viewer = (IInternalTreeModelViewer)_viewer;
- TestElement element = getElement(path);
- if ( Boolean.TRUE.equals(_viewer.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)) ) {
- Assert.assertTrue(element.getChecked() == viewer.getElementChecked(path));
- Assert.assertTrue(element.getGrayed() == viewer.getElementGrayed(path));
- }
-
- if (!expandedElementsOnly || path.getSegmentCount() == 0 || viewer.getExpandedState(path) ) {
- TestElement[] children = element.getChildren();
-
- int viewerIndex = 0;
- for (int i = 0; i < children.length; i++) {
- if (TestModelUpdatesListener.isFiltered(children[i], filters)) {
- continue;
- }
- Assert.assertEquals(children[i], viewer.getChildElement(path, viewerIndex));
- validateData(viewer, path.createChildPath(children[i]), expandedElementsOnly, filters);
- viewerIndex++;
- }
- Assert.assertEquals(viewerIndex, viewer.getChildCount(path));
- } else if (!viewer.getExpandedState(path)) {
- // If element not expanded, verify the plus sign.
- Assert.assertTrue(viewer.getHasChildren(path) == element.getChildren().length > 0);
- }
- }
-
- public void setRoot(TestElement root) {
- fRoot = root;
- }
-
- public void postDelta(IModelDelta delta) {
- fModelProxy.fireModelChanged(delta);
- }
-
- /** Create or retrieve delta for given path
- * @param combine if then new deltas for the given path are created. If false existing ones are reused.
- */
- public ModelDelta getElementDelta(ModelDelta baseDelta, TreePath path, boolean combine) {
- TestElement element = getRootElement();
- ModelDelta delta = baseDelta;
-
- for (int i = 0; i < path.getSegmentCount(); i++) {
- TestElement[] children = element.getChildren();
- delta.setChildCount(children.length);
- Object segment = path.getSegment(i);
- int j;
- for (j = 0; j < children.length; j++) {
- if (segment.equals(children[j])) {
- element = children[j];
- ModelDelta nextDelta = null;
- if (combine) {
- nextDelta = delta.getChildDelta(element);
- }
- if (nextDelta == null) {
- nextDelta = delta.addNode(element, j, IModelDelta.NO_CHANGE, element.getChildren().length);
- }
- delta = nextDelta;
- break;
- }
- }
- if (j == children.length) {
- throw new IllegalArgumentException("Invalid path"); //$NON-NLS-1$
- }
- }
- return delta;
-
- }
-
- private TreePath getRelativePath(TreePath path) {
- Object[] segments = new Object[path.getSegmentCount() - fRootPath.getSegmentCount()];
- for (int i = fRootPath.getSegmentCount(), _i = 0; i < path.getSegmentCount(); i++, _i++) {
- segments[_i] = path.getSegment(i);
- }
- return new TreePath(segments);
- }
-
- public ModelDelta appendElementLabel(TreePath path, String labelAppendix) {
- org.junit.Assert.assertTrue(path.startsWith(fRootPath, null));
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(path);
- TestElement element = getElement(relativePath);
- ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
- element.setLabelAppendix(labelAppendix);
- delta.setFlags(delta.getFlags() | IModelDelta.STATE);
-
- return rootDelta;
- }
-
- public ModelDelta setElementChecked(TreePath path, boolean checked, boolean grayed) {
- Assert.assertTrue(path.startsWith(fRootPath, null));
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(path);
- TestElement element = getElement(relativePath);
- ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
- element.setChecked(checked, grayed);
- delta.setFlags(delta.getFlags() | IModelDelta.STATE);
-
- return rootDelta;
- }
-
- public ModelDelta setElementChildren(TreePath path, TestElement[] children) {
- Assert.assertTrue(path.startsWith(fRootPath, null));
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(path);
-
- // Find the parent element and generate the delta node for it.
- TestElement element = getElement(relativePath);
- ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
-
- // Set the new children array
- element.fChildren = children;
-
- // Add the delta flag and update the child count in the parent delta.
- delta.setFlags(delta.getFlags() | IModelDelta.CONTENT);
- delta.setChildCount(children.length);
-
- return rootDelta;
- }
-
- public ModelDelta replaceElementChild(TreePath parentPath, int index, TestElement child) {
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(parentPath);
-
- TestElement element = getElement(relativePath);
- ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
- TestElement oldChild = element.fChildren[index];
- element.fChildren[index] = child;
- delta.addNode(oldChild, child, IModelDelta.REPLACED);
- // TODO: set replacement index!?!
-
- return rootDelta;
- }
-
- public ModelDelta addElementChild(TreePath parentPath, ModelDelta rootDelta, int index, TestElement newChild) {
- if (rootDelta == null) {
- rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- }
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(parentPath);
-
- // Find the parent element and generate the delta node for it.
- TestElement element = getElement(relativePath);
- ModelDelta delta= getElementDelta(baseDelta, relativePath, true);
-
- // Add the new element
- element.fChildren = doInsertElementInArray(element.fChildren, index, newChild);
-
- // Add the delta flag and update the child count in the parent delta.
- delta.setChildCount(element.getChildren().length);
- delta.addNode(newChild, index, IModelDelta.ADDED);
-
- return rootDelta;
- }
-
- public ModelDelta insertElementChild(TreePath parentPath, int index, TestElement newChild) {
- return insertElementChild(null, parentPath, index, newChild);
- }
-
- public ModelDelta insertElementChild(ModelDelta rootDelta, TreePath parentPath, int index, TestElement newChild) {
- if (rootDelta == null) {
- rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- }
- ModelDelta baseDelta = getBaseDelta(rootDelta);
- TreePath relativePath = getRelativePath(parentPath);
-
- // Find the parent element and generate the delta node for it.
- TestElement element = getElement(relativePath);
- ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
-
- // Add the new element
- element.fChildren = doInsertElementInArray(element.fChildren, index, newChild);
-
- // Add the delta flag and update the child count in the parent delta.
- delta.setChildCount(element.getChildren().length);
- delta.addNode(newChild, index, IModelDelta.INSERTED);
-
- return rootDelta;
- }
-
- private TestElement[] doInsertElementInArray(TestElement[] children, int index, TestElement newChild) {
- // Create the new children array add the element to it and set it to
- // the parent.
- TestElement[] newChildren = new TestElement[children.length + 1];
- System.arraycopy(children, 0, newChildren, 0, index);
- newChildren[index] = newChild;
- System.arraycopy(children, index, newChildren, index + 1, children.length - index);
- return newChildren;
- }
-
- public ModelDelta removeElementChild(TreePath parentPath, int index) {
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
-
- // Find the parent element and generate the delta node for it.
- TestElement element = getElement(parentPath);
- ModelDelta delta= getElementDelta(baseDelta, parentPath, false);
-
- // Create a new child array with the element removed
- TestElement[] children = element.getChildren();
- TestElement childToRemove = children[index];
- TestElement[] newChildren = new TestElement[children.length - 1];
- System.arraycopy(children, 0, newChildren, 0, index);
- System.arraycopy(children, index + 1, newChildren, index, children.length - index - 1);
- element.fChildren = newChildren;
-
- // Add the delta flag and update the child count in the parent delta.
- delta.setChildCount(element.getChildren().length);
- delta.addNode(childToRemove, index, IModelDelta.REMOVED);
-
- return rootDelta;
- }
-
- public ModelDelta makeElementDelta(TreePath path, int flags) {
- ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
- ModelDelta baseDelta = getBaseDelta(rootDelta);
-
- // Find the element and generate the delta node for it.
- ModelDelta delta= getElementDelta(baseDelta, path, false);
-
- delta.setFlags(flags);
- return rootDelta;
- }
-
- public TreePath findElement(String label) {
- return findElement(TreePath.EMPTY, label);
- }
-
- public TreePath findElement(TreePath startPath, String label) {
- TestElement element = getElement(startPath);
- for (int i = 0; i < element.getChildren().length; i++) {
- TestElement child = element.getChildren()[i];
- TreePath path = startPath.createChildPath(child);
- if ( label.equals(child.getLabel()) ) {
- return path;
- } else {
- TreePath subPath = findElement(path, label);
- if (subPath != null) {
- return subPath;
- }
- }
- }
- return null;
- }
-
- @Override
+ fModelProxy = new ModelProxy();
+ fInput = input;
+ fRootPath = path;
+ return fModelProxy;
+ }
+
+ public IModelProxy getModelProxy() {
+ return fModelProxy;
+ }
+
+ public TestElement getElement(TreePath path) {
+ if (path.getSegmentCount() == 0) {
+ return getRootElement();
+ } else {
+ return (TestElement)path.getLastSegment();
+ }
+ }
+
+ public void setAllExpanded() {
+ doSetExpanded(fRoot);
+ }
+
+ private void doSetExpanded(TestElement element) {
+ element.fExpanded = true;
+ for (int i = 0; i < element.fChildren.length; i++) {
+ doSetExpanded(element.fChildren[i]);
+ }
+ }
+
+ public void setAllAppendix(String appendix) {
+ doSetAllAppendix(fRoot, appendix);
+ }
+
+ private void doSetAllAppendix(TestElement element, String appendix) {
+ element.setLabelAppendix(appendix);
+ for (int i = 0; i < element.fChildren.length; i++) {
+ doSetAllAppendix(element.fChildren[i], appendix);
+ }
+ }
+
+ public void validateData(ITreeModelViewer viewer, TreePath path) {
+ validateData(viewer, path, false);
+ }
+
+ public void validateData(ITreeModelViewer _viewer, TreePath path, boolean expandedElementsOnly) {
+ validateData(_viewer, path, expandedElementsOnly, TestModelUpdatesListener.EMPTY_FILTER_ARRAY);
+ }
+
+ public void validateData(ITreeModelViewer _viewer, TreePath path, boolean expandedElementsOnly, ViewerFilter[] filters) {
+ IInternalTreeModelViewer viewer = (IInternalTreeModelViewer)_viewer;
+ TestElement element = getElement(path);
+ if ( Boolean.TRUE.equals(_viewer.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)) ) {
+ Assert.assertTrue(element.getChecked() == viewer.getElementChecked(path));
+ Assert.assertTrue(element.getGrayed() == viewer.getElementGrayed(path));
+ }
+
+ if (!expandedElementsOnly || path.getSegmentCount() == 0 || viewer.getExpandedState(path) ) {
+ TestElement[] children = element.getChildren();
+
+ int viewerIndex = 0;
+ for (int i = 0; i < children.length; i++) {
+ if (TestModelUpdatesListener.isFiltered(children[i], filters)) {
+ continue;
+ }
+ Assert.assertEquals(children[i], viewer.getChildElement(path, viewerIndex));
+ validateData(viewer, path.createChildPath(children[i]), expandedElementsOnly, filters);
+ viewerIndex++;
+ }
+ Assert.assertEquals(viewerIndex, viewer.getChildCount(path));
+ } else if (!viewer.getExpandedState(path)) {
+ // If element not expanded, verify the plus sign.
+ Assert.assertTrue(viewer.getHasChildren(path) == element.getChildren().length > 0);
+ }
+ }
+
+ public void setRoot(TestElement root) {
+ fRoot = root;
+ }
+
+ public void postDelta(IModelDelta delta) {
+ fModelProxy.fireModelChanged(delta);
+ }
+
+ /** Create or retrieve delta for given path
+ * @param combine if then new deltas for the given path are created. If false existing ones are reused.
+ */
+ public ModelDelta getElementDelta(ModelDelta baseDelta, TreePath path, boolean combine) {
+ TestElement element = getRootElement();
+ ModelDelta delta = baseDelta;
+
+ for (int i = 0; i < path.getSegmentCount(); i++) {
+ TestElement[] children = element.getChildren();
+ delta.setChildCount(children.length);
+ Object segment = path.getSegment(i);
+ int j;
+ for (j = 0; j < children.length; j++) {
+ if (segment.equals(children[j])) {
+ element = children[j];
+ ModelDelta nextDelta = null;
+ if (combine) {
+ nextDelta = delta.getChildDelta(element);
+ }
+ if (nextDelta == null) {
+ nextDelta = delta.addNode(element, j, IModelDelta.NO_CHANGE, element.getChildren().length);
+ }
+ delta = nextDelta;
+ break;
+ }
+ }
+ if (j == children.length) {
+ throw new IllegalArgumentException("Invalid path"); //$NON-NLS-1$
+ }
+ }
+ return delta;
+
+ }
+
+ private TreePath getRelativePath(TreePath path) {
+ Object[] segments = new Object[path.getSegmentCount() - fRootPath.getSegmentCount()];
+ for (int i = fRootPath.getSegmentCount(), _i = 0; i < path.getSegmentCount(); i++, _i++) {
+ segments[_i] = path.getSegment(i);
+ }
+ return new TreePath(segments);
+ }
+
+ public ModelDelta appendElementLabel(TreePath path, String labelAppendix) {
+ org.junit.Assert.assertTrue(path.startsWith(fRootPath, null));
+ ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ ModelDelta baseDelta = getBaseDelta(rootDelta);
+ TreePath relativePath = getRelativePath(path);
+ TestElement element = getElement(relativePath);
+ ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
+ element.setLabelAppendix(labelAppendix);
+ delta.setFlags(delta.getFlags() | IModelDelta.STATE);
+
+ return rootDelta;
+ }
+
+ public ModelDelta setElementChecked(TreePath path, boolean checked, boolean grayed) {
+ Assert.assertTrue(path.startsWith(fRootPath, null));
+ ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ ModelDelta baseDelta = getBaseDelta(rootDelta);
+ TreePath relativePath = getRelativePath(path);
+ TestElement element = getElement(relativePath);
+ ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
+ element.setChecked(checked, grayed);
+ delta.setFlags(delta.getFlags() | IModelDelta.STATE);
+
+ return rootDelta;
+ }
+
+ public ModelDelta setElementChildren(TreePath path, TestElement[] children) {
+ Assert.assertTrue(path.startsWith(fRootPath, null));
+ ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ ModelDelta baseDelta = getBaseDelta(rootDelta);
+ TreePath relativePath = getRelativePath(path);
+
+ // Find the parent element and generate the delta node for it.
+ TestElement element = getElement(relativePath);
+ ModelDelta delta = getElementDelta(baseDelta, relativePath, false);
+
+ // Set the new children array
+ element.fChildren = children;
+
+ // Add the delta flag and update the child count in the parent delta.
+ delta.setFlags(delta.getFlags() | IModelDelta.CONTENT);
+ delta.setChildCount(children.length);
+
+ return rootDelta;
+ }
+
+ public ModelDelta replaceElementChild(TreePath parentPath, int index, TestElement child) {
+ ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ ModelDelta baseDelta = getBaseDelta(rootDelta);
+ TreePath relativePath = getRelativePath(parentPath);
+
+ TestElement element = getElement(relativePath);
+ ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
+ TestElement oldChild = element.fChildren[index];
+ element.fChildren[index] = child;
+ delta.addNode(oldChild, child, IModelDelta.REPLACED);
+ // TODO: set replacement index!?!
+
+ return rootDelta;
+ }
+
+ public ModelDelta addElementChild(TreePath parentPath, ModelDelta rootDelta, int index, TestElement newChild) {
+ if (rootDelta == null) {
+ rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ }
+ ModelDelta baseDelta = getBaseDelta(rootDelta);
+ TreePath relativePath = getRelativePath(parentPath);
+
+ // Find the parent element and generate the delta node for it.
+ TestElement element = getElement(relativePath);
+ ModelDelta delta= getElementDelta(baseDelta, relativePath, true);
+
+ // Add the new element
+ element.fChildren = doInsertElementInArray(element.fChildren, index, newChild);
+
+ // Add the delta flag and update the child count in the parent delta.
+ delta.setChildCount(element.getChildren().length);
+ delta.addNode(newChild, index, IModelDelta.ADDED);
+
+ return rootDelta;
+ }
+
+ public ModelDelta insertElementChild(TreePath parentPath, int index, TestElement newChild) {
+ return insertElementChild(null, parentPath, index, newChild);
+ }
+
+ public ModelDelta insertElementChild(ModelDelta rootDelta, TreePath parentPath, int index, TestElement newChild) {
+ if (rootDelta == null) {
+ rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ }
+ ModelDelta baseDelta = getBaseDelta(rootDelta);
+ TreePath relativePath = getRelativePath(parentPath);
+
+ // Find the parent element and generate the delta node for it.
+ TestElement element = getElement(relativePath);
+ ModelDelta delta= getElementDelta(baseDelta, relativePath, false);
+
+ // Add the new element
+ element.fChildren = doInsertElementInArray(element.fChildren, index, newChild);
+
+ // Add the delta flag and update the child count in the parent delta.
+ delta.setChildCount(element.getChildren().length);
+ delta.addNode(newChild, index, IModelDelta.INSERTED);
+
+ return rootDelta;
+ }
+
+ private TestElement[] doInsertElementInArray(TestElement[] children, int index, TestElement newChild) {
+ // Create the new children array add the element to it and set it to
+ // the parent.
+ TestElement[] newChildren = new TestElement[children.length + 1];
+ System.arraycopy(children, 0, newChildren, 0, index);
+ newChildren[index] = newChild;
+ System.arraycopy(children, index, newChildren, index + 1, children.length - index);
+ return newChildren;
+ }
+
+ public ModelDelta removeElementChild(TreePath parentPath, int index) {
+ ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ ModelDelta baseDelta = getBaseDelta(rootDelta);
+
+ // Find the parent element and generate the delta node for it.
+ TestElement element = getElement(parentPath);
+ ModelDelta delta= getElementDelta(baseDelta, parentPath, false);
+
+ // Create a new child array with the element removed
+ TestElement[] children = element.getChildren();
+ TestElement childToRemove = children[index];
+ TestElement[] newChildren = new TestElement[children.length - 1];
+ System.arraycopy(children, 0, newChildren, 0, index);
+ System.arraycopy(children, index + 1, newChildren, index, children.length - index - 1);
+ element.fChildren = newChildren;
+
+ // Add the delta flag and update the child count in the parent delta.
+ delta.setChildCount(element.getChildren().length);
+ delta.addNode(childToRemove, index, IModelDelta.REMOVED);
+
+ return rootDelta;
+ }
+
+ public ModelDelta makeElementDelta(TreePath path, int flags) {
+ ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
+ ModelDelta baseDelta = getBaseDelta(rootDelta);
+
+ // Find the element and generate the delta node for it.
+ ModelDelta delta= getElementDelta(baseDelta, path, false);
+
+ delta.setFlags(flags);
+ return rootDelta;
+ }
+
+ public TreePath findElement(String label) {
+ return findElement(TreePath.EMPTY, label);
+ }
+
+ public TreePath findElement(TreePath startPath, String label) {
+ TestElement element = getElement(startPath);
+ for (int i = 0; i < element.getChildren().length; i++) {
+ TestElement child = element.getChildren()[i];
+ TreePath path = startPath.createChildPath(child);
+ if ( label.equals(child.getLabel()) ) {
+ return path;
+ } else {
+ TreePath subPath = findElement(path, label);
+ if (subPath != null) {
+ return subPath;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
public String toString() {
- return getElementString(fRoot, ""); //$NON-NLS-1$
- }
-
- public String getElementString(TestElement element, String indent) {
- StringBuilder builder = new StringBuilder();
- builder.append(indent);
- builder.append(element.toString());
- builder.append('\n');
- TestElement[] children = element.getChildren();
- for (int i = 0; i < children.length; i++) {
- builder.append(getElementString(children[i], indent + " ")); //$NON-NLS-1$
- }
- return builder.toString();
- }
-
- public static TestModel simpleSingleLevel() {
- TestModel model = new TestModel();
- model.setRoot( new TestElement(model, "root", makeSingleLevelModelElements(model, 6, ""))); //$NON-NLS-1$ //$NON-NLS-2$
- return model;
- }
-
- public static TestElement[] makeSingleLevelModelElements(TestModel model, int length, String prefix) {
- TestElement[] elements = new TestElement[length];
- for (int i = 1; i <= length; i++) {
- String name = prefix + i;
- elements[i - 1] = new TestElement(model, name, new TestElement[0]);
- }
- return elements;
- }
-
- public static TestElement[] makeMultiLevelElements(TestModel model, int depth, String prefix) {
- TestElement[] elements = new TestElement[depth];
- for (int i = 0; i < depth; i++) {
- String name = prefix + i;
- elements[i] = new TestElement(model, name, makeMultiLevelElements(model, i, name + ".")); //$NON-NLS-1$
- }
- return elements;
- }
-
- public static TestElement[] makeMultiLevelElements2(TestModel model, int[] levelCounts, String prefix) {
- if (levelCounts.length == 0) {
+ return getElementString(fRoot, ""); //$NON-NLS-1$
+ }
+
+ public String getElementString(TestElement element, String indent) {
+ StringBuilder builder = new StringBuilder();
+ builder.append(indent);
+ builder.append(element.toString());
+ builder.append('\n');
+ TestElement[] children = element.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ builder.append(getElementString(children[i], indent + " ")); //$NON-NLS-1$
+ }
+ return builder.toString();
+ }
+
+ public static TestModel simpleSingleLevel() {
+ TestModel model = new TestModel();
+ model.setRoot( new TestElement(model, "root", makeSingleLevelModelElements(model, 6, ""))); //$NON-NLS-1$ //$NON-NLS-2$
+ return model;
+ }
+
+ public static TestElement[] makeSingleLevelModelElements(TestModel model, int length, String prefix) {
+ TestElement[] elements = new TestElement[length];
+ for (int i = 1; i <= length; i++) {
+ String name = prefix + i;
+ elements[i - 1] = new TestElement(model, name, new TestElement[0]);
+ }
+ return elements;
+ }
+
+ public static TestElement[] makeMultiLevelElements(TestModel model, int depth, String prefix) {
+ TestElement[] elements = new TestElement[depth];
+ for (int i = 0; i < depth; i++) {
+ String name = prefix + i;
+ elements[i] = new TestElement(model, name, makeMultiLevelElements(model, i, name + ".")); //$NON-NLS-1$
+ }
+ return elements;
+ }
+
+ public static TestElement[] makeMultiLevelElements2(TestModel model, int[] levelCounts, String prefix) {
+ if (levelCounts.length == 0) {
return new TestElement[0];
}
- int count = levelCounts[0];
- int[] oldLevelCounts = levelCounts;
- levelCounts = new int[levelCounts.length - 1];
- System.arraycopy(oldLevelCounts, 1, levelCounts, 0, levelCounts.length);
- TestElement[] elements = new TestElement[count];
- for (int i = 0; i < count; i++) {
- String name = prefix + i;
- elements[i] = new TestElement(model, name, makeMultiLevelElements2(model, levelCounts, name + ".")); //$NON-NLS-1$
- }
- return elements;
- }
-
- public static TestModel simpleMultiLevel() {
- TestModel model = new TestModel();
- model.setRoot( new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "2", true, false, new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "2.1", true, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "2.2", false, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "2.3", true, false, new TestElement[0]), //$NON-NLS-1$
- }),
- new TestElement(model, "3", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.1", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.1.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.1.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.1.3", new TestElement[0]), //$NON-NLS-1$
- }),
- new TestElement(model, "3.2", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.2.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.2.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.2.3", new TestElement[0]), //$NON-NLS-1$
- }),
- new TestElement(model, "3.3", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.3.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.3.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.3.3", new TestElement[0]), //$NON-NLS-1$
- }),
- })
- }) );
- return model;
- }
-
- public static TestModel compositeMultiLevel() {
- TestModel m2 = new TestModel();
- m2.setRoot( new TestElement(m2, "m2.root", new TestElement[] { //$NON-NLS-1$
- new TestElement(m2, "m2.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(m2, "m2.2", true, false, new TestElement[] { //$NON-NLS-1$
- new TestElement(m2, "m2.2.1", true, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(m2, "m2.2.2", false, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(m2, "m2.2.3", true, false, new TestElement[0]), //$NON-NLS-1$
- }),
- }) );
-
- TestModel m3 = new TestModel();
- m3.setRoot( new TestElement(m3, "m3.root", new TestElement[] { //$NON-NLS-1$
- new TestElement(m3, "m3.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(m3, "m3.2", true, false, new TestElement[] { //$NON-NLS-1$
- new TestElement(m3, "m3.2.1", true, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(m3, "m3.2.2", false, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(m3, "m3.2.3", true, false, new TestElement[0]), //$NON-NLS-1$
- }),
- }) );
-
- TestModel m4 = new TestModel();
- m4.setRoot( new TestElement(m4, "m4.root", new TestElement[] { //$NON-NLS-1$
- new TestElement(m4, "m4.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(m4, "m4.2", true, false, new TestElement[] { //$NON-NLS-1$
- new TestElement(m4, "m4.2.1", true, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(m4, "m4.2.2", false, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(m4, "m4.2.3", true, false, new TestElement[0]), //$NON-NLS-1$
- }),
- }) );
-
- TestModel m1 = new TestModel();
- m1.setRoot( new TestElement(m1, "m1.root", new TestElement[] { //$NON-NLS-1$
- new TestElement(m1, "m1.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(m1, "m1.2", true, false, new TestElement[] { //$NON-NLS-1$
- m2.fRoot,
- m3.fRoot,
- m4.fRoot,
- }),
- }) );
-
-
- return m1;
- }
-
- public static TestModel simpleDeepMultiLevel() {
- TestModel model = new TestModel();
- model.setRoot( new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "2", true, false, new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "2.1", true, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "2.2", false, true, new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "2.3", true, false, new TestElement[0]), //$NON-NLS-1$
- }),
- new TestElement(model, "3", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.1", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.1.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.1.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.1.3", new TestElement[0]), //$NON-NLS-1$
- }),
- new TestElement(model, "3.2", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.2.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.2.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.2.3", new TestElement[0]), //$NON-NLS-1$
- }),
- new TestElement(model, "3.3", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.3.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.3.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.3.3", new TestElement[0]), //$NON-NLS-1$
- }),
- new TestElement(model, "3.4", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.4.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.4.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.4.3", new TestElement[0]), //$NON-NLS-1$
- }),
- new TestElement(model, "3.5", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.5.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.5.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.5.3", new TestElement[0]), //$NON-NLS-1$
- }),
- new TestElement(model, "3.6", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.6.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.6.3.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.4", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.5", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.6", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.7", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.8", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.9", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.10", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.11", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.12", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.13", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.14", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.15", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.4", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.5", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.6", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.7", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.8", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.9", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.10", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.11", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.12", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.13", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.14", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.15", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.4", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.5", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.6", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.7", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.8", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.9", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.10", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.11", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.12", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.13", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.14", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.15", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.4", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.5", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.6", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.7", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.8", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.9", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.10", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.11", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.12", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.13", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.14", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.15", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.4", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.5", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.6", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.7", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.8", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.9", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.10", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.11", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.12", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.13", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.14", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.15", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16", new TestElement[] { //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.1", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.2", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.4", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.5", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.6", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.7", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.8", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.9", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.10", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.11", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.12", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.13", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.14", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.15", new TestElement[0]), //$NON-NLS-1$
- new TestElement(model, "3.6.3.16.16.16.16.16.16", new TestElement[0]), //$NON-NLS-1$
- }),
- }),
- }),
- }),
- }),
- }),
- }),
- })
- }) );
- return model;
- }
+ int count = levelCounts[0];
+ int[] oldLevelCounts = levelCounts;
+ levelCounts = new int[levelCounts.length - 1];
+ System.arraycopy(oldLevelCounts, 1, levelCounts, 0, levelCounts.length);
+ TestElement[] elements = new TestElement[count];
+ for (int i = 0; i < count; i++) {
+ String name = prefix + i;
+ elements[i] = new TestElement(model, name, makeMultiLevelElements2(model, levelCounts, name + ".")); //$NON-NLS-1$
+ }
+ return elements;
+ }
+
+ public static TestModel simpleMultiLevel() {
+ TestModel model = new TestModel();
+ model.setRoot( new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "2", true, false, new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "2.1", true, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "2.2", false, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "2.3", true, false, new TestElement[0]), //$NON-NLS-1$
+ }),
+ new TestElement(model, "3", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.1", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.1.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.1.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.1.3", new TestElement[0]), //$NON-NLS-1$
+ }),
+ new TestElement(model, "3.2", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.2.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.2.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.2.3", new TestElement[0]), //$NON-NLS-1$
+ }),
+ new TestElement(model, "3.3", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.3.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.3.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.3.3", new TestElement[0]), //$NON-NLS-1$
+ }),
+ })
+ }) );
+ return model;
+ }
+
+ public static TestModel compositeMultiLevel() {
+ TestModel m2 = new TestModel();
+ m2.setRoot( new TestElement(m2, "m2.root", new TestElement[] { //$NON-NLS-1$
+ new TestElement(m2, "m2.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m2, "m2.2", true, false, new TestElement[] { //$NON-NLS-1$
+ new TestElement(m2, "m2.2.1", true, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m2, "m2.2.2", false, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m2, "m2.2.3", true, false, new TestElement[0]), //$NON-NLS-1$
+ }),
+ }) );
+
+ TestModel m3 = new TestModel();
+ m3.setRoot( new TestElement(m3, "m3.root", new TestElement[] { //$NON-NLS-1$
+ new TestElement(m3, "m3.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m3, "m3.2", true, false, new TestElement[] { //$NON-NLS-1$
+ new TestElement(m3, "m3.2.1", true, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m3, "m3.2.2", false, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m3, "m3.2.3", true, false, new TestElement[0]), //$NON-NLS-1$
+ }),
+ }) );
+
+ TestModel m4 = new TestModel();
+ m4.setRoot( new TestElement(m4, "m4.root", new TestElement[] { //$NON-NLS-1$
+ new TestElement(m4, "m4.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m4, "m4.2", true, false, new TestElement[] { //$NON-NLS-1$
+ new TestElement(m4, "m4.2.1", true, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m4, "m4.2.2", false, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m4, "m4.2.3", true, false, new TestElement[0]), //$NON-NLS-1$
+ }),
+ }) );
+
+ TestModel m1 = new TestModel();
+ m1.setRoot( new TestElement(m1, "m1.root", new TestElement[] { //$NON-NLS-1$
+ new TestElement(m1, "m1.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(m1, "m1.2", true, false, new TestElement[] { //$NON-NLS-1$
+ m2.fRoot,
+ m3.fRoot,
+ m4.fRoot,
+ }),
+ }) );
+
+
+ return m1;
+ }
+
+ public static TestModel simpleDeepMultiLevel() {
+ TestModel model = new TestModel();
+ model.setRoot( new TestElement(model, "root", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "2", true, false, new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "2.1", true, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "2.2", false, true, new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "2.3", true, false, new TestElement[0]), //$NON-NLS-1$
+ }),
+ new TestElement(model, "3", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.1", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.1.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.1.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.1.3", new TestElement[0]), //$NON-NLS-1$
+ }),
+ new TestElement(model, "3.2", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.2.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.2.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.2.3", new TestElement[0]), //$NON-NLS-1$
+ }),
+ new TestElement(model, "3.3", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.3.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.3.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.3.3", new TestElement[0]), //$NON-NLS-1$
+ }),
+ new TestElement(model, "3.4", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.4.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.4.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.4.3", new TestElement[0]), //$NON-NLS-1$
+ }),
+ new TestElement(model, "3.5", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.5.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.5.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.5.3", new TestElement[0]), //$NON-NLS-1$
+ }),
+ new TestElement(model, "3.6", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.6.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.6.3.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.4", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.5", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.6", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.7", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.8", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.9", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.10", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.11", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.12", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.13", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.14", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.15", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.4", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.5", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.6", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.7", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.8", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.9", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.10", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.11", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.12", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.13", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.14", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.15", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.4", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.5", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.6", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.7", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.8", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.9", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.10", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.11", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.12", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.13", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.14", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.15", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.4", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.5", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.6", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.7", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.8", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.9", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.10", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.11", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.12", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.13", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.14", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.15", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.4", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.5", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.6", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.7", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.8", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.9", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.10", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.11", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.12", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.13", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.14", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.15", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16", new TestElement[] { //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.1", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.2", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.4", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.5", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.6", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.7", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.8", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.9", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.10", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.11", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.12", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.13", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.14", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.15", new TestElement[0]), //$NON-NLS-1$
+ new TestElement(model, "3.6.3.16.16.16.16.16.16", new TestElement[0]), //$NON-NLS-1$
+ }),
+ }),
+ }),
+ }),
+ }),
+ }),
+ }),
+ })
+ }) );
+ return model;
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java
index 2798ee6cf..33b262caf 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreeModelViewerAutopopulateAgent.java
@@ -29,76 +29,76 @@ import org.eclipse.swt.widgets.Widget;
public class TreeModelViewerAutopopulateAgent implements IViewerUpdateListener {
- private TreeModelViewer fViewer;
+ private TreeModelViewer fViewer;
- public TreeModelViewerAutopopulateAgent(TreeModelViewer viewer) {
- fViewer = viewer;
- fViewer.addViewerUpdateListener(this);
- }
+ public TreeModelViewerAutopopulateAgent(TreeModelViewer viewer) {
+ fViewer = viewer;
+ fViewer.addViewerUpdateListener(this);
+ }
- public void dispose() {
- fViewer.removeViewerUpdateListener(this);
- fViewer = null;
- }
+ public void dispose() {
+ fViewer.removeViewerUpdateListener(this);
+ fViewer = null;
+ }
- @Override
+ @Override
public void updateComplete(IViewerUpdate update) {
- if (update instanceof IChildrenCountUpdate) {
- TreePath path = update.getElementPath();
- ILazyTreePathContentProvider contentProvider = (ILazyTreePathContentProvider) fViewer.getContentProvider();
-
- Widget[] items = fViewer.testFindItems(update.getElement());
- for (int i = 0; i < items.length; i++) {
- if ( path.equals(getTreePath(items[i])) ) {
- int itemCount = getItemChildCount(items[i]);
- for (int j = 0; j < itemCount; j++) {
- contentProvider.updateElement(path, j);
- }
- }
- }
- }
- }
-
- @Override
+ if (update instanceof IChildrenCountUpdate) {
+ TreePath path = update.getElementPath();
+ ILazyTreePathContentProvider contentProvider = (ILazyTreePathContentProvider) fViewer.getContentProvider();
+
+ Widget[] items = fViewer.testFindItems(update.getElement());
+ for (int i = 0; i < items.length; i++) {
+ if ( path.equals(getTreePath(items[i])) ) {
+ int itemCount = getItemChildCount(items[i]);
+ for (int j = 0; j < itemCount; j++) {
+ contentProvider.updateElement(path, j);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
public void updateStarted(IViewerUpdate update) {
- // TODO Auto-generated method stub
+ // TODO Auto-generated method stub
- }
+ }
- @Override
+ @Override
public void viewerUpdatesBegin() {
- // TODO Auto-generated method stub
+ // TODO Auto-generated method stub
- }
+ }
- @Override
+ @Override
public void viewerUpdatesComplete() {
- // TODO Auto-generated method stub
+ // TODO Auto-generated method stub
- }
+ }
- private TreePath getTreePath(Widget w) {
- if (w instanceof TreeItem) {
- TreeItem item = (TreeItem)w;
+ private TreePath getTreePath(Widget w) {
+ if (w instanceof TreeItem) {
+ TreeItem item = (TreeItem)w;
LinkedList<Object> segments = new LinkedList<>();
- while (item != null) {
- Object segment = item.getData();
- Assert.isNotNull(segment);
- segments.addFirst(segment);
- item = item.getParentItem();
- }
- return new TreePath(segments.toArray());
- }
- return TreePath.EMPTY;
- }
-
- private int getItemChildCount(Widget w) {
- if (w instanceof Tree) {
- return ((Tree)w).getItemCount();
- } else if (w instanceof TreeItem) {
- return ((TreeItem)w).getItemCount();
- }
- return 0;
- }
+ while (item != null) {
+ Object segment = item.getData();
+ Assert.isNotNull(segment);
+ segments.addFirst(segment);
+ item = item.getParentItem();
+ }
+ return new TreePath(segments.toArray());
+ }
+ return TreePath.EMPTY;
+ }
+
+ private int getItemChildCount(Widget w) {
+ if (w instanceof Tree) {
+ return ((Tree)w).getItemCount();
+ } else if (w instanceof TreeItem) {
+ return ((TreeItem)w).getItemCount();
+ }
+ return 0;
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreePathWrapper.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreePathWrapper.java
index b68c73280..306f020b8 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreePathWrapper.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/TreePathWrapper.java
@@ -24,48 +24,48 @@ import org.junit.Assert;
* @since 3.7
*/
public class TreePathWrapper {
- private final TreePath fPath;
+ private final TreePath fPath;
- public TreePathWrapper(TreePath path) {
- fPath = path;
- }
+ public TreePathWrapper(TreePath path) {
+ fPath = path;
+ }
- @Override
+ @Override
public int hashCode() {
- return fPath.hashCode();
- }
+ return fPath.hashCode();
+ }
- @Override
+ @Override
public boolean equals(Object obj) {
- return obj instanceof TreePathWrapper &&
- fPath.equals( ((TreePathWrapper)obj).fPath );
- }
+ return obj instanceof TreePathWrapper &&
+ fPath.equals( ((TreePathWrapper)obj).fPath );
+ }
- @Override
+ @Override
public String toString() {
- if (fPath.getSegmentCount() == 0) {
- return "TreePath:EMPTY"; //$NON-NLS-1$
- }
+ if (fPath.getSegmentCount() == 0) {
+ return "TreePath:EMPTY"; //$NON-NLS-1$
+ }
- StringBuilder buf = new StringBuilder("TreePath:["); //$NON-NLS-1$
+ StringBuilder buf = new StringBuilder("TreePath:["); //$NON-NLS-1$
- for (int i = 0; i < fPath.getSegmentCount(); i++) {
- if (i != 0) {
- buf.append(", "); //$NON-NLS-1$
- }
- buf.append(fPath.getSegment(i));
- }
- buf.append(']');
- return buf.toString();
- }
+ for (int i = 0; i < fPath.getSegmentCount(); i++) {
+ if (i != 0) {
+ buf.append(", "); //$NON-NLS-1$
+ }
+ buf.append(fPath.getSegment(i));
+ }
+ buf.append(']');
+ return buf.toString();
+ }
- /**
- * Asserts that the two given tree paths are the same. In case of failure, the
- * generated exception will contain a printout of the tree paths' contents.
- */
- public static void assertEqual(TreePath expected, TreePath actual) {
- Assert.assertEquals(
- expected != null ? new TreePathWrapper(expected) : null,
- actual != null ? new TreePathWrapper(actual) : null);
- }
+ /**
+ * Asserts that the two given tree paths are the same. In case of failure, the
+ * generated exception will contain a printout of the tree paths' contents.
+ */
+ public static void assertEqual(TreePath expected, TreePath actual) {
+ Assert.assertEquals(
+ expected != null ? new TreePathWrapper(expected) : null,
+ actual != null ? new TreePathWrapper(actual) : null);
+ }
} \ No newline at end of file
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/UpdateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/UpdateTests.java
index b51907bc2..bba5dec82 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/UpdateTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/UpdateTests.java
@@ -39,235 +39,235 @@ import org.junit.Assert;
*/
abstract public class UpdateTests extends AbstractViewerModelTest implements ITestModelUpdatesListenerConstants {
- public UpdateTests(String name) {
- super(name);
- }
+ public UpdateTests(String name) {
+ super(name);
+ }
@Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
return new TestModelUpdatesListener(viewer, false, false);
}
- /**
- * This test:
- * - creates a simple model
- * - replaces the list of elements with a shorter list of elements
- * - refreshes the viewer
- */
+ /**
+ * This test:
+ * - creates a simple model
+ * - replaces the list of elements with a shorter list of elements
+ * - refreshes the viewer
+ */
public void testRemoveElements() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- TestElement root = model.getRootElement();
- TreePath rootPath = new TreePath(new Object[] {});
- TestElement[] newElements = new TestElement[] {
+ // Update the model
+ TestElement root = model.getRootElement();
+ TreePath rootPath = new TreePath(new Object[] {});
+ TestElement[] newElements = new TestElement[] {
new TestElement(model, "1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "2", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "3", new TestElement[0]), //$NON-NLS-1$
- };
- model.setElementChildren(rootPath, newElements);
+ };
+ model.setElementChildren(rootPath, newElements);
- // Reset the listener to NOT fail on redundant updates.
- // When elements are remvoed from the model and the model is
- // refreshed the viewer will issue an IChildrenUpdate for the
- // missing elements as an optimization.
- fListener.reset(rootPath, root, -1, false, false);
+ // Reset the listener to NOT fail on redundant updates.
+ // When elements are remvoed from the model and the model is
+ // refreshed the viewer will issue an IChildrenUpdate for the
+ // missing elements as an optimization.
+ fListener.reset(rootPath, root, -1, false, false);
- model.postDelta(new ModelDelta(root, IModelDelta.CONTENT));
+ model.postDelta(new ModelDelta(root, IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- /**
- * This test:
- * - creates a simple model
- * - sets a list of children to one of the elements
- * - refreshes the viewer
- */
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
+
+ /**
+ * This test:
+ * - creates a simple model
+ * - sets a list of children to one of the elements
+ * - refreshes the viewer
+ */
public void testAddNewChildren() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- TestElement element = model.getRootElement().getChildren()[0];
- TreePath elementPath = new TreePath(new Object[] { element });
- TestElement[] newChildren = new TestElement[] {
+ // Update the model
+ TestElement element = model.getRootElement().getChildren()[0];
+ TreePath elementPath = new TreePath(new Object[] { element });
+ TestElement[] newChildren = new TestElement[] {
new TestElement(model, "1.1", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "1.2", new TestElement[0]), //$NON-NLS-1$
new TestElement(model, "1.3", new TestElement[0]), //$NON-NLS-1$
- };
- model.setElementChildren(elementPath, newChildren);
-
- // Reset the viewer to ignore redundant updates. The '1' element
- // will be updated for "hasChildren" before it is expanded, which is
- // expected.
- TreePath rootPath = TreePath.EMPTY;
- TestElement rootElement = model.getRootElement();
- fListener.reset(rootPath, rootElement, -1, false, false);
-
- // Refresh the viewer
- model.postDelta(new ModelDelta(rootElement, IModelDelta.CONTENT));
+ };
+ model.setElementChildren(elementPath, newChildren);
+
+ // Reset the viewer to ignore redundant updates. The '1' element
+ // will be updated for "hasChildren" before it is expanded, which is
+ // expected.
+ TreePath rootPath = TreePath.EMPTY;
+ TestElement rootElement = model.getRootElement();
+ fListener.reset(rootPath, rootElement, -1, false, false);
+
+ // Refresh the viewer
+ model.postDelta(new ModelDelta(rootElement, IModelDelta.CONTENT));
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
private void removeElement(TestModel model, int index, boolean validate) throws Exception {
- ModelDelta delta = model.removeElementChild(TreePath.EMPTY, index);
+ ModelDelta delta = model.removeElementChild(TreePath.EMPTY, index);
- // Remove delta should generate no new updates, but we still need to wait for the event to
- // be processed.
- fListener.reset();
- model.postDelta(delta);
+ // Remove delta should generate no new updates, but we still need to wait for the event to
+ // be processed.
+ fListener.reset();
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- if (validate) {
- model.validateData(fViewer, TreePath.EMPTY);
- }
- }
+ if (validate) {
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
+ }
private void addElement(TestModel model, String label, int position, boolean validate) throws Exception {
- ModelDelta delta = model.addElementChild(TreePath.EMPTY, null, position, new TestElement(model, label, new TestElement[0]));
+ ModelDelta delta = model.addElementChild(TreePath.EMPTY, null, position, new TestElement(model, label, new TestElement[0]));
- // Remove delta should generate no new updates, but we still need to wait for the event to
- // be processed.
- fListener.reset();
- model.postDelta(delta);
+ // Remove delta should generate no new updates, but we still need to wait for the event to
+ // be processed.
+ fListener.reset();
+ model.postDelta(delta);
- if (validate) {
+ if (validate) {
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- } else {
+ model.validateData(fViewer, TreePath.EMPTY);
+ } else {
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- }
- }
+ }
+ }
private void insertElement(TestModel model, String label, int position, boolean validate) throws Exception {
- ModelDelta delta = model.insertElementChild(TreePath.EMPTY, position, new TestElement(model, label, new TestElement[0]));
+ ModelDelta delta = model.insertElementChild(TreePath.EMPTY, position, new TestElement(model, label, new TestElement[0]));
- // Remove delta should generate no new updates, but we still need to wait for the event to
- // be processed.
- fListener.reset();
- model.postDelta(delta);
+ // Remove delta should generate no new updates, but we still need to wait for the event to
+ // be processed.
+ fListener.reset();
+ model.postDelta(delta);
- if (validate) {
+ if (validate) {
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- } else {
+ model.validateData(fViewer, TreePath.EMPTY);
+ } else {
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- }
- }
+ }
+ }
public void testRepeatedAddRemoveElement() throws Exception {
- //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Update the model
- removeElement(model, 2, true);
+ // Update the model
+ removeElement(model, 2, true);
addElement(model, "3-new", 3, true); //$NON-NLS-1$
- removeElement(model, 4, true);
+ removeElement(model, 4, true);
addElement(model, "5-new", 5, true); //$NON-NLS-1$
- removeElement(model, 1, true);
+ removeElement(model, 1, true);
addElement(model, "1-new", 1, true); //$NON-NLS-1$
- removeElement(model, 3, true);
+ removeElement(model, 3, true);
addElement(model, "4-new", 4, true); //$NON-NLS-1$
- }
+ }
- /**
- * This test verifies that when the viewer processes a delta that causes viewer
- * updates it initiates the model update sequence before it finishes processing
- * the delta.
- */
+ /**
+ * This test verifies that when the viewer processes a delta that causes viewer
+ * updates it initiates the model update sequence before it finishes processing
+ * the delta.
+ */
public void testNotifyUpdatesTartedOnModelChanged() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Refresh the viewer so that updates are generated.
- fListener.reset();
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Refresh the viewer so that updates are generated.
+ fListener.reset();
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- // Wait for the delta to be processed.
+ // Wait for the delta to be processed.
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- Assert.assertTrue( fListener.isFinished(CONTENT_SEQUENCE_STARTED) );
- }
+ Assert.assertTrue( fListener.isFinished(CONTENT_SEQUENCE_STARTED) );
+ }
- /**
- * This test case attempts to create a race condition between processing
- * of the content updates and processing of add/remove model deltas.
- * <br>
- * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a>
- */
+ /**
+ * This test case attempts to create a race condition between processing
+ * of the content updates and processing of add/remove model deltas.
+ * <br>
+ * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a>
+ */
public void testContentPlusAddRemoveUpdateRaceConditionsElement() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Create a listener to listen only to a children count update for the root.
- TestModelUpdatesListener childrenCountUpdateListener = new TestModelUpdatesListener(fViewer, false, false);
+ // Create a listener to listen only to a children count update for the root.
+ TestModelUpdatesListener childrenCountUpdateListener = new TestModelUpdatesListener(fViewer, false, false);
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 10; i++) {
String pass = "pass #" + i; //$NON-NLS-1$
- // Request a content update for view
- childrenCountUpdateListener.reset();
- childrenCountUpdateListener.addChildreCountUpdate(TreePath.EMPTY);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- // Wait until the delta is processed
+ // Request a content update for view
+ childrenCountUpdateListener.reset();
+ childrenCountUpdateListener.addChildreCountUpdate(TreePath.EMPTY);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Wait until the delta is processed
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- removeElement(model, 5, false);
- removeElement(model, 4, false);
- removeElement(model, 3, false);
- removeElement(model, 2, false);
- removeElement(model, 1, false);
- removeElement(model, 0, false);
+ removeElement(model, 5, false);
+ removeElement(model, 4, false);
+ removeElement(model, 3, false);
+ removeElement(model, 2, false);
+ removeElement(model, 1, false);
+ removeElement(model, 0, false);
- // Wait until the children count update is completed using the count from
- // before elements were removed.
+ // Wait until the children count update is completed using the count from
+ // before elements were removed.
waitWhile(t -> !childrenCountUpdateListener.isFinished(CHILD_COUNT_UPDATES), createListenerErrorMessage());
insertElement(model, "1 - " + pass, 0, false); //$NON-NLS-1$
@@ -278,37 +278,37 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe
insertElement(model, "6 - " + pass, 5, false); //$NON-NLS-1$
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- }
+ }
- childrenCountUpdateListener.dispose();
- }
+ childrenCountUpdateListener.dispose();
+ }
- /**
- * This test case attempts to create a race condition between processing
- * of the content updates and processing of add/remove model deltas.
- * <br>
- * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a>
- */
+ /**
+ * This test case attempts to create a race condition between processing
+ * of the content updates and processing of add/remove model deltas.
+ * <br>
+ * See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=304066">bug 304066</a>
+ */
public void testInsertAtInvalidIndex() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Insert element at the end of the list.
- final int insertIndex = model.getRootElement().getChildren().length;
+ // Insert element at the end of the list.
+ final int insertIndex = model.getRootElement().getChildren().length;
ModelDelta delta = model.insertElementChild(TreePath.EMPTY, insertIndex, new TestElement(model, "last - invalid index", new TestElement[0])); //$NON-NLS-1$
- // Change insert index to out of range
- delta.accept(new IModelDeltaVisitor() {
+ // Change insert index to out of range
+ delta.accept(new IModelDeltaVisitor() {
@Override
public boolean visit(IModelDelta visitorDelta, int depth) {
@@ -320,341 +320,341 @@ abstract public class UpdateTests extends AbstractViewerModelTest implements ITe
}
});
- // Remove delta should generate no new updates, but we still need to wait for the event to
- // be processed.
- fListener.reset();
- model.postDelta(delta);
+ // Remove delta should generate no new updates, but we still need to wait for the event to
+ // be processed.
+ fListener.reset();
+ model.postDelta(delta);
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_SEQUENCE_COMPLETE | LABEL_SEQUENCE_COMPLETE), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
- }
-
- /**
- * This test forces the viewer to reschedule pending content updates
- * due to a remove event from the model.
- * @see org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider#rescheduleUpdates
- */
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
+
+ /**
+ * This test forces the viewer to reschedule pending content updates
+ * due to a remove event from the model.
+ * @see org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider#rescheduleUpdates
+ */
public void testRescheduleUpdates() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- for (int i = 0; i < 5; i++) {
- // Refresh the viewer so that updates are generated.
- TestElement rootElement = model.getRootElement();
- fListener.reset();
- fListener.addUpdates(TreePath.EMPTY, model.getRootElement(), 1, CHILD_COUNT_UPDATES);
- model.postDelta(new ModelDelta(rootElement, IModelDelta.CONTENT));
+ for (int i = 0; i < 5; i++) {
+ // Refresh the viewer so that updates are generated.
+ TestElement rootElement = model.getRootElement();
+ fListener.reset();
+ fListener.addUpdates(TreePath.EMPTY, model.getRootElement(), 1, CHILD_COUNT_UPDATES);
+ model.postDelta(new ModelDelta(rootElement, IModelDelta.CONTENT));
- // Wait for the delta to be processed.
+ // Wait for the delta to be processed.
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES | CHILDREN_UPDATES_STARTED), createListenerErrorMessage());
- // Update the model
- removeElement(model, 0, true);
+ // Update the model
+ removeElement(model, 0, true);
addElement(model, "1", 0, true); //$NON-NLS-1$
- }
- }
-
- /**
- * This test forces the viewer to cancel updates then process them at once.
- * <p>
- * - Wait until CHILDREN COUNT update started then refresh<br>
- * - Process queued updates in order.<br>
- * </p>
- */
+ }
+ }
+
+ /**
+ * This test forces the viewer to cancel updates then process them at once.
+ * <p>
+ * - Wait until CHILDREN COUNT update started then refresh<br>
+ * - Process queued updates in order.<br>
+ * </p>
+ */
public void testCanceledUpdates1() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- model.setQeueueingUpdate(true);
+ model.setQeueueingUpdate(true);
- for (int i = 0; i < 5; i++) {
- // Refresh the viewer so that updates are generated.
- fListener.reset();
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ for (int i = 0; i < 5; i++) {
+ // Refresh the viewer so that updates are generated.
+ fListener.reset();
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- // Wait for the delta to be processed.
+ // Wait for the delta to be processed.
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES_STARTED), createListenerErrorMessage());
- }
+ }
- model.setQeueueingUpdate(false);
+ model.setQeueueingUpdate(false);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- }
+ }
- /**
- * This test forces the viewer to cancel updates then process them at once.
- * <p>
- * - Wait until CHILDREN COUNT update started then refresh<br>
- * - Process queued updates in REVERSE order.<br>
- * </p>
- */
+ /**
+ * This test forces the viewer to cancel updates then process them at once.
+ * <p>
+ * - Wait until CHILDREN COUNT update started then refresh<br>
+ * - Process queued updates in REVERSE order.<br>
+ * </p>
+ */
public void testCanceledUpdates2() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- model.setQeueueingUpdate(true);
+ model.setQeueueingUpdate(true);
- for (int i = 0; i < 5; i++) {
- // Refresh the viewer so that updates are generated.
- fListener.reset();
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ for (int i = 0; i < 5; i++) {
+ // Refresh the viewer so that updates are generated.
+ fListener.reset();
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- // Wait for the delta to be processed.
+ // Wait for the delta to be processed.
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES_STARTED), createListenerErrorMessage());
- }
+ }
ArrayList<IViewerUpdate> updates = new ArrayList<>(model.getQueuedUpdates());
- model.getQueuedUpdates().clear();
- for (int i = updates.size() - 1; i >= 0; i--) {
- model.processUpdate(updates.get(i));
- }
+ model.getQueuedUpdates().clear();
+ for (int i = updates.size() - 1; i >= 0; i--) {
+ model.processUpdate(updates.get(i));
+ }
- model.setQeueueingUpdate(false);
+ model.setQeueueingUpdate(false);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- }
-
- /**
- * This test forces the viewer to cancel updates then process them at once.
- * <p>
- * - Wait until CHILDREN update started then refresh<br>
- * - Process queued updates in order.<br>
- * </p>
- */
+ }
+
+ /**
+ * This test forces the viewer to cancel updates then process them at once.
+ * <p>
+ * - Wait until CHILDREN update started then refresh<br>
+ * - Process queued updates in order.<br>
+ * </p>
+ */
public void testCanceledUpdates3() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- model.setQeueueingUpdate(true);
+ model.setQeueueingUpdate(true);
- for (int i = 0; i < 5; i++) {
- // Refresh the viewer so that updates are generated.
- fListener.reset();
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ for (int i = 0; i < 5; i++) {
+ // Refresh the viewer so that updates are generated.
+ fListener.reset();
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
long start = System.currentTimeMillis();
- // Wait for the delta to be processed.
+ // Wait for the delta to be processed.
while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILDREN_UPDATES_STARTED)
&& System.currentTimeMillis() - start < testTimeout) {
- completeQueuedUpdatesOfType(model, IChildrenCountUpdate.class);
- completeQueuedUpdatesOfType(model, IHasChildrenUpdate.class);
+ completeQueuedUpdatesOfType(model, IChildrenCountUpdate.class);
+ completeQueuedUpdatesOfType(model, IHasChildrenUpdate.class);
TestUtil.processUIEvents();
- }
- }
+ }
+ }
- model.setQeueueingUpdate(false);
+ model.setQeueueingUpdate(false);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- }
+ }
- /**
- * This test forces the viewer to cancel updates then process them at once.
- * <p>
- * - Wait until CHILDREN update started then refresh<br>
- * - Process queued updates in REVERSE order.<br>
- * </p>
- */
+ /**
+ * This test forces the viewer to cancel updates then process them at once.
+ * <p>
+ * - Wait until CHILDREN update started then refresh<br>
+ * - Process queued updates in REVERSE order.<br>
+ * </p>
+ */
public void testCanceledUpdates4() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- model.setQeueueingUpdate(true);
+ model.setQeueueingUpdate(true);
- for (int i = 0; i < 5; i++) {
- // Refresh the viewer so that updates are generated.
- fListener.reset();
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ for (int i = 0; i < 5; i++) {
+ // Refresh the viewer so that updates are generated.
+ fListener.reset();
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- long start = System.currentTimeMillis();
- // Wait for the delta to be processed.
- while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILDREN_UPDATES_STARTED)
- && System.currentTimeMillis() - start < testTimeout) {
- completeQueuedUpdatesOfType(model, IChildrenCountUpdate.class);
- completeQueuedUpdatesOfType(model, IHasChildrenUpdate.class);
- TestUtil.processUIEvents();
- }
+ long start = System.currentTimeMillis();
+ // Wait for the delta to be processed.
+ while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILDREN_UPDATES_STARTED)
+ && System.currentTimeMillis() - start < testTimeout) {
+ completeQueuedUpdatesOfType(model, IChildrenCountUpdate.class);
+ completeQueuedUpdatesOfType(model, IHasChildrenUpdate.class);
+ TestUtil.processUIEvents();
+ }
- }
+ }
ArrayList<IViewerUpdate> updates = new ArrayList<>(model.getQueuedUpdates());
- model.getQueuedUpdates().clear();
- for (int i = updates.size() - 1; i >= 0; i--) {
- model.processUpdate(updates.get(i));
- }
+ model.getQueuedUpdates().clear();
+ for (int i = updates.size() - 1; i >= 0; i--) {
+ model.processUpdate(updates.get(i));
+ }
- model.setQeueueingUpdate(false);
+ model.setQeueueingUpdate(false);
waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- }
-
- /**
- * This test removes an element while there are updates running on its
- * sub-tree. With a precise timing this operation caused Bug 373790.
- * <p>
- * See Bug 373790 - Debug view stays busy after Resume
- * </p>
- * @see org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider#rescheduleUpdates
- */
+ }
+
+ /**
+ * This test removes an element while there are updates running on its
+ * sub-tree. With a precise timing this operation caused Bug 373790.
+ * <p>
+ * See Bug 373790 - Debug view stays busy after Resume
+ * </p>
+ * @see org.eclipse.debug.internal.ui.viewers.model.ModelContentProvider#rescheduleUpdates
+ */
public void testCancelUpdatesOnRemoveElementWhileUpdatingSubTree() throws Exception {
- TestModel model = TestModel.simpleMultiLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleMultiLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- // Refresh the viewer so that updates are generated.
- fListener.reset();
+ // Refresh the viewer so that updates are generated.
+ fListener.reset();
TreePath path = model.findElement("2"); //$NON-NLS-1$
- fListener.addUpdates(path, model.getElement(path), 1, CHILD_COUNT_UPDATES);
- fListener.addChildreUpdate(path, 0);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ fListener.addUpdates(path, model.getElement(path), 1, CHILD_COUNT_UPDATES);
+ fListener.addChildreUpdate(path, 0);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- // Wait for the delta to be processed and child updates for "2" to get started.
+ // Wait for the delta to be processed and child updates for "2" to get started.
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES | CHILDREN_UPDATES_RUNNING), createListenerErrorMessage());
- // Remove element "2"
- removeElement(model, 1, true);
+ // Remove element "2"
+ removeElement(model, 1, true);
- // Wait for all updates to finish.
- waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
- }
+ // Wait for all updates to finish.
+ waitWhile(t -> !fListener.isFinished(ALL_UPDATES_COMPLETE), createListenerErrorMessage());
+ }
- /**
- * This test forces the viewer to cancel updates upon setInput().
- * <p>
- * - Wait until CHILDREN update started then refresh<br>
- * - Process queued updates in order.<br>
- * </p>
- */
+ /**
+ * This test forces the viewer to cancel updates upon setInput().
+ * <p>
+ * - Wait until CHILDREN update started then refresh<br>
+ * - Process queued updates in order.<br>
+ * </p>
+ */
public void testCanceledUpdatesOnSetInput() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- model.setQeueueingUpdate(false);
+ model.setQeueueingUpdate(false);
- // Refresh the viewer so that updates are generated.
- fListener.reset();
- fListener.addChildreCountUpdate(TreePath.EMPTY);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Refresh the viewer so that updates are generated.
+ fListener.reset();
+ fListener.addChildreCountUpdate(TreePath.EMPTY);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- // Wait for the delta to be processed.
+ // Wait for the delta to be processed.
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES), createListenerErrorMessage());
- TestModel model2 = new TestModel();
+ TestModel model2 = new TestModel();
model2.setRoot(new TestElement(model2, "root", new TestElement[0])); //$NON-NLS-1$
- fViewer.setInput(model2.getRootElement());
+ fViewer.setInput(model2.getRootElement());
waitWhile(t -> !fListener.isFinished(CONTENT_COMPLETE | VIEWER_UPDATES_RUNNING), createListenerErrorMessage());
- }
+ }
- /**
- * This test forces the viewer to cancel updates upon setInput().
- * <p>
- * - Wait until CHILDREN update started then refresh<br>
- * - Process queued updates in order.<br>
- * </p>
- */
+ /**
+ * This test forces the viewer to cancel updates upon setInput().
+ * <p>
+ * - Wait until CHILDREN update started then refresh<br>
+ * - Process queued updates in order.<br>
+ * </p>
+ */
public void testCanceledUpdatesOnSetNullInput() throws Exception {
- TestModel model = TestModel.simpleSingleLevel();
- fViewer.setAutoExpandLevel(-1);
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
- // Create the listener
- fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, false, false);
- // Set the input into the view and update the view.
- fViewer.setInput(model.getRootElement());
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
waitWhile(t -> !fListener.isFinished(), createListenerErrorMessage());
- model.validateData(fViewer, TreePath.EMPTY);
+ model.validateData(fViewer, TreePath.EMPTY);
- model.setQeueueingUpdate(false);
+ model.setQeueueingUpdate(false);
- // Refresh the viewer so that updates are generated.
- fListener.reset();
- fListener.addChildreCountUpdate(TreePath.EMPTY);
- model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
+ // Refresh the viewer so that updates are generated.
+ fListener.reset();
+ fListener.addChildreCountUpdate(TreePath.EMPTY);
+ model.postDelta(new ModelDelta(model.getRootElement(), IModelDelta.CONTENT));
- // Wait for the delta to be processed.
+ // Wait for the delta to be processed.
waitWhile(t -> !fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILD_COUNT_UPDATES), createListenerErrorMessage());
- fViewer.setInput(null);
+ fViewer.setInput(null);
waitWhile(t -> !fListener.isFinished(CONTENT_COMPLETE | VIEWER_UPDATES_RUNNING), createListenerErrorMessage());
- }
+ }
private void completeQueuedUpdatesOfType(TestModel model, Class<?> updateClass) {
List<IViewerUpdate> updatesToComplete = new LinkedList<>();
for (Iterator<IViewerUpdate> itr = model.getQueuedUpdates().iterator(); itr.hasNext();) {
- IViewerUpdate update = itr.next();
- if (updateClass.isInstance(update)) {
- updatesToComplete.add(update);
- itr.remove();
- }
- }
- if (updatesToComplete != null) {
+ IViewerUpdate update = itr.next();
+ if (updateClass.isInstance(update)) {
+ updatesToComplete.add(update);
+ itr.remove();
+ }
+ }
+ if (updatesToComplete != null) {
for (Iterator<IViewerUpdate> itr = updatesToComplete.iterator(); itr.hasNext();) {
- model.processUpdate(itr.next());
- }
- }
- }
+ model.processUpdate(itr.next());
+ }
+ }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerContentTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerContentTests.java
index 6ac55ba4a..af1434896 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerContentTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerContentTests.java
@@ -25,12 +25,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VirtualViewerContentTests extends ContentTests {
- public VirtualViewerContentTests(String name) {
- super(name);
- }
+ public VirtualViewerContentTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerDeltaTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerDeltaTests.java
index c53058364..2c68368f0 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerDeltaTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerDeltaTests.java
@@ -25,12 +25,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VirtualViewerDeltaTests extends DeltaTests {
- public VirtualViewerDeltaTests(String name) {
- super(name);
- }
+ public VirtualViewerDeltaTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerFilterTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerFilterTests.java
index cc0f46095..f0aff25a4 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerFilterTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerFilterTests.java
@@ -26,12 +26,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VirtualViewerFilterTests extends FilterTests {
- public VirtualViewerFilterTests(String name) {
- super(name);
- }
+ public VirtualViewerFilterTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new VirtualTreeModelViewer(fDisplay, SWT.VIRTUAL, new PresentationContext("TestViewer"), new VisibleVirtualItemValidator(0, 100)); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerLazyModeTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerLazyModeTests.java
index 18653ec09..8c95b7fba 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerLazyModeTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerLazyModeTests.java
@@ -30,9 +30,9 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VirtualViewerLazyModeTests extends AbstractViewerModelTest {
- public VirtualViewerLazyModeTests(String name) {
- super(name);
- }
+ public VirtualViewerLazyModeTests(String name) {
+ super(name);
+ }
@Override
protected TestModelUpdatesListener createListener(IInternalTreeModelViewer viewer) {
@@ -42,9 +42,9 @@ public class VirtualViewerLazyModeTests extends AbstractViewerModelTest {
@Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new VirtualTreeModelViewer(display, SWT.VIRTUAL, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
- public void test() {
- // TODO
- }
+ public void test() {
+ // TODO
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPerformanceTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPerformanceTests.java
index c70ec1706..6143a3184 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPerformanceTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPerformanceTests.java
@@ -26,17 +26,17 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VirtualViewerPerformanceTests extends PerformanceTests {
- public VirtualViewerPerformanceTests(String name) {
- super(name);
- }
+ public VirtualViewerPerformanceTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new VirtualTreeModelViewer(fDisplay, SWT.VIRTUAL, new PresentationContext("TestViewer"), fVirtualItemValidator); //$NON-NLS-1$
- }
+ }
- @Override
+ @Override
protected int getTestModelDepth() {
- return 7;
- }
+ return 7;
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPopupTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPopupTests.java
index 055cd88bd..fd07796f4 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPopupTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerPopupTests.java
@@ -25,14 +25,14 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VirtualViewerPopupTests extends PopupTests {
- public VirtualViewerPopupTests(String name) {
- super(name);
- }
+ public VirtualViewerPopupTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell, int style) {
return new VirtualTreeModelViewer(fDisplay, style, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerSelectionTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerSelectionTests.java
index f4edf0b01..68100fab3 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerSelectionTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerSelectionTests.java
@@ -25,12 +25,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VirtualViewerSelectionTests extends SelectionTests {
- public VirtualViewerSelectionTests(String name) {
- super(name);
- }
+ public VirtualViewerSelectionTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerStateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerStateTests.java
index ff0e3e29a..1c39f0bb1 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerStateTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerStateTests.java
@@ -25,12 +25,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VirtualViewerStateTests extends StateTests {
- public VirtualViewerStateTests(String name) {
- super(name);
- }
+ public VirtualViewerStateTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerUpdateTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerUpdateTests.java
index 6e202e342..42a69e80c 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerUpdateTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VirtualViewerUpdateTests.java
@@ -25,12 +25,12 @@ import org.eclipse.swt.widgets.Shell;
*/
public class VirtualViewerUpdateTests extends UpdateTests {
- public VirtualViewerUpdateTests(String name) {
- super(name);
- }
+ public VirtualViewerUpdateTests(String name) {
+ super(name);
+ }
- @Override
+ @Override
protected IInternalTreeModelViewer createViewer(Display display, Shell shell) {
return new VirtualTreeModelViewer(fDisplay, 0, new PresentationContext("TestViewer")); //$NON-NLS-1$
- }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VisibleVirtualItemValidator.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VisibleVirtualItemValidator.java
index b59c02edb..02ebae98a 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VisibleVirtualItemValidator.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/viewer/model/VisibleVirtualItemValidator.java
@@ -23,78 +23,78 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTree;
*/
public class VisibleVirtualItemValidator implements IVirtualItemValidator {
- private int fStart = 0;
- private int fEnd = 0;
+ private int fStart = 0;
+ private int fEnd = 0;
- public VisibleVirtualItemValidator(int startPosition, int length) {
- setVisibleRange(startPosition, length);
- }
+ public VisibleVirtualItemValidator(int startPosition, int length) {
+ setVisibleRange(startPosition, length);
+ }
- public void setVisibleRange(int startPosition, int length) {
- fStart = startPosition;
- fEnd = startPosition + length;
- }
+ public void setVisibleRange(int startPosition, int length) {
+ fStart = startPosition;
+ fEnd = startPosition + length;
+ }
- public int getStartPosition() {
- return fStart;
- }
+ public int getStartPosition() {
+ return fStart;
+ }
- public int getLength() {
- return fEnd - fStart;
- }
+ public int getLength() {
+ return fEnd - fStart;
+ }
- @Override
+ @Override
public boolean isItemVisible(VirtualItem item) {
- int position = 0;
- while (item.getParent() != null) {
- position += item.getIndex().intValue();
- item = item.getParent();
- }
- return position >= fStart && position < fEnd || isSelected(item);
- }
+ int position = 0;
+ while (item.getParent() != null) {
+ position += item.getIndex().intValue();
+ item = item.getParent();
+ }
+ return position >= fStart && position < fEnd || isSelected(item);
+ }
- @Override
+ @Override
public void showItem(VirtualItem item) {
- int length = fEnd - fStart;
- fStart = calcPosition(item);
- fEnd = fStart + length;
- }
+ int length = fEnd - fStart;
+ fStart = calcPosition(item);
+ fEnd = fStart + length;
+ }
- private int calcPosition(VirtualItem item) {
- int position = 0;
- while (item.getParent() != null) {
- position += item.getIndex().intValue();
- item = item.getParent();
- }
- return position;
- }
+ private int calcPosition(VirtualItem item) {
+ int position = 0;
+ while (item.getParent() != null) {
+ position += item.getIndex().intValue();
+ item = item.getParent();
+ }
+ return position;
+ }
- private boolean isSelected(VirtualItem item) {
- VirtualItem[] selection = getSelection(item);
- for (int i = 0; i < selection.length; i++) {
- VirtualItem selectionItem = selection[i];
- while (selectionItem != null) {
- if (item.equals(selectionItem)) {
- return true;
- }
- selectionItem = selectionItem.getParent();
- }
- }
- return false;
- }
+ private boolean isSelected(VirtualItem item) {
+ VirtualItem[] selection = getSelection(item);
+ for (int i = 0; i < selection.length; i++) {
+ VirtualItem selectionItem = selection[i];
+ while (selectionItem != null) {
+ if (item.equals(selectionItem)) {
+ return true;
+ }
+ selectionItem = selectionItem.getParent();
+ }
+ }
+ return false;
+ }
- private VirtualItem[] getSelection(VirtualItem item) {
- VirtualTree tree = getTree(item);
- if (tree != null) {
- return tree.getSelection();
- }
- return new VirtualItem[0];
- }
+ private VirtualItem[] getSelection(VirtualItem item) {
+ VirtualTree tree = getTree(item);
+ if (tree != null) {
+ return tree.getSelection();
+ }
+ return new VirtualItem[0];
+ }
- private VirtualTree getTree(VirtualItem item) {
- while (item != null && !(item instanceof VirtualTree)) {
- item = item.getParent();
- }
- return (VirtualTree)item;
- }
+ private VirtualTree getTree(VirtualItem item) {
+ while (item != null && !(item instanceof VirtualTree)) {
+ item = item.getParent();
+ }
+ return (VirtualTree)item;
+ }
}

Back to the top