SPONSORS:






User Tag List

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Oct 1999
    Location
    Mumbai, India
    Posts
    15
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Power ful methods for TreeView class wanted!

    Hi all,
    Testing Java 1.2.2 application using SilkTest 5.0.
    Can I get better methods for SilkTest TreeView class? The methods already available are of very limited power.
    It will be great if I have following methods:
    1) Given/Selected Node Expanded or not( fully expanded not just 1st level)
    2) Given/Selected node Collapsed or not(--""--)
    3)All contents of the node ( including sub sub nodes as well)
    4)Full path of any node.
    5)Bitmaps present in the node( other than those icons for collapse
    expand control areas.) etc...
    Any ideas?
    Regards,
    Kishor.

  2. #2
    Junior Member
    Join Date
    Sep 2004
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Power ful methods for TreeView class wanted!

    Try this

    ExpAll(window wTree, STRING sItemName)
    {

    oENTERPRISEDESIGNER.SetActive();
    wTree.ExpandItem(sItemName);
    BOOLEAN bTextMatches = True;

    while (bTextMatches == True)
    {
    INTEGER iItems = wTree.GetItemCount();
    wTree.Select(wTree.GetSelText());
    if (!MatchStr ("{sItemName}*", wTree.GetSelText()) || (wTree.GetSelIndex()>=iItems))
    {
    if (MatchStr ("{sItemName}*", wTree.GetSelText()))
    {
    if (wTree.IsItemExpandable(wTree.GetSelText()))
    {
    wTree.TypeKeys("<Right>");
    bTextMatches = True;
    }
    else
    bTextMatches = False;
    }
    else
    bTextMatches = False;
    }
    else
    {

    wTree.TypeKeys("<Right>");
    bTextMatches = True;
    }

    }

    }

  3. #3
    Member
    Join Date
    Apr 2006
    Location
    Toronto, Canada
    Posts
    69
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Power ful methods for TreeView class wanted!

    Just write your own methods [img]images/icons/smile.gif[/img] It's not that hard.
    Plus, *you* will know better, in which form you would like the return values (if any) and which selection/key actions your tree takes. And any other tricks (for example, our tree's nodes with no children still show themselves as if they have chilren, so I have to account for it. Aside from that I have to press space to actually select the node. I mean, I'm the only one that really knows this, right? Same probably applies to your case.

    For finding contents of the node, take the root and the tree and for each child of the root, if expandable, recurse, if not, add child to a list list and Collapse at the end of the children list (otherwise you indexes will be messed up, since they're calculated relative to parent). (keep passing your list as paremeter when you recurse, or keep a global container of some sort)

    Here are two functions I am using, they're not *exactly* what you need, but I'm sure, if you throw out some stuff you can adjust it to your needs [img]images/icons/smile.gif[/img]
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> [ ] //returns the index of the file/folder and expands/exposes the tree
    [ ] //or returns 0 if the item is not there, cannot be exposed, etc.
    [-] public int browse_to_file (Window tree, String path)
    [ ] String item = path
    [ ] String root
    [-] while path != &quot;&quot;
    [-] if (StrPos(&quot;/&quot;, path) != 0)
    [ ] root = SubStr(path, 1, StrPos(&quot;/&quot;, path)-1)
    [ ] path = SubStr (path, StrPos(&quot;/&quot;, path)+1)
    [-] else
    [ ] root = path
    [ ] path = &quot;&quot;
    [-] do
    [ ] tree.ExposeItem (root)
    [-] except
    [ ] return 0
    [-] if (tree.VScrollBar.Exists () &amp;&amp; tree.VScrollBar.isEnabled () &amp;&amp; tree.VScrollBar.isVisible ())
    [-] do
    [ ] tree.VScrollBar.ScrollByLine (1)
    [-] except
    [ ] LogWarning (&quot;*** Problem with scrollbar&quot
    [-] if tree.IsItemExpandable (root)
    [ ] tree.Expand (root)
    [ ] return tree.FindItem(item)
    </pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica"></font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
    [ ] [ ] //leverage - a real number btwn 0 and 1 to favour selection or expansion of folders
    [ ] //numbers less than 0.5 favour expansion, greater or equal - selection
    [-] public RandomSelection (String root, Window tree, Real leverage optional)
    [ ] //RandSeed (GetDateTimePart (GetDateTime (), DTP_SECOND))
    [ ] Real split_point
    [-] if leverage != NULL
    [ ] split_point = leverage
    [-] else
    [ ] split_point = 0.6 //by default favour expansion a bit more
    [ ]
    [ ] tree.Expand (root)
    [ ] Int NumItems = tree.GetSubItemCount (root)
    [ ] Int RandNumItems
    [-] if (NumItems &gt;1)
    [ ] RandNumItems = RandInt (1, NumItems) //TD change when fix is avail
    [-] else
    [ ] RandNumItems = 1
    [ ]
    [ ] Int i
    [-] for (i = 1; i &lt;= RandNumItems; ++i)
    [ ] //select root
    [ ] tree.ExposeItem (root)
    [ ] tree.Select (root)
    [-] if (NumItems &gt;1) //if more than one child - make a random choice of how many children to explore/select
    [ ] Int RandomItem = RandInt (tree.GetSelIndex ()+1, tree.GetSelIndex ()+NumItems-1) //index of root + local index of random select
    [ ] String item = root + &quot;/&quot; + tree.GetItemText (RandomItem)
    [ ] print (item)
    [-] else
    [ ] item = root + &quot;/&quot; + tree.GetItemText (tree.GetSelIndex ()+1)
    [ ] //TD: check if the item is not already selected
    [ ] Real Action = RandReal ()
    [-] if (Action &gt; split_point) &amp;&amp; (tree.IsItemExpandable (item)) //expand
    [ ] tree.ExposeItem (item)
    [-] if (tree.VScrollBar.Exists () &amp;&amp; tree.VScrollBar.isEnabled () &amp;&amp; tree.VScrollBar.isVisible ())
    [-] do
    [ ] tree.VScrollBar.ScrollByLine (1)
    [-] except
    [ ] LogWarning (&quot;*** Problem with scrollbar&quot
    [ ]
    [-] do
    [ ] tree.Expand (item)
    [ ]
    [ ] //close window that comes up for removable media empty drive
    [-] if FujifilmImageArmD3.Exists ()
    [ ] FujifilmImageArmD3.SetActive ()
    [ ] FujifilmImageArmD3.Cancel.Click ()
    [ ]
    [ ] RandomSelection (item, tree)
    [ ] tree.Collapse (item)
    [-] except
    [ ] LogWarning (&quot;*** Trying to expand an empty folder&quot
    [-] else if (Action &lt; 0.4) //select
    [ ] tree.ExposeItem (item)
    [-] if (tree.VScrollBar.Exists () &amp;&amp; tree.VScrollBar.isEnabled ())
    [ ] tree.VScrollBar.ScrollByLine (1)
    [ ] tree.Select (item)
    [ ] tree.TypeKeys (&quot; &quot //to actually select the root</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 12:33 AM.

Copyright BetaSoft Inc.