01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08:
09: * 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.xslt.lib;
21:
22: import com.nwoods.jgo.JGoDocument;
23: import com.nwoods.jgo.JGoListPosition;
24: import com.nwoods.jgo.JGoObject;
25: import java.util.Iterator;
26: import java.util.List;
27: import org.netbeans.jemmy.ComponentChooser;
28: import org.netbeans.jemmy.JemmyProperties;
29: import org.netbeans.jemmy.Timeouts;
30: import org.netbeans.jemmy.Waitable;
31: import org.netbeans.jemmy.Waiter;
32: import org.netbeans.jemmy.operators.JComponentOperator;
33: import org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo.BasicCanvasView;
34: import org.netbeans.modules.soa.mapper.common.basicmapper.canvas.gtk.ICanvasMethoidNode;
35:
36: /**
37: *
38: * @author ca@netbeans.org
39: */
40:
41: public class CanvasOperator extends JComponentOperator {
42:
43: private BasicCanvasView m_canvasView;
44:
45: /** Creates a new instance of CanvasOperator */
46: public CanvasOperator(JComponentOperator opContainer) {
47: super (opContainer, new ComponentChooser() {
48: final String strClassName = "org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo.BasicCanvasView";
49:
50: public boolean checkComponent(java.awt.Component comp) {
51: return comp.getClass().toString().equals(
52: "class " + strClassName);
53: }
54:
55: public String getDescription() {
56: return strClassName;
57: }
58: });
59:
60: m_canvasView = (BasicCanvasView) getSource();
61: }
62:
63: public MethoidOperator findMethoid(String strName, int index) {
64: int counter = 0;
65:
66: List nodeList = m_canvasView.getNodes();
67: Iterator iterator = nodeList.iterator();
68:
69: while (iterator.hasNext()) {
70: Object jgoObj = iterator.next();
71:
72: if (!(jgoObj instanceof ICanvasMethoidNode)) {
73: continue;
74: }
75:
76: ICanvasMethoidNode methoidCanvasNode = (ICanvasMethoidNode) jgoObj;
77:
78: if (methoidCanvasNode.getTitle().equals(strName)) {
79: if (counter++ == index) {
80: return new MethoidOperator(methoidCanvasNode);
81: }
82: }
83: }
84:
85: return null;
86: }
87:
88: public void listCanvasObjects() {
89: List nodes = m_canvasView.getNodes();
90:
91: Iterator iter = nodes.iterator();
92:
93: while (iter.hasNext()) {
94: Object obj = iter.next();
95: Helpers.writeJemmyLog("Object: " + obj.toString());
96: }
97: }
98: }
|