Source Code Cross Referenced for WingSet.java in  » Swing-Library » wings3 » wingset » 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 » Swing Library » wings3 » wingset 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package wingset;
002:
003:        import org.apache.commons.logging.Log;
004:        import org.apache.commons.logging.LogFactory;
005:        import org.wings.Resource;
006:        import org.wings.SBorderLayout;
007:        import org.wings.SCardLayout;
008:        import org.wings.SComponent;
009:        import org.wings.SConstants;
010:        import org.wings.SDimension;
011:        import org.wings.SFrame;
012:        import org.wings.SPanel;
013:        import org.wings.SScrollPane;
014:        import org.wings.STemplateLayout;
015:        import org.wings.STree;
016:        import org.wings.border.SLineBorder;
017:        import org.wings.header.StyleSheetHeader;
018:        import org.wings.plaf.WingSetExample;
019:        import org.wings.plaf.css.Utils;
020:        import org.wings.resource.ReloadResource;
021:        import org.wings.session.ResourceMapper;
022:        import org.wings.session.SessionManager;
023:        import org.wings.style.CSSProperty;
024:        import org.wings.tree.SDefaultTreeCellRenderer;
025:
026:        import javax.swing.event.TreeSelectionEvent;
027:        import javax.swing.event.TreeSelectionListener;
028:        import javax.swing.tree.DefaultMutableTreeNode;
029:        import javax.swing.tree.TreeSelectionModel;
030:        import java.awt.Color;
031:        import java.util.Enumeration;
032:        import java.util.HashMap;
033:        import java.util.Map;
034:
035:        /**
036:         * The root of the WingSet demo application.
037:         *
038:         * @author holger engels
039:         */
040:        public class WingSet {
041:            /**
042:             * If true then use {@link wingset.StatisticsTimerTask} to log statistics on a regular basis to a logging file. (Typically a file named
043:             * wings-statisticsxxxlog placed in jakarta-tomcat/temp directory)
044:             */
045:            private static final boolean LOG_STATISTICS_TO_FILE = false;
046:
047:            private final static Log log = LogFactory.getLog(WingSet.class);
048:
049:            static {
050:                if (LOG_STATISTICS_TO_FILE) {
051:                    StatisticsTimerTask.startStatisticsLogging(60);
052:                }
053:            }
054:
055:            /**
056:             * The root frame of the WingSet application.
057:             */
058:            private final SFrame frame = new SFrame("WingSet Demo");
059:
060:            private final SPanel panel;
061:            private final STree tree;
062:            private final SPanel header;
063:            private final SPanel content;
064:            private final WingsImage wingsImage;
065:            private final SCardLayout cards = new SCardLayout();
066:            private final Map<String, WingSetExample> exampleByName = new HashMap<String, WingSetExample>();
067:
068:            /**
069:             * Constructor of the wingS application.
070:             * <p/>
071:             * <p>This class is referenced in the <code>web.xml</code> as root entry point for the wingS application. For every new client an new
072:             * {@link org.wings.session.Session} is created which constructs a new instance of this class.
073:             */
074:            public WingSet() {
075:                wingsImage = new WingsImage();
076:
077:                WingSetTreeModel treeModel = new WingSetTreeModel();
078:                tree = new STree(treeModel);
079:                tree.setName("examples");
080:                tree.addTreeSelectionListener(new TreeSelectionListener() {
081:                    public void valueChanged(TreeSelectionEvent e) {
082:                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree
083:                                .getLastSelectedPathComponent();
084:                        if (node == null) {
085:                            show(wingsImage);
086:                        } else {
087:                            Object userObject = node.getUserObject();
088:                            if (userObject instanceof  WingSetExample) {
089:                                WingSetExample wingSetPane = (WingSetExample) userObject;
090:                                wingSetPane.activateExample();
091:                                show(wingSetPane.getExample());
092:                            } else {
093:                                show(wingsImage);
094:                            }
095:                        }
096:                    }
097:                });
098:                tree.getSelectionModel().setSelectionMode(
099:                        TreeSelectionModel.SINGLE_TREE_SELECTION);
100:                tree.setVerticalAlignment(SConstants.TOP_ALIGN);
101:                tree.setCellRenderer(new SDefaultTreeCellRenderer() {
102:                    public SComponent getTreeCellRendererComponent(STree tree,
103:                            Object value, boolean selected, boolean expanded,
104:                            boolean leaf, int row, boolean hasFocus) {
105:                        if (value instanceof  DefaultMutableTreeNode) {
106:                            Object example = ((DefaultMutableTreeNode) value)
107:                                    .getUserObject();
108:                            if (example instanceof  WingSetExample)
109:                                value = ((WingSetExample) example)
110:                                        .getExampleName();
111:                        }
112:                        return super .getTreeCellRendererComponent(tree, value,
113:                                selected, expanded, leaf, row, hasFocus);
114:                    }
115:                });
116:                expandAllTreeNodes(tree);
117:
118:                SScrollPane scrollPane = new SScrollPane(tree);
119:                scrollPane.setMode(SScrollPane.MODE_COMPLETE);
120:                scrollPane.setPreferredSize(new SDimension("220px", "100%"));
121:                scrollPane.setVerticalAlignment(SConstants.TOP_ALIGN);
122:                SLineBorder border = new SLineBorder(new Color(190, 190, 190),
123:                        0);
124:                border.setThickness(1, SConstants.RIGHT);
125:                scrollPane.setBorder(border);
126:
127:                header = createHeader();
128:
129:                content = new SPanel(cards);
130:                content.setPreferredSize(SDimension.FULLAREA);
131:                content.add(wingsImage);
132:
133:                panel = new SPanel(new SBorderLayout());
134:                panel.setPreferredSize(SDimension.FULLAREA);
135:                panel.add(header, SBorderLayout.NORTH);
136:                panel.add(scrollPane, SBorderLayout.WEST);
137:                panel.add(content, SBorderLayout.CENTER);
138:
139:                frame.getContentPane().add(panel, SBorderLayout.CENTER);
140:                frame.getContentPane().setPreferredSize(SDimension.FULLAREA);
141:                if (!Utils.isMSIE(frame)) {
142:                    frame.getContentPane().setAttribute(CSSProperty.POSITION,
143:                            "absolute");
144:                    frame.getContentPane().setAttribute(CSSProperty.HEIGHT,
145:                            "100%");
146:                    frame.getContentPane().setAttribute(CSSProperty.WIDTH,
147:                            "100%");
148:                }
149:                frame.setAttribute(CSSProperty.POSITION, "absolute");
150:                frame.setAttribute(CSSProperty.HEIGHT, "100%");
151:                frame.setAttribute(CSSProperty.WIDTH, "100%");
152:
153:                frame.addHeader(new StyleSheetHeader("../css/wingset2.css"));
154:
155:                frame.show();
156:
157:                Enumeration enumeration = ((DefaultMutableTreeNode) treeModel
158:                        .getRoot()).breadthFirstEnumeration();
159:                while (enumeration.hasMoreElements()) {
160:                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) enumeration
161:                            .nextElement();
162:                    Object userObject = node.getUserObject();
163:                    if (userObject instanceof  WingSetExample) {
164:                        WingSetExample wingSetPane = (WingSetExample) userObject;
165:                        exampleByName.put(wingSetPane.getExampleName(),
166:                                wingSetPane);
167:                    }
168:                }
169:
170:                SessionManager.getSession().setResourceMapper(
171:                        new ResourceMapper() {
172:                            public Resource mapResource(String url) {
173:                                String name = url.substring(1);
174:                                WingSetExample pane = exampleByName.get(name);
175:                                if (pane != null) {
176:                                    show(pane.getExample());
177:                                }
178:                                return frame
179:                                        .getDynamicResource(ReloadResource.class);
180:                            }
181:                        });
182:            }
183:
184:            public final void expandAllTreeNodes(STree tree) {
185:                for (int i = 0; i < tree.getRowCount(); ++i) {
186:                    tree.expandRow(i);
187:                }
188:            }
189:
190:            private void show(SComponent component) {
191:                if (component.getParent() != content) {
192:                    content.add(component);
193:                }
194:                cards.show(component);
195:            }
196:
197:            private SPanel createHeader() {
198:                SPanel header = new SPanel();
199:                header.setPreferredSize(SDimension.FULLWIDTH);
200:                header.setStyle("wingset_header");
201:
202:                try {
203:                    header.setLayout(new STemplateLayout(SessionManager
204:                            .getSession().getServletContext().getRealPath(
205:                                    "/templates/WingSetHeader.thtml")));
206:                } catch (java.io.IOException ex) {
207:                    log.error("Could not find template file!", ex);
208:                }
209:
210:                return header;
211:            }
212:
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.