TreeItems and PropertySheetCategory

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

TreeItems and PropertySheetCategory

Postby jeremyweber » Thu Mar 12, 2009 6:36 am

I have a tabbed property sheet called All which contains a bunch of tree items, however the organized in the under PropertySheetCategory's.


Activity ( PropertSheetCategory )
Activity Name
Activity Type
Comment
etc.
Simulation ( PropertSheetCategory )
Input Attachments
Input Message
etc.
Visual ( PropertSheetCategory )
Background Color
Border
etc.

When I run the following code:

Code: Select all
Display.getDefault().syncExec(new Runnable() {
         public void run() {
            Tree tree = item.getParent();
            TreeItem[] items = tree.getItems();
            for (TreeItem treeItem : items)
            {
               System.out.println("Text: " + treeItem.getText());
            }
         }
      });


Only yields:

Text: Activity
Text: Simulation
Text: Visual

It looks like PropertSheetCategory is not public so I dont have the option to call getItems on it. Additionally, when I call

Code: Select all
new DebugHelper().printWidgets();


TreeItem {Activity}<HC|11952250>
TreeItem {Activity Name}<HC|13632031>
TreeItem {Activity Type}<HC|3884215>

So my goal is, is to validate that I have several properties present and their default data. Can anyone suggest a workaround to get at the tree items?
jeremyweber
 
Posts: 10
Joined: Wed Jun 11, 2008 3:48 am

Re: TreeItems and PropertySheetCategory

Postby Phil Quitslund » Fri Mar 13, 2009 9:32 am

Hi Jeremy,

Have you tried recursing into the top level category tree items? I think the trick is to get the children of the catgeory tree items. Here's a quick stab. Let me know if it it gets you any closer:
Code: Select all
      Display.getDefault().syncExec(new Runnable() {
            public void run() {
               Tree tree = item.getParent();
               TreeItem[] categories = tree.getItems();
               for (TreeItem category : categories)
               {
                  System.out.println("Text: " + category.getText());
                  TreeItem[] children = category.getItems();
                  for (TreeItem child : children) {
                     System.out.println("Child Text: " + child.getText());
            }
               }
            }
         });
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: TreeItems and PropertySheetCategory

Postby jeremyweber » Fri Mar 13, 2009 12:02 pm

Yes of course, should have seen this. Thanks!
jeremyweber
 
Posts: 10
Joined: Wed Jun 11, 2008 3:48 am

Re: TreeItems and PropertySheetCategory

Postby Phil Quitslund » Mon Mar 16, 2009 10:51 am

Great. You're welcome!

-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest