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.NbDialogOperator;
045: import org.netbeans.jellytools.modules.javacvs.actions.MergeAction;
046: import org.netbeans.jellytools.nodes.Node;
047: import org.netbeans.jemmy.operators.JButtonOperator;
048: import org.netbeans.jemmy.operators.JCheckBoxOperator;
049: import org.netbeans.jemmy.operators.JLabelOperator;
050: import org.netbeans.jemmy.operators.JRadioButtonOperator;
051: import org.netbeans.jemmy.operators.JTextFieldOperator;
052:
053: /** Class implementing all necessary methods for handling "Merge Changes from Branch"
054: * dialog. It is opened from main menu or from popup on versioned file.
055: * <br>
056: * Usage:<br>
057: * <pre>
058: * Node node = new Node(new SourcePackagesNode("MyProject"), "mypackage|MyFile");
059: * MergeChangesFromBranchOperator mcfbo = MergeChangesFromBranchOperator.invoke(node);
060: * mcfbo.mergeFromTag();
061: * BrowseTagsOperator bto = mcfbo.browseStartingFromTag();
062: * bto.selectPath("HEAD");
063: * bto.ok();
064: * // or mcfbo.setStartingFromTag("mytag");
065: * mcfbo.mergeUntilBranchHead();
066: * bto = mcfbo.browseBranchHead();
067: * bto.selectBranch("mybranch");
068: * bto.ok();
069: * // or mcfbo.setBranchHead("myBranch");
070: * mcfbo.mergeUntilTag();
071: * bto = mcfbo.browseUntilTag();
072: * bto.selectTag("myTag");
073: * bto.ok();
074: * // or mcfbo.setUntilTag("myTag");
075: * mcfbo.mergeTrunkHead();
076: * mcfbo.checkTagAfterMerge(true);
077: * bto = mcfbo.browseTagName();
078: * bto.selectTag("mytag");
079: * bto.ok();
080: * // or mcfbo.setTagName("myTagAfterMerge");
081: * mcfbo.merge();
082: * </pre>
083: *
084: * @see BrowseTagsOperator
085: * @see org.netbeans.jellytools.modules.javacvs.actions.MergeAction
086: *
087: * @author Jiri.Skrivanek@sun.com
088: */
089: public class MergeChangesFromBranchOperator extends NbDialogOperator {
090:
091: /** Waits for dialog with "Merge Changes from Branch" title. */
092: public MergeChangesFromBranchOperator() {
093: super (
094: Bundle
095: .getStringTrimmed(
096: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
097: "CTL_MergeBranchDialog_Title"));
098: }
099:
100: /** Selects nodes and call merge action on them.
101: * @param nodes an array of nodes
102: * @return MergeChangesFromBranchOperator instance
103: */
104: public static MergeChangesFromBranchOperator invoke(Node[] nodes) {
105: new MergeAction().perform(nodes);
106: return new MergeChangesFromBranchOperator();
107: }
108:
109: /** Selects node and call merge action on it.
110: * @param node node to be selected
111: * @return MergeChangesFromBranchOperator instance
112: */
113: public static MergeChangesFromBranchOperator invoke(Node node) {
114: return invoke(new Node[] { node });
115: }
116:
117: private JLabelOperator _lblWorkingBranch;
118: private JTextFieldOperator _txtWorkingBranch;
119: private JRadioButtonOperator _rbBranchingPoint;
120: private JRadioButtonOperator _rbStartingFromTag;
121: private JTextFieldOperator _txtStartingFromTag;
122: private JButtonOperator _btBrowseStartingFromTag;
123: private JRadioButtonOperator _rbTrunkHead;
124: private JRadioButtonOperator _rbBranchHead;
125: private JTextFieldOperator _txtBranchHead;
126: private JButtonOperator _btBrowseBranchHead;
127: private JRadioButtonOperator _rbUntilTag;
128: private JTextFieldOperator _txtTagName;
129: private JTextFieldOperator _txtUntilTag;
130: private JButtonOperator _btBrowseUntilTag;
131: private JCheckBoxOperator _cbTagAfterMerge;
132: private JButtonOperator _btBrowseTagName;
133: private JButtonOperator _btMerge;
134:
135: //******************************
136: // Subcomponents definition part
137: //******************************
138:
139: /** Tries to find "Merge Changes Into Working Branch:" JLabel in this dialog.
140: * @return JLabelOperator
141: */
142: public JLabelOperator lblWorkingBranch() {
143: if (_lblWorkingBranch == null) {
144: _lblWorkingBranch = new JLabelOperator(
145: this ,
146: Bundle
147: .getStringTrimmed(
148: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
149: "MergePanel.jLabel1.text"));
150: }
151: return _lblWorkingBranch;
152: }
153:
154: /** Tries to find "Merge Changes Into Working Branch:" JTextField in this dialog.
155: * @return JTextFieldOperator
156: */
157: public JTextFieldOperator txtWorkingBranch() {
158: if (_txtWorkingBranch == null) {
159: _txtWorkingBranch = new JTextFieldOperator(this , 1);
160: }
161: return _txtWorkingBranch;
162: }
163:
164: /** Tries to find "Branching Point / Branch Root" JRadioButton in this dialog.
165: * @return Branching Point / Branch Root JRadioButtonOperator
166: */
167: public JRadioButtonOperator rbBranchingPoint() {
168: if (_rbBranchingPoint == null) {
169: _rbBranchingPoint = new JRadioButtonOperator(
170: this ,
171: Bundle
172: .getStringTrimmed(
173: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
174: "MergePanel.rbFromBranchRoot.text"));
175: }
176: return _rbBranchingPoint;
177: }
178:
179: /** Tries to find "Tag / Revision" JRadioButton in Starting From section of this dialog.
180: * @return "Tag / Revision" JRadioButtonOperator
181: */
182: public JRadioButtonOperator rbStartingFromTag() {
183: if (_rbStartingFromTag == null) {
184: _rbStartingFromTag = new JRadioButtonOperator(
185: this ,
186: Bundle
187: .getStringTrimmed(
188: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
189: "MergePanel.rbFromTag.text"));
190: }
191: return _rbStartingFromTag;
192: }
193:
194: /** Tries to find "Tag / Revision" JTextField in in Starting From section of this dialog.
195: * @return "Tag / Revision" JTextFieldOperator
196: */
197: public JTextFieldOperator txtStartingFromTag() {
198: if (_txtStartingFromTag == null) {
199: _txtStartingFromTag = new JTextFieldOperator(this , 2);
200: }
201: return _txtStartingFromTag;
202: }
203:
204: /** Tries to find "Browse..." JButton in in Starting From section of this dialog.
205: * @return JButtonOperator
206: */
207: public JButtonOperator btBrowseStartingFromTag() {
208: if (_btBrowseStartingFromTag == null) {
209: _btBrowseStartingFromTag = new JButtonOperator(
210: this ,
211: Bundle
212: .getStringTrimmed(
213: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
214: "CTL_MergeBranchForm_Browse"), 1);
215: }
216: return _btBrowseStartingFromTag;
217: }
218:
219: /** Tries to find "Trunk HEAD" JRadioButton in Until section of this dialog.
220: * @return "Trunk HEAD" JRadioButtonOperator
221: */
222: public JRadioButtonOperator rbTrunkHead() {
223: if (_rbTrunkHead == null) {
224: _rbTrunkHead = new JRadioButtonOperator(
225: this ,
226: Bundle
227: .getStringTrimmed(
228: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
229: "MergePanel.rbToHEAD.text"));
230: }
231: return _rbTrunkHead;
232: }
233:
234: /** Tries to find "Branch Head" JRadioButton in Until section of this dialog.
235: * @return "Branch Head" JRadioButtonOperator
236: */
237: public JRadioButtonOperator rbBranchHead() {
238: if (_rbBranchHead == null) {
239: _rbBranchHead = new JRadioButtonOperator(
240: this ,
241: Bundle
242: .getStringTrimmed(
243: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
244: "MergePanel.rbToBranchHead.text"));
245: }
246: return _rbBranchHead;
247: }
248:
249: /** Tries to find "Branch Head" JTextField in in Until section of this dialog.
250: * @return "Branch Head" JTextFieldOperator
251: */
252: public JTextFieldOperator txtBranchHead() {
253: if (_txtBranchHead == null) {
254: _txtBranchHead = new JTextFieldOperator(this , 4);
255: }
256: return _txtBranchHead;
257: }
258:
259: /** Tries to find "Browse..." JButton in Until Branch Head section of this dialog.
260: * @return JButtonOperator
261: */
262: public JButtonOperator btBrowseBranchHead() {
263: if (_btBrowseBranchHead == null) {
264: _btBrowseBranchHead = new JButtonOperator(
265: this ,
266: Bundle
267: .getStringTrimmed(
268: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
269: "CTL_MergeBranchForm_Browse"), 2);
270: }
271: return _btBrowseBranchHead;
272: }
273:
274: /** Tries to find "Tag / Revision" JRadioButton in Until section of this dialog.
275: * @return "Tag / Revision" JRadioButtonOperator
276: */
277: public JRadioButtonOperator rbUntilTag() {
278: if (_rbUntilTag == null) {
279: _rbUntilTag = new JRadioButtonOperator(
280: this ,
281: Bundle
282: .getStringTrimmed(
283: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
284: "MergePanel.rbToTag.text"), 1);
285: }
286: return _rbUntilTag;
287: }
288:
289: /** Tries to find "Tag Name" JTextField in this dialog.
290: * @return "Tag Name" JTextFieldOperator
291: */
292: public JTextFieldOperator txtTagName() {
293: if (_txtTagName == null) {
294: _txtTagName = new JTextFieldOperator(this , 0);
295: }
296: return _txtTagName;
297: }
298:
299: /** Tries to find "Tag / Revision" JTextField in Until section of this dialog.
300: * @return JTextFieldOperator
301: */
302: public JTextFieldOperator txtUntilTag() {
303: if (_txtUntilTag == null) {
304: _txtUntilTag = new JTextFieldOperator(this , 3);
305: }
306: return _txtUntilTag;
307: }
308:
309: /** Tries to find "Browse..." JButton in this dialog.
310: * @return JButtonOperator
311: */
312: public JButtonOperator btBrowseUntilTag() {
313: if (_btBrowseUntilTag == null) {
314: _btBrowseUntilTag = new JButtonOperator(
315: this ,
316: Bundle
317: .getStringTrimmed(
318: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
319: "CTL_MergeBranchForm_Browse"), 3);
320: }
321: return _btBrowseUntilTag;
322: }
323:
324: /** Tries to find "Tag "branch_name" after Merge" JCheckBox in this dialog.
325: * @return JCheckBoxOperator
326: */
327: public JCheckBoxOperator cbTagAfterMerge() {
328: if (_cbTagAfterMerge == null) {
329: _cbTagAfterMerge = new JCheckBoxOperator(this );
330: }
331: return _cbTagAfterMerge;
332: }
333:
334: /** Tries to find "Browse..." JButton in this dialog.
335: * @return JButtonOperator
336: */
337: public JButtonOperator btBrowseTagName() {
338: if (_btBrowseTagName == null) {
339: _btBrowseTagName = new JButtonOperator(
340: this ,
341: Bundle
342: .getStringTrimmed(
343: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
344: "MergePanel.browseAfterMergeTag.text"),
345: 0);
346: }
347: return _btBrowseTagName;
348: }
349:
350: /** Tries to find "Merge" JButton in this dialog.
351: * @return JButtonOperator
352: */
353: public JButtonOperator btMerge() {
354: if (_btMerge == null) {
355: _btMerge = new JButtonOperator(
356: this ,
357: Bundle
358: .getStringTrimmed(
359: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
360: "CTL_MergeBranchDialog_Action_Merge"));
361: }
362: return _btMerge;
363: }
364:
365: //****************************************
366: // Low-level functionality definition part
367: //****************************************
368:
369: /** Gets working branch name.
370: * @return Working branch name.
371: */
372: public String getWorkingBranch() {
373: return txtWorkingBranch().getText();
374: }
375:
376: /** clicks on "Branching Point" JRadioButton
377: */
378: public void mergeFromBranchingPoint() {
379: rbBranchingPoint().push();
380: }
381:
382: /** clicks on "Tag / Revision" JRadioButton in Starting From Section
383: */
384: public void mergeFromTag() {
385: rbStartingFromTag().push();
386: }
387:
388: /** clicks on "Trunk HEAD" JRadioButton in Until section
389: */
390: public void mergeTrunkHead() {
391: rbTrunkHead().push();
392: }
393:
394: /** clicks on "Branch Head" JRadioButton in Until section. */
395: public void mergeUntilBranchHead() {
396: rbBranchHead().push();
397: }
398:
399: /** clicks on "Tag / Revision" JRadioButton in Until section. */
400: public void mergeUntilTag() {
401: rbUntilTag().push();
402: }
403:
404: /** gets text for "Tag / Revision" in Starting From Section
405: * @return String text
406: */
407: public String getStartingFromTag() {
408: return txtStartingFromTag().getText();
409: }
410:
411: /** sets text for "Tag / Revision" in Starting From Section
412: * @param text String text
413: */
414: public void setStartingFromTag(String text) {
415: txtStartingFromTag().setText(text);
416: }
417:
418: /** clicks on "Browse..." JButton and returns BrowseTagsOperator
419: * @return BrowseTagsOperator instance
420: */
421: public BrowseTagsOperator browseStartingFromTag() {
422: btBrowseStartingFromTag().pushNoBlock();
423: return new BrowseTagsOperator();
424: }
425:
426: /** gets text for "Branch Head" in Until section
427: * @return String text
428: */
429: public String getBrancHead() {
430: return txtBranchHead().getText();
431: }
432:
433: /** sets text for "Branch Head" in Until section
434: * @param text String text
435: */
436: public void setBranchHead(String text) {
437: txtBranchHead().setText(text);
438: }
439:
440: /** clicks on "Browse..." JButton Branch Head and returns BrowseTagsOperator
441: * @return BrowseTagsOperator instance
442: */
443: public BrowseTagsOperator browseBranchHead() {
444: btBrowseBranchHead().pushNoBlock();
445: return new BrowseTagsOperator();
446: }
447:
448: /** gets text for "Tag / Revision" in Until section
449: * @return String text
450: */
451: public String getUntilTag() {
452: return txtUntilTag().getText();
453: }
454:
455: /** sets text for "Tag / Revision" in Until section
456: * @param text String text
457: */
458: public void setUntilTag(String text) {
459: txtUntilTag().setText(text);
460: }
461:
462: /** clicks on "Browse..." JButton "Until Tag / Revision" and returns BrowseTagsOperator
463: * @return BrowseTagsOperator instance
464: */
465: public BrowseTagsOperator browseUntilTag() {
466: btBrowseUntilTag().pushNoBlock();
467: return new BrowseTagsOperator();
468: }
469:
470: /** checks or unchecks "Tag After Merge" checkbox
471: * @param state boolean requested state
472: */
473: public void checkTagAfterMerge(boolean state) {
474: if (cbTagAfterMerge().isSelected() != state) {
475: cbTagAfterMerge().push();
476: }
477: }
478:
479: /** Sets text for "Tag Name" text field.
480: * @param text text
481: */
482: public void setTagName(String text) {
483: txtTagName().setText(text);
484: }
485:
486: /** clicks on "Browse..." JButton and returns BrowseTagsOperator
487: * @return BrowseTagsOperator instance
488: */
489: public BrowseTagsOperator browseTagName() {
490: btBrowseTagName().pushNoBlock();
491: return new BrowseTagsOperator();
492: }
493:
494: /** clicks on "Merge" JButton
495: */
496: public void merge() {
497: btMerge().push();
498: }
499:
500: //*****************************************
501: // High-level functionality definition part
502: //*****************************************
503:
504: /**
505: * Performs verification of MergeChangesFromBranchOperator by accessing all its components.
506: */
507: public void verify() {
508: lblWorkingBranch();
509: txtWorkingBranch();
510: rbBranchingPoint();
511: rbStartingFromTag();
512: txtStartingFromTag();
513: btBrowseStartingFromTag();
514: txtUntilTag();
515: btBrowseUntilTag();
516: cbTagAfterMerge();
517: btBrowseTagName();
518: btMerge();
519: }
520: }
|