Source Code Cross Referenced for SwingXFormImpl.java in  » Web-Services » soapui-1.7.5 » com » eviware » x » impl » swing » 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.x.impl.swing 
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.x.impl.swing;
014:
015:        import java.util.HashMap;
016:        import java.util.Iterator;
017:        import java.util.Map;
018:
019:        import javax.swing.BorderFactory;
020:        import javax.swing.JLabel;
021:        import javax.swing.JPanel;
022:        import javax.swing.JSeparator;
023:        import javax.swing.border.Border;
024:
025:        import com.eviware.soapui.impl.wsdl.actions.iface.tools.support.NamespaceTable;
026:        import com.eviware.soapui.model.iface.Interface;
027:        import com.eviware.soapui.support.types.StringToStringMap;
028:        import com.eviware.x.form.XForm;
029:        import com.eviware.x.form.XFormField;
030:        import com.eviware.x.form.XFormOptionsField;
031:        import com.eviware.x.form.XFormTextField;
032:        import com.jgoodies.forms.layout.CellConstraints;
033:        import com.jgoodies.forms.layout.FormLayout;
034:        import com.jgoodies.forms.layout.RowSpec;
035:
036:        public class SwingXFormImpl implements  XForm {
037:            private JPanel panel;
038:            private CellConstraints cc = new CellConstraints();
039:            private FormLayout layout;
040:            private RowSpec rowSpec;
041:            private int rowSpacing = 5;
042:            private Map<String, XFormField> components = new HashMap<String, XFormField>();
043:            private String rowAlignment = "top";
044:            private String name;
045:
046:            public SwingXFormImpl(String name) {
047:                this .name = name;
048:                layout = new FormLayout(
049:                        "5px,right:pref,5px,left:default,5px:grow(1.0)");
050:                panel = new JPanel(layout);
051:                rowSpec = new RowSpec(rowAlignment + ":pref");
052:            }
053:
054:            public String getName() {
055:                return name;
056:            }
057:
058:            public void setName(String name) {
059:                this .name = name;
060:            }
061:
062:            public JPanel getPanel() {
063:                return panel;
064:            }
065:
066:            public void addSpace(int size) {
067:                if (size > 0)
068:                    layout.appendRow(new RowSpec(size + "px"));
069:            }
070:
071:            public XFormField addCheckBox(String name, String description) {
072:                JCheckBoxFormField checkBox = new JCheckBoxFormField(
073:                        description == null ? name : description);
074:                addComponent(name, checkBox);
075:                return checkBox;
076:            }
077:
078:            public XFormField addComponent(String label,
079:                    XFormField formComponent) {
080:                components.put(label, formComponent);
081:
082:                if (rowSpacing > 0 && !components.isEmpty())
083:                    addSpace(rowSpacing);
084:
085:                layout.appendRow(rowSpec);
086:
087:                int row = layout.getRowCount();
088:
089:                AbstractSwingXFormField swingFormComponent = (AbstractSwingXFormField) formComponent;
090:
091:                if (label != null) {
092:                    JLabel jlabel = new JLabel(label);
093:                    jlabel.setBorder(BorderFactory
094:                            .createEmptyBorder(2, 0, 0, 0));
095:                    panel.add(jlabel, cc.xy(2, row));
096:                }
097:
098:                panel.add(swingFormComponent.getComponent(), cc.xy(4, row));
099:                components.put(label, formComponent);
100:
101:                return formComponent;
102:            }
103:
104:            public XFormOptionsField addComboBox(String name, Object[] values,
105:                    String description) {
106:                JComboBoxFormField comboBox = new JComboBoxFormField(values);
107:                comboBox.setToolTip(description);
108:                addComponent(name, comboBox);
109:                return comboBox;
110:            }
111:
112:            //   public <T extends ModelItem> XFormOptionsField addComboBox( String name, Object [] values, String description,
113:            //         final T target, final SoapUIAction<T> action  )
114:            //   {
115:            //      // TODO Not implemented for Swing
116:            //      return null;
117:            //   }
118:
119:            public void addSeparator() {
120:                addSeparator(null);
121:            }
122:
123:            public void addSeparator(String label) {
124:                addSpace(rowSpacing);
125:
126:                layout.appendRow(rowSpec);
127:                int row = layout.getRowCount();
128:
129:                if (label == null)
130:                    panel.add(new JSeparator(), cc.xywh(2, row, 3, 1));
131:                else
132:                    panel.add(new JLabel(label), cc.xywh(2, row, 3, 1));
133:            }
134:
135:            public XFormTextField addTextField(String name, String description,
136:                    FieldType type) {
137:                if (type == FieldType.FOLDER || type == FieldType.FILE
138:                        || type == FieldType.PROJECT_FOLDER
139:                        || type == FieldType.PROJECT_FILE) {
140:                    return (XFormTextField) addComponent(name,
141:                            new FileFormField(description, type));
142:                } else if (type == FieldType.PASSWORD) {
143:                    JPasswordFieldFormField pwdField = new JPasswordFieldFormField();
144:                    pwdField.getComponent().setColumns(30);
145:                    pwdField.setToolTip(description);
146:                    addComponent(name, pwdField);
147:                    return pwdField;
148:                } else if (type == FieldType.TEXTAREA) {
149:                    JTextAreaFormField field = new JTextAreaFormField();
150:                    field.getTextArea().setColumns(40);
151:                    field.getTextArea().setRows(5);
152:                    field.setToolTip(description);
153:                    addComponent(name, field);
154:                    return field;
155:                } else {
156:                    JTextFieldFormField textField = new JTextFieldFormField();
157:                    textField.getComponent().setColumns(40);
158:                    textField.setToolTip(description);
159:                    addComponent(name, textField);
160:                    return textField;
161:                }
162:            }
163:
164:            public void setComponentValue(String label, String value) {
165:                XFormField component = getComponent(label);
166:                if (component != null)
167:                    component.setValue(value);
168:            }
169:
170:            public String getComponentValue(String name) {
171:                XFormField component = getComponent(name);
172:                return component == null ? null : component.getValue();
173:            }
174:
175:            public XFormField getComponent(String label) {
176:                return components.get(label);
177:            }
178:
179:            public void setBorder(Border border) {
180:                panel.setBorder(border);
181:            }
182:
183:            public XFormField addComponent(XFormField component) {
184:                if (rowSpacing > 0 && !components.isEmpty())
185:                    addSpace(rowSpacing);
186:
187:                layout.appendRow(rowSpec);
188:                int row = layout.getRowCount();
189:
190:                AbstractSwingXFormField swingFormComponent = (AbstractSwingXFormField) component;
191:                panel.add(swingFormComponent.getComponent(), cc.xyw(1, row, 4));
192:
193:                return component;
194:            }
195:
196:            public void setValues(StringToStringMap values) {
197:                for (Iterator<String> i = values.keySet().iterator(); i
198:                        .hasNext();) {
199:                    String key = i.next();
200:                    setComponentValue(key, values.get(key));
201:                }
202:            }
203:
204:            public StringToStringMap getValues() {
205:                StringToStringMap values = new StringToStringMap();
206:
207:                for (Iterator<String> i = components.keySet().iterator(); i
208:                        .hasNext();) {
209:                    String key = i.next();
210:                    values.put(key, getComponentValue(key));
211:                }
212:
213:                return values;
214:            }
215:
216:            public void addNameSpaceTable(String label, Interface modelItem) {
217:                addComponent(label, new NamespaceTable(modelItem));
218:            }
219:
220:            public void setOptions(String name, Object[] values) {
221:                XFormOptionsField combo = (XFormOptionsField) getComponent(name);
222:                if (combo != null)
223:                    combo.setOptions(values);
224:            }
225:
226:            public void addLabel(String name, String label) {
227:                addComponent(name, new JLabelFormField(label));
228:            }
229:
230:            public XFormField[] getFormFields() {
231:                return components.values().toArray(
232:                        new XFormField[components.size()]);
233:            }
234:
235:            public void setFormFieldProperty(String name, Object value) {
236:                for (XFormField field : components.values()) {
237:                    field.setProperty(name, value);
238:                }
239:            }
240:
241:            public String[] getOptions(String name) {
242:                XFormField combo = getComponent(name);
243:                if (combo instanceof  XFormOptionsField)
244:                    return ((XFormOptionsField) combo).getOptions();
245:
246:                return null;
247:            }
248:
249:            public XFormField getFormField(String name) {
250:                return components.get(name);
251:            }
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.