Source Code Cross Referenced for JsfDesignerPreferences.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » designer » jsf » 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 » visualweb.api.designer » org.netbeans.modules.visualweb.designer.jsf 
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:        package org.netbeans.modules.visualweb.designer.jsf;
042:
043:        import java.beans.IntrospectionException;
044:        import java.util.prefs.PreferenceChangeListener;
045:        import java.util.prefs.Preferences;
046:        import org.openide.nodes.BeanNode;
047:        import org.openide.util.NbPreferences;
048:        import org.openide.util.WeakListeners;
049:
050:        /** JSF Designer settings.
051:         *
052:         * @todo Possible new designer options: Show table borders, show named
053:         *       anchors, show <br/>'s, show tags
054:         *
055:         * @author Po-Ting Wu
056:         * @author Tor Norbye
057:         * @author Peter Zavadsky (migration to NB Preferences)
058:         */
059:        public class JsfDesignerPreferences {
060:
061:            // Constants for the page size
062:            private static final int CONSTRAINTS_UNINITIALIZED = -1;
063:            public static final int CONSTRAINTS_NONE = 0;
064:            public static final int CONSTRAINTS_640x480 = 1;
065:            public static final int CONSTRAINTS_800x600 = 2;
066:            public static final int CONSTRAINTS_1024x768 = 3;
067:            public static final int CONSTRAINTS_1280x1024 = 4;
068:
069:            /** Value of the default font size used in designer. */
070:            private static final int DEFAULT_FONT_SIZE = 16;
071:
072:            /** show grid */
073:            public static final String PROP_GRID_SHOW = "gridShow"; // NOI18N
074:
075:            /** snap to grid */
076:            public static final String PROP_GRID_SNAP = "gridSnap"; // NOI18N
077:
078:            /** grid width */
079:            public static final String PROP_GRID_WIDTH = "gridWidth"; // NOI18N
080:
081:            /** grid height */
082:            public static final String PROP_GRID_HEIGHT = "gridHeight"; // NOI18N
083:
084:            /** page resolution */
085:            public static final String PROP_PAGE_SIZE = "pageSize"; // NOI18N
086:
087:            /** Property name of 'decorations' property. */
088:            public static final String PROP_SHOW_DECORATIONS = "showDecorations"; // NOI18N
089:
090:            /** Default size of the font used in the designer.
091:             * XXX There might be needed also default font itself to be present. */
092:            public static final String PROP_DEFAULT_FONT_SIZE = "defaultFontSize"; // NOI18N
093:
094:            /** XXX To speed up getPageWidht/getPageHeight. */
095:            private transient int constraints = CONSTRAINTS_UNINITIALIZED; // cache
096:
097:            /** Default font size property. */
098:            private transient int defaultFontSize;
099:
100:            private static final JsfDesignerPreferences INSTANCE = new JsfDesignerPreferences();
101:
102:            // Default instance of this system option, for the convenience of associated classes.
103:            public static JsfDesignerPreferences getInstance() {
104:                return INSTANCE;
105:            }
106:
107:            public static BeanNode createViewNode()
108:                    throws IntrospectionException {
109:                return new BeanNode<JsfDesignerPreferences>(INSTANCE);
110:            }
111:
112:            public void addWeakPreferenceChangeListener(
113:                    PreferenceChangeListener l) {
114:                Preferences designerPreferences = getPreferences();
115:                designerPreferences.addPreferenceChangeListener(WeakListeners
116:                        .create(PreferenceChangeListener.class, l,
117:                                designerPreferences));
118:            }
119:
120:            //    // do NOT use constructore for setting default values
121:            //    protected void initialize() {
122:            //        // Set default values of properties
123:            //        super.initialize();
124:            //
125:            //        putProperty(PROP_GRID_SHOW, Boolean.TRUE, true);
126:            //        putProperty(PROP_GRID_SNAP, Boolean.TRUE, true);
127:            //        putProperty(PROP_GRID_WIDTH, new Integer(24), true);
128:            //        putProperty(PROP_GRID_HEIGHT, new Integer(24), true);
129:            //
130:            //        putProperty(PROP_SHOW_DECORATIONS, Boolean.FALSE, true);
131:            //    }
132:
133:            //    // This method must be overriden. It returns display name of this options.
134:            //    public String displayName() {
135:            //        return NbBundle.getBundle(DesignerSettings.class).getString("CTL_DesignerSettings");
136:            //    }
137:            //
138:            //    public HelpCtx getHelpCtx() {
139:            //        return HelpCtx.findHelp("projrave_ui_elements_options_visual_editor"); // NOI18N
140:            //    }
141:
142:            public void setGridShow(boolean set) {
143:                //        putProperty(PROP_GRID_SHOW, set ? Boolean.TRUE : Boolean.FALSE, true);
144:                getPreferences().putBoolean(PROP_GRID_SHOW, set);
145:            }
146:
147:            public boolean getGridShow() {
148:                //        return ((Boolean)getProperty(PROP_GRID_SHOW)).booleanValue();
149:                return getPreferences().getBoolean(PROP_GRID_SHOW, true);
150:            }
151:
152:            public void setGridSnap(boolean set) {
153:                //        putProperty(PROP_GRID_SNAP, set ? Boolean.TRUE : Boolean.FALSE, true);
154:                getPreferences().putBoolean(PROP_GRID_SNAP, set);
155:            }
156:
157:            public boolean getGridSnap() {
158:                //        return ((Boolean)getProperty(PROP_GRID_SNAP)).booleanValue();
159:                return getPreferences().getBoolean(PROP_GRID_SNAP, true);
160:            }
161:
162:            public void setGridWidth(int width) {
163:                if (width < 4) {
164:                    width = 4;
165:                }
166:
167:                //        putProperty(PROP_GRID_WIDTH, new Integer(width), true);
168:                getPreferences().putInt(PROP_GRID_WIDTH, width);
169:            }
170:
171:            public int getGridWidth() {
172:                //        return ((Integer)getProperty(PROP_GRID_WIDTH)).intValue();
173:                return getPreferences().getInt(PROP_GRID_WIDTH, 24);
174:            }
175:
176:            public void setGridHeight(int height) {
177:                if (height < 4) {
178:                    height = 4;
179:                }
180:
181:                //        putProperty(PROP_GRID_HEIGHT, new Integer(height), true);
182:                getPreferences().putInt(PROP_GRID_HEIGHT, height);
183:            }
184:
185:            public int getGridHeight() {
186:                //        return ((Integer)getProperty(PROP_GRID_HEIGHT)).intValue();
187:                return getPreferences().getInt(PROP_GRID_HEIGHT, 24);
188:            }
189:
190:            public void setPageSize(int size) {
191:                // XXX Speeding up the getPageSizeWidth/getPageSizeHeight methods.
192:                constraints = size;
193:                // if CONSTRAINTS_NONE, remove it?
194:                //        putProperty(PROP_PAGE_SIZE, new Integer(size), true);
195:                getPreferences().putInt(PROP_PAGE_SIZE, size);
196:            }
197:
198:            public int getPageSize() {
199:                //        Object o = getProperty(PROP_PAGE_SIZE);
200:                //
201:                //        if (o == null) {
202:                //            return CONSTRAINTS_NONE;
203:                //        }
204:                //
205:                //        return ((Integer)o).intValue();
206:                return getPreferences()
207:                        .getInt(PROP_PAGE_SIZE, CONSTRAINTS_NONE);
208:            }
209:
210:            /** Synthesized from the page size property: get the resolution width. -1 means no constraint. */
211:            public int getPageSizeWidth() {
212:                if (constraints == CONSTRAINTS_UNINITIALIZED) {
213:                    constraints = getPageSize();
214:                }
215:
216:                switch (constraints) {
217:                case CONSTRAINTS_640x480: // 600x300
218:                    return 600;
219:
220:                case CONSTRAINTS_800x600: // 760x420
221:                    return 760;
222:
223:                case CONSTRAINTS_1024x768: // 955x600
224:                    return 955;
225:
226:                case CONSTRAINTS_1280x1024: // 1210x856
227:                    return 1210;
228:
229:                case CONSTRAINTS_NONE:
230:                default:
231:                    return -1;
232:                }
233:            }
234:
235:            /** Synthesized from the page size property: get the resolution height. -1 means no constraint. */
236:            public int getPageSizeHeight() {
237:                if (constraints == CONSTRAINTS_UNINITIALIZED) {
238:                    constraints = getPageSize();
239:                }
240:
241:                switch (constraints) {
242:                case CONSTRAINTS_640x480: // 600x300
243:                    return 300;
244:
245:                case CONSTRAINTS_800x600: // 760x420
246:                    return 420;
247:
248:                case CONSTRAINTS_1024x768: // 955x600
249:                    return 600;
250:
251:                case CONSTRAINTS_1280x1024: // 1210x856
252:                    return 856;
253:
254:                case CONSTRAINTS_NONE:
255:                default:
256:                    return -1;
257:                }
258:            }
259:
260:            public void setShowDecorations(boolean showDecorations) {
261:                //        putProperty(PROP_SHOW_DECORATIONS, Boolean.valueOf(showDecorations), true);
262:                getPreferences().putBoolean(PROP_SHOW_DECORATIONS,
263:                        showDecorations);
264:            }
265:
266:            public boolean isShowDecorations() {
267:                //        return ((Boolean)getProperty(PROP_SHOW_DECORATIONS)).booleanValue();
268:                return getPreferences()
269:                        .getBoolean(PROP_SHOW_DECORATIONS, false);
270:            }
271:
272:            /** Sets default font size used in the designer.
273:             * @exception IllegalArgumentException in case the specified font size is zero or negative */
274:            public void setDefaultFontSize(int defaultFontSize) {
275:                if (defaultFontSize <= 0) {
276:                    throw new IllegalArgumentException(
277:                            "Zero or negative font size is not allowed, size="
278:                                    + defaultFontSize); // NOI18N
279:                }
280:                this .defaultFontSize = defaultFontSize;
281:                //        putProperty(PROP_DEFAULT_FONT_SIZE, new Integer(defaultFontSize));
282:                getPreferences()
283:                        .putInt(PROP_DEFAULT_FONT_SIZE, defaultFontSize);
284:            }
285:
286:            public int getDefaultFontSize() {
287:                if (defaultFontSize > 0) {
288:                    return defaultFontSize;
289:                }
290:
291:                //        Integer size = (Integer)getProperty(PROP_DEFAULT_FONT_SIZE);
292:                //        if (size != null) {
293:                //            defaultFontSize = size.intValue();
294:                //        }
295:                //        
296:                //        if (defaultFontSize <= 0) {
297:                //            defaultFontSize = DEFAULT_FONT_SIZE;
298:                //        }
299:                defaultFontSize = getPreferences().getInt(
300:                        PROP_DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
301:                return defaultFontSize;
302:            }
303:
304:            private Preferences getPreferences() {
305:                return NbPreferences.forModule(JsfDesignerPreferences.class);
306:            }
307:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.