Source Code Cross Referenced for FeatureTree.java in  » Web-Framework » Millstone » org » millstone » examples » features » 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 » Web Framework » Millstone » org.millstone.examples.features 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* *************************************************************************
002:         
003:                                        Millstone(TM) 
004:                           Open Sourced User Interface Library for
005:                               Internet Development with Java
006:
007:                     Millstone is a registered trademark of IT Mill Ltd
008:                          Copyright (C) 2000-2005 IT Mill Ltd
009:                             
010:         *************************************************************************
011:
012:           This library is free software; you can redistribute it and/or
013:           modify it under the terms of the GNU Lesser General Public
014:           license version 2.1 as published by the Free Software Foundation.
015:
016:           This library is distributed in the hope that it will be useful,
017:           but WITHOUT ANY WARRANTY; without even the implied warranty of
018:           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019:           Lesser General Public License for more details.
020:
021:           You should have received a copy of the GNU Lesser General Public
022:           License along with this library; if not, write to the Free Software
023:           Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:
025:         *************************************************************************
026:           
027:           For more information, contact:
028:           
029:           IT Mill Ltd                           phone: +358 2 4802 7180
030:           Ruukinkatu 2-4                        fax:  +358 2 4802 7181
031:           20540, Turku                          email: info@itmill.com
032:           Finland                               company www: www.itmill.com
033:           
034:           Primary source for MillStone information and releases: www.millstone.org
035:
036:         ********************************************************************** */
037:
038:        package org.millstone.examples.features;
039:
040:        import java.util.Iterator;
041:
042:        import org.millstone.base.ui.*;
043:        import org.millstone.base.event.Action;
044:
045:        public class FeatureTree extends Feature implements  Action.Handler {
046:
047:            private static final String[] firstnames = new String[] { "John",
048:                    "Mary", "Joe", "Sarah", "Jeff", "Jane", "Peter", "Marc",
049:                    "Josie", "Linus" };
050:            private static final String[] lastnames = new String[] {
051:                    "Torvalds", "Smith", "Jones", "Beck", "Sheridan", "Picard",
052:                    "Hill", "Fielding", "Einstein" };
053:
054:            private Tree t;
055:
056:            private boolean actionsActive = false;
057:            private Button actionHandlerSwitch = new Button("Activate actions",
058:                    this , "toggleActions");
059:
060:            public FeatureTree() {
061:                super ();
062:            }
063:
064:            public void toggleActions() {
065:                if (actionsActive) {
066:                    t.removeActionHandler(this );
067:                    actionsActive = false;
068:                    actionHandlerSwitch.setCaption("Activate Actions");
069:                } else {
070:                    t.addActionHandler(this );
071:                    actionsActive = true;
072:                    actionHandlerSwitch.setCaption("Deactivate Actions");
073:                }
074:            }
075:
076:            public void expandAll() {
077:                for (Iterator i = t.rootItemIds().iterator(); i.hasNext();) {
078:                    t.expandItemsRecursively(i.next());
079:                }
080:            }
081:
082:            public void collapseAll() {
083:                for (Iterator i = t.rootItemIds().iterator(); i.hasNext();) {
084:                    t.collapseItemsRecursively(i.next());
085:                }
086:            }
087:
088:            protected Component getDemoComponent() {
089:
090:                OrderedLayout l = new OrderedLayout();
091:
092:                // Create names
093:                Panel show = new Panel("Tree component");
094:                String[] names = new String[100];
095:                for (int i = 0; i < names.length; i++)
096:                    names[i] = firstnames[(int) (Math.random() * (firstnames.length - 1))]
097:                            + " "
098:                            + lastnames[(int) (Math.random() * (lastnames.length - 1))];
099:
100:                // Create tree
101:                t = new Tree("Family Tree");
102:                for (int i = 0; i < 100; i++) {
103:                    t.addItem(names[i]);
104:                    String parent = names[(int) (Math.random() * (names.length - 1))];
105:                    if (t.containsId(parent))
106:                        t.setParent(names[i], parent);
107:                }
108:
109:                // Forbid childless people to have children (makes them leaves)
110:                for (int i = 0; i < 100; i++)
111:                    if (!t.hasChildren(names[i]))
112:                        t.setChildrenAllowed(names[i], false);
113:
114:                show.addComponent(t);
115:                l.addComponent(show);
116:
117:                // Actions
118:                l.addComponent(this .actionHandlerSwitch);
119:
120:                // Expand and Collapse buttons 
121:                l.addComponent(new Button("Expand All", this , "expandAll"));
122:                l.addComponent(new Button("Collapse All", this , "collapseAll"));
123:
124:                // Properties
125:                PropertyPanel p = new PropertyPanel(t);
126:                Form ap = p
127:                        .createBeanPropertySet(new String[] { "selectable" });
128:                Select themes = (Select) p.getField("style");
129:                themes.addItem("menu").getItemProperty(
130:                        themes.getItemCaptionPropertyId()).setValue("menu");
131:                p.addProperties("Tree Properties", ap);
132:                l.addComponent(p);
133:
134:                return l;
135:            }
136:
137:            protected String getExampleSrc() {
138:                return "// Create tree\n"
139:                        + "t = new Tree(\"Family Tree\");\n"
140:                        + "for (int i = 0; i < 100; i++) {\n"
141:                        + " t.addItem(names[i]);\n"
142:                        + " String parent = names[(int) (Math.random() * (names.length - 1))];\n"
143:                        + " if (t.containsId(parent)) \n"
144:                        + "     t.setParent(names[i],parent);\n"
145:                        + "}\n\n"
146:                        + "// Forbid childless people to have children (makes them leaves)\n"
147:                        + "for (int i = 0; i < 100; i++)\n"
148:                        + " if (!t.hasChildren(names[i]))\n"
149:                        + "     t.setChildrenAllowed(names[i], false);\n";
150:            }
151:
152:            protected String getDescriptionXHTML() {
153:                return "<p>A tree is a natural way to represent datasets that have"
154:                        + " hierarchical relationships, such as filesystems, message "
155:                        + "threads or... family trees. Millstone features a versatile "
156:                        + "and powerful Tree component that works much like the tree components "
157:                        + "of most modern operating systems. </p>"
158:                        + "<p>The most prominent use of the Tree component is to "
159:                        + "use it for displaying a hierachical menu, like the "
160:                        + "menu on the left side of the screen for instance "
161:                        + "or to display filesystems or other hierarchical datasets.</p>"
162:                        + "<p>The tree component uses <code>Container</code> "
163:                        + "datasources much like the Table component, "
164:                        + "with the addition that it also utilizes the hierarchy "
165:                        + "information maintained by the container. </p><p>On "
166:                        + "the demo tab you can try out how the different properties "
167:                        + "affect the presentation of the tree component.</p>";
168:            }
169:
170:            protected String getImage() {
171:                return "tree.jpg";
172:            }
173:
174:            protected String getTitle() {
175:                return "Tree";
176:            }
177:
178:            private Action ACTION1 = new Action("Action 1");
179:            private Action ACTION2 = new Action("Action 2");
180:            private Action ACTION3 = new Action("Action 3");
181:
182:            private Action[] actions = new Action[] { ACTION1, ACTION2, ACTION3 };
183:
184:            public Action[] getActions(Object target, Object sender) {
185:                return actions;
186:            }
187:
188:            public void handleAction(Action action, Object sender, Object target) {
189:                t.setDescription("Last action clicked was '"
190:                        + action.getCaption() + "' on item '" + target + "'");
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.