Source Code Cross Referenced for SubstanceMenuBarUI.java in  » Swing-Library » substance-look-feel » org » jvnet » substance » 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 » substance look feel » org.jvnet.substance 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         *  o Redistributions of source code must retain the above copyright notice,
008:         *    this list of conditions and the following disclaimer.
009:         *
010:         *  o Redistributions in binary form must reproduce the above copyright notice,
011:         *    this list of conditions and the following disclaimer in the documentation
012:         *    and/or other materials provided with the distribution.
013:         *
014:         *  o Neither the name of Substance Kirill Grouchnikov nor the names of
015:         *    its contributors may be used to endorse or promote products derived
016:         *    from this software without specific prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029:         */
030:        package org.jvnet.substance;
031:
032:        import java.awt.Graphics;
033:        import java.util.Iterator;
034:        import java.util.Set;
035:
036:        import javax.swing.JComponent;
037:        import javax.swing.plaf.ComponentUI;
038:        import javax.swing.plaf.basic.BasicMenuBarUI;
039:
040:        import org.jvnet.lafwidget.*;
041:        import org.jvnet.lafwidget.layout.TransitionLayout;
042:        import org.jvnet.lafwidget.menu.MenuSearchWidget;
043:        import org.jvnet.substance.painter.decoration.DecorationAreaType;
044:        import org.jvnet.substance.painter.decoration.SubstanceDecorationUtilities;
045:        import org.jvnet.substance.utils.MemoryAnalyzer;
046:
047:        /**
048:         * UI for menu bars in <b>Substance</b> look and feel.
049:         * 
050:         * @author Kirill Grouchnikov
051:         */
052:        public class SubstanceMenuBarUI extends BasicMenuBarUI {
053:            /**
054:             * Set of registered widgets. This UI delegate maintains the widget set on
055:             * its own since it needs to reset the relevant ({@link Resettable})
056:             * widgets on theme change and on locale change.
057:             */
058:            protected Set<?> lafWidgets;
059:
060:            /**
061:             * Delegate for painting the background.
062:             */
063:            // private static SubstanceFillBackgroundDelegate backgroundDelegate = new
064:            // SubstanceFillBackgroundDelegate();
065:            // /**
066:            // * Locale change listener. Resets all {@link Resettable} widgets.
067:            // */
068:            // private LocaleChangeListener substanceLocaleChangeListener;
069:            //
070:            // /**
071:            // * Theme change listener. Resets all {@link Resettable} widgets.
072:            // */
073:            // private ThemeChangeListener substanceThemeChangeListener;
074:            /**
075:             * Hides search panels on all menu bars (both JFrames and JInternalFrames).
076:             * 
077:             * @param toRepaint
078:             *            Indication whether the relevant menu bars should be repainted.
079:             */
080:            public static void hideSearchPanels(final boolean toRepaint) {
081:                MenuSearchWidget.hideSearchPanels(toRepaint);
082:            }
083:
084:            /**
085:             * Shows search panels on all menu bars (both JFrames and JInternalFrames).
086:             */
087:            public static void showSearchPanels() {
088:                MenuSearchWidget.showSearchPanels();
089:            }
090:
091:            /*
092:             * (non-Javadoc)
093:             * 
094:             * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent)
095:             */
096:            public static ComponentUI createUI(JComponent c) {
097:                if (MemoryAnalyzer.isRunning()) {
098:                    MemoryAnalyzer
099:                            .enqueueUsage("SubstanceMenuBarUI to be created");
100:                }
101:                return new SubstanceMenuBarUI();
102:            }
103:
104:            /*
105:             * (non-Javadoc)
106:             * 
107:             * @see javax.swing.plaf.basic.BasicMenuBarUI#installListeners()
108:             */
109:            @Override
110:            protected void installListeners() {
111:                super .installListeners();
112:
113:                // this.substanceThemeChangeListener = new ThemeChangeListener() {
114:                // public void themeChanged() {
115:                // for (Iterator<?> it = lafWidgets.iterator(); it.hasNext();) {
116:                // LafWidget lw = (LafWidget) it.next();
117:                // if (lw instanceof Resettable) {
118:                // ((Resettable) lw).reset();
119:                // }
120:                // }
121:                // }
122:                // };
123:                // SubstanceLookAndFeel
124:                // .registerThemeChangeListener(this.substanceThemeChangeListener);
125:                //
126:                // substanceLocaleChangeListener = new LocaleChangeListener() {
127:                // public void localeChanged() {
128:                // for (Iterator<?> it = lafWidgets.iterator(); it.hasNext();) {
129:                // LafWidget lw = (LafWidget) it.next();
130:                // if (lw instanceof Resettable) {
131:                // ((Resettable) lw).reset();
132:                // }
133:                // }
134:                // }
135:                // };
136:                // SubstanceLookAndFeel
137:                // .registerLocaleChangeListener(substanceLocaleChangeListener);
138:
139:                // Installs listeners on all widgets
140:                for (Iterator<?> it = this .lafWidgets.iterator(); it.hasNext();) {
141:                    LafWidget lw = (LafWidget) it.next();
142:                    lw.installListeners();
143:                }
144:
145:            }
146:
147:            /*
148:             * (non-Javadoc)
149:             * 
150:             * @see javax.swing.plaf.basic.BasicMenuBarUI#uninstallListeners()
151:             */
152:            @Override
153:            protected void uninstallListeners() {
154:                // SubstanceLookAndFeel
155:                // .unregisterThemeChangeListener(this.substanceThemeChangeListener);
156:                // this.substanceThemeChangeListener = null;
157:                //
158:                // SubstanceLookAndFeel
159:                // .unregisterLocaleChangeListener(this.substanceLocaleChangeListener);
160:                // this.substanceLocaleChangeListener = null;
161:
162:                super .uninstallListeners();
163:
164:                // Uninstalls defaults on all widgets
165:                for (Iterator<?> it = this .lafWidgets.iterator(); it.hasNext();) {
166:                    LafWidget lw = (LafWidget) it.next();
167:                    lw.uninstallDefaults();
168:                }
169:            }
170:
171:            /*
172:             * (non-Javadoc)
173:             * 
174:             * @see javax.swing.plaf.basic.BasicMenuBarUI#installUI(javax.swing.JComponent)
175:             */
176:            @Override
177:            public void installUI(JComponent c) {
178:                // Fetches all widgets that were registered for the
179:                // specified component
180:                this .lafWidgets = LafWidgetRepository.getRepository()
181:                        .getMatchingWidgets(c);
182:                super .installUI(c);
183:
184:                // Installs all widgets
185:                for (Iterator<?> it = this .lafWidgets.iterator(); it.hasNext();) {
186:                    LafWidget lw = (LafWidget) it.next();
187:                    lw.installUI();
188:                }
189:            }
190:
191:            /*
192:             * (non-Javadoc)
193:             * 
194:             * @see javax.swing.plaf.basic.BasicMenuBarUI#installDefaults()
195:             */
196:            @Override
197:            protected void installDefaults() {
198:                super .installDefaults();
199:
200:                // Installs defaults on all widgets
201:                for (Iterator<?> it = this .lafWidgets.iterator(); it.hasNext();) {
202:                    LafWidget lw = (LafWidget) it.next();
203:                    lw.installDefaults();
204:                }
205:
206:                SubstanceDecorationUtilities.setDecorationType(this .menuBar,
207:                        DecorationAreaType.HEADER);
208:            }
209:
210:            /*
211:             * (non-Javadoc)
212:             * 
213:             * @see javax.swing.plaf.basic.BasicMenuBarUI#uninstallUI(javax.swing.JComponent)
214:             */
215:            @Override
216:            public void uninstallUI(JComponent c) {
217:                // System.out.println("Uninstalling MenuBarUI " + this.menuBar);
218:                if (this .menuBar == null)
219:                    return;
220:
221:                super .uninstallUI(c);
222:
223:                // Uninstalls all widgets
224:                for (Iterator<?> it = this .lafWidgets.iterator(); it.hasNext();) {
225:                    LafWidget lw = (LafWidget) it.next();
226:                    lw.uninstallUI();
227:                }
228:            }
229:
230:            /*
231:             * (non-Javadoc)
232:             * 
233:             * @see javax.swing.plaf.basic.BasicMenuBarUI#uninstallDefaults()
234:             */
235:            @Override
236:            protected void uninstallDefaults() {
237:                SubstanceDecorationUtilities.clearDecorationType(this .menuBar);
238:
239:                super .uninstallDefaults();
240:
241:                // Uninstalls defaults on all widgets
242:                for (Iterator<?> it = this .lafWidgets.iterator(); it.hasNext();) {
243:                    LafWidget lw = (LafWidget) it.next();
244:                    lw.uninstallDefaults();
245:                }
246:            }
247:
248:            /*
249:             * (non-Javadoc)
250:             * 
251:             * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics,
252:             *      javax.swing.JComponent)
253:             */
254:            @Override
255:            public void update(Graphics g, JComponent c) {
256:                boolean isOpaque = TransitionLayout.isOpaque(c);
257:                if (isOpaque) {
258:                    SubstanceFillBackgroundDelegate.GLOBAL_INSTANCE.update(g,
259:                            c, false);
260:                } else {
261:                    super .update(g, c);
262:                }
263:                // GhostPaintingUtils.paintGhostImages(c, g);
264:            }
265:
266:            /**
267:             * Returns the installed widgets.
268:             * 
269:             * @return Installed widgets.
270:             */
271:            public Set<?> getLafWidgets() {
272:                return lafWidgets;
273:            }
274:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.