Source Code Cross Referenced for SheetTableOperator.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » gravy » properties » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » visualweb.api.designer » org.netbeans.modules.visualweb.gravy.properties 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.modules.visualweb.gravy.properties;
043:
044:        import org.netbeans.modules.visualweb.gravy.TestUtils;
045:        import org.netbeans.modules.visualweb.gravy.Util;
046:        import java.awt.Component;
047:        import java.awt.event.KeyEvent;
048:        import java.awt.event.InputEvent;
049:        import java.util.*;
050:        import java.util.List;
051:        import java.lang.reflect.*;
052:        import javax.swing.*;
053:        import javax.swing.table.TableCellRenderer;
054:        import org.netbeans.jemmy.ComponentChooser;
055:        import org.netbeans.jemmy.drivers.DriverManager;
056:        import org.netbeans.jemmy.operators.JComboBoxOperator;
057:        import org.netbeans.jemmy.operators.JTableOperator;
058:        import org.netbeans.jemmy.operators.JTextComponentOperator;
059:        import org.netbeans.jemmy.operators.*;
060:        import org.netbeans.jemmy.*;
061:        import org.netbeans.jellytools.Bundle;
062:
063:        import org.openide.explorer.propertysheet.InplaceEditor;
064:
065:        /**
066:         * Class represented sheet of properties.
067:         */
068:        public class SheetTableOperator extends JTableOperator {
069:
070:            /**
071:             * Look for SheetTable in main window.
072:             */
073:            public SheetTableOperator() {
074:                super (Util.getMainWindow(), new SheetTableChooser());
075:            }
076:
077:            /**
078:             * Look for SheetTable in specified container.
079:             * @param container Container where SheetTable is looked for.
080:             */
081:            public SheetTableOperator(ContainerOperator container) {
082:                super (container, new SheetTableChooser());
083:            }
084:
085:            /**
086:             * Set comparison style.
087:             * @param compareExactly Make comparison by exact match. If false, comparison is made by entry.
088:             * @param caseSensitive Make case sensitive comparison.
089:             */
090:            public void setCompareStyle(boolean compareExactly,
091:                    boolean caseSensitive) {
092:                setComparator(new DefaultStringComparator(compareExactly,
093:                        caseSensitive));
094:            }
095:
096:            /**
097:             * Find row for specified property in this SheetTable.
098:             * @param propName Name of the property.
099:             */
100:            private int findRow(String propName) {
101:                return findCell(new PropertyCellChooser(propName), null,
102:                        new int[] { 0 }, 0).y;
103:            }
104:
105:            /**
106:             * Click on row for specified property in this SheetTable.
107:             * @param propName Name of the property.
108:             */
109:            public void clickCell(String propName) {
110:                clickOnCell(findRow(propName), 1);
111:                //TODO need second click to let component exit from inline editing mode
112:                clickOnCell(findRow(propName), 1);
113:            }
114:
115:            /**
116:             * Make row for specified property editable.
117:             * @param propName Name of the property.
118:             */
119:            public void startEditing(String propName) {
120:                //clicknCell(findRow(propName), 1);
121:                clickCell(propName);
122:                pushKey(KeyEvent.VK_SPACE);
123:            }
124:
125:            /**
126:             * Push dotten button in row for specified property.
127:             * @param propName Name of the property.
128:             */
129:            public void pushDotted(String propName) {
130:                clickOnCell(findRow(propName), 0);
131:                TestUtils.wait(2000);
132:                pushKey(KeyEvent.VK_SPACE, InputEvent.CTRL_MASK);
133:            }
134:
135:            /**
136:             * Get value of specified property.
137:             * @param propName Name of the property.
138:             * @return String Value of specified property.
139:             */
140:            public String getValue(String propName) {
141:                return (((InplaceEditor) getRenderedComponent(
142:                        findRow(propName), 1)).getValue().toString());
143:            }
144:
145:            /**
146:             * Set value of specified property.
147:             * @param propName Name of the property.
148:             * @param value Value for specified property.
149:             */
150:            public void setValue(String propName, String value) {
151:                int row = findRow(propName);
152:                //((InplaceEditor)getRenderedComponent(row, 1)).setValue(value);
153:                System.out.println("Class: "
154:                        + ((InplaceEditor) getRenderedComponent(row, 1))
155:                                .getClass());
156:            }
157:
158:            /**
159:             * Set value of specified property with Text Component.
160:             * @param propName Name of the property.
161:             * @param value Value for specified property.
162:             */
163:            public void setTextValue(String propName, String value) {
164:                startEditing(propName);
165:                new JTextComponentOperator(this ).enterText(value);
166:                Util.wait(500);
167:            }
168:
169:            /**
170:             * Set value of specified property where is a button for call dialog for set value.
171:             * @param propName Name of the property.
172:             * @param value Value for specified property.
173:             */
174:            public void setButtonValue(String propName, String value) {
175:                clickForEdit(findCell(propName, 2).y, 1);
176:                //second click added to let component exit from inline editing mode
177:                clickForEdit(findCell(propName, 2).y, 1);
178:                new JTextComponentOperator(this ).enterText(value);
179:            }
180:
181:            /**
182:             * Set value of specified property with ComboBox.
183:             * @param propName Name of the property.
184:             * @param value Value for specified property.
185:             */
186:            public void setComboBoxValue(String propName, String value) {
187:                clickOnCell(findRow(propName), 1);
188:                new JComboBoxOperator(this ).selectItem(value);
189:            }
190:
191:            /**
192:             * Set value of specified property with CheckBox.
193:             * @param propName Name of the property.
194:             * @param value Value for specified property.
195:             */
196:            public void setCheckBoxValue(String propName, String value) {
197:                if (!getValue(propName).equals(value))
198:                    switchCheckBox(propName);
199:            }
200:
201:            /**
202:             * Switch value of CheckBox for specified property.
203:             * @param propName Name of the property.
204:             */
205:            public void switchCheckBox(String propName) {
206:                clickOnCell(findRow(propName), 1);
207:            }
208:
209:            /**
210:             * Set image 
211:             * @param componentID ID of component.
212:             * @param propertyName url for image component and imageURL for imagehyperlink component.
213:             * @param imagePath Path to image.
214:             */
215:            public void setImage(String componentID, String propertyName,
216:                    String imagePath) {
217:                pushDotted(propertyName);
218:                JDialogOperator dialog1 = new JDialogOperator(componentID);
219:                new JButtonOperator(dialog1, Bundle.getStringTrimmed(
220:                        "org.netbeans.modules.visualweb.gravy.Bundle",
221:                        "PropertySheet_AddFile")).pushNoBlock();
222:                JDialogOperator dialog2 = new JDialogOperator(Bundle
223:                        .getStringTrimmed(
224:                                "org.netbeans.modules.visualweb.gravy.Bundle",
225:                                "PropertySheet_AddFile"));
226:                new JTextFieldOperator(dialog2, 0).setText(imagePath);
227:                Util.wait(1000);
228:                new JButtonOperator(dialog2, Bundle.getStringTrimmed(
229:                        "org.netbeans.modules.visualweb.gravy.Bundle",
230:                        "PropertySheet_AddFile")).pushNoBlock();
231:                dialog2.waitClosed();
232:                Util.wait(1000);
233:                new JButtonOperator(dialog1, "OK").pushNoBlock();
234:                dialog1.waitClosed();
235:            }
236:
237:            /**
238:             * Set specified value of specified property with ComboBox.
239:             * @param propName Name of the property.
240:             * @param item Item for specified property.
241:             */
242:            public void selectCombo(String propName, final String item) {
243:                int row = findRow(propName);
244:                //        ((InplaceEditor)getRenderedComponent(row, 1)).setValue(value);
245:                //        JComboBoxOperator combo = new JComboBoxOperator(((JComboBox)getRenderedComponent(row, 1)));
246:                //        combo.setVerification(false);
247:                //        combo.selectItem(item);
248:            }
249:
250:            /** 
251:             * Get current component's id 
252:             */
253:            public String getSelectedComponentID() {
254:                setCompareStyle(true, true);
255:                String id = getValue("id");
256:                return id;
257:            }
258:
259:            /**
260:             * Prints all properties from propertysheet to string
261:             * @return String with names and values
262:             */
263:            public String printAllProperties() {
264:                String output = "";
265:
266:                for (int row = 0; row < getRowCount(); row++) {
267:
268:                    Object currentValue = null;
269:                    String currentStringValue = "";
270:                    String currentName = "";
271:                    Object renderedComponent = null;
272:
273:                    currentName = ((JLabel) getRenderedComponent(row, 0))
274:                            .getText();
275:
276:                    try {
277:                        renderedComponent = getRenderedComponent(row, 1);
278:                        currentValue = ((InplaceEditor) renderedComponent)
279:                                .getValue();
280:
281:                        try {
282:                            currentStringValue = (String) currentValue;
283:                        } catch (ClassCastException e) {
284:                            currentStringValue = "Can't cast class "
285:                                    + currentValue.getClass().getName()
286:                                    + " to String. toString returns: \""
287:                                    + currentValue.toString() + "\"";
288:                        }
289:
290:                    } catch (ClassCastException e) {
291:                        if (renderedComponent instanceof  TableCellRenderer) {
292:                            currentStringValue = "$TableCellRenderer";
293:                        } else {
294:                            currentStringValue = "Can't cast class "
295:                                    + renderedComponent.getClass().getName()
296:                                    + " to InplaceEditor.";
297:                        }
298:                    }
299:
300:                    output += "Property: " + currentName + "; Value: "
301:                            + currentStringValue + "\r\n";
302:                } // for
303:
304:                return output;
305:            }
306:
307:            /**
308:             * Open SheetTable.
309:             * @return Opened SheetTable.
310:             */
311:            public static SheetTableOperator createInstance() {
312:                Util.getMainMenu().pushMenuNoBlock("Window|Properties"); // show if hidden (collapse if already shown)
313:
314:                SheetTableOperator props = new SheetTableOperator();
315:                int propsCnt = props.getRowCount();
316:                Util.getMainMenu().pushMenuNoBlock("Window|Properties"); // toggle expansion
317:                if (propsCnt > props.getRowCount()) {
318:                    Util.getMainMenu().pushMenuNoBlock("Window|Properties"); // toggle expansion another time if was collapsed
319:                }
320:
321:                return props;
322:            }
323:
324:            protected static class PropertyCellChooser implements 
325:                    JTableOperator.TableCellChooser {
326:                String text;
327:
328:                public PropertyCellChooser(String text) {
329:                    this .text = text;
330:                }
331:
332:                public boolean checkCell(JTableOperator oper, int row,
333:                        int column) {
334:                    JLabel label = (JLabel) oper.getRenderedComponent(row,
335:                            column);
336:                    return (label != null && oper.getComparator().equals(
337:                            label.getText(), text));
338:                }
339:
340:                public String getDescription() {
341:                    return (text + " property");
342:                }
343:            }
344:
345:            static class SheetTableChooser implements  ComponentChooser {
346:                public SheetTableChooser() {
347:                }
348:
349:                public boolean checkComponent(Component comp) {
350:                    return (comp.getClass().getName()
351:                            .equals("org.openide.explorer.propertysheet.SheetTable"));
352:                }
353:
354:                public String getDescription() {
355:                    return ("org.openide.explorer.propertysheet.SheetTable");
356:                }
357:            }
358:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.