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: /*
043: * Project.java
044: *
045: * Created on January 25, 2006, 1:37 PM
046: *
047: */
048:
049: package org.netbeans.test.umllib.project;
050:
051: import org.netbeans.jellytools.MainWindowOperator;
052: import org.netbeans.jellytools.nodes.Node;
053: import org.netbeans.jemmy.operators.JButtonOperator;
054: import org.netbeans.jemmy.operators.JDialogOperator;
055: import org.netbeans.jemmy.operators.JMenuBarOperator;
056: import org.netbeans.jemmy.operators.JTextFieldOperator;
057: import org.netbeans.test.umllib.exceptions.UMLCommonException;
058: import org.netbeans.test.umllib.util.Utils;
059:
060: /**
061: *
062: * @author Alexandr Scherbatiy
063: */
064: public abstract class Project {
065:
066: String name;
067: String location;
068: ProjectType type;
069:
070: /**
071: * Creates a new instance of Project
072: * @param name
073: * @param type
074: */
075: public Project(String name, ProjectType type) {
076: this (name, type, null);
077: }
078:
079: /**
080: *
081: * @param name
082: * @param type
083: * @param location
084: */
085: public Project(String name, ProjectType type, String location) {
086: this .name = name;
087: this .type = type;
088:
089: this .location = (location == null) ? Utils.WORK_DIR : location;
090: }
091:
092: /**
093: *
094: * @return
095: */
096: public String getName() {
097: return name;
098: }
099:
100: /**
101: *
102: * @return
103: */
104: public ProjectType getType() {
105: return type;
106: }
107:
108: /**
109: *
110: * @return
111: */
112: public String getLocation() {
113: return location;
114: }
115:
116: public abstract Node getProjectNode();
117:
118: public static void openProject(String projectPath) {
119: JMenuBarOperator menuBar = new JMenuBarOperator(
120: MainWindowOperator.getDefault());
121:
122: menuBar.pushMenuNoBlock("File|Open Project...");
123:
124: JDialogOperator dialog = new JDialogOperator("Open Project");
125:
126: JTextFieldOperator textField = new JTextFieldOperator(dialog, 1);
127: textField.setText(projectPath);
128:
129: JButtonOperator button = new JButtonOperator(dialog,
130: "Open Project");
131: try {
132: button.waitComponentEnabled();
133: } catch (InterruptedException ex) {
134: throw new UMLCommonException(
135: "Open project button is disabled");
136: }
137: button.pushNoBlock();
138: dialog.waitClosed();
139: try {
140: Thread.sleep(100);
141: } catch (Exception ex) {
142: }
143: JDialogOperator dlg = null;
144: try {
145: dlg = new JDialogOperator("Opening Project");
146: } catch (Exception ex) {
147:
148: }
149: if (dlg != null) {
150: dlg.waitClosed();
151: }
152: Utils.waitScanningClassPath();
153:
154: }
155:
156: }
|