Source Code Cross Referenced for Showcase2.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:        /*
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:
009:        package com.gwtext.sample.showcase2.client;
010:
011:        import com.google.gwt.core.client.EntryPoint;
012:        import com.google.gwt.user.client.History;
013:        import com.google.gwt.user.client.HistoryListener;
014:        import com.google.gwt.user.client.ui.HTML;
015:        import com.google.gwt.user.client.ui.PopupPanel;
016:        import com.gwtext.client.core.EventObject;
017:        import com.gwtext.client.core.Margins;
018:        import com.gwtext.client.core.Position;
019:        import com.gwtext.client.core.RegionPosition;
020:        import com.gwtext.client.widgets.*;
021:        import com.gwtext.client.widgets.event.PanelListenerAdapter;
022:        import com.gwtext.client.widgets.event.TabPanelListenerAdapter;
023:        import com.gwtext.client.widgets.layout.BorderLayout;
024:        import com.gwtext.client.widgets.layout.BorderLayoutData;
025:        import com.gwtext.client.widgets.layout.FitLayout;
026:        import com.gwtext.client.widgets.menu.BaseItem;
027:        import com.gwtext.client.widgets.menu.Item;
028:        import com.gwtext.client.widgets.menu.Menu;
029:        import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
030:        import com.gwtext.client.widgets.tree.TreePanel;
031:
032:        public class Showcase2 implements  EntryPoint, HistoryListener {
033:
034:            private static PopupPanel messagePanel = new PopupPanel(true);
035:            private TabPanel centerPanel;
036:            private ScreenManager screenManager;
037:            private Menu menu;
038:
039:            public void onModuleLoad() {
040:
041:                //create the main panel and assign it a BorderLayout
042:                Panel mainPanel = new Panel();
043:                mainPanel.setLayout(new BorderLayout());
044:
045:                BorderLayoutData northLayoutData = new BorderLayoutData(
046:                        RegionPosition.NORTH);
047:                northLayoutData.setSplit(false);
048:
049:                BorderLayoutData centerLayoutData = new BorderLayoutData(
050:                        RegionPosition.CENTER);
051:                centerLayoutData.setMargins(new Margins(5, 0, 5, 5));
052:
053:                Panel centerPanelWrappper = new Panel();
054:                centerPanelWrappper.setLayout(new FitLayout());
055:                centerPanelWrappper.setBorder(false);
056:                centerPanelWrappper.setBodyBorder(false);
057:
058:                centerPanel = new TabPanel();
059:                centerPanel.setBodyBorder(false);
060:                centerPanel.setEnableTabScroll(true);
061:                centerPanel.setAutoScroll(true);
062:                centerPanel.setAutoDestroy(false);
063:                centerPanel.setActiveTab(0);
064:
065:                //hide the panel when the tab is closed
066:                centerPanel.addListener(new TabPanelListenerAdapter() {
067:                    public boolean doBeforeTabChange(TabPanel source,
068:                            Panel newPanel, Panel oldPanel) {
069:                        WindowMgr.hideAll();
070:                        return true;
071:                    }
072:
073:                    public void onRemove(Container self, Component component) {
074:                        component.hide();
075:                    }
076:
077:                    public void onContextMenu(TabPanel source, Panel tab,
078:                            EventObject e) {
079:                        showMenu(tab, e);
080:                    }
081:                });
082:
083:                centerPanel.setLayoutOnTabChange(true);
084:                centerPanel.setTitle("Main Content");
085:
086:                screenManager = new ScreenManager(centerPanel);
087:
088:                //setup the west regions layout properties
089:                BorderLayoutData westLayoutData = new BorderLayoutData(
090:                        RegionPosition.WEST);
091:                westLayoutData.setMargins(new Margins(5, 5, 0, 5));
092:                westLayoutData.setCMargins(new Margins(5, 5, 5, 5));
093:                westLayoutData.setMinSize(155);
094:                westLayoutData.setMaxSize(350);
095:                westLayoutData.setSplit(true);
096:
097:                //create the west panel and add it to the main panel applying the west region layout properties
098:                Panel westPanel = createWestPanel();
099:                mainPanel.add(westPanel, westLayoutData);
100:
101:                final Panel introPanel = new Panel();
102:                introPanel.setTitle("GWT-Ext 2.0 Showcase");
103:                introPanel.setPaddings(10);
104:                introPanel.setLayout(new FitLayout());
105:                final ShowcaseView showcaseView = new ShowcaseView(
106:                        screenManager);
107:                introPanel.add(showcaseView);
108:
109:                centerPanel.add(introPanel, centerLayoutData);
110:                centerPanelWrappper.add(centerPanel);
111:                mainPanel.add(centerPanelWrappper, centerLayoutData);
112:
113:                final String initToken = History.getToken();
114:                if (initToken.length() != 0) {
115:                    mainPanel.addListener(new PanelListenerAdapter() {
116:                        public void onRender(Component component) {
117:                            onHistoryChanged(initToken);
118:                        }
119:                    });
120:                }
121:
122:                Viewport viewport = new Viewport(mainPanel);
123:
124:                // Add history listener
125:                History.addHistoryListener(this );
126:            }
127:
128:            private Panel createWestPanel() {
129:                Panel westPanel = new Panel();
130:                westPanel.setId("side-nav");
131:                westPanel.setTitle("Showcase Explorer");
132:                westPanel.setLayout(new FitLayout());
133:                westPanel.setWidth(210);
134:                westPanel.setCollapsible(true);
135:
136:                Toolbar toolbar = new Toolbar();
137:                toolbar.addFill();
138:                toolbar.addItem(new ToolbarTextItem("Select Theme "));
139:                toolbar.addSpacer();
140:                toolbar.addField(new ThemeChanger());
141:                westPanel.setTopToolbar(toolbar);
142:
143:                TabPanel tabPanel = new TabPanel();
144:                tabPanel.setActiveTab(0);
145:                tabPanel.setDeferredRender(true);
146:                tabPanel.setTabPosition(Position.BOTTOM);
147:                TreePanel treePanel = screenManager.getTreeNav();
148:
149:                tabPanel.add(treePanel);
150:                tabPanel.add(screenManager.getAccordionNav());
151:                westPanel.add(tabPanel);
152:
153:                return westPanel;
154:            }
155:
156:            /**
157:             * This method is called whenever the application's history changes.
158:             *
159:             * @param historyToken the histrory token
160:             */
161:            public void onHistoryChanged(String historyToken) {
162:                screenManager.showScreen(historyToken);
163:            }
164:
165:            private void showMenu(final Panel tab, EventObject e) {
166:                if (menu == null) {
167:                    menu = new Menu();
168:                    Item close = new Item("Close Tab");
169:                    close.setId("close-tab-item");
170:                    close.addListener(new BaseItemListenerAdapter() {
171:                        public void onClick(BaseItem item, EventObject e) {
172:                            centerPanel.remove(centerPanel.getActiveTab());
173:                        }
174:                    });
175:                    menu.addItem(close);
176:
177:                    Item closeOthers = new Item("Close Other Tabs");
178:                    closeOthers.setId("close-others-item");
179:                    closeOthers.addListener(new BaseItemListenerAdapter() {
180:                        public void onClick(BaseItem item, EventObject e) {
181:                            Component[] items = centerPanel.getItems();
182:                            for (int i = 0; i < items.length; i++) {
183:                                Panel panel = (Panel) items[i];
184:                                if (panel.isClosable()
185:                                        && !panel.getId().equals(
186:                                                centerPanel.getActiveTab()
187:                                                        .getId())) {
188:                                    centerPanel.remove(panel);
189:                                }
190:                            }
191:                        }
192:                    });
193:                    menu.addItem(closeOthers);
194:                }
195:
196:                BaseItem close = menu.getItem("close-tab-item");
197:                if (!centerPanel.getActiveTab().isClosable()) {
198:                    close.disable();
199:                } else {
200:                    close.enable();
201:                }
202:
203:                BaseItem closeOthers = menu.getItem("close-others-item");
204:                if (centerPanel.getItems().length == 1) {
205:                    closeOthers.disable();
206:                } else {
207:                    closeOthers.enable();
208:                }
209:                menu.showAt(e.getXY());
210:            }
211:
212:            public static void showMessage(String title, String message) {
213:                messagePanel.setPopupPosition(500, 300);
214:                messagePanel
215:                        .setWidget(new HTML(getMessageHtml(title, message)));
216:                messagePanel.setWidth("300px");
217:                messagePanel.show();
218:            }
219:
220:            private static native String getMessageHtml(String title,
221:                    String message) /*-{
222:                                                                     return ['<div class="msg">',
223:                                                                             '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
224:                                                                             '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', title, '</h3>', message, '</div></div></div>',
225:                                                                             '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
226:                                                                             '</div>'].join('');
227:                                                                 }-*/;
228:
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.