Source Code Cross Referenced for JSPFile.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » gravy » model » project » 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.model.project 
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.model.project;
043:
044:        import org.netbeans.modules.visualweb.gravy.RaveWindowOperator;
045:        import org.netbeans.modules.visualweb.gravy.EditorOperator;
046:        import org.netbeans.modules.visualweb.gravy.TestUtils;
047:
048:        import javax.swing.tree.TreePath;
049:        import java.util.ArrayList;
050:        import java.util.List;
051:
052:        import org.netbeans.jemmy.operators.JPopupMenuOperator;
053:        import org.netbeans.jemmy.TimeoutExpiredException;
054:
055:        /**
056:         * Class for JSP files.
057:         */
058:
059:        public class JSPFile extends SourceFile implements  ProjectEntry {
060:
061:            private final static String reformatCode = "Reformat Code";
062:
063:            WebPage webpage = null;
064:
065:            private EditorOperator editor = null;
066:
067:            /**
068:             * Parent of the jsp file.
069:             */
070:            protected ProjectEntry parent;
071:
072:            /**
073:             * Child project entries of the jsp file.
074:             */
075:            protected List childList = new ArrayList();
076:
077:            /**
078:             * Creates a new instance of web page.
079:             * @param path Path to web page in project.
080:             * @param name Name of web page.
081:             */
082:            JSPFile(TreePath path, String name, ProjectEntry parent) {
083:                super (path, name);
084:                setParent(parent);
085:            }
086:
087:            /**
088:             * Save project entry.
089:             */
090:            public void save() {
091:            }
092:
093:            /**
094:             * Save project entry as project entry with specified name.
095:             */
096:            public void saveAs(String name) {
097:            }
098:
099:            /**
100:             * @return Name of the project entry.
101:             */
102:            public String getName() {
103:                return name;
104:            }
105:
106:            /**
107:             * @return TreePath of the project entry.
108:             */
109:            public TreePath getTreePath() {
110:                return path;
111:            }
112:
113:            /**
114:             * @return Parent of the jsp file.
115:             */
116:            public ProjectEntry getParent() {
117:                return parent;
118:            }
119:
120:            /**
121:             * Set parent of the jsp file.
122:             */
123:            private void setParent(ProjectEntry parent) {
124:                this .parent = parent;
125:            }
126:
127:            /**
128:             * @return Child project entries of the jsp file.
129:             */
130:            public ProjectEntry[] getChildren() {
131:                return ((ProjectEntry[]) childList
132:                        .toArray(new ProjectEntry[childList.size()]));
133:            }
134:
135:            /**
136:             * Remove project entry.
137:             */
138:            public void delete() {
139:            }
140:
141:            /**
142:             * Open jsp file editor.
143:             */
144:            private void doOpenJSPEditor() {
145:                webpage.open();
146:                editor = webpage.page.getJSPEditor();
147:                editor.setVerification(false);
148:                editor.requestFocus();
149:            }
150:
151:            /**
152:             * Open jsp code of web page.
153:             */
154:            private EditorOperator openJSP() {
155:                long tmpTimeout = 0;
156:                try {
157:                    tmpTimeout = RaveWindowOperator.getDefaultRave()
158:                            .getTimeouts().getTimeout(
159:                                    "ComponentOperator.WaitComponentTimeout");
160:                    RaveWindowOperator.getDefaultRave().getTimeouts()
161:                            .setTimeout(
162:                                    "ComponentOperator.WaitComponentTimeout",
163:                                    5000);
164:                    if (editor == null) {
165:                        doOpenJSPEditor();
166:                    } else {
167:                        try {
168:                            editor.makeComponentVisible();
169:                        } catch (Exception e) {
170:                            throw new TimeoutExpiredException("");
171:                        }
172:                    }
173:                } catch (TimeoutExpiredException e) {
174:                    doOpenJSPEditor();
175:                } finally {
176:                    RaveWindowOperator.getDefaultRave().getTimeouts()
177:                            .setTimeout(
178:                                    "ComponentOperator.WaitComponentTimeout",
179:                                    tmpTimeout);
180:                }
181:                return editor;
182:            }
183:
184:            /**
185:             * Gets text from the currently opened jsp file of web page.
186:             * @return String representing whole content of the jsp file of web page.
187:             * (including new line characters)
188:             */
189:            public String getText() {
190:                editor = openJSP();
191:                return editor.getText();
192:            }
193:
194:            /**
195:             * Gets text from specified line.
196:             * @param lineNumber Number of line.
197:             * @return String representing content of the line.
198:             */
199:            public String getText(int lineNumber) {
200:                editor = openJSP();
201:                return editor.getText(lineNumber);
202:            }
203:
204:            /**
205:             * Checks if jsp file of web page contains text specified as parameter text.
206:             * @param text Text to compare to.
207:             * @return true if text was found, false otherwise.
208:             */
209:            public boolean contains(String text) {
210:                editor = openJSP();
211:                return editor.contains(text);
212:            }
213:
214:            /**
215:             * Replaces first occurence of oldText by newText.
216:             * @param oldText Text to be replaced.
217:             * @param newText Text to write instead.
218:             */
219:            public void replace(String oldText, String newText) {
220:                editor = openJSP();
221:                editor.replace(oldText, newText);
222:            }
223:
224:            /**
225:             * Replaced index-th occurence of oldText by newText.
226:             * @param oldText Text to be replaced
227:             * @param newText Text to write instead
228:             * @param index Index of oldText occurence.
229:             */
230:            public void replace(String oldText, String newText, int index) {
231:                editor = openJSP();
232:                editor.replace(oldText, newText, index);
233:            }
234:
235:            /**
236:             * Insert text to current position. 
237:             * @param text String to be inserted.
238:             */
239:            public void insert(String text) {
240:                editor = openJSP();
241:                editor.insert(text);
242:            }
243:
244:            /**
245:             * Inserts text to position specified by line number and column.
246:             * @param text String to be inserted.
247:             * @param lineNumber Number of line.
248:             * @param column Column position.
249:             */
250:            public void insert(String text, int lineNumber, int column) {
251:                editor = openJSP();
252:                editor.insert(text, lineNumber, column);
253:            }
254:
255:            /**
256:             * Deletes given number of characters from specified possition.
257:             * @param offset Position inside document.
258:             * @param length Number of characters to be deleted.
259:             */
260:            public void delete(int offset, int length) {
261:                editor = openJSP();
262:                editor.delete(offset, length);
263:            }
264:
265:            /**
266:             * Deletes given number of characters from current caret possition.
267:             * @param length Number of characters to be deleted.
268:             */
269:            public void delete(int length) {
270:                editor = openJSP();
271:                editor.delete(length);
272:            }
273:
274:            /**
275:             * Delete specified line.
276:             * @param line Number of line.
277:             */
278:            public void deleteLine(int line) {
279:                editor = openJSP();
280:                editor.deleteLine(line);
281:            }
282:
283:            /**
284:             * Deletes characters between column1 and column2 on the specified line.
285:             * @param lineNumber Number of line.
286:             * @param column1 Column position where to start deleting.
287:             * @param column2 Column position where to stop deleting.
288:             */
289:            public void delete(int lineNumber, int column1, int column2) {
290:                editor = openJSP();
291:                editor.delete(lineNumber, column1, column2);
292:            }
293:
294:            /**
295:             * Pushs key.
296:             * @param keyCode Key code (KeyEvent.VK_* value)
297:             * @param modifiers Modifiers (combination of InputEvent.*_MASK fields)
298:             */
299:            public void pushKey(int keyCode, int modifiers) {
300:                editor = openJSP();
301:                editor.pushKey(keyCode, modifiers);
302:            }
303:
304:            /**
305:             * Pushs key.
306:             * @param keyCode Key code (KeyEvent.VK_* value)
307:             */
308:            public void pushKey(int keyCode) {
309:                editor = openJSP();
310:                editor.pushKey(keyCode);
311:            }
312:
313:            /**
314:             * Get position of caret.
315:             * @return int Position of caret.
316:             */
317:            public int getCaretPosition() {
318:                editor = openJSP();
319:                return editor.txtEditorPane().getCaretPosition();
320:            }
321:
322:            /** 
323:             * Reformat code in JSP editor accordingly to specified rules.
324:             */
325:            public void reformatCode() {
326:                editor = openJSP();
327:                editor.txtEditorPane().clickForPopup();
328:                TestUtils.wait(1000);
329:                new JPopupMenuOperator().pushMenu(reformatCode);
330:                TestUtils.wait(1000);
331:            }
332:        }
w_w___w_.__j___a__v__a__2_s.___c___o__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.