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: package org.netbeans.jellytools.modules.javacvs;
042:
043: import org.netbeans.jellytools.Bundle;
044: import org.netbeans.jellytools.WizardOperator;
045: import org.netbeans.jellytools.modules.javacvs.actions.CheckoutAction;
046: import org.netbeans.jemmy.JemmyException;
047:
048: /** Class implementing all necessary methods for handling "Checkout" wizard.
049: * It is opened from main menu CVS|Checkout....
050: * <br>
051: * Usage:<br>
052: * <pre>
053: * CheckoutWizardOperator.invoke();
054: * CVSRootStepOperator cvsRootOper = new CVSRootStepOperator();
055: * cvsRootOper.setPassword("password");
056: * cvsRootOper.setCVSRoot(":pserver:user@host:repository");
057: * cvsRootOper.next();
058: * ModuleToCheckoutStepOperator moduleOper = new ModuleToCheckoutStepOperator();
059: * moduleOper.setModule("module");
060: * moduleOper.setBranch("branch");
061: * moduleOper.setLocalFolder("/tmp");
062: * moduleOper.finish();
063: * </pre>
064: *
065: * @see BrowseCVSModuleOperator
066: * @see BrowseTagsOperator
067: * @see CVSRootStepOperator
068: * @see EditCVSRootOperator
069: * @see ModuleToCheckoutStepOperator
070: * @see org.netbeans.jellytools.modules.javacvs.actions.CheckoutAction
071: * @author Jiri.Skrivanek@sun.com
072: */
073: public class CheckoutWizardOperator extends WizardOperator {
074:
075: /** Waits for dialog with "Checkout" title. */
076: public CheckoutWizardOperator() {
077: super (
078: Bundle
079: .getString(
080: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
081: "BK0007"));
082: }
083:
084: /** Invokes new wizard and returns instance of CheckoutWizardOperator.
085: * @return instance of CheckoutWizardOperator
086: */
087: public static CheckoutWizardOperator invoke() {
088: new CheckoutAction().perform();
089: return new CheckoutWizardOperator();
090: }
091:
092: //*****************************************
093: // High-level functionality definition part
094: //*****************************************
095:
096: /**
097: * Goes through the wizard and fill supplied parameter. Some of them can be
098: * null if not applicable or you want to use defaults.
099: * @param cvsRoot CVS root - must not be null
100: * @param password password - can be null
101: * @param module module name - can be null
102: * @param branch branch - can be null
103: * @param localFolder local folder path - can be null
104: */
105: public void doCheckout(String cvsRoot, String password,
106: String module, String branch, String localFolder) {
107: CheckoutWizardOperator.invoke();
108: CVSRootStepOperator cvsRootOper = new CVSRootStepOperator();
109: if (password != null) {
110: cvsRootOper.setPassword(password);
111: }
112: if (cvsRoot == null) {
113: throw new JemmyException("CVS root must not be null."); // NOI18N
114: }
115: cvsRootOper.setCVSRoot(cvsRoot);
116: cvsRootOper.next();
117: ModuleToCheckoutStepOperator moduleOper = new ModuleToCheckoutStepOperator();
118: if (module != null) {
119: moduleOper.setModule(module);
120: }
121: if (branch != null) {
122: moduleOper.setBranch(branch);
123: }
124: if (localFolder != null) {
125: moduleOper.setLocalFolder(localFolder);
126: }
127: moduleOper.finish();
128: }
129: }
|