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


001:        package org.jvnet.substance.netbeans.ui;
002:
003:        import java.awt.Frame;
004:        import java.awt.event.ActionEvent;
005:        import java.beans.PropertyChangeListener;
006:        import java.util.Iterator;
007:        import java.util.Map;
008:        import javax.swing.AbstractAction;
009:        import javax.swing.Action;
010:        import javax.swing.JMenu;
011:        import javax.swing.JMenuItem;
012:        import javax.swing.LookAndFeel;
013:        import javax.swing.SwingUtilities;
014:        import javax.swing.UIManager;
015:        import org.jvnet.substance.SubstanceLookAndFeel;
016:        import org.jvnet.substance.button.ButtonShaperInfo;
017:        import org.openide.util.NbBundle;
018:        import org.openide.util.WeakListeners;
019:        import org.openide.util.WeakSet;
020:        import org.openide.util.actions.Presenter;
021:
022:        /**
023:         *
024:         * @author Timothy Boudreau
025:         */
026:        public class ButtonShapeSelector extends AbstractAction implements 
027:                Presenter.Menu, Presenter.Popup {
028:            public void actionPerformed(ActionEvent e) {
029:                throw new UnsupportedOperationException();
030:            }
031:
032:            public JMenuItem getPopupPresenter() {
033:                return getMenuPresenter();
034:            }
035:
036:            public JMenuItem getMenuPresenter() {
037:                LookAndFeel lf = UIManager.getLookAndFeel();
038:                JMenu result = new JMenu(NbBundle.getMessage(getClass(),
039:                        "LBL_ButtonShapers")); //NOI18N
040:
041:                if (lf instanceof  SubstanceLookAndFeel) {
042:                    Map shapers = SubstanceLookAndFeel.getAllButtonShapers();
043:                    for (Iterator i = shapers.keySet().iterator(); i.hasNext();) {
044:                        String shaper = (String) i.next();
045:                        JMenuItem item = new JMenuItem(
046:                                new ChangeButtonShaperAction(shaper));
047:
048:                        result.add(item);
049:                    }
050:                } else {
051:                    result.setText(NbBundle.getMessage(getClass(),
052:                            "LBL_NotRunning")); //NOI18N
053:                    result.setEnabled(false);
054:                }
055:                return result;
056:            }
057:
058:            private static final WeakSet allActions = new WeakSet();
059:
060:            private static void updateActions() {
061:                for (Iterator i = allActions.iterator(); i.hasNext();) {
062:                    ChangeButtonShaperAction a = (ChangeButtonShaperAction) i
063:                            .next();
064:                    if (a != null) {
065:                        a.update();
066:                    }
067:                }
068:            }
069:
070:            private static final class ChangeButtonShaperAction extends
071:                    AbstractAction {
072:                private final String name;
073:
074:                public ChangeButtonShaperAction(String name) {
075:                    this .name = name;
076:                    update();
077:                    allActions.add(this );
078:                }
079:
080:                private void update() {
081:                    String nm = name;
082:                    if (nm.equals(SubstanceLookAndFeel
083:                            .getCurrentButtonShaperName())) {
084:                        nm = "<html><b>" + nm + "</b></html>"; //NOI18N
085:                    }
086:                    putValue(Action.NAME, nm);
087:                }
088:
089:                public void addPropertyChangeListener(PropertyChangeListener pcl) {
090:                    //ensure old menu items can be garbage collected
091:                    super .addPropertyChangeListener(WeakListeners
092:                            .propertyChange(pcl, this ));
093:                }
094:
095:                public void actionPerformed(ActionEvent e) {
096:                    ButtonShaperInfo info = (ButtonShaperInfo) SubstanceLookAndFeel
097:                            .getAllButtonShapers().get(name);
098:
099:                    String shaperClass = info.getClassName();
100:                    setButtonShaper(shaperClass);
101:                    ButtonShapeSelector.updateUIs();
102:                    persist(shaperClass);
103:                    updateActions();
104:                    assert info != null;
105:                }
106:            }
107:
108:            static void setButtonShaper(String s) {
109:                SubstanceLookAndFeel.setCurrentButtonShaper(s);
110:            }
111:
112:            static void persist(String value) {
113:                NbPrefs p = new NbPrefs();
114:                p.put("shaperClassName", value); //NOI18N
115:                // p.put ("skinClassName", null); //NOI18N
116:            }
117:
118:            public static boolean restore() {
119:                NbPrefs p = new NbPrefs();
120:                String preferred = p.get("shaperClassName", null); //NOI18N
121:                if (preferred != null) {
122:                    setButtonShaper(preferred);
123:                }
124:                return preferred != null;
125:            }
126:
127:            public static final void updateUIs() {
128:                Frame[] f = Frame.getFrames();
129:                for (int i = 0; i < f.length; i++) {
130:                    SwingUtilities.updateComponentTreeUI(f[i]);
131:                }
132:            }
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.