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


001:        /*
002:         * GWT-Ext Widget Library
003:         * Copyright(c) 2007-2008, GWT-Ext.
004:         * licensing@gwt-ext.com
005:         * 
006:         * http://www.gwt-ext.com/license
007:         */
008:        package com.gwtext.sample.showcase2.client.grid;
009:
010:        import com.gwtext.client.core.EventObject;
011:        import com.gwtext.client.data.*;
012:        import com.gwtext.client.widgets.*;
013:        import com.gwtext.client.widgets.event.ButtonListenerAdapter;
014:        import com.gwtext.client.widgets.form.NumberField;
015:        import com.gwtext.client.widgets.grid.ColumnConfig;
016:        import com.gwtext.client.widgets.grid.ColumnModel;
017:        import com.gwtext.client.widgets.grid.GridPanel;
018:        import com.gwtext.client.widgets.layout.FitLayout;
019:        import com.gwtext.sample.showcase2.client.SampleData;
020:        import com.gwtext.sample.showcase2.client.ShowcasePanel;
021:
022:        public class LargeGridSample extends ShowcasePanel {
023:            private Store store;
024:
025:            public String getSourceUrl() {
026:                return "source/grid/LargeGridSample.java.html";
027:            }
028:
029:            public Panel getViewPanel() {
030:                if (panel == null) {
031:                    panel = new Panel();
032:                    panel.setLayout(new FitLayout());
033:                    RecordDef recordDef = new RecordDef(new FieldDef[] {
034:                            new StringFieldDef("company"),
035:                            new FloatFieldDef("price"),
036:                            new FloatFieldDef("change"),
037:                            new FloatFieldDef("pctChange"),
038:                            new DateFieldDef("lastChanged", "n/j h:ia"),
039:                            new StringFieldDef("symbol"),
040:                            new StringFieldDef("industry") });
041:
042:                    final GridPanel gridPanel = new GridPanel();
043:
044:                    Object[][] data = SampleData.getCompanyDataLarge();
045:                    MemoryProxy proxy = new MemoryProxy(data);
046:
047:                    ArrayReader reader = new ArrayReader(recordDef);
048:                    store = new Store(proxy, reader);
049:                    store.load();
050:                    gridPanel.setStore(store);
051:
052:                    ColumnConfig[] columns = new ColumnConfig[] {
053:                            //column ID is company which is later used in setAutoExpandColumn
054:                            new ColumnConfig("Company", "company", 160, true,
055:                                    null, "company"),
056:                            new ColumnConfig("Price", "price", 35),
057:                            new ColumnConfig("Change", "change", 45),
058:                            new ColumnConfig("% Change", "pctChange", 65),
059:                            new ColumnConfig("Last Updated", "lastChanged", 65),
060:                            new ColumnConfig("Industry", "industry", 60, true) };
061:
062:                    ColumnModel columnModel = new ColumnModel(columns);
063:                    gridPanel.setColumnModel(columnModel);
064:
065:                    gridPanel.setTitle("Large Grid");
066:                    gridPanel.setEnableColumnResize(false);
067:                    gridPanel.setEnableDragDrop(false);
068:                    gridPanel.setEnableColumnHide(false);
069:                    gridPanel.setEnableColumnMove(false);
070:
071:                    Toolbar top = new Toolbar();
072:                    top
073:                            .addItem(new ToolbarTextItem(
074:                                    "This example dynamically generates data to populate the grid. Creating very large Grids might cause the browser to get unstable and might require a restart."));
075:                    gridPanel.setTopToolbar(top);
076:
077:                    Toolbar bottom = new Toolbar();
078:                    bottom
079:                            .addItem(new ToolbarTextItem(
080:                                    "<sup>*</sup>Total time for Grid update includes the time taken to generate the local data"));
081:
082:                    bottom.addFill();
083:                    bottom.addItem(new ToolbarTextItem("Columns"));
084:                    bottom.addSpacer();
085:                    final NumberField cols = new NumberField("Columns",
086:                            "numCols", 40, 10);
087:                    cols.setAllowDecimals(false);
088:                    bottom.addField(cols);
089:
090:                    bottom.addSeparator();
091:
092:                    bottom.addItem(new ToolbarTextItem("Rows"));
093:                    bottom.addSpacer();
094:                    final NumberField rows = new NumberField("Rows", "numRows",
095:                            40, 200);
096:                    rows.setAllowDecimals(false);
097:                    bottom.addField(rows);
098:
099:                    bottom.addSeparator();
100:
101:                    ToolbarButton generateButton = new ToolbarButton(
102:                            "Generate", new ButtonListenerAdapter() {
103:                                public void onClick(Button button, EventObject e) {
104:                                    updateGrid(gridPanel, cols.getValue()
105:                                            .intValue(), rows.getValue()
106:                                            .intValue());
107:                                }
108:                            });
109:                    generateButton.setIconCls("database-add-icon");
110:                    bottom.addButton(generateButton);
111:
112:                    ToolbarButton clearButton = new ToolbarButton("Clear Data",
113:                            new ButtonListenerAdapter() {
114:                                public void onClick(Button button, EventObject e) {
115:                                    store.removeAll();
116:                                }
117:                            });
118:                    clearButton.setIconCls("database-delete-icon");
119:                    bottom.addButton(clearButton);
120:
121:                    gridPanel.setBottomToolbar(bottom);
122:                    panel.add(gridPanel);
123:                }
124:                return panel;
125:            }
126:
127:            private void updateGrid(GridPanel gridPanel, int cols, int rows) {
128:                if (store != null) {
129:                    store.removeAll();
130:                }
131:
132:                Object[][] data = new Object[rows][cols];
133:                ColumnConfig[] columns = new ColumnConfig[cols];
134:                FieldDef[] fields = new FieldDef[cols];
135:
136:                for (int i = 0; i < cols; i++) {
137:                    String colName = "Column" + i;
138:                    fields[i] = new StringFieldDef(colName);
139:                    columns[i] = new ColumnConfig(colName, colName, 90);
140:                }
141:
142:                RecordDef recordDef = new RecordDef(fields);
143:                ColumnModel columnModel = new ColumnModel(columns);
144:
145:                for (int i = 0; i < rows; i++) {
146:                    for (int j = 0; j < cols; j++) {
147:                        data[i][j] = "(" + i + "," + j + ")";
148:                    }
149:                }
150:
151:                MemoryProxy proxy = new MemoryProxy(data);
152:                ArrayReader reader = new ArrayReader(recordDef);
153:                store = new Store(proxy, reader);
154:                store.load();
155:
156:                gridPanel.reconfigure(store, columnModel);
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.