Source Code Cross Referenced for PreferenceAccessor.java in  » IDE-Netbeans » uml » org » netbeans » modules » uml » core » preferenceframework » 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 » IDE Netbeans » uml » org.netbeans.modules.uml.core.preferenceframework 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.uml.core.preferenceframework;
043:
044:        import org.openide.util.NbBundle;
045:
046:        /**
047:         * @author sumitabhk
048:         *
049:         */
050:        public class PreferenceAccessor implements  IPreferenceAccessor {
051:
052:            private static PreferenceAccessor m_Instance = null;
053:            private static String unknownClassifierType = "DataType";
054:
055:            private PreferenceAccessor() {
056:            }
057:
058:            public static PreferenceAccessor instance() {
059:                if (m_Instance == null) {
060:                    m_Instance = new PreferenceAccessor();
061:                }
062:                return m_Instance;
063:            }
064:
065:            /**
066:             * Retrieves the default name to use for a new project from the preference file.
067:             *
068:             * @param name[out]	The default name
069:             *
070:             * @return HRESULT
071:             *
072:             */
073:            public String getDefaultProjectName() {
074:                //all callers removed.
075:                throw new UnsupportedOperationException(
076:                        "DefaultProjectName pref no longer valid.");
077:            }
078:
079:            /**
080:             * Gets the IDType preference from the preference file.  This is the
081:             * type of id to create when generating a unique id.
082:             *
083:             * @param type[out]	The id type found in the file
084:             *
085:             * @return HRESULT
086:             *
087:             */
088:            public int getIDType() {
089:                //kris richards - "IDType" pref expunged. Also, this method is never called.
090:                throw new UnsupportedOperationException(
091:                        "IDType pref no longer valid.");
092:            }
093:
094:            /**
095:             * Gets the default element name from the preferences file.  This is the
096:             * name to be used when a new element is created.
097:             * 
098:             *
099:             * @param *name[out] The name to use for unnamed elements
100:             *
101:             * @return HRESULT
102:             *
103:             */
104:            public String getDefaultElementName() {
105:                //kris richards - "DefaultElementName" pref expunged. Set to "Unnamed"
106:
107:                return NbBundle.getMessage(PreferenceAccessor.class, "UNNAMED");
108:            }
109:
110:            /**
111:             * Gets a flag from the preferences file which tells us whether or not to create a classifier
112:             * if Describe cannot resolve it to the model or any of its imported packages.
113:             * 
114:             *
115:             * @param val[out]	Whether or not to create
116:             *
117:             * @return HRESULT
118:             *
119:             */
120:            public boolean getUnknownClassifierCreate() {
121:                //kris richards - "UnknownClassifierCreate" pref expunged. Set to true.
122:
123:                return true;
124:            }
125:
126:            /**
127:             * When Describe has been told to create a classifier if it cannot 
128:             * be resolved in the model or any imported packages, this is the 
129:             * type of element to create.  This is retrieved from the preferences file.
130:             *
131:             * @param val[out]	The type of element to create
132:             *
133:             * @return HRESULT
134:             *
135:             */
136:            public String getUnknownClassifierType() {
137:                //kris richards - "UnknownClassifierType" pref expunged. Set to "DataType"
138:                //change default to Class: see issue 110338
139:                //            return "DataType" ; //returning "Class" causes other problems (see issue 111821)
140:                return unknownClassifierType;
141:
142:            }
143:
144:            // workaround for 110338, default type for creating unknown lifeline representing classifier is different
145:            public synchronized void setUnknownClassifierType(String type) {
146:                unknownClassifierType = type;
147:            }
148:
149:            /**
150:             * The default mode of a new Describe session found in the preferences file.
151:             *
152:             * @param *val[out]	The mode
153:             *
154:             * @return HRESULT
155:             *
156:             */
157:            public String getDefaultMode() {
158:                //kris richards - all calls to this have been removed.
159:
160:                throw new UnsupportedOperationException(
161:                        "DefaultMode pref no longer valid.");
162:            }
163:
164:            /**
165:             * The default language for a new Describe session based on the mode in the preferences file.
166:             *
167:             * @param mode[in]	The mode
168:             * @param val[out]	The default language
169:             *
170:             * @return HRESULT
171:             *
172:             */
173:            public String getDefaultLanguage(String mode) {
174:                String lang = "Java";
175:                if (!mode.equals("Implementation"))
176:                    lang = "UML";
177:
178:                return lang;
179:            }
180:
181:            /**
182:             *
183:             * Based on a particular language and behavior type, this 
184:             * retrieves the behavior value in the preferences file.
185:             *
186:             * @param lang[in]		The language
187:             * @param behavior[in]	The behavior type
188:             * @param *val[out]		The value of the behavior
189:             *
190:             * @return HRESULT
191:             *
192:             */
193:            public String getDefaultRoundTripBehavior(String lang,
194:                    String behavior) {
195:                throw new UnsupportedOperationException(
196:                        "RoundTrip prefs are no long valid.");
197:                //		// String str = "RoundTrip|";
198:                //		String str = "RoundTrip|";
199:                //		str += lang;
200:                //		String value = getPreferenceValue("", str, behavior);
201:                //		return value;
202:            }
203:
204:            /**
205:             * Retrieves the default customization file to be used for the property editor specified 
206:             * in the preferences file.
207:             * 
208:             *
209:             * @param val[out] The file
210:             *
211:             * @return HRESULT
212:             *
213:             */
214:            public String getDefaultEditorCustomizationFile() {
215:                throw new UnsupportedOperationException(
216:                        "PropertyEditor|CustomizationFile pref is no long valid.");
217:                //		String value = getPreferenceValue("", "PropertyEditor", "CustomizationFile");
218:                //		return value;
219:            }
220:
221:            /**
222:             * Retrieves the default filter from the preferences file to be used for the property editor.
223:             *
224:             * @param *val[out] The default filter
225:             *
226:             * @return HRESULT
227:             *
228:             */
229:            public String getDefaultEditorFilter() {
230:                throw new UnsupportedOperationException(
231:                        "This pref is no long valid.");
232:            }
233:
234:            /**
235:             * Retrieves the max number to select from the preference file for the property editor.
236:             *
237:             * @param *val[out]	The max number for selection
238:             *
239:             * @return HRESULT
240:             *
241:             */
242:            public int getDefaultEditorSelect() {
243:                //kris richards - MaxSelect pref expunged
244:                throw new UnsupportedOperationException(
245:                        "MaxSelect pref is no long valid.");
246:            }
247:
248:            /**
249:             *	Retrieves a value for a particular expansion variable in the preferences file.
250:             *
251:             * @param name[in]	The variable to find
252:             * @param val[in]	The value
253:             *
254:             * @return HRESULT
255:             *
256:             */
257:            public String getExpansionVariable(String name) {
258:                throw new UnsupportedOperationException(
259:                        "getExpansionVariable pref is no long valid.");
260:            }
261:
262:            /**
263:             * Asks the preference manager to read the preference file and get the asked
264:             * for information.
265:             * 
266:             *
267:             * @param key[in]	"key" preference is found under, if blank, look in "Default"
268:             * @param path[in]	Path to the preference (if preference is nested, this is the "|" delimited path
269:             * @param name[in]	Name of preference
270:             * @param pVal[out]	Preference value
271:             *
272:             * @return HRESULT
273:             *
274:             */
275:            private String getPreferenceValue(String key, String path,
276:                    String name) {
277:                throw new UnsupportedOperationException("key=" + key
278:                        + "::path=" + path + "::name=" + name
279:                        + ":: Using old options.");
280:
281:                //		String value = "";
282:                //		ICoreProduct prod = ProductRetriever.retrieveProduct();
283:                //		if (prod != null)
284:                //		{
285:                //			IPreferenceManager2 prefMan = prod.getPreferenceManager();
286:                //			if (prefMan != null)
287:                //			{
288:                //				if (key.length() > 0)
289:                //				{
290:                //					value = prefMan.getPreferenceValue(key, path, name);
291:                //				}
292:                //				else
293:                //				{
294:                //					value = prefMan.getPreferenceValue(path, name);
295:                //				}
296:                //			}
297:                //		}
298:                //		return value;
299:            }
300:
301:            /**
302:             * Based on a particular font category (DefaultClassFont, DefaultFont, etc), this retrieves 
303:             * the font name value in the preferences file.
304:             *
305:             * @param category[in]	The font category
306:             * @param *val[out]		The font name for this category
307:             *
308:             * @return HRESULT
309:             */
310:            public String getFontName(String category) {
311:                String str = "Presentation|";
312:                str += category;
313:                String value = getPreferenceValue("", str, "FaceName");
314:                return value;
315:            }
316:
317:            /**
318:             * Based on a particular font category (DefaultClassFont, DefaultFont, etc), this retrieves 
319:             * the font size value in the preferences file.
320:             *
321:             * @param category[in]	The font category
322:             * @param *val[out]		The font size for this category
323:             *
324:             * @return HRESULT
325:             */
326:            public String getFontSize(String category) {
327:                String str = "Presentation|";
328:                str += category;
329:                String value = getPreferenceValue("", str, "Height");
330:
331:                // cvc - CR 6293191
332:                // if prefs are not read in properly, this value will be an 
333:                //  empty string and throw a NumberFormatException, so need
334:                //  to have a default in case the config default isn't available
335:                if (value == null || value.equals(""))
336:                    value = "11";
337:
338:                return value;
339:            }
340:
341:            /**
342:             * Based on a particular font category (DefaultClassFont, DefaultFont, etc), this retrieves 
343:             * whether the font is bold or not in the preferences file.
344:             *
345:             * @param category[in]	The font category
346:             * @param *val[out]		Whether or not the font is bold for this category
347:             *
348:             * @return HRESULT
349:             */
350:            public boolean getFontBold(String category) {
351:                boolean val = false;
352:                String str = "Presentation|";
353:                str += category;
354:                String value = getPreferenceValue("", str, "Weight");
355:
356:                // cvc - CR 6293191
357:                // if prefs are not read in properly, this value will be an 
358:                //  empty string and throw a NumberFormatException, so need
359:                //  to have a default in case the config default isn't available
360:                if (value == null || value.equals(""))
361:                    value = "400";
362:
363:                if (Integer.parseInt(value) > 400)
364:                    val = true;
365:                return val;
366:            }
367:
368:            /**
369:             * Based on a particular font category (DefaultClassFont, DefaultFont, etc), this retrieves 
370:             * whether the font is italic or not in the preferences file.
371:             *
372:             * @param category[in]	The font category
373:             * @param *val[out]		Whether or not the font is italic for this category
374:             *
375:             * @return HRESULT
376:             */
377:            public boolean getFontItalic(String category) {
378:                boolean val = false;
379:                String str = "Presentation|";
380:                str += category;
381:                String value = getPreferenceValue("", str, "Italic");
382:                if (!value.equals("0"))
383:                    val = true;
384:                return val;
385:            }
386:
387:            /**
388:             * Based on a particular font category (DefaultClassFont, DefaultFont, etc), this retrieves 
389:             * whether the font is strikeout or not in the preferences file.
390:             *
391:             * @param category[in]	The font category
392:             * @param *val[out]		Whether or not the font is strikeout for this category
393:             *
394:             * @return HRESULT
395:             */
396:            public boolean getFontStrikeout(String category) {
397:                boolean val = false;
398:                String str = "Presentation|";
399:                str += category;
400:                String value = getPreferenceValue("", str, "Strikeout");
401:                if (!value.equals("0"))
402:                    val = true;
403:                return val;
404:            }
405:
406:            /**
407:             * Based on a particular font category (DefaultClassFont, DefaultFont, etc), this retrieves 
408:             * whether the font is underlined or not in the preferences file.
409:             *
410:             * @param category[in]	The font category
411:             * @param *val[out]		Whether or not the font is underlined for this category
412:             *
413:             * @return HRESULT
414:             */
415:            public boolean getFontUnderline(String category) {
416:                boolean val = false;
417:                String str = "Presentation|";
418:                str += category;
419:                String value = getPreferenceValue("", str, "Underline");
420:                if (!value.equals("0"))
421:                    val = true;
422:                return val;
423:            }
424:
425:            /**
426:             * Based on a particular font category (DefaultClassFont, DefaultFont, etc), this retrieves 
427:             * the font color value in the preferences file.
428:             *
429:             * @param category[in]	The font category
430:             * @param *val[out]		The font color for this category
431:             *
432:             * @return HRESULT
433:             */
434:            public String getFontColor(String category) {
435:                String str = "Presentation|";
436:                str += category;
437:                String value = getPreferenceValue("", str, "Color");
438:                return value;
439:            }
440:
441:            /**
442:             * Asks the preference manager to read the preference file and set the given
443:             * preference.
444:             * 
445:             *
446:             * @param key[in]	"key" preference is found under, if blank, look in "Default"
447:             * @param path[in]	Path to the preference (if preference is nested, this is the "|" delimited path
448:             * @param name[in]	Name of preference
449:             * @param pVal[out]	Preference value
450:             *
451:             * @return HRESULT
452:             *
453:             */
454:            public void setPreferenceValue(String key, String path,
455:                    String name, String value) {
456:                throw new UnsupportedOperationException("key=" + key
457:                        + "::path=" + path + "::name=" + name + "::value="
458:                        + value + ":: Using old options.");
459:                //		ICoreProduct prod = ProductRetriever.retrieveProduct();
460:                //		if (prod != null)
461:                //		{
462:                //			IPreferenceManager2 prefMan = prod.getPreferenceManager();
463:                //			if (prefMan != null)
464:                //			{
465:                //				if (key.length() > 0)
466:                //				{
467:                //					prefMan.setPreferenceValue(key, path, name, value);
468:                //				}
469:                //				else
470:                //				{
471:                //					prefMan.setPreferenceValue(path, name, value);
472:                //				}
473:                //			}
474:                //		}
475:            }
476:
477:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.