Source Code Cross Referenced for MethodPanel.java in  » Net » Coadunation_1.0.1 » com » rift » coad » web » admin » client » 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 » Net » Coadunation_1.0.1 » com.rift.coad.web.admin.client 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * CoadunationAdmin: The admin frontend for coadunation.
003:         * Copyright (C) 2007 - 2008  Rift IT Contracting
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
018:         *
019:         * Method.java
020:         */
021:
022:        // imports
023:        package com.rift.coad.web.admin.client;
024:
025:        // imports
026:        import com.google.gwt.user.client.ui.AbstractImagePrototype;
027:        import com.google.gwt.user.client.ui.Composite;
028:        import com.google.gwt.user.client.ui.ImageBundle;
029:        import com.google.gwt.user.client.ui.VerticalPanel;
030:        import com.google.gwt.user.client.ui.Label;
031:        import com.google.gwt.user.client.ui.ScrollPanel;
032:        import com.google.gwt.user.client.ui.HTML;
033:        import com.google.gwt.user.client.ui.Button;
034:        import com.google.gwt.user.client.ui.FlexTable;
035:        import com.google.gwt.user.client.ui.TextBox;
036:        import com.google.gwt.user.client.ui.TextArea;
037:        import com.google.gwt.user.client.ui.ClickListener;
038:        import com.google.gwt.user.client.ui.Widget;
039:
040:        /**
041:         * This panel is responsible for displaying a single methods information and
042:         * providing a means to invoke it.
043:         *
044:         * @author brett chaldecott
045:         */
046:        public class MethodPanel extends Composite implements  ClickListener {
047:
048:            // class constants
049:            private final static int MAX_DEFAULT_ROWS = 5;
050:
051:            // scroll panel
052:            private MethodListener listener = null;
053:            private HTML methodName = new HTML();
054:            private HTML methodResult = new HTML();
055:            private HTML description = new HTML();
056:            private FlexTable parameters = new FlexTable();
057:            private Button invoke = new Button("Invoke");
058:            private MethodDef method = null;
059:            private TextArea[] textAreas = null;
060:
061:            /**
062:             * Creates a new instance of Method
063:             */
064:            public MethodPanel(MethodListener listener) {
065:                this .listener = listener;
066:                VerticalPanel panel = new VerticalPanel();
067:                panel.setWidth("100%");
068:
069:                // setup the label
070:                Label objectLabel = new Label("Method");
071:                objectLabel.setStyleName("header-Label");
072:                objectLabel.setWidth("100%");
073:                panel.add(objectLabel);
074:
075:                // add the description
076:                VerticalPanel descVerticalPanel = new VerticalPanel();
077:                descVerticalPanel.setWidth("100%");
078:                methodName.setWidth("100%");
079:                methodName.setStyleName("method-NameRow");
080:                descVerticalPanel.add(methodName);
081:                methodResult.setWidth("100%");
082:                methodResult.setStyleName("method-ResultRow");
083:                descVerticalPanel.add(methodResult);
084:                description.setWordWrap(true);
085:                descVerticalPanel.add(description);
086:                ScrollPanel descScrollPanel = new ScrollPanel(descVerticalPanel);
087:                descScrollPanel.setStyleName("method-Desc-Scroller");
088:                descScrollPanel.setWidth("100%");
089:                panel.add(descScrollPanel);
090:
091:                // parameter panel
092:                parameters.setCellSpacing(0);
093:                parameters.setCellPadding(0);
094:                parameters.setWidth("100%");
095:                ScrollPanel scrollPanel = new ScrollPanel(parameters);
096:                scrollPanel.setWidth("100%");
097:                scrollPanel.setStyleName("method-Scroller");
098:                scrollPanel.setAlwaysShowScrollBars(true);
099:                panel.add(scrollPanel);
100:                resetMethod();
101:
102:                // button panel
103:                VerticalPanel buttonPanel = new VerticalPanel();
104:                buttonPanel.setWidth("100%");
105:                buttonPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
106:                buttonPanel.add(invoke);
107:                buttonPanel.setStyleName("button-Panel");
108:                panel.add(buttonPanel);
109:                invoke.addClickListener(this );
110:
111:                // border
112:                panel.setStyleName("panel-Border");
113:
114:                initWidget(panel);
115:            }
116:
117:            /**
118:             * Initializes the table so that it contains enough rows for a full page of
119:             * emails. Also creates the images that will be used as 'read' flags.
120:             */
121:            private void initTable() {
122:                // Create the header row.
123:                parameters.clear();
124:                parameters.setText(0, 0, "Name");
125:                parameters.setText(0, 1, "Value");
126:                parameters.setText(0, 2, "Type");
127:                parameters.setText(0, 3, "Description");
128:                parameters.getRowFormatter().setStyleName(0,
129:                        "parameter-ListHeader");
130:
131:                // Initialize the rest of the rows.
132:                for (int i = 0; i < MAX_DEFAULT_ROWS; ++i) {
133:                    parameters.setText(i + 1, 0, "");
134:                    TextArea text = new TextArea();
135:                    text.setCharacterWidth(40);
136:                    text.setVisibleLines(2);
137:                    text.setText("");
138:                    text.setEnabled(false);
139:                    parameters.setWidget(i + 1, 1, text);
140:                    parameters.setText(i + 1, 2, "");
141:                    parameters.setText(i + 1, 3, "");
142:                    parameters.getCellFormatter().setWordWrap(i + 1, 0, false);
143:                    parameters.getCellFormatter().setWordWrap(i + 1, 1, false);
144:                    parameters.getCellFormatter().setWordWrap(i + 1, 2, false);
145:                    parameters.getCellFormatter().setWordWrap(i + 1, 2, false);
146:                    styleRow(i + 1);
147:                }
148:            }
149:
150:            /**
151:             * Initializes the table so that it contains enough rows for a full page of
152:             * emails. Also creates the images that will be used as 'read' flags.
153:             */
154:            private void setParameters(VariableDef[] parameterArray) {
155:                // Create the header row.
156:                parameters.clear();
157:                parameters.setText(0, 0, "Name");
158:                parameters.setText(0, 1, "Value");
159:                parameters.setText(0, 2, "Type");
160:                parameters.setText(0, 3, "Description");
161:                parameters.getRowFormatter().setStyleName(0,
162:                        "parameter-ListHeader");
163:
164:                // loop through the parameter arrauy
165:                int pos = 1;
166:                textAreas = new TextArea[parameterArray.length];
167:                for (int index = 0; index < parameterArray.length; index++) {
168:
169:                    parameters.setText(pos, 0, parameterArray[index].getName());
170:                    textAreas[index] = new TextArea();
171:                    textAreas[index].setCharacterWidth(40);
172:                    textAreas[index].setVisibleLines(2);
173:                    textAreas[index].setText("");
174:                    textAreas[index].setEnabled(true);
175:                    parameters.setWidget(pos, 1, textAreas[index]);
176:                    parameters.setText(pos, 2, parameterArray[index].getType());
177:                    parameters.setText(pos, 3, parameterArray[index]
178:                            .getDescription());
179:                    parameters.getCellFormatter().setWordWrap(pos, 0, false);
180:                    parameters.getCellFormatter().setWordWrap(pos, 1, false);
181:                    parameters.getCellFormatter().setWordWrap(pos, 2, false);
182:                    parameters.getCellFormatter().setWordWrap(pos, 2, false);
183:                    styleRow(pos);
184:                    pos++;
185:
186:                }
187:
188:                // Initialize the rest of the rows.
189:                for (int i = 0; i < (MAX_DEFAULT_ROWS - parameterArray.length); ++i) {
190:                    parameters.setText(pos, 0, "");
191:                    TextArea text = new TextArea();
192:                    text.setCharacterWidth(40);
193:                    text.setVisibleLines(2);
194:                    text.setText("");
195:                    text.setEnabled(false);
196:                    parameters.setWidget(pos, 1, text);
197:                    parameters.setText(pos, 2, "");
198:                    parameters.setText(pos, 3, "");
199:                    parameters.getCellFormatter().setWordWrap(pos, 0, false);
200:                    parameters.getCellFormatter().setWordWrap(pos, 1, false);
201:                    parameters.getCellFormatter().setWordWrap(pos, 2, false);
202:                    parameters.getCellFormatter().setWordWrap(pos, 2, false);
203:                    styleRow(pos);
204:                    pos++;
205:                }
206:            }
207:
208:            /**
209:             * This method sets the style on a row
210:             */
211:            private void styleRow(int row) {
212:                if ((row % 2) == 0) {
213:                    parameters.getRowFormatter().addStyleName(row,
214:                            "parameter-LightRow");
215:                } else {
216:                    parameters.getRowFormatter().removeStyleName(row,
217:                            "parameter-DarkRow");
218:                }
219:
220:            }
221:
222:            /**
223:             * This method displays the method information
224:             */
225:            public void setMethod(MethodDef method) {
226:                this .method = method;
227:                methodName.setHTML(method.getName());
228:                methodResult.setHTML(method.getResult().getType());
229:                description.setHTML(method.getDescription());
230:                setParameters(method.getParameters());
231:            }
232:
233:            /**
234:             * This method resets the method
235:             */
236:            public void resetMethod() {
237:                methodName.setHTML("&nbsp;");
238:                methodResult.setHTML("&nbsp;");
239:                description.setHTML("&nbsp;");
240:                initTable();
241:                method = null;
242:                textAreas = null;
243:            }
244:
245:            public void onClick(Widget sender) {
246:                if (this .invoke == sender) {
247:                    VariableDef[] variables = method.getParameters();
248:                    for (int index = 0; index < textAreas.length; index++) {
249:                        variables[index].setValue(textAreas[index].getText());
250:                    }
251:                    listener.methodInvoked(method);
252:                }
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.