OpenAgent"

From Documentation
m (correct highlight (via JWB))
 
Line 8: Line 8:
  
 
<!-- open a tree item -->
 
<!-- open a tree item -->
<tt> OpenAgent </tt> is used to expand a ''treeitem'', ''listgroup'', ''detail'', ''bandbox'', ''groupbox'' or ''combobutton'' etc.
+
<code> OpenAgent </code> is used to expand a ''treeitem'', ''listgroup'', ''detail'', ''bandbox'', ''groupbox'' or ''combobutton'' etc.
  
  
Line 20: Line 20:
 
'''OpenTest.java'''
 
'''OpenTest.java'''
  
<source lang="java" high="3,6,10,11,14">
+
<source lang="java" highlight="3,6,10,11,14">
  
 
@Test
 
@Test
Line 40: Line 40:
  
 
</source>
 
</source>
* Although there are two ''treeitems'', <tt> query() </tt> only returns the first one. (line 3)
+
* Although there are two ''treeitems'', <code> query() </code> only returns the first one. (line 3)
 
* Before expanding, its visible item count is one(only itself). (line 6)
 
* Before expanding, its visible item count is one(only itself). (line 6)
 
* After we expand the first ''treeitem'' and its first child item, its visible item count should now be five as shown in the image above. (line 8-9)
 
* After we expand the first ''treeitem'' and its first child item, its visible item count should now be five as shown in the image above. (line 8-9)
* Call <tt> open(false) </tt> to collapse first ''treeitem'', and its visible item count comes back to one. (line 12)
+
* Call <code> open(false) </code> to collapse first ''treeitem'', and its visible item count comes back to one. (line 12)
  
 
=Supported Components=
 
=Supported Components=

Latest revision as of 02:55, 18 January 2022




Open

OpenAgent is used to expand a treeitem, listgroup, detail, bandbox, groupbox or combobutton etc.


Here we use a tree with binary structure to demonstrate this agent's usage. Each treeitem has two children.

Smalltalk-mimic-open.png


In the test case below, we expand the first treeitem (node1) and its first child treeitem (node3), the first treeitem's visible item count should be 5. Before expanding, its visible item count is 1(only itself).

OpenTest.java

	@Test
	public void testAgent() {
		DesktopAgent desktop = Zats.newClient().connect("/open-tree.zul");

		ComponentAgent firstItem = desktop.query("#tree").query("treeitem");
		Assert.assertEquals(1, firstItem.as(Treeitem.class).getVisibleItemCount());
		
		//open first item
		firstItem.as(OpenAgent.class).open(true);
		firstItem.query("treechildren").query("treeitem").as(OpenAgent.class).open(true);
		Assert.assertEquals(5, firstItem.as(Treeitem.class).getVisibleItemCount());
		
		//collapse first item
		firstItem.as(OpenAgent.class).open(false);
		Assert.assertEquals(1, firstItem.as(Treeitem.class).getVisibleItemCount());
	}
  • Although there are two treeitems, query() only returns the first one. (line 3)
  • Before expanding, its visible item count is one(only itself). (line 6)
  • After we expand the first treeitem and its first child item, its visible item count should now be five as shown in the image above. (line 8-9)
  • Call open(false) to collapse first treeitem, and its visible item count comes back to one. (line 12)

Supported Components

Components
Version
Note
Combobutton, Popup, Bandbox, Combobox, Groupbox,

Panel, Window, Detail, Group, Listgroup, Treeitem,

Center, North, East, West, South, Splitter

5, 6




Last Update : 2022/01/18

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.