Source Code Cross Referenced for MockAttachmentTableModel.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » panels » attachments » 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.attachments 
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.attachments;
014:
015:        import java.beans.PropertyChangeEvent;
016:        import java.beans.PropertyChangeListener;
017:        import java.io.File;
018:        import java.io.IOException;
019:        import java.util.Arrays;
020:
021:        import javax.swing.table.AbstractTableModel;
022:
023:        import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
024:        import com.eviware.soapui.impl.wsdl.support.WsdlAttachment;
025:        import com.eviware.soapui.model.iface.Attachment;
026:
027:        /**
028:         * TableModel for MockAttachments in a WsdlMockResponse
029:         * 
030:         * @author ole.matzura
031:         */
032:
033:        public class MockAttachmentTableModel extends AbstractTableModel
034:                implements  PropertyChangeListener, AttachmentTableModel {
035:
036:            private boolean isResponse = false;
037:            private WsdlMockResponse mockResponse;
038:
039:            /** Creates a new instance of AttachmentTableModel */
040:            public MockAttachmentTableModel(WsdlMockResponse mockOperation2,
041:                    boolean isResponse) {
042:                this .mockResponse = mockOperation2;
043:                this .isResponse = isResponse;
044:
045:                mockResponse.addPropertyChangeListener(this );
046:            }
047:
048:            public void release() {
049:                mockResponse.removePropertyChangeListener(this );
050:            }
051:
052:            public void addFile(File file, boolean cacheInRequest)
053:                    throws IOException {
054:                if (isResponse) {
055:                    Attachment attachment = mockResponse.attachFile(file,
056:                            cacheInRequest);
057:                    attachment.setContentType(ContentTypeHandler
058:                            .getContentTypeFromFilename(file.getName()));
059:                    this .fireTableRowsInserted(mockResponse
060:                            .getAttachmentCount(), mockResponse
061:                            .getAttachmentCount());
062:                }
063:            }
064:
065:            public void removeAttachment(int[] rowIndexes) {
066:                Arrays.sort(rowIndexes);
067:                for (int i = rowIndexes.length - 1; i >= 0; i--)
068:                    removeAttachment(rowIndexes[i]);
069:            }
070:
071:            public void removeAttachment(int rowIndex) {
072:                if (isResponse) {
073:                    mockResponse.removeAttachment(mockResponse
074:                            .getAttachmentAt(rowIndex));
075:                    this .fireTableRowsDeleted(rowIndex, rowIndex);
076:                }
077:            }
078:
079:            public int getRowCount() {
080:                if (isResponse)
081:                    return mockResponse.getAttachmentCount();
082:                else {
083:                    try {
084:                        // Response may not exist yet and attachments may be null
085:                        return mockResponse.getMockResult().getMockRequest()
086:                                .getRequestAttachments().length;
087:                    } catch (Exception e) {
088:                        return 0;
089:                    }
090:                }
091:            }
092:
093:            public int getColumnCount() {
094:                return isResponse ? 6 : 5;
095:            }
096:
097:            public Attachment getAttachmentAt(int rowIndex) {
098:                if (isResponse)
099:                    return mockResponse.getAttachmentAt(rowIndex);
100:                else
101:                    return mockResponse.getMockResult().getMockRequest()
102:                            .getRequestAttachments()[rowIndex];
103:            }
104:
105:            public Object getValueAt(int rowIndex, int columnIndex) {
106:                if (rowIndex > getRowCount())
107:                    return null;
108:
109:                Attachment att = null;
110:                if (isResponse)
111:                    att = mockResponse.getAttachmentAt(rowIndex);
112:                else
113:                    att = mockResponse.getMockResult().getMockRequest()
114:                            .getRequestAttachments()[rowIndex];
115:
116:                switch (columnIndex) {
117:                case 0:
118:                    return att.getName();
119:                case 1:
120:                    return att.getContentType();
121:                case 2:
122:                    return att.getSize();
123:                case 3:
124:                    return att.getPart();
125:                case 4:
126:                    return att.getAttachmentType();
127:                case 5:
128:                    return att.getContentID();
129:                default:
130:                    return null;
131:                }
132:            }
133:
134:            public int findColumn(String columnName) {
135:                if (columnName.equals("Name"))
136:                    return 0;
137:                else if (columnName.equals("Content type"))
138:                    return 1;
139:                else if (columnName.equals("Size"))
140:                    return 2;
141:                else if (columnName.equals("Part"))
142:                    return 3;
143:                else if (columnName.equals("Type"))
144:                    return 4;
145:
146:                return -1;
147:            }
148:
149:            public String getColumnName(int column) {
150:                if (column == 0)
151:                    return "Name";
152:                else if (column == 1)
153:                    return "Content type";
154:                else if (column == 2)
155:                    return "Size";
156:                else if (column == 3)
157:                    return "Part";
158:                else if (column == 4)
159:                    return "Type";
160:                else if (column == 5)
161:                    return "ContentID";
162:                else
163:                    return null;
164:            }
165:
166:            public boolean isCellEditable(int rowIndex, int columnIndex) {
167:                return isResponse
168:                        && (columnIndex == 1 || columnIndex == 3 || columnIndex == 5);
169:            }
170:
171:            public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
172:                if (!isResponse)
173:                    return;
174:
175:                WsdlAttachment att = (WsdlAttachment) mockResponse
176:                        .getAttachmentAt(rowIndex);
177:                if (columnIndex == 1)
178:                    att.setContentType((String) aValue);
179:                else if (columnIndex == 3)
180:                    att.setPart((String) aValue);
181:                else if (columnIndex == 5)
182:                    att.setContentID((String) aValue);
183:
184:                fireTableRowsUpdated(rowIndex, rowIndex);
185:            }
186:
187:            /**
188:             * Update table when attachments or response changes
189:             */
190:
191:            public void propertyChange(PropertyChangeEvent evt) {
192:                fireTableDataChanged();
193:            }
194:
195:        }
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.