001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.test.xml.schema.lib;
043:
044: import javax.swing.JList;
045: import org.netbeans.jellytools.TopComponentOperator;
046: import org.netbeans.jellytools.actions.SaveAllAction;
047: import org.netbeans.jemmy.operators.JComponentOperator;
048: import org.netbeans.jemmy.operators.JListOperator;
049: import org.netbeans.jemmy.operators.JToggleButtonOperator;
050: import org.netbeans.test.xml.schema.lib.util.Helpers;
051:
052: /**
053: *
054: * @author ca@netbeans.org
055: */
056: public class SchemaMultiView {
057:
058: private TopComponentOperator m_opTopComponent;
059:
060: private JToggleButtonOperator m_opSchemaButton;
061: private JToggleButtonOperator m_opDesignButton;
062: private JToggleButtonOperator m_opSourceButton;
063:
064: private JToggleButtonOperator m_opColumnsButton;
065: private JToggleButtonOperator m_opTreeButton;
066:
067: private boolean m_bMacOS = true;
068:
069: /**
070: * Creates a new instance of SchemaMultiView
071: */
072: public SchemaMultiView(String strTopComponentName) {
073: m_opTopComponent = new TopComponentOperator(strTopComponentName);
074:
075: // On MacOS
076: JComponentOperator opToolbar = Helpers.getComponentOperator(
077: m_opTopComponent,
078: "org.netbeans.core.multiview.TabsComponent$TB", 0);
079:
080: // On Win/UNIX
081: if (opToolbar == null) {
082: opToolbar = Helpers.getComponentOperator(m_opTopComponent,
083: "javax.swing.JToolBar", 0);
084: m_bMacOS = false;
085: }
086:
087: JComponentOperator opSchemaViewToolbar = Helpers
088: .getComponentOperator(m_opTopComponent,
089: "javax.swing.JToolBar", m_bMacOS ? 0 : 1);
090:
091: m_opSchemaButton = new JToggleButtonOperator(opToolbar,
092: "Schema");
093: m_opDesignButton = new JToggleButtonOperator(opToolbar,
094: "Design");
095: m_opSourceButton = new JToggleButtonOperator(opToolbar,
096: "Source");
097:
098: switchToSchema();
099:
100: m_opColumnsButton = new JToggleButtonOperator(
101: opSchemaViewToolbar, 0);
102: m_opTreeButton = new JToggleButtonOperator(opSchemaViewToolbar,
103: 1);
104: }
105:
106: public TopComponentOperator getTopComponentOperator() {
107: return m_opTopComponent;
108: }
109:
110: public void switchToSchema() {
111: m_opSchemaButton.push();
112: Helpers.waitNoEvent();
113: }
114:
115: public void switchToDesign() {
116: m_opDesignButton.push();
117: Helpers.waitNoEvent();
118: }
119:
120: public void switchToSource() {
121: m_opSourceButton.push();
122: Helpers.waitNoEvent();
123: }
124:
125: public void switchToSchemaColumns() {
126: m_opColumnsButton.push();
127: Helpers.waitNoEvent();
128: }
129:
130: public void switchToSchemaTree() {
131: m_opTreeButton.push();
132: Helpers.waitNoEvent();
133: }
134:
135: public JListOperator getColumnListOperator(int column) {
136: JComponentOperator opComponent = Helpers
137: .getComponentOperator(
138: m_opTopComponent,
139: "org.netbeans.modules.xml.xam.ui.column.ColumnListView$ColumnList",
140: column, 200);
141: if (opComponent == null) {
142: return null;
143: }
144: JList list = (JList) opComponent.getSource();
145:
146: return new JListOperator(list);
147: }
148:
149: public void close() {
150: new SaveAllAction().performAPI();
151:
152: m_opTopComponent.close();
153: }
154: }
|