KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > xml > schema > core > lib > SchemaMultiView


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.test.xml.schema.core.lib;
21 import javax.swing.JList JavaDoc;
22 import org.netbeans.jellytools.TopComponentOperator;
23 import org.netbeans.jellytools.actions.SaveAllAction;
24 import org.netbeans.jemmy.operators.JComponentOperator;
25 import org.netbeans.jemmy.operators.JListOperator;
26 import org.netbeans.jemmy.operators.JToggleButtonOperator;
27 import org.netbeans.test.xml.schema.core.lib.util.Helpers;
28
29 /**
30  *
31  * @author ca@netbeans.org
32  */

33 public class SchemaMultiView {
34     
35     private TopComponentOperator m_opTopComponent;
36     
37     private JToggleButtonOperator m_opSchemaButton;
38     private JToggleButtonOperator m_opDesignButton;
39     private JToggleButtonOperator m_opSourceButton;
40     
41     private JToggleButtonOperator m_opColumnsButton;
42     private JToggleButtonOperator m_opTreeButton;
43     
44     private boolean m_bMacOS = true;
45     
46     /**
47      * Creates a new instance of SchemaMultiView
48      */

49     public SchemaMultiView(String JavaDoc strTopComponentName) {
50         m_opTopComponent = new TopComponentOperator(strTopComponentName);
51         
52         // On MacOS
53
JComponentOperator opToolbar = Helpers.getComponentOperator(m_opTopComponent, "org.netbeans.core.multiview.TabsComponent$TB", 0);
54         
55         // On Win/UNIX
56
if (opToolbar == null) {
57             opToolbar = Helpers.getComponentOperator(m_opTopComponent, "javax.swing.JToolBar", 0);
58             m_bMacOS = false;
59         }
60         
61         JComponentOperator opSchemaViewToolbar = Helpers.getComponentOperator(m_opTopComponent, "javax.swing.JToolBar", m_bMacOS ? 0: 1);
62         
63         m_opSchemaButton = new JToggleButtonOperator(opToolbar, "Schema");
64         m_opDesignButton = new JToggleButtonOperator(opToolbar, "Design");
65         m_opSourceButton = new JToggleButtonOperator(opToolbar, "Source");
66         
67         switchToSchema();
68         
69         m_opColumnsButton = new JToggleButtonOperator(opSchemaViewToolbar, 0);
70         m_opTreeButton = new JToggleButtonOperator(opSchemaViewToolbar, 1);
71     }
72     
73     public TopComponentOperator getTopComponentOperator() {
74         return m_opTopComponent;
75     }
76     
77     public void switchToSchema() {
78         m_opSchemaButton.push();
79         Helpers.waitNoEvent();
80     }
81     
82     public void switchToDesign() {
83         m_opDesignButton.push();
84         Helpers.waitNoEvent();
85     }
86     
87     public void switchToSource() {
88         m_opSourceButton.push();
89         Helpers.waitNoEvent();
90     }
91     
92     public void switchToSchemaColumns() {
93         m_opColumnsButton.push();
94         Helpers.waitNoEvent();
95     }
96     
97     public void switchToSchemaTree() {
98         m_opTreeButton.push();
99         Helpers.waitNoEvent();
100     }
101     
102     public JListOperator getColumnListOperator(int column) {
103         JComponentOperator opComponent = Helpers.getComponentOperator(m_opTopComponent, "org.netbeans.modules.xml.xam.ui.column.ColumnListView$ColumnList", column, 200);
104         if (opComponent == null) {
105             return null;
106         }
107         JList JavaDoc list = (JList JavaDoc) opComponent.getSource();
108         
109         return new JListOperator(list);
110     }
111     
112     public void close() {
113         new SaveAllAction().performAPI();
114         
115         m_opTopComponent.close();
116     }
117 }
118
Popular Tags