Source Code Cross Referenced for FormSettings.java in  » IDE-Netbeans » form » org » netbeans » modules » form » 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 » form » org.netbeans.modules.form 
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-2006 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.form;
043:
044:        import java.util.*;
045:        import org.netbeans.modules.form.project.ClassPathUtils;
046:
047:        /**
048:         * Settings for one form.
049:         *
050:         * @author Jan Stola
051:         */
052:        public class FormSettings {
053:            /** Prefix for session settings. */
054:            private static final String SESSION_PREFIX = "Session_"; // NOI18N
055:            private FormModel formModel;
056:            private Map<String, Object> settings = new TreeMap<String, Object>();
057:
058:            FormSettings(FormModel formModel) {
059:                this .formModel = formModel;
060:
061:                // Variables Modifier
062:                int variablesModifier = FormLoaderSettings.getInstance()
063:                        .getVariablesModifier();
064:                settings.put(FormLoaderSettings.PROP_VARIABLES_MODIFIER,
065:                        new Integer(variablesModifier));
066:
067:                // Local Variables
068:                boolean localVariables = FormLoaderSettings.getInstance()
069:                        .getVariablesLocal();
070:                settings.put(FormLoaderSettings.PROP_VARIABLES_LOCAL, Boolean
071:                        .valueOf(localVariables));
072:
073:                // Generate Mnemonics Code
074:                boolean generateMnemonicsCode = FormLoaderSettings
075:                        .getInstance().getGenerateMnemonicsCode();
076:                settings.put(FormLoaderSettings.PROP_GENERATE_MNEMONICS,
077:                        Boolean.valueOf(generateMnemonicsCode));
078:
079:                // Listener Generation Style
080:                int listenerGenerationStyle = FormLoaderSettings.getInstance()
081:                        .getListenerGenerationStyle();
082:                settings.put(FormLoaderSettings.PROP_LISTENER_GENERATION_STYLE,
083:                        new Integer(listenerGenerationStyle));
084:            }
085:
086:            // -----
087:            // code generation
088:
089:            public int getVariablesModifier() {
090:                Integer variablesModifier = (Integer) settings
091:                        .get(FormLoaderSettings.PROP_VARIABLES_MODIFIER);
092:                return variablesModifier.intValue();
093:            }
094:
095:            public void setVariablesModifier(int value) {
096:                settings.put(FormLoaderSettings.PROP_VARIABLES_MODIFIER,
097:                        new Integer(value));
098:            }
099:
100:            public boolean getVariablesLocal() {
101:                Boolean variablesLocal = (Boolean) settings
102:                        .get(FormLoaderSettings.PROP_VARIABLES_LOCAL);
103:                return variablesLocal.booleanValue();
104:            }
105:
106:            public void setVariablesLocal(boolean value) {
107:                settings.put(FormLoaderSettings.PROP_VARIABLES_LOCAL, Boolean
108:                        .valueOf(value));
109:            }
110:
111:            public boolean getAutoSetComponentName() {
112:                Boolean setting = (Boolean) settings
113:                        .get(FormLoaderSettings.PROP_AUTO_SET_COMPONENT_NAME);
114:                boolean autoName;
115:                if (setting != null) {
116:                    autoName = setting.booleanValue();
117:                } else { // no setting - detect for newly created form, false otherwise
118:                    autoName = FormEditor.getFormEditor(formModel)
119:                            .needPostCreationUpdate() ? getDefaultAutoSetComponentName()
120:                            : false;
121:                    setAutoSetComponentName(autoName);
122:                }
123:                return autoName;
124:            }
125:
126:            public void setAutoSetComponentName(boolean setName) {
127:                settings.put(FormLoaderSettings.PROP_AUTO_SET_COMPONENT_NAME,
128:                        Boolean.valueOf(setName));
129:            }
130:
131:            boolean getDefaultAutoSetComponentName() {
132:                int globalNaming = FormLoaderSettings.getInstance()
133:                        .getAutoSetComponentName();
134:                boolean autoName = globalNaming == FormLoaderSettings.AUTO_NAMING_ON;
135:                if (globalNaming == FormLoaderSettings.AUTO_NAMING_DEFAULT) {
136:                    ResourceSupport resourceSupport = FormEditor
137:                            .getResourceSupport(formModel);
138:                    if (resourceSupport.projectUsesResources()) {
139:                        autoName = true;
140:                    }
141:                }
142:                return autoName;
143:            }
144:
145:            public boolean getGenerateMnemonicsCode() {
146:                Boolean generateMnemonicsCode = (Boolean) settings
147:                        .get(FormLoaderSettings.PROP_GENERATE_MNEMONICS);
148:                return generateMnemonicsCode.booleanValue();
149:            }
150:
151:            public void setGenerateMnemonicsCode(boolean value) {
152:                settings.put(FormLoaderSettings.PROP_GENERATE_MNEMONICS,
153:                        Boolean.valueOf(value));
154:            }
155:
156:            public int getListenerGenerationStyle() {
157:                Integer listenerGenerationStyle = (Integer) settings
158:                        .get(FormLoaderSettings.PROP_LISTENER_GENERATION_STYLE);
159:                return listenerGenerationStyle.intValue();
160:            }
161:
162:            public void setListenerGenerationStyle(int value) {
163:                settings.put(FormLoaderSettings.PROP_LISTENER_GENERATION_STYLE,
164:                        new Integer(value));
165:            }
166:
167:            public int getLayoutCodeTarget() {
168:                return checkLayoutCodeTarget();
169:            }
170:
171:            public void setLayoutCodeTarget(int value) {
172:                settings.put(FormLoaderSettings.PROP_LAYOUT_CODE_TARGET,
173:                        new Integer(value));
174:            }
175:
176:            private int checkLayoutCodeTarget() {
177:                Integer lctSetting = (Integer) settings
178:                        .get(FormLoaderSettings.PROP_LAYOUT_CODE_TARGET);
179:                int layoutCodeTarget;
180:                if (lctSetting != null) {
181:                    layoutCodeTarget = lctSetting.intValue();
182:                } else { // no setting
183:                    layoutCodeTarget = FormEditor.getFormEditor(formModel)
184:                            .needPostCreationUpdate() ? JavaCodeGenerator.LAYOUT_CODE_AUTO
185:                            : // newly created form - detect
186:                            JavaCodeGenerator.LAYOUT_CODE_LIBRARY; // old form - use library
187:                }
188:                if (layoutCodeTarget == JavaCodeGenerator.LAYOUT_CODE_AUTO) {
189:                    int globalLCT = FormLoaderSettings.getInstance()
190:                            .getLayoutCodeTarget();
191:                    if (globalLCT == JavaCodeGenerator.LAYOUT_CODE_AUTO) {
192:                        layoutCodeTarget = ClassPathUtils
193:                                .isJava6ProjectPlatform(FormEditor
194:                                        .getFormDataObject(formModel)
195:                                        .getPrimaryFile()) ? JavaCodeGenerator.LAYOUT_CODE_JDK6
196:                                : JavaCodeGenerator.LAYOUT_CODE_LIBRARY;
197:                    } else
198:                        layoutCodeTarget = globalLCT;
199:                    setLayoutCodeTarget(layoutCodeTarget);
200:                } else if (lctSetting == null) {
201:                    setLayoutCodeTarget(layoutCodeTarget);
202:                }
203:
204:                return layoutCodeTarget;
205:            }
206:
207:            // -----
208:            // resource management / internationalization
209:
210:            // for compatibility
211:            static final String PROP_AUTO_I18N = "i18nAutoMode"; // NOI18N
212:
213:            void setResourceAutoMode(int value) {
214:                settings.put(ResourceSupport.PROP_AUTO_RESOURCING, value);
215:                settings
216:                        .put(PROP_AUTO_I18N, value == ResourceSupport.AUTO_I18N); // for compatibility
217:            }
218:
219:            int getResourceAutoMode() {
220:                Integer resSetting = (Integer) settings
221:                        .get(ResourceSupport.PROP_AUTO_RESOURCING);
222:                int resAutoMode = ResourceSupport.AUTO_OFF;
223:                if (resSetting != null) {
224:                    resAutoMode = resSetting.intValue();
225:                } else {
226:                    Boolean i18nSetting = (Boolean) settings
227:                            .get(PROP_AUTO_I18N);
228:                    if (i18nSetting != null) {
229:                        if (Boolean.TRUE.equals(i18nSetting))
230:                            resAutoMode = ResourceSupport.AUTO_I18N;
231:                    } else { // no setting available
232:                        if (FormEditor.getFormEditor(formModel)
233:                                .needPostCreationUpdate()) {
234:                            int globalResAutoMode = FormLoaderSettings
235:                                    .getInstance().getI18nAutoMode();
236:                            if (globalResAutoMode == FormLoaderSettings.AUTO_RESOURCE_ON) {
237:                                ResourceSupport resourceSupport = FormEditor
238:                                        .getResourceSupport(formModel);
239:                                if (resourceSupport.projectUsesResources())
240:                                    resAutoMode = ResourceSupport.AUTO_RESOURCING; // only if app framework already on cp
241:                                else
242:                                    resAutoMode = ResourceSupport.AUTO_I18N;
243:                            } else if (globalResAutoMode == FormLoaderSettings.AUTO_RESOURCE_DEFAULT) { // detect
244:                                ResourceSupport resourceSupport = FormEditor
245:                                        .getResourceSupport(formModel);
246:                                if (resourceSupport.projectWantsUseResources())
247:                                    resAutoMode = ResourceSupport.AUTO_RESOURCING; // only if app framework already on cp
248:                                else if (resourceSupport
249:                                        .isDefaultInternationalizableProject())
250:                                    resAutoMode = ResourceSupport.AUTO_I18N; // NBM project
251:                            }
252:                        }
253:                        setResourceAutoMode(resAutoMode);
254:                    }
255:                }
256:                return resAutoMode;
257:            }
258:
259:            public boolean isI18nAutoMode() {
260:                return getResourceAutoMode() == ResourceSupport.AUTO_I18N;
261:            }
262:
263:            public void setFormBundle(String bundleName) {
264:                settings.put(ResourceSupport.PROP_FORM_BUNDLE, bundleName);
265:            }
266:
267:            public String getFormBundle() {
268:                return (String) settings.get(ResourceSupport.PROP_FORM_BUNDLE);
269:            }
270:
271:            // design locale is not persisted in settings
272:
273:            // -----
274:
275:            public void set(String name, Object value) {
276:                set(name, value, false);
277:            }
278:
279:            public void set(String name, Object value, boolean session) {
280:                if (session) {
281:                    name = SESSION_PREFIX + name;
282:                }
283:                settings.put(name, value);
284:            }
285:
286:            public Object get(String name) {
287:                Object value;
288:                if (settings.containsKey(name)) {
289:                    value = settings.get(name);
290:                } else {
291:                    value = settings.get(SESSION_PREFIX + name);
292:                }
293:                return value;
294:            }
295:
296:            boolean isSessionSetting(String name) {
297:                return name.startsWith(SESSION_PREFIX);
298:            }
299:
300:            Map<String, Object> allSettings() {
301:                return Collections.unmodifiableMap(settings);
302:            }
303:
304:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.