Source Code Cross Referenced for ShowcasePanel.java in  » Ajax » gwtext-2.01 » com » gwtext » sample » showcase2 » 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 » Ajax » gwtext 2.01 » com.gwtext.sample.showcase2.client 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.gwtext.sample.showcase2.client;
002:
003:        import com.google.gwt.i18n.client.DateTimeFormat;
004:        import com.google.gwt.user.client.ui.Frame;
005:        import com.gwtext.client.core.*;
006:        import com.gwtext.client.data.*;
007:        import com.gwtext.client.util.Format;
008:        import com.gwtext.client.widgets.*;
009:        import com.gwtext.client.widgets.event.ButtonListenerAdapter;
010:        import com.gwtext.client.widgets.event.PanelListenerAdapter;
011:        import com.gwtext.client.widgets.event.TabPanelListenerAdapter;
012:        import com.gwtext.client.widgets.event.WindowListenerAdapter;
013:        import com.gwtext.client.widgets.grid.*;
014:        import com.gwtext.client.widgets.layout.BorderLayout;
015:        import com.gwtext.client.widgets.layout.BorderLayoutData;
016:        import com.gwtext.client.widgets.layout.FitLayout;
017:        import com.gwtext.client.widgets.layout.VerticalLayout;
018:
019:        import java.util.Date;
020:
021:        public abstract class ShowcasePanel extends Panel {
022:
023:            private Window sourceWindow = null;
024:            private String sourceIconCls = "source-icon";
025:            private ToolbarButton sourceButton;
026:            private Toolbar toolbar;
027:
028:            protected static final String EVENT = "event";
029:            protected static final String MESSAGE = "message";
030:
031:            private RecordDef recordDef;
032:            private Store store;
033:
034:            protected Panel panel;
035:
036:            protected ShowcasePanel() {
037:                setTitle(getTitle());
038:                setClosable(true);
039:                setTopToolbar(new Toolbar());
040:                setPaddings(20);
041:                setLayout(new FitLayout());
042:                setBorder(false);
043:                setAutoScroll(true);
044:                addListener(new PanelListenerAdapter() {
045:                    public void onActivate(Panel panel) {
046:                        ShowcasePanel.this .onActivate();
047:                    }
048:                });
049:            }
050:
051:            protected void onActivate() {
052:                Panel viewPanel = getViewPanel();
053:                if (viewPanel instanceof  Window) {
054:                    ((Window) viewPanel).show();
055:                }
056:            }
057:
058:            protected void afterRender() {
059:
060:                ButtonListenerAdapter listener = new ButtonListenerAdapter() {
061:                    public void onClick(Button button, EventObject e) {
062:                        Window window = getSourceWindow();
063:                        window.show(sourceButton.getId());
064:                    }
065:                };
066:
067:                sourceButton = new ToolbarButton("View Source", listener);
068:                sourceButton.setIconCls(sourceIconCls);
069:
070:                if (getSourceUrl() == null) {
071:                    sourceButton.setDisabled(true);
072:                }
073:                toolbar = getTopToolbar();
074:
075:                toolbar.addFill();
076:                toolbar.addButton(sourceButton);
077:
078:                addViewPanel();
079:            }
080:
081:            private void addViewPanel() {
082:                Panel mainPanel = new Panel();
083:                mainPanel.setBorder(false);
084:                //mainPanel.setLayout(new BorderLayout());
085:                mainPanel.setLayout(new BorderLayout());
086:
087:                Panel viewPanel = getViewPanel();
088:                if (viewPanel instanceof  Window) {
089:                    viewPanel.show();
090:                    viewPanel = new Panel();
091:                }
092:                viewPanel.setAutoScroll(true);
093:                viewPanel.setBorder(false);
094:
095:                BorderLayoutData centerLayoutData = new BorderLayoutData(
096:                        RegionPosition.CENTER);
097:                //centerLayoutData.setMargins(new Margins(15, 15, 15, 15));
098:                mainPanel.add(viewPanel, centerLayoutData);
099:
100:                boolean hasIntro = getIntro() != null;
101:
102:                if (hasIntro) {
103:
104:                    Panel rightPanel = new Panel();
105:                    rightPanel.setPaddings(0, 15, 0, 0);
106:                    rightPanel.setWidth(210);
107:                    rightPanel.setLayout(new VerticalLayout(15));
108:
109:                    Panel introPanel = new Panel();
110:                    introPanel.setIconCls("book-icon");
111:                    introPanel.setFrame(true);
112:                    introPanel.setTitle("Overview");
113:                    introPanel.setHtml("<p>" + getIntro() + "</p>");
114:
115:                    //introPanel.setPaddings(0, 0, 0, 15);
116:                    rightPanel.add(introPanel);
117:                    if (showEvents()) {
118:                        GridPanel loggerGrid = getLoggerGrid();
119:                        loggerGrid.setWidth(195);
120:                        loggerGrid.setHeight(300);
121:                        rightPanel.add(loggerGrid);
122:                    }
123:
124:                    BorderLayoutData eastLayoutData = new BorderLayoutData(
125:                            RegionPosition.EAST);
126:                    //eastLayoutData.setMargins(new Margins(0, 15, 0, 0));
127:                    mainPanel.add(rightPanel, eastLayoutData);
128:                }
129:                add(mainPanel);
130:            }
131:
132:            protected void log(String eventType, String messsage) {
133:                if (recordDef != null) {
134:                    Record record = recordDef.createRecord(new Object[] {
135:                            new Date(), eventType, messsage });
136:                    store.insert(0, record);
137:                }
138:            }
139:
140:            protected boolean showEvents() {
141:                return false;
142:            }
143:
144:            private Window getSourceWindow() {
145:                if (sourceWindow == null) {
146:                    sourceWindow = new Window();
147:                    sourceWindow.setTitle("Source");
148:                    sourceWindow.setLayout(new FitLayout());
149:                    sourceWindow.setIconCls(sourceIconCls);
150:
151:                    int width = 640;
152:                    int userWidth = Ext.getBody().getWidth(true) - 20;
153:                    if (userWidth < width)
154:                        width = userWidth;
155:                    sourceWindow.setWidth(width);
156:
157:                    int height = 600;
158:                    int userHeight = Ext.getBody().getHeight(true) - 96;
159:                    if (userHeight < height)
160:                        height = userHeight;
161:                    sourceWindow.setHeight(height);
162:
163:                    sourceWindow.setAnimateTarget(sourceButton.getId());
164:
165:                    int[] panelXY = getPosition();
166:
167:                    int windowTop = panelXY[1]
168:                            + toolbar.getEl().getHeight(true) + 20;
169:                    int windowLeft = Ext.getBody().getWidth(true)
170:                            - (sourceWindow.getWidth() + 20);
171:                    sourceWindow.setPosition(windowLeft, windowTop);
172:                    sourceWindow.addListener(new WindowListenerAdapter() {
173:                        public void onClose(Panel panel) {
174:                            sourceWindow = null;
175:                        }
176:                    });
177:
178:                    TabPanel sourceTabPanel = new TabPanel();
179:                    sourceTabPanel.setActiveTab(0);
180:
181:                    String sourceUrl = getSourceUrl();
182:
183:                    if (sourceUrl != null) {
184:                        Panel sourceTab = new Panel("Java");
185:                        sourceTab.setLayout(new FitLayout());
186:                        sourceTab.setIconCls("java-icon");
187:                        Frame frame = new Frame(sourceUrl);
188:                        sourceTab.add(frame);
189:                        sourceTabPanel.add(sourceTab);
190:                    }
191:
192:                    String htmlUrl = getHtmlUrl();
193:                    if (htmlUrl != null) {
194:                        Panel htmlTab = new Panel("HTML");
195:                        htmlTab.setLayout(new FitLayout());
196:                        Frame frame = new Frame(htmlUrl);
197:                        htmlTab.setIconCls("html-icon");
198:                        sourceTabPanel.add(frame);
199:                    }
200:
201:                    String cssUrl = getCssUrl();
202:                    if (cssUrl != null) {
203:                        Panel cssTab = new Panel("CSS");
204:                        cssTab.setLayout(new FitLayout());
205:                        cssTab.setIconCls("css-icon");
206:                        Frame frame = new Frame(cssUrl);
207:                        cssTab.add(frame);
208:                        sourceTabPanel.add(cssTab);
209:                    }
210:
211:                    String xmlDataUrl = getXmlDataUrl();
212:                    if (xmlDataUrl != null) {
213:                        Panel xmlTab = new Panel("XML");
214:                        xmlTab.setLayout(new FitLayout());
215:                        xmlTab.setIconCls("xml-icon");
216:                        Frame frame = new Frame(xmlDataUrl);
217:                        xmlTab.add(frame);
218:                        sourceTabPanel.add(xmlTab);
219:                    }
220:
221:                    String jsonDataUrl = getJsonDataUrl();
222:                    if (jsonDataUrl != null) {
223:                        Panel jsonTab = new Panel("Json");
224:                        jsonTab.setLayout(new FitLayout());
225:                        jsonTab.setIconCls("json-icon");
226:                        Frame frame = new Frame(jsonDataUrl);
227:                        jsonTab.add(frame);
228:                        sourceTabPanel.add(jsonTab);
229:                    }
230:                    sourceWindow.add(sourceTabPanel);
231:                }
232:                return sourceWindow;
233:            }
234:
235:            private GridPanel getLoggerGrid() {
236:
237:                recordDef = new RecordDef(new FieldDef[] {
238:                        new DateFieldDef("date"), new StringFieldDef("type"),
239:                        new StringFieldDef("message") });
240:
241:                store = new Store(recordDef);
242:
243:                ColumnModel columnModel = new ColumnModel(new ColumnConfig[] {
244:                        new ColumnConfig("&nbsp", "type", 3, true,
245:                                new Renderer() {
246:                                    public String render(Object value,
247:                                            CellMetadata cellMetadata,
248:                                            Record record, int rowIndex,
249:                                            int colNum, Store store) {
250:                                        if (value.equals(EVENT)) {
251:                                            String someTip = "Event";
252:                                            cellMetadata
253:                                                    .setHtmlAttribute("style=\"background:#FFFF88;padding:5px\"");
254:                                        } else {
255:                                            cellMetadata
256:                                                    .setHtmlAttribute("style=\"background:#4096EE;padding:5px\"");
257:                                        }
258:                                        return "";
259:                                    }
260:                                }),
261:
262:                        new ColumnConfig("Time", "date", 70, true,
263:                                new Renderer() {
264:                                    public String render(Object value,
265:                                            CellMetadata cellMetadata,
266:                                            Record record, int rowIndex,
267:                                            int colNum, Store store) {
268:                                        DateTimeFormat formatter = DateTimeFormat
269:                                                .getFormat("hh:mm:ss");
270:                                        return formatter.format((Date) value);
271:                                    }
272:                                }) });
273:
274:                GridPanel gridPanel = new GridPanel(store, columnModel);
275:                gridPanel.setTitle("Logger");
276:                gridPanel.setAutoExpandColumn("date");
277:                gridPanel.addTool(new Tool(Tool.MINUS, new Function() {
278:                    public void execute() {
279:                        store.removeAll();
280:                        store.commitChanges();
281:                    }
282:                }, "Clear Log"));
283:
284:                GridView view = new GridView() {
285:                    public String getRowClass(Record record, int index,
286:                            RowParams rowParams, Store store) {
287:                        rowParams.setBody(Format.format("<p>{0}</p>", record
288:                                .getAsString("message")));
289:                        return "";
290:                    }
291:                };
292:
293:                view.setEnableRowBody(true);
294:                view.setForceFit(true);
295:                gridPanel.setView(view);
296:
297:                return gridPanel;
298:            }
299:
300:            public String getSourceUrl() {
301:                return null;
302:            }
303:
304:            public String getHtmlUrl() {
305:                return null;
306:            }
307:
308:            public String getXmlDataUrl() {
309:                return null;
310:            }
311:
312:            public String getJsonDataUrl() {
313:                return null;
314:            }
315:
316:            public String getCssUrl() {
317:                return null;
318:            }
319:
320:            public String getIntro() {
321:                return null;
322:            }
323:
324:            public abstract Panel getViewPanel();
325:
326:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.