Source Code Cross Referenced for PropertiesStepDesktopPanel.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » panels » teststeps » 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.impl.wsdl.panels.teststeps 
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.impl.wsdl.panels.teststeps;
014:
015:        import java.awt.BorderLayout;
016:        import java.awt.Component;
017:        import java.awt.Dimension;
018:        import java.awt.event.ActionEvent;
019:        import java.io.File;
020:        import java.io.IOException;
021:
022:        import javax.swing.AbstractAction;
023:        import javax.swing.Action;
024:        import javax.swing.Box;
025:        import javax.swing.Icon;
026:        import javax.swing.JButton;
027:        import javax.swing.JComponent;
028:        import javax.swing.JLabel;
029:        import javax.swing.JPanel;
030:        import javax.swing.JScrollPane;
031:        import javax.swing.JTable;
032:        import javax.swing.JTextField;
033:        import javax.swing.event.ListSelectionEvent;
034:        import javax.swing.event.ListSelectionListener;
035:        import javax.swing.table.AbstractTableModel;
036:        import javax.swing.text.Document;
037:
038:        import com.eviware.soapui.impl.wsdl.actions.support.ShowOnlineHelpAction;
039:        import com.eviware.soapui.impl.wsdl.panels.support.TestRunComponentEnabler;
040:        import com.eviware.soapui.impl.wsdl.support.HelpUrls;
041:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlPropertiesTestStep;
042:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStepListenerAdapter;
043:        import com.eviware.soapui.impl.wsdl.teststeps.WsdlPropertiesTestStep.StepProperty;
044:        import com.eviware.soapui.model.ModelItem;
045:        import com.eviware.soapui.model.testsuite.TestStepProperty;
046:        import com.eviware.soapui.support.DocumentListenerAdapter;
047:        import com.eviware.soapui.support.UISupport;
048:        import com.eviware.soapui.support.components.JXToolBar;
049:        import com.eviware.soapui.ui.desktop.DesktopPanel;
050:
051:        /**
052:         * DesktopPanel for WsdlPropertiesTestSteps
053:         * 
054:         * @author Ole.Matzura
055:         */
056:
057:        public class PropertiesStepDesktopPanel extends JPanel implements 
058:                DesktopPanel {
059:            private final WsdlPropertiesTestStep testStep;
060:            private JTextField sourceField;
061:            private JTextField targetField;
062:            private PropertiesModel propertiesModel;
063:            private JTable propertiesTable;
064:            private RemovePropertyAction removePropertyAction;
065:            private TestRunComponentEnabler componentEnabler;
066:            private InternalWsdlTestStepListener wsdlTestStepListener;
067:
068:            public PropertiesStepDesktopPanel(WsdlPropertiesTestStep testStep) {
069:                super (new BorderLayout());
070:                this .testStep = testStep;
071:                componentEnabler = new TestRunComponentEnabler(testStep
072:                        .getTestCase());
073:                buildUI();
074:
075:                wsdlTestStepListener = new InternalWsdlTestStepListener();
076:                testStep.addTestStepListener(wsdlTestStepListener);
077:            }
078:
079:            private void buildUI() {
080:                add(buildToolbar(), BorderLayout.NORTH);
081:                add(buildPropertiesTable(), BorderLayout.CENTER);
082:
083:                setPreferredSize(new Dimension(600, 400));
084:            }
085:
086:            private Component buildPropertiesTable() {
087:                propertiesModel = new PropertiesModel();
088:                propertiesTable = new JTable(propertiesModel);
089:
090:                propertiesTable.setDragEnabled(true);
091:
092:                //		propertiesTable.setTransferHandler(new PropertiesTransferHandler( propertiesTable ));
093:
094:                propertiesTable.putClientProperty("terminateEditOnFocusLost",
095:                        Boolean.TRUE);
096:                propertiesTable.getSelectionModel().addListSelectionListener(
097:                        new ListSelectionListener() {
098:
099:                            public void valueChanged(ListSelectionEvent e) {
100:                                removePropertyAction.setEnabled(propertiesTable
101:                                        .getSelectedRow() != -1);
102:                            }
103:                        });
104:
105:                componentEnabler.add(propertiesTable);
106:
107:                return new JScrollPane(propertiesTable);
108:            }
109:
110:            private JComponent buildToolbar() {
111:                JXToolBar toolbar = UISupport.createToolbar();
112:
113:                JButton addPropertyButton = UISupport
114:                        .createToolbarButton(new AddPropertyAction());
115:                toolbar.add(addPropertyButton);
116:                removePropertyAction = new RemovePropertyAction();
117:                JButton removePropertyButton = UISupport
118:                        .createToolbarButton(removePropertyAction);
119:                toolbar.add(removePropertyButton);
120:
121:                toolbar.addSeparator();
122:                toolbar.add(new JLabel("Load from:"));
123:                sourceField = new JTextField(testStep.getSource(), 15);
124:                sourceField
125:                        .setToolTipText("The filename/url or referring system-property to load properties from");
126:                sourceField.getDocument().addDocumentListener(
127:                        new DocumentListenerAdapter() {
128:                            public void update(Document document) {
129:                                testStep.setSource(sourceField.getText());
130:
131:                            }
132:                        });
133:
134:                toolbar.addFixed(sourceField);
135:                JButton setSourceButton = UISupport
136:                        .createToolbarButton(new SetPropertiesSourceAction());
137:                toolbar.add(setSourceButton);
138:
139:                toolbar.addSeparator();
140:                toolbar.add(new JLabel("Save to:"));
141:                targetField = new JTextField(testStep.getTarget(), 15);
142:                targetField
143:                        .setToolTipText("The filename/url or referring system-property to save properties to");
144:                targetField.getDocument().addDocumentListener(
145:                        new DocumentListenerAdapter() {
146:                            public void update(Document document) {
147:                                testStep.setTarget(targetField.getText());
148:
149:                            }
150:                        });
151:
152:                toolbar.addFixed(targetField);
153:                JButton setTargetButton = UISupport
154:                        .createToolbarButton(new SetPropertiesTargetAction());
155:                toolbar.add(setTargetButton);
156:
157:                toolbar.add(Box.createHorizontalGlue());
158:                toolbar.addSeparator();
159:                toolbar.add(UISupport
160:                        .createToolbarButton(new ShowOnlineHelpAction(
161:                                HelpUrls.PROPERTIESSTEPEDITOR_HELP_URL)));
162:
163:                componentEnabler.add(sourceField);
164:                componentEnabler.add(targetField);
165:                componentEnabler.add(setTargetButton);
166:                componentEnabler.add(setSourceButton);
167:                componentEnabler.add(addPropertyButton);
168:                componentEnabler.add(removePropertyButton);
169:
170:                return toolbar;
171:            }
172:
173:            public Icon getIcon() {
174:                return getModelItem().getIcon();
175:            }
176:
177:            public ModelItem getModelItem() {
178:                return testStep;
179:            }
180:
181:            public boolean onClose(boolean canCancel) {
182:                if (propertiesTable.isEditing())
183:                    propertiesTable.getCellEditor().stopCellEditing();
184:
185:                componentEnabler.release();
186:                testStep.removeTestStepListener(wsdlTestStepListener);
187:                return true;
188:            }
189:
190:            public JComponent getComponent() {
191:                return this ;
192:            }
193:
194:            public boolean dependsOn(ModelItem modelItem) {
195:                return modelItem == testStep
196:                        || modelItem == testStep.getTestCase()
197:                        || modelItem == testStep.getTestCase().getTestSuite()
198:                        || modelItem == testStep.getTestCase().getTestSuite()
199:                                .getProject();
200:            }
201:
202:            public String getTitle() {
203:                return testStep.getTestCase().getName() + " - "
204:                        + testStep.getName();
205:            }
206:
207:            public String getDescription() {
208:                return "Properties: [" + testStep.getName() + "] - "
209:                        + testStep.getTestStepTitle();
210:            }
211:
212:            private final class InternalWsdlTestStepListener extends
213:                    WsdlTestStepListenerAdapter {
214:                private boolean enabled = true;
215:
216:                public boolean isEnabled() {
217:                    return enabled;
218:                }
219:
220:                public void setEnabled(boolean enabled) {
221:                    this .enabled = enabled;
222:                }
223:
224:                public void propertyAdded(String name) {
225:                    if (enabled)
226:                        propertiesModel.fireTableDataChanged();
227:                }
228:
229:                public void propertyRemoved(String name) {
230:                    if (enabled)
231:                        propertiesModel.fireTableDataChanged();
232:                }
233:
234:                public void propertyRenamed(String oldName, String newName) {
235:                    if (enabled)
236:                        propertiesModel.fireTableDataChanged();
237:                }
238:
239:                public void propertyValueChanged(String name, String oldValue,
240:                        String newValue) {
241:                    if (enabled)
242:                        propertiesModel.fireTableDataChanged();
243:                }
244:            }
245:
246:            private class PropertiesModel extends AbstractTableModel {
247:                public int getRowCount() {
248:                    return testStep.getStepPropertyCount();
249:                }
250:
251:                public int getColumnCount() {
252:                    return 2;
253:                }
254:
255:                public String getColumnName(int columnIndex) {
256:                    switch (columnIndex) {
257:                    case 0:
258:                        return "Name";
259:                    case 1:
260:                        return "Value";
261:                    }
262:
263:                    return null;
264:                }
265:
266:                public boolean isCellEditable(int rowIndex, int columnIndex) {
267:                    return true;
268:                }
269:
270:                public void setValueAt(Object aValue, int rowIndex,
271:                        int columnIndex) {
272:                    StepProperty property = testStep
273:                            .getTestStepPropertyAt(rowIndex);
274:                    switch (columnIndex) {
275:                    case 0: {
276:                        TestStepProperty prop = testStep
277:                                .getProperty((String) aValue);
278:                        if (prop != null && prop != property) {
279:                            UISupport.showErrorMessage("Property name exists!");
280:                            return;
281:                        }
282:                        wsdlTestStepListener.setEnabled(false);
283:                        property.setName(aValue.toString());
284:                        wsdlTestStepListener.setEnabled(true);
285:                        break;
286:                    }
287:                    case 1: {
288:                        wsdlTestStepListener.setEnabled(false);
289:                        property.setValue(aValue.toString());
290:                        wsdlTestStepListener.setEnabled(true);
291:                        break;
292:                    }
293:                    }
294:                }
295:
296:                public Object getValueAt(int rowIndex, int columnIndex) {
297:                    TestStepProperty property = testStep
298:                            .getTestStepPropertyAt(rowIndex);
299:
300:                    switch (columnIndex) {
301:                    case 0:
302:                        return property.getName();
303:                    case 1:
304:                        return property.getValue();
305:                    }
306:
307:                    return null;
308:                }
309:            }
310:
311:            private class AddPropertyAction extends AbstractAction {
312:                public AddPropertyAction() {
313:                    putValue(Action.SMALL_ICON, UISupport
314:                            .createImageIcon("/add_property.gif"));
315:                    putValue(Action.SHORT_DESCRIPTION,
316:                            "Adds a property to the property list");
317:                }
318:
319:                public void actionPerformed(ActionEvent e) {
320:                    String name = UISupport.prompt("Specify property name",
321:                            "Add Property", "");
322:                    if (name != null) {
323:                        wsdlTestStepListener.setEnabled(false);
324:                        testStep.addProperty(name);
325:                        wsdlTestStepListener.setEnabled(true);
326:                        int row = testStep.getStepPropertyCount() - 1;
327:                        propertiesModel.fireTableRowsInserted(row, row);
328:                        propertiesTable.editCellAt(row, 1);
329:                    }
330:                }
331:            }
332:
333:            private class RemovePropertyAction extends AbstractAction {
334:                public RemovePropertyAction() {
335:                    putValue(Action.SMALL_ICON, UISupport
336:                            .createImageIcon("/remove_property.gif"));
337:                    putValue(Action.SHORT_DESCRIPTION,
338:                            "Removes the selected property from the property list");
339:                    setEnabled(false);
340:                }
341:
342:                public void actionPerformed(ActionEvent e) {
343:                    int row = propertiesTable.getSelectedRow();
344:                    if (row == -1)
345:                        return;
346:
347:                    UISupport.stopCellEditing(propertiesTable);
348:
349:                    if (UISupport.confirm("Remove property ["
350:                            + propertiesModel.getValueAt(row, 0) + "]?",
351:                            "Remove Property")) {
352:                        wsdlTestStepListener.setEnabled(false);
353:                        testStep.removePropertyAt(row);
354:                        wsdlTestStepListener.setEnabled(true);
355:                        propertiesModel.fireTableRowsDeleted(row, row);
356:                    }
357:                }
358:            }
359:
360:            private class SetPropertiesSourceAction extends AbstractAction {
361:                public SetPropertiesSourceAction() {
362:                    putValue(Action.SMALL_ICON, UISupport
363:                            .createImageIcon("/set_properties_source.gif"));
364:                    putValue(Action.SHORT_DESCRIPTION,
365:                            "Selects the properties source file");
366:                }
367:
368:                public void actionPerformed(ActionEvent e) {
369:                    File file = UISupport.getFileDialogs().open(this ,
370:                            "Set properties source", null, null, null);
371:                    if (file != null) {
372:                        testStep.setSource(file.getAbsolutePath());
373:                        sourceField.setText(testStep.getSource());
374:                        try {
375:                            boolean createMissing = UISupport.confirm(
376:                                    "Create missing properties?",
377:                                    "Set Properties Source");
378:                            int cnt = testStep.loadProperties(createMissing);
379:                            UISupport.showInfoMessage("Loaded " + cnt
380:                                    + " properties from ["
381:                                    + testStep.getSource() + "]");
382:                        } catch (IOException e1) {
383:                            UISupport
384:                                    .showErrorMessage("Failed to load properties from ["
385:                                            + testStep.getSource() + "]; " + e1);
386:                        }
387:                    }
388:                }
389:            }
390:
391:            private class SetPropertiesTargetAction extends AbstractAction {
392:                public SetPropertiesTargetAction() {
393:                    putValue(Action.SMALL_ICON, UISupport
394:                            .createImageIcon("/set_properties_target.gif"));
395:                    putValue(Action.SHORT_DESCRIPTION,
396:                            "Selects the properties target file");
397:                }
398:
399:                public void actionPerformed(ActionEvent e) {
400:                    File file = UISupport.getFileDialogs().saveAs(this ,
401:                            "Set properties target");
402:                    if (file != null) {
403:                        testStep.setTarget(file.getAbsolutePath());
404:                        targetField.setText(testStep.getTarget());
405:
406:                        try {
407:                            int cnt = testStep.saveProperties();
408:                            UISupport.showInfoMessage("Saved " + cnt
409:                                    + " properties to [" + testStep.getTarget()
410:                                    + "]");
411:                        } catch (IOException e1) {
412:                            UISupport
413:                                    .showErrorMessage("Failed to save properties to ["
414:                                            + testStep.getTarget() + "]; " + e1);
415:                        }
416:                    }
417:                }
418:            }
419:
420:            /*
421:            public class PropertiesTransferHandler extends AbstractPropertiesTransferHandler
422:            {
423:            	public PropertiesTransferHandler(JComponent component)
424:            	{
425:            		super(component);
426:            	}
427:
428:            	protected StepProperty getSelectedProperty(JComponent c)
429:            	{
430:            		int rowIndex = propertiesTable.getSelectedRow();
431:            		if (rowIndex == -1)
432:            			return null;
433:
434:            		return testStep.getTestStepPropertyAt(rowIndex);
435:            	}
436:            }*/
437:        }
w__w_w__._ja_v__a2s._c_o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.