Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormhussein2012-05-03 15:12:57 +0000
committerDoug Schaefer2012-05-04 13:55:26 +0000
commita2cfb6e5cd7eacc5415d74e5ccf29f36fc6c7037 (patch)
treec690288b323f12c6c5197abf771c3b4b9e794d33 /build/org.eclipse.cdt.managedbuilder.core.tests
parent621ee0fe2260723d9a134e0938ac748ce6528ec9 (diff)
downloadorg.eclipse.cdt-a2cfb6e5cd7eacc5415d74e5ccf29f36fc6c7037.tar.gz
org.eclipse.cdt-a2cfb6e5cd7eacc5415d74e5ccf29f36fc6c7037.tar.xz
org.eclipse.cdt-a2cfb6e5cd7eacc5415d74e5ccf29f36fc6c7037.zip
Bug 365718: Support tree option style in managed build options
Managed build options in tools provide several styles for option type, for example: string, boolean, libPaths, enumerated, ... The enumerated type allows the user to select from a pre-defined list of values. A usability problem might happen if the list of possible values is Huge, in this case the simple drop-box wouldn't be sufficient for the user to properly and easily select the needed option. In most of those cases the huge list of options can be organized in some hierarchy that allows the user to easily pick the needed option. The attached patch attempts to support this by doing the following: 1- Adding support of a new option valueType "tree" - Adding schema for treeOption - Adding support for tree type similar to enumerated option type 2- Provide UI to easily select items from this tree - Provide a field editor with a text box and browse button - Provide popup tree picker with filtered search - Each item in the tree can optionally provide an icon, and specify its relative order among its peers. Updates: - Expose TreeSelectionDialog and TreeRoot to allow usage in other contexts - Remove extra whitespaces. - Support Double-click to select - Added unit test Change-Id: I3e7e8c6e3e9878f7c6dadeb149326b375cd3631d Reviewed-on: https://git.eclipse.org/r/5558 Reviewed-by: Doug Schaefer <dschaefer@qnx.com> IP-Clean: Doug Schaefer <dschaefer@qnx.com> Tested-by: Doug Schaefer <dschaefer@qnx.com>
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core.tests')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml62
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests.java64
2 files changed, 126 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
index 67494d80a53..dfaafb86cec 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml
@@ -9311,4 +9311,66 @@
name="Test Plugin GCC BOP Patterns Highlighter">
</errorparser>
</extension>
+ <!-- Tree Option -->
+ <extension
+ id="cdt.managed.build.test.tree.option"
+ name="Test Managed Build TreeOption"
+ point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
+ <managedBuildRevision fileVersion="4.0.0"/>
+ <tool
+ natureFilter="cnature"
+ name="Test Tool"
+ outputFlag="-o"
+ command="gcc"
+ id="cdt.managedbuild.tool.gnu.c.linker.test.tree.tool"
+ errorParsers="org.eclipse.cdt.core.GLDErrorParser">
+
+ <option
+ defaultValue="grandChild_1_1_1"
+ name="Dummy Tree Option"
+ command="-dummy"
+ id="cdt.managedbuild.tool.gnu.c.linker.test.tree.option"
+ valueType="tree">
+ <treeOptionRoot name="root" id="option.tree.root">
+ <treeOption name="Parent 1" id="parent_1">
+ <treeOption name="Child 1 1" id="child_1_1">
+ <treeOption name="Grand Child 1 1 1" id="grandChild_1_1_1" />
+ <treeOption name="Grand Child 1 1 2" id="grandChild_1_1_2" />
+ <treeOption name="Grand Child 1 1 3" id="grandChild_1_1_3" />
+ </treeOption>
+ <treeOption name="Child 1 2" id="child_1_2">
+ <treeOption name="Grand Child 1 2 1" id="grandChild_1_2_1" />
+ <treeOption name="Grand Child 1 2 2" id="grandChild_1_2_2" command="-dummy122" />
+ <treeOption name="Grand Child 1 2 3" id="grandChild_1_2_3" />
+ </treeOption>
+ </treeOption>
+ <treeOption name="Parent 2" id="parent_2">
+ <treeOption name="Child 2 1" id="child_2_1">
+ <treeOption name="Grand Child 2 1 1" id="grandChild_2_1_1" />
+ <treeOption name="Grand Child 2 1 2" id="grandChild_2_1_2" />
+ <treeOption name="Grand Child 2 1 3" id="grandChild_2_1_3" />
+ </treeOption>
+ <treeOption name="Child 2 2" id="child_2_2">
+ <treeOption name="Grand Child 2 2 1" id="grandChild_2_2_1" />
+ <treeOption name="Grand Child 2 2 2" id="grandChild_2_2_2" />
+ <treeOption name="Grand Child 2 2 3" id="grandChild_2_2_3" />
+ </treeOption>
+ </treeOption>
+ <treeOption name="Parent 3" id="parent_3" order="0">
+ <treeOption name="Child 3 1" id="child_3_1">
+ <treeOption name="Grand Child 3 1 1" id="grandChild_3_1_1" />
+ <treeOption name="Grand Child 3 1 2" id="grandChild_3_1_2" />
+ <treeOption name="Grand Child 3 1 3" id="grandChild_3_1_3" />
+ </treeOption>
+ <treeOption name="Child 3 2" id="child_3_2">
+ <treeOption name="Grand Child 3 2 1" id="grandChild_3_2_1" />
+ <treeOption name="Grand Child 3 2 2" id="grandChild_3_2_2" />
+ <treeOption name="Grand Child 3 2 3" id="grandChild_3_2_3" />
+ </treeOption>
+ </treeOption>
+ </treeOptionRoot>
+ </option>
+ </tool>
+ </extension>
+
</plugin>
diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests.java
index 68e2a10bb90..e1bf503c10a 100644
--- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests.java
+++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests.java
@@ -22,6 +22,9 @@ import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOption.ITreeOption;
+import org.eclipse.cdt.managedbuilder.core.IOption.ITreeRoot;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
@@ -30,6 +33,7 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
import org.eclipse.core.runtime.IConfigurationElement;
+import org.junit.Assert;
public class ManagedBuildCoreTests extends TestCase {
@@ -44,6 +48,7 @@ public class ManagedBuildCoreTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(ManagedBuildCoreTests.class.getName());
suite.addTest(new ManagedBuildCoreTests("testLoadManifest"));
+ suite.addTest(new ManagedBuildCoreTests("testTreeOptions"));
return suite;
}
@@ -598,5 +603,64 @@ public class ManagedBuildCoreTests extends TestCase {
} // end for
} // end routine
+
+ /**
+ * Tests Options of type tree as implemented in bug 365718
+ * @throws Exception
+ */
+ public void testTreeOptions() throws Exception {
+ IOption treeOption = ManagedBuildManager.getExtensionOption("cdt.managedbuild.tool.gnu.c.linker.test.tree.option");
+ assertNotNull(treeOption);
+
+ // standard options
+ assertEquals(IOption.TREE, treeOption.getValueType());
+ assertEquals("grandChild_1_1_1", treeOption.getValue());
+ assertEquals("grandChild_1_1_1", treeOption.getDefaultValue());
+ assertEquals("cdt.managedbuild.tool.gnu.c.linker.test.tree.option", treeOption.getId());
+ assertEquals("-dummy", treeOption.getCommand());
+ assertEquals("-dummy122", treeOption.getCommand("grandChild_1_2_2"));
+
+ String[] applicableValues = treeOption.getApplicableValues();
+ String[] expected = new String[18];
+ int index = 0;
+ for (int i = 1; i < 4; i++) {
+ for (int j = 1; j < 3; j++) {
+ for (int k = 1; k < 4; k++) {
+ expected[index++] = "Grand Child " + i + ' ' + j + ' ' + k;
+ }
+ }
+ }
+ Assert.assertArrayEquals(expected, applicableValues);
+
+ ITreeRoot treeRoot = treeOption.getTreeRoot();
+ assertNotNull(treeRoot);
+
+ // test some tree option attributes
+ ITreeOption[] children = treeRoot.getChildren();
+ assertNotNull(children);
+ assertEquals(0, children[2].getOrder());
+ assertEquals("Parent 2", children[1].getName());
+ assertTrue(children[0].isContainer());
+
+ ITreeOption findNode = treeRoot.findNode("grandChild_2_1_3");
+ assertNotNull(findNode);
+
+ int size = children.length;
+ treeRoot.addChild("newID", "New Name");
+ assertEquals(size+1, treeRoot.getChildren().length);
+ assertEquals("newID", treeRoot.getChild("New Name").getID());
+
+ // check tree only methods
+ IOption nonTreeOption = ManagedBuildManager.getExtensionOption("testgnu.c.compiler.exe.debug.option.debugging.level");
+ assertFalse(IOption.TREE == nonTreeOption.getValueType());
+ boolean exception = false;
+ try {
+ nonTreeOption.getTreeRoot();
+ } catch (Exception e) {
+ exception = true;
+ }
+ assertTrue(exception);
+
+ }
} // end class

Back to the top