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


001:        /*
002:         * Copyright 2000,2005 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:        package org.wings;
014:
015:        import org.wings.io.Device;
016:        import org.wings.plaf.MenuBarCG;
017:        import org.wings.plaf.MenuCG;
018:        import javax.swing.*;
019:        import java.io.IOException;
020:        import java.util.ArrayList;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Set;
024:
025:        /**
026:         * Aggregates various {@link SMenuItem}s under a main header entry.
027:         *
028:         * @author <a href="mailto:andre.lison@general-bytes.com">Andre Lison</a>
029:         * @author <a href="mailto:haaf@mercatis.de">Armin Haaf</a>
030:         */
031:        public class SMenu extends SMenuItem {
032:            private boolean popupMenuVisible = false;
033:            protected final List menuItems = new ArrayList();
034:            private double widthScaleFactor = 0.7f;
035:
036:            public SMenu(String text) {
037:                super (text);
038:            }
039:
040:            public SMenu() {
041:                super ();
042:            }
043:
044:            public SMenu(SIcon i) {
045:                super (i);
046:            }
047:
048:            public SMenu(String text, SIcon icon) {
049:                super (text, icon);
050:            }
051:
052:            /**
053:             * Add a menu item to this menu.
054:             */
055:            public void add(SMenuItem menuItem) {
056:                menuItems.add(menuItem);
057:                menuItem.setParentMenu(this );
058:                menuItem.putClientProperty("drm:realParentComponent", this );
059:                reload();
060:            }
061:
062:            /**
063:             * Add a menu item to this menu.
064:             */
065:            public void add(SComponent menuItem) {
066:                menuItems.add(menuItem);
067:                menuItem.setParentFrame(getParentFrame());
068:                menuItem.putClientProperty("drm:realParentComponent", this );
069:                reload();
070:            }
071:
072:            /**
073:             * Add a separator to this menu.
074:             */
075:            public void addSeparator() {
076:                add(new SSeparator());
077:            }
078:
079:            public void setParentFrame(SFrame f) {
080:                if (getParentFrame() == null && f != null) {
081:                    reload();
082:                }
083:                if (f != null
084:                        || (f == null && !getSession().getMenuManager()
085:                                .isMenuLinked(this ))) {
086:                    super .setParentFrame(f);
087:                    for (int i = 0; i < menuItems.size(); i++) {
088:                        ((SComponent) menuItems.get(i)).setParentFrame(f);
089:                    }
090:                }
091:            }
092:
093:            /**
094:             * Add a menu item to this menu.
095:             */
096:            public void add(String menuitem) {
097:                this .add(new SMenuItem(menuitem));
098:            }
099:
100:            public SComponent getMenuComponent(int pos) {
101:                return (SComponent) menuItems.get(pos);
102:            }
103:
104:            /**
105:             * Return the number of items on the menu, including separators.
106:             */
107:            public int getMenuComponentCount() {
108:                return menuItems.size();
109:            }
110:
111:            /**
112:             * Remove all {@link SMenuItem} from this menu.
113:             */
114:            public void removeAll() {
115:                while (menuItems.size() > 0) {
116:                    remove(0);
117:                }
118:            }
119:
120:            /**
121:             * Removes the menu item at specified index from the menu.
122:             */
123:            public void remove(int pos) {
124:                remove(getMenuComponent(pos));
125:            }
126:
127:            /**
128:             * removes a specific menu item component.
129:             */
130:            public void remove(SComponent comp) {
131:                if (menuItems.remove(comp)) {
132:                    reload();
133:                }
134:                comp.setParentFrame(null);
135:                comp.putClientProperty("drm:realParentComponent", "drm:null");
136:            }
137:
138:            public void setCG(MenuBarCG cg) {
139:                super .setCG(cg);
140:            }
141:
142:            /**
143:             * Sets the visibility of the menu's popup.
144:             * If the menu is not enabled, this method will have no effect.
145:             *
146:             * @param b a boolean value -- true to make the menu visible, false to hide it
147:             */
148:            public void setPopupMenuVisible(boolean b) {
149:                if (!isEnabled())
150:                    return;
151:                popupMenuVisible = b;
152:            }
153:
154:            /**
155:             * Returns true if the menu's popup window is visible.
156:             *
157:             * @return true if the menu is visible, else false.
158:             */
159:            public boolean isPopupMenuVisible() {
160:                return popupMenuVisible;
161:            }
162:
163:            /**
164:             * Returns the scale factor for the width of the Menu components.
165:             * The length of the children texts is multiplied by this factor and set as
166:             * width (in em) for the children.
167:             *
168:             * @return Returns the widthScaleFactor.
169:             */
170:            public double getWidthScaleFactor() {
171:                return widthScaleFactor;
172:            }
173:
174:            /**
175:             * Sets the scale factor for the width of the Menu components.
176:             * The length of the children texts is multiplied by this factor and set as
177:             * width (in em) for the children.
178:             *
179:             * Default value is 0.8.
180:             *
181:             * @param widthScaleFactor The widthScaleFactor to set.
182:             */
183:            public void setWidthScaleFactor(double widthScaleFactor) {
184:                this .widthScaleFactor = widthScaleFactor;
185:            }
186:
187:            /**
188:             * @return Returns the amount of children elements.
189:             */
190:            public int getChildrenCount() {
191:                return menuItems.size();
192:            }
193:
194:            /** gets the n'th child of the menu. If the index is too high, returns
195:             * null.
196:             * @param index the index of the child to return
197:             * @return the n'th child.
198:             */
199:            public SComponent getChild(int index) {
200:                if (getChildrenCount() > index) {
201:                    return (SComponent) menuItems.get(index);
202:                } else {
203:                    return null;
204:                }
205:            }
206:
207:            public void writePopup(Device device) throws IOException {
208:                ((MenuCG) getCG()).writePopup(device, this );
209:            }
210:
211:            public void setAccelerator(KeyStroke keyStroke) {
212:                throw new UnsupportedOperationException(
213:                        "Only invoke this on SMenuItem.");
214:            }
215:
216:            public void setEnabled(boolean enabled) {
217:                if (enabled != isEnabled()) {
218:                    Set menuLinks = getSession().getMenuManager()
219:                            .getMenueLinks(this );
220:                    for (Iterator i = menuLinks.iterator(); i.hasNext();) {
221:                        ((SComponent) i.next()).reload();
222:                    }
223:                }
224:                super.setEnabled(enabled);
225:            }
226:
227:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.