Source Code Cross Referenced for XQueryXPathTesterAction.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » actions » 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 » Web Services » soapui 1.7.5 » com.eviware.soapui.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.actions;
014:
015:        import java.awt.BorderLayout;
016:        import java.awt.Color;
017:        import java.awt.Dimension;
018:        import java.awt.event.ActionEvent;
019:        import java.lang.reflect.InvocationTargetException;
020:
021:        import javax.swing.AbstractAction;
022:        import javax.swing.Action;
023:        import javax.swing.BorderFactory;
024:        import javax.swing.JButton;
025:        import javax.swing.JComponent;
026:        import javax.swing.JDialog;
027:        import javax.swing.JLabel;
028:        import javax.swing.JPanel;
029:        import javax.swing.JScrollPane;
030:        import javax.swing.JSplitPane;
031:        import javax.swing.JTabbedPane;
032:        import javax.swing.JTextArea;
033:
034:        import org.apache.xmlbeans.XmlException;
035:        import org.apache.xmlbeans.XmlObject;
036:        import org.apache.xmlbeans.XmlOptions;
037:
038:        import com.eviware.soapui.SoapUI;
039:        import com.eviware.soapui.support.UISupport;
040:        import com.eviware.soapui.support.xml.JXEditTextArea;
041:        import com.eviware.soapui.support.xml.XmlUtils;
042:        import com.jgoodies.forms.builder.ButtonBarBuilder;
043:
044:        /**
045:         * Action for starting XQuery/XPath tester - not used for now..
046:         * 
047:         * @author Ole.Matzura
048:         */
049:
050:        public class XQueryXPathTesterAction extends AbstractAction {
051:            private JDialog dialog;
052:            private JSplitPane mainSplit;
053:            private JXEditTextArea resultArea;
054:            private JSplitPane querySplit;
055:            private JXEditTextArea inputArea;
056:            private JTextArea xqueryArea;
057:            private JTextArea xpathArea;
058:            private JTabbedPane queryTabs;
059:            private JLabel statusLabel;
060:
061:            public XQueryXPathTesterAction() {
062:                super ("XQuery/XPath Tester");
063:            }
064:
065:            public void actionPerformed(ActionEvent e) {
066:                if (dialog == null)
067:                    buildDialog();
068:
069:                dialog.setVisible(true);
070:            }
071:
072:            private void buildDialog() {
073:                JPanel panel = new JPanel(new BorderLayout());
074:                panel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
075:
076:                mainSplit = UISupport.createHorizontalSplit(createQueryPanel(),
077:                        createResultPanel());
078:                mainSplit.setResizeWeight(0.4);
079:                panel.add(mainSplit, BorderLayout.CENTER);
080:                panel.add(createStatusBar(), BorderLayout.SOUTH);
081:
082:                dialog = new JDialog(UISupport.getMainFrame(),
083:                        "XQuery / XPath Tester", false);
084:                dialog.getContentPane().add(panel, BorderLayout.CENTER);
085:                dialog.setPreferredSize(new Dimension(600, 400));
086:                dialog.pack();
087:
088:                mainSplit.setDividerLocation(0.5);
089:                querySplit.setDividerLocation(0.3);
090:            }
091:
092:            private JPanel createToolbar() {
093:                ButtonBarBuilder builder = new ButtonBarBuilder();
094:
095:                JButton runButton = UISupport
096:                        .createToolbarButton(new RunAction());
097:                builder.addFixed(runButton);
098:                builder.addRelatedGap();
099:                JButton declareNsButton = UISupport
100:                        .createToolbarButton(new DeclareNSAction());
101:                builder.addFixed(declareNsButton);
102:                builder.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
103:                return builder.getPanel();
104:            }
105:
106:            private JComponent createStatusBar() {
107:                JPanel panel = new JPanel(new BorderLayout());
108:                statusLabel = new JLabel();
109:                panel.add(statusLabel, BorderLayout.WEST);
110:                return panel;
111:            }
112:
113:            private JPanel createQueryPanel() {
114:                JPanel panel = new JPanel(new BorderLayout());
115:
116:                querySplit = UISupport.createVerticalSplit(buildQueryTabs(),
117:                        buildInputArea());
118:                querySplit.setBorder(null);
119:                querySplit.setResizeWeight(0.2);
120:                panel.add(querySplit, BorderLayout.CENTER);
121:
122:                return panel;
123:            }
124:
125:            private JComponent buildQueryTabs() {
126:                JPanel panel = new JPanel(new BorderLayout());
127:                panel.add(createToolbar(), BorderLayout.NORTH);
128:
129:                queryTabs = new JTabbedPane();
130:                queryTabs.addTab("XQuery query", buildXQueryArea());
131:                queryTabs.addTab("XPath query", buildXPathArea());
132:                queryTabs.setTabPlacement(JTabbedPane.BOTTOM);
133:
134:                panel.setBackground(Color.LIGHT_GRAY);
135:                panel.add(queryTabs, BorderLayout.CENTER);
136:                return panel;
137:            }
138:
139:            private JComponent buildXQueryArea() {
140:                xqueryArea = new JTextArea();
141:                return new JScrollPane(xqueryArea);
142:            }
143:
144:            private JComponent buildXPathArea() {
145:                xpathArea = new JTextArea();
146:                return new JScrollPane(xpathArea);
147:            }
148:
149:            private JComponent buildInputArea() {
150:                inputArea = JXEditTextArea.createXmlEditor();
151:                return inputArea;
152:            }
153:
154:            private JPanel createResultPanel() {
155:                JPanel panel = new JPanel(new BorderLayout());
156:
157:                resultArea = JXEditTextArea.createXmlEditor();
158:                panel.add(resultArea, BorderLayout.CENTER);
159:
160:                return panel;
161:            }
162:
163:            private class RunAction extends AbstractAction {
164:                public RunAction() {
165:                    putValue(Action.SMALL_ICON, UISupport
166:                            .createImageIcon("/submit_request.gif"));
167:                    putValue(Action.SHORT_DESCRIPTION, "Execute current query");
168:                    putValue(Action.ACCELERATOR_KEY, UISupport
169:                            .getKeyStroke("alt ENTER"));
170:                }
171:
172:                public void actionPerformed(ActionEvent e) {
173:                    try {
174:                        XmlObject xmlObject = XmlObject.Factory.parse(inputArea
175:                                .getText());
176:                        XmlObject[] objects;
177:
178:                        // xquery?
179:                        if (queryTabs.getSelectedIndex() == 0) {
180:                            objects = xmlObject.execQuery(xqueryArea.getText());
181:                        } else {
182:                            objects = xmlObject.selectPath(xpathArea.getText());
183:                        }
184:
185:                        StringBuffer result = new StringBuffer();
186:                        XmlOptions options = new XmlOptions();
187:                        options.setSaveOuter();
188:
189:                        for (int c = 0; c < objects.length; c++) {
190:
191:                            result.append(objects[c].xmlText(options));
192:                            result.append("\n");
193:                        }
194:
195:                        resultArea.setText(result.toString());
196:                        statusLabel.setText("Expression returned "
197:                                + objects.length + " hits");
198:                    } catch (Throwable e1) {
199:                        if (e1 instanceof  RuntimeException) {
200:                            e1 = ((RuntimeException) e1).getCause();
201:                            if (e1 instanceof  InvocationTargetException) {
202:                                e1 = ((InvocationTargetException) e1)
203:                                        .getTargetException();
204:                            }
205:                        }
206:
207:                        statusLabel.setText(e1.getMessage());
208:                    }
209:                }
210:            }
211:
212:            private class DeclareNSAction extends AbstractAction {
213:                public DeclareNSAction() {
214:                    putValue(Action.SMALL_ICON, UISupport
215:                            .createImageIcon("/declareNs.gif"));
216:                    putValue(Action.SHORT_DESCRIPTION,
217:                            "Declares namespaces in current input in xpath expression");
218:                }
219:
220:                public void actionPerformed(ActionEvent e) {
221:                    try {
222:                        String namespaceDeclarations = XmlUtils
223:                                .declareXPathNamespaces(inputArea.getText());
224:                        xpathArea.setText(namespaceDeclarations
225:                                + xpathArea.getText());
226:                        xqueryArea.setText(namespaceDeclarations
227:                                + xqueryArea.getText());
228:                    } catch (XmlException e1) {
229:                        SoapUI.logError(e1);
230:                    }
231:                }
232:            }
233:
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.