Source Code Cross Referenced for SwingConfigurationDialogImpl.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » support » components » 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.support.components 
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.support.components;
014:
015:        import java.awt.BorderLayout;
016:        import java.awt.Dimension;
017:        import java.awt.event.ActionEvent;
018:        import java.util.HashMap;
019:        import java.util.Map;
020:
021:        import javax.swing.AbstractAction;
022:        import javax.swing.BorderFactory;
023:        import javax.swing.DefaultComboBoxModel;
024:        import javax.swing.ImageIcon;
025:        import javax.swing.JComboBox;
026:        import javax.swing.JComponent;
027:        import javax.swing.JDialog;
028:        import javax.swing.JList;
029:        import javax.swing.JPanel;
030:        import javax.swing.JSeparator;
031:
032:        import com.eviware.soapui.impl.wsdl.actions.support.ShowOnlineHelpAction;
033:        import com.eviware.soapui.support.UISupport;
034:        import com.eviware.soapui.support.action.swing.ActionList;
035:        import com.eviware.soapui.support.action.swing.DefaultActionList;
036:        import com.jgoodies.forms.layout.FormLayout;
037:
038:        /**
039:         * Utility for creating simple configuration dialogs
040:         * 
041:         * @author Ole.Matzura
042:         */
043:
044:        public class SwingConfigurationDialogImpl implements 
045:                ConfigurationDialog {
046:            private JDialog dialog;
047:            private SimpleForm form;
048:            private boolean result;
049:            private Map<String, String> values;
050:            private Map<String, FieldType> fieldTypes = new HashMap<String, FieldType>();
051:            private final String title;
052:            private Dimension size;
053:            private JComponent content;
054:            private ActionList actions;
055:            private String description;
056:            private ImageIcon icon;
057:
058:            public SwingConfigurationDialogImpl(String title, String helpUrl,
059:                    String description, ImageIcon icon) {
060:                this .title = title;
061:                this .description = description;
062:                this .icon = icon;
063:                form = new SimpleForm(new FormLayout(
064:                        "10px,right:pref,10px,left:pref,5px"));
065:
066:                actions = new DefaultActionList("Actions");
067:                if (helpUrl != null) {
068:                    actions.addAction(new ShowOnlineHelpAction(helpUrl));
069:                    actions.addSeparator();
070:                }
071:
072:                actions.addAction(new OkAction());
073:                actions.addAction(new CancelAction());
074:            }
075:
076:            public boolean show(Map<String, String> values) {
077:                if (dialog == null)
078:                    buildDialog();
079:
080:                this .values = values;
081:
082:                result = false;
083:
084:                form.setValues(values);
085:
086:                if (size == null)
087:                    dialog.pack();
088:                else
089:                    dialog.setSize(size);
090:
091:                UISupport.showDialog(dialog);
092:                return result;
093:            }
094:
095:            public Dimension getSize() {
096:                return size;
097:            }
098:
099:            public void setSize(Dimension preferredSize) {
100:                this .size = preferredSize;
101:            }
102:
103:            public void addTextField(String name, String tooltip) {
104:                addTextField(name, tooltip, FieldType.TEXT);
105:            }
106:
107:            public void addTextField(String name, String tooltip, FieldType type) {
108:                if (type == FieldType.DIRECTORY)
109:                    form.append(name, new DirectoryFormComponent(tooltip));
110:                else
111:                    form.appendTextField(name, tooltip);
112:
113:                fieldTypes.put(name, type);
114:            }
115:
116:            public void addCheckBox(String caption, String label,
117:                    boolean selected) {
118:                form.appendCheckBox(caption, label, selected);
119:            }
120:
121:            public void setContent(JComponent content) {
122:                this .content = content;
123:            }
124:
125:            private void buildDialog() {
126:                dialog = new JDialog(UISupport.getMainFrame(), title, true);
127:
128:                form.getPanel().setBorder(
129:                        BorderFactory.createEmptyBorder(5, 0, 5, 0));
130:
131:                JPanel panel = new JPanel(new BorderLayout());
132:                JComponent contentPanel = content == null ? form.getPanel()
133:                        : content;
134:                panel.add(contentPanel, BorderLayout.CENTER);
135:
136:                JButtonBar buttons = UISupport.initDialogActions(actions,
137:                        dialog);
138:                buttons.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
139:
140:                if (content == null) {
141:                    JPanel p = new JPanel(new BorderLayout());
142:                    p.add(new JSeparator(), BorderLayout.NORTH);
143:                    p.add(buttons, BorderLayout.CENTER);
144:
145:                    panel.add(p, BorderLayout.SOUTH);
146:                } else {
147:                    panel.add(buttons, BorderLayout.SOUTH);
148:                }
149:
150:                if (description != null || icon != null)
151:                    dialog.getContentPane()
152:                            .add(
153:                                    UISupport.buildDescription(title,
154:                                            description, icon),
155:                                    BorderLayout.NORTH);
156:
157:                dialog.getContentPane().add(panel);
158:                dialog.pack();
159:            }
160:
161:            private class OkAction extends AbstractAction {
162:                public OkAction() {
163:                    super ("Ok");
164:                }
165:
166:                public void actionPerformed(ActionEvent e) {
167:                    result = true;
168:
169:                    form.getValues(values);
170:                    dialog.setVisible(false);
171:                }
172:            }
173:
174:            private class CancelAction extends AbstractAction {
175:                public CancelAction() {
176:                    super ("Cancel");
177:                }
178:
179:                public void actionPerformed(ActionEvent e) {
180:                    dialog.setVisible(false);
181:                }
182:            }
183:
184:            public void addComboBox(String label, Object[] objects,
185:                    String tooltip) {
186:                form.appendComboBox(label, objects, tooltip);
187:            }
188:
189:            public void setValues(String id, String[] values) {
190:                JComponent component = form.getComponent(id);
191:                if (component instanceof  JComboBox) {
192:                    ((JComboBox) component).setModel(new DefaultComboBoxModel(
193:                            values));
194:                } else if (component instanceof  JList) {
195:                    ((JList) component).setModel(new DefaultComboBoxModel(
196:                            values));
197:                } else
198:                    throw new RuntimeException("Could not set values on ["
199:                            + component + "]");
200:            }
201:
202:            public void addComboBox(String label, String tooltip) {
203:                form.appendComboBox(label, new String[] {}, tooltip);
204:            }
205:
206:            public void addComponent(JComponent component) {
207:                form.addComponent(component);
208:            }
209:
210:            public void getValues(Map<String, String> values) {
211:                form.getValues(values);
212:            }
213:
214:            public ActionList getActions() {
215:                return actions;
216:            }
217:
218:            public void hide() {
219:                dialog.setVisible(false);
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.