Source Code Cross Referenced for SynthLookAndFeel.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » plaf » synth » 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 » Apache Harmony Java SE » javax package » javax.swing.plaf.synth 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        package javax.swing.plaf.synth;
019:
020:        import java.awt.Component;
021:        import java.io.IOException;
022:        import java.io.InputStream;
023:        import java.io.Serializable;
024:        import java.text.ParseException;
025:
026:        import javax.swing.JComponent;
027:        import javax.swing.UIDefaults;
028:        import javax.swing.plaf.ComponentUI;
029:        import javax.swing.plaf.basic.BasicLookAndFeel;
030:        import javax.xml.parsers.ParserConfigurationException;
031:        import javax.xml.parsers.SAXParser;
032:        import javax.xml.parsers.SAXParserFactory;
033:
034:        import org.apache.harmony.x.swing.internal.nls.Messages;
035:        import org.xml.sax.SAXException;
036:
037:        import org.apache.harmony.luni.util.NotImplementedException;
038:
039:        public class SynthLookAndFeel extends BasicLookAndFeel implements 
040:                Serializable {
041:
042:            /** Path used in UIDefaults */
043:            private final static String pathToSynthLaf = "javax.swing.plaf.synth.SynthLookAndFeel"; //$NON-NLS-1$
044:
045:            private static SynthStyleFactory currentFactory;
046:
047:            private UIDefaults uiDefaults;
048:
049:            public static SynthStyle getStyle(JComponent c, Region r) {
050:
051:                return currentFactory.getStyle(c, r);
052:            }
053:
054:            public static SynthStyleFactory getStyleFactory() {
055:
056:                return currentFactory;
057:            }
058:
059:            public static void setStyleFactory(SynthStyleFactory proposed) {
060:                currentFactory = proposed;
061:            }
062:
063:            /**
064:             * Creates the Synth UI object corresponds JComponent given. (This method
065:             * used by UIManager because all the UIs classes are package-protected
066:             * according to spec, so reference in defaults table points to
067:             * SynthLookAndFeel)
068:             * 
069:             * @see SynthLookAndFeel#initClassDefaults(UIDefaults)
070:             */
071:            @SuppressWarnings("nls")
072:            public static ComponentUI createUI(JComponent c)
073:                    throws NotImplementedException {
074:
075:                // Commented because UI's patch is not ready for now
076:
077:                // String uiClassID = c.getUIClassID().intern();
078:                //
079:                // if (uiClassID == "InternalFrameUI") {
080:                // return SynthInternalFrameUI.createUI(c);
081:                // } else if (uiClassID == "ViewportUI") {
082:                // return SynthViewportUI.createUI(c);
083:                // } else if (uiClassID == "ScrollBarUI") {
084:                // SynthScrollBarUI.createUI(c);
085:                // } else if (uiClassID == "ToolTipUI") {
086:                // return SynthToolTipUI.createUI(c);
087:                // } else if (uiClassID == "MenuItemUI") {
088:                // return SynthMenuItemUI.createUI(c);
089:                // } else if (uiClassID == "MenuUI") {
090:                // return SynthMenuUI.createUI(c);
091:                // } else if (uiClassID == "TextAreaUI") {
092:                // return SynthTextAreaUI.createUI(c);
093:                // } else if (uiClassID == "PopupMenuUI") {
094:                // return SynthPopupMenuUI.createUI(c);
095:                // } else if (uiClassID == "ScrollPaneUI") {
096:                // return SynthScrollPaneUI.createUI(c);
097:                // } else if (uiClassID == "SliderUI") {
098:                // return SynthSliderUI.createUI(c);
099:                // } else if (uiClassID == "ComboBoxUI") {
100:                // return SynthComboBoxUI.createUI(c);
101:                // } else if (uiClassID == "RadioButtonUI") {
102:                // return SynthRadioButtonUI.createUI(c);
103:                // } else if (uiClassID == "FormattedTextFieldUI") {
104:                // return SynthFormattedTextFieldUI.createUI(c);
105:                // } else if (uiClassID == "TreeUI") {
106:                // return SynthTreeUI.createUI(c);
107:                // } else if (uiClassID == "MenuBarUI") {
108:                // return SynthMenuBarUI.createUI(c);
109:                // } else if (uiClassID == "RadioButtonMenuItemUI") {
110:                // return SynthRadioButtonMenuItemUI.createUI(c);
111:                // } else if (uiClassID == "ProgressBarUI") {
112:                // return SynthProgressBarUI.createUI(c);
113:                // } else if (uiClassID == "ToolBarUI") {
114:                // return SynthToolBarUI.createUI(c);
115:                // } else if (uiClassID == "ColorChooserUI") {
116:                // return SynthColorChooserUI.createUI(c);
117:                // } else if (uiClassID == "ToolBarSeparatorUI") {
118:                // return SynthToolBarSeparatorUI.createUI(c);
119:                // } else if (uiClassID == "TabbedPaneUI") {
120:                // return SynthTabbedPaneUI.createUI(c);
121:                // } else if (uiClassID == "DesktopPaneUI") {
122:                // return SynthDesktopPaneUI.createUI(c);
123:                // } else if (uiClassID == "TableUI") {
124:                // return SynthTableUI.createUI(c);
125:                // } else if (uiClassID == "PanelUI") {
126:                // return SynthPanelUI.createUI(c);
127:                // } else if (uiClassID == "CheckBoxMenuItemUI") {
128:                // return SynthCheckBoxMenuItemUI.createUI(c);
129:                // } else if (uiClassID == "PasswordFieldUI") {
130:                // return SynthPasswordFieldUI.createUI(c);
131:                // } else if (uiClassID == "CheckBoxUI") {
132:                // return SynthCheckBoxUI.createUI(c);
133:                // } else if (uiClassID == "TableHeaderUI") {
134:                // return SynthTableHeaderUI.createUI(c);
135:                // } else if (uiClassID == "SplitPaneUI") {
136:                // return SynthSplitPaneUI.createUI(c);
137:                // } else if (uiClassID == "EditorPaneUI") {
138:                // return SynthEditorPaneUI.createUI(c);
139:                // } else if (uiClassID == "ListUI") {
140:                // return SynthListUI.createUI(c);
141:                // } else if (uiClassID == "SpinnerUI") {
142:                // return SynthSpinnerUI.createUI(c);
143:                // } else if (uiClassID == "DesktopIconUI") {
144:                // return SynthDesktopIconUI.createUI(c);
145:                // } else if (uiClassID == "TextFieldUI") {
146:                // return SynthTextFieldUI.createUI(c);
147:                // } else if (uiClassID == "TextPaneUI") {
148:                // return SynthTextPaneUI.createUI(c);
149:                // } else if (uiClassID == "ButtonUI") {
150:                // return SynthButtonUI.createUI(c);
151:                // } else if (uiClassID == "LabelUI") {
152:                // return SynthLabelUI.createUI(c);
153:                // } else if (uiClassID == "ToggleButtonUI") {
154:                // SynthToggleButtonUI.createUI(c);
155:                // } else if (uiClassID == "OptionPaneUI") {
156:                // return SynthOptionPaneUI.createUI(c);
157:                // } else if (uiClassID == "PopupMenuSeparatorUI") {
158:                // return SynthPopupMenuSeparatorUI.createUI(c);
159:                // } else if (uiClassID == "RootPaneUI") {
160:                // return SynthRootPaneUI.createUI(c);
161:                // } else if (uiClassID == "SeparatorUI") {
162:                // return SynthSeparatorUI.createUI(c);
163:                // }
164:                // compatible with RI
165:                return null;
166:            }
167:
168:            /**
169:             * Renew the synth styles for the JComponent. This method isn't fully
170:             * correct, but does what needs (The method is unused in package)
171:             */
172:            public static void updateStyles(Component c) {
173:                c.setName(c.getName() + " "); //$NON-NLS-1$
174:            }
175:
176:            /**
177:             * Calculates the region corresponds JComponent given
178:             */
179:            public static Region getRegion(JComponent c) {
180:
181:                return Region.getRegionFromUIID(c.getUIClassID());
182:            }
183:
184:            @Override
185:            public String getName() {
186:
187:                return "Synth Look and Feel"; //$NON-NLS-1$
188:            }
189:
190:            @Override
191:            public String getID() {
192:
193:                return "Synth"; //$NON-NLS-1$
194:            }
195:
196:            @Override
197:            public String getDescription() {
198:
199:                return Messages.getString("swing.B4"); //$NON-NLS-1$
200:            }
201:
202:            @Override
203:            public boolean isNativeLookAndFeel() {
204:
205:                return false;
206:            }
207:
208:            @Override
209:            public boolean isSupportedLookAndFeel() {
210:
211:                return true;
212:            }
213:
214:            @Override
215:            public UIDefaults getDefaults() {
216:
217:                if (uiDefaults == null) {
218:                    uiDefaults = new UIDefaults();
219:                    initClassDefaults(uiDefaults);
220:                    initComponentDefaults(uiDefaults);
221:                }
222:
223:                return uiDefaults;
224:            }
225:
226:            @Override
227:            public void initialize() {
228:                // Do nothing
229:            }
230:
231:            @Override
232:            public void uninitialize() {
233:                // Do nothing
234:            }
235:
236:            @SuppressWarnings("unused")
237:            public void load(InputStream input, Class<?> resourceBase)
238:                    throws ParseException, IllegalArgumentException {
239:
240:                if (input == null || resourceBase == null) {
241:                    throw new IllegalArgumentException(Messages
242:                            .getString("swing.err.1D")); //$NON-NLS-1$
243:                }
244:
245:                try {
246:
247:                    SAXParser saxParser = SAXParserFactory.newInstance()
248:                            .newSAXParser();
249:                    saxParser.parse(input, new XMLSynthParser(resourceBase));
250:
251:                } catch (ParserConfigurationException e) {
252:                    throw new ParseException(e.getMessage(), 0);
253:                } catch (SAXException e) {
254:                    e.printStackTrace();
255:                    throw new ParseException(e.getMessage(), 0);
256:                } catch (IOException e) {
257:                    throw new ParseException(e.getMessage(), 0);
258:                }
259:            }
260:
261:            /** The default implementation returns false */
262:            public boolean shouldUpdateStyleOnAncestorChanged() {
263:
264:                return false;
265:            }
266:
267:            @SuppressWarnings("nls")
268:            @Override
269:            protected void initClassDefaults(UIDefaults defaults) {
270:                Object[] initDefaults = { "InternalFrameUI", pathToSynthLaf,
271:                        "ViewportUI", pathToSynthLaf, "ScrollBarUI",
272:                        pathToSynthLaf, "ToolTipUI", pathToSynthLaf,
273:                        "MenuItemUI", pathToSynthLaf, "MenuUI", pathToSynthLaf,
274:                        "TextAreaUI", pathToSynthLaf, "PopupMenuUI",
275:                        pathToSynthLaf, "ScrollPaneUI", pathToSynthLaf,
276:                        "SliderUI", pathToSynthLaf, "ComboBoxUI",
277:                        pathToSynthLaf, "RadioButtonUI", pathToSynthLaf,
278:                        "FormattedTextFieldUI", pathToSynthLaf, "TreeUI",
279:                        pathToSynthLaf, "MenuBarUI", pathToSynthLaf,
280:                        "RadioButtonMenuItemUI", pathToSynthLaf,
281:                        "ProgressBarUI", pathToSynthLaf, "ToolBarUI",
282:                        pathToSynthLaf, "ColorChooserUI", pathToSynthLaf,
283:                        "ToolBarSeparatorUI", pathToSynthLaf, "TabbedPaneUI",
284:                        pathToSynthLaf, "DesktopPaneUI", pathToSynthLaf,
285:                        "TableUI", pathToSynthLaf, "PanelUI", pathToSynthLaf,
286:                        "CheckBoxMenuItemUI", pathToSynthLaf,
287:                        "PasswordFieldUI", pathToSynthLaf, "CheckBoxUI",
288:                        pathToSynthLaf, "TableHeaderUI", pathToSynthLaf,
289:                        "SplitPaneUI", pathToSynthLaf, "EditorPaneUI",
290:                        pathToSynthLaf, "ListUI", pathToSynthLaf, "SpinnerUI",
291:                        pathToSynthLaf, "DesktopIconUI", pathToSynthLaf,
292:                        "TextFieldUI", pathToSynthLaf, "TextPaneUI",
293:                        pathToSynthLaf, "ButtonUI", pathToSynthLaf, "LabelUI",
294:                        pathToSynthLaf, "ToggleButtonUI", pathToSynthLaf,
295:                        "OptionPaneUI", pathToSynthLaf, "PopupMenuSeparatorUI",
296:                        pathToSynthLaf, "RootPaneUI", pathToSynthLaf,
297:                        "SeparatorUI", pathToSynthLaf };
298:                defaults.putDefaults(initDefaults);
299:            }
300:
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.