Source Code Cross Referenced for IDESettings.java in  » IDE-Netbeans » library » org » netbeans » core » 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 » library » org.netbeans.core 
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.core;
043:
044:        import java.net.MalformedURLException;
045:        import java.net.URL;
046:        import java.util.logging.Level;
047:        import java.util.logging.Logger;
048:        import java.util.prefs.Preferences;
049:        import java.util.regex.Pattern;
050:        import java.util.regex.PatternSyntaxException;
051:        import org.openide.awt.HtmlBrowser;
052:        import org.openide.cookies.InstanceCookie;
053:        import org.openide.filesystems.FileObject;
054:        import org.openide.filesystems.Repository;
055:        import org.openide.loaders.DataFolder;
056:        import org.openide.loaders.DataNode;
057:        import org.openide.loaders.DataObject;
058:        import org.openide.nodes.BeanNode;
059:        import org.openide.util.Exceptions;
060:        import org.openide.util.HelpCtx;
061:        import org.openide.util.Lookup;
062:        import org.openide.util.NbBundle;
063:        import org.openide.util.NbPreferences;
064:
065:        /** Global IDE settings.
066:         *
067:         * @author Ian Formanek
068:         */
069:        public class IDESettings {
070:            private static final IDESettings INSTANCE = new IDESettings();
071:
072:            /** showToolTipsInIDE property name */
073:            public static final String PROP_SHOW_TOOLTIPS_IN_IDE = "showToolTipsInIDE"; // NOI18N
074:            /** confirmDelete property name */
075:            public static final String PROP_CONFIRM_DELETE = "confirmDelete"; // NOI18N
076:            /** home page property name */
077:            public static final String PROP_HOME_PAGE = "homePage"; // NOI18N
078:            /** show file extensions property name */
079:            public static final String PROP_SHOW_FILE_EXTENSIONS = "showFileExtensions"; // NOI18N
080:            /** Web Browser prefered by user */
081:            public static final String PROP_WWWBROWSER = "WWWBrowser"; // NOI18N
082:
083:            /** files that should be ignored
084:             *
085:             * DO NOT CHANGE THIS PROPERTY NAME without checking that
086:             * this property name was changed also in GlobalVisibilityQueryImpl
087:             * in module org.netbeans.modules.masterfs.
088:             *
089:             */
090:            public static final String PROP_IGNORED_FILES = "IgnoredFiles"; // NOI18N    
091:
092:            // ------------------------------------------
093:            // properties
094:
095:            public static IDESettings getInstance() {
096:                return INSTANCE;
097:            }
098:
099:            static Preferences getPreferences() {
100:                return NbPreferences.forModule(IDESettings.class);
101:            }
102:
103:            // ------------------------------------------
104:            // property access methods
105:
106:            /** Getter for ShowToolTipsInIDE
107:             * @return true if dialog will be shown*/
108:            public boolean getShowToolTipsInIDE() {
109:                return getPreferences().getBoolean(PROP_SHOW_TOOLTIPS_IN_IDE,
110:                        true);
111:            }
112:
113:            /** Setter for ShowToolTipsInIDE
114:             * @param value true if on the next start of corona the dialog will be shown
115:             *              false otherwise */
116:            public void setShowToolTipsInIDE(boolean value) {
117:                getPreferences().putBoolean(PROP_SHOW_TOOLTIPS_IN_IDE, value);
118:            }
119:
120:            /** Getter for ConfirmDelete
121:             * @param true if the user should asked for confirmation of object delete, false otherwise */
122:            public boolean getConfirmDelete() {
123:                return getPreferences().getBoolean(PROP_CONFIRM_DELETE, true);
124:            }
125:
126:            /** Setter for ConfirmDelete
127:             * @param value if true the user is asked for confirmation of object delete, not if false */
128:            public void setConfirmDelete(boolean value) {
129:                getPreferences().putBoolean(PROP_CONFIRM_DELETE, value);
130:            }
131:
132:            /** This method must be overriden. It returns display name of this options.
133:             */
134:            public String displayName() {
135:                return NbBundle.getBundle(IDESettings.class).getString(
136:                        "CTL_IDESettings");
137:            }
138:
139:            public HelpCtx getHelpCtx() {
140:                return new HelpCtx(IDESettings.class);
141:            }
142:
143:            /** Getter for home page used in html viewer.
144:             */
145:            public String getHomePage() {
146:                return HtmlBrowser.getHomePage();
147:            }
148:
149:            /** Setter for home page used in html viewer.
150:             */
151:            public void setHomePage(String homePage) {
152:                HtmlBrowser.setHomePage(homePage);
153:            }
154:
155:            /** Getter for showing file extensions.
156:             * @return whether to show them
157:             */
158:            public boolean getShowFileExtensions() {
159:                return DataNode.getShowFileExtensions();
160:            }
161:
162:            /** Setter for showing file extensions.
163:             * @param s whether to show them
164:             */
165:            public void setShowFileExtensions(boolean s) {
166:                DataNode.setShowFileExtensions(s);
167:            }
168:
169:            /** Getter for preffered web browser.
170:             *
171:             * First time when this function is called Lookup is used
172:             * to find prefered browser factory in a browser registry.
173:             *
174:             * @return prefered browser,
175:             * may return null if it is not possible to get the browser
176:             */
177:            public static HtmlBrowser.Factory getWWWBrowser() {
178:                try {
179:                    Object obj = getPreferences().get(PROP_WWWBROWSER, null);
180:
181:                    if (obj instanceof  String && !"".equals(obj)) {
182:                        // use new style
183:                        Lookup.Item<HtmlBrowser.Factory> item = Lookup
184:                                .getDefault()
185:                                .lookupItem(
186:                                        new Lookup.Template<HtmlBrowser.Factory>(
187:                                                HtmlBrowser.Factory.class,
188:                                                (String) obj, null));
189:                        return item == null ? null : item.getInstance();
190:                    }
191:
192:                    // the browser is not set yet - find the first one
193:                    if (obj == null || "".equals(obj)) {
194:                        Lookup.Result<HtmlBrowser.Factory> res = Lookup
195:                                .getDefault().lookupResult(
196:                                        HtmlBrowser.Factory.class);
197:                        java.util.Iterator<? extends HtmlBrowser.Factory> it = res
198:                                .allInstances().iterator();
199:                        while (it.hasNext()) {
200:                            HtmlBrowser.Factory brow = it.next();
201:
202:                            // check if it is not set to be hidden
203:                            FileObject fo = Repository.getDefault()
204:                                    .getDefaultFileSystem().findResource(
205:                                            "Services/Browsers"); // NOI18N
206:
207:                            DataFolder folder = DataFolder.findFolder(fo);
208:                            DataObject[] dobjs = folder.getChildren();
209:                            for (int i = 0; i < dobjs.length; i++) {
210:                                Object o = null;
211:
212:                                try {
213:                                    if (Boolean.TRUE.equals(dobjs[i]
214:                                            .getPrimaryFile().getAttribute(
215:                                                    "hidden")))
216:                                        continue;
217:                                    InstanceCookie cookie = (InstanceCookie) dobjs[i]
218:                                            .getCookie(InstanceCookie.class);
219:
220:                                    if (cookie == null)
221:                                        continue;
222:                                    o = cookie.instanceCreate();
223:                                    if (o != null && o.equals(brow)) {
224:                                        return brow;
225:                                    }
226:                                }
227:                                // exceptions are thrown if module is uninstalled
228:                                catch (java.io.IOException ex) {
229:                                    Logger.getLogger(
230:                                            IDESettings.class.getName()).log(
231:                                            Level.WARNING, null, ex);
232:                                } catch (ClassNotFoundException ex) {
233:                                    Logger.getLogger(
234:                                            IDESettings.class.getName()).log(
235:                                            Level.WARNING, null, ex);
236:                                }
237:                            }
238:
239:                        }
240:                        return null;
241:                    }
242:                } catch (Exception ex) {
243:                    Exceptions.printStackTrace(ex);
244:                }
245:                return null;
246:            }
247:
248:            /** Setter for preffered browser.
249:             *
250:             *  Actually Node.Handle of node that represent browser in lookup folder is stored.
251:             *
252:             * @param brow prefered browser capable of providing implementation
253:             */
254:            public static void setWWWBrowser(HtmlBrowser.Factory brow) {
255:                try {
256:                    if (brow == null) {
257:                        getPreferences().put(PROP_WWWBROWSER, "");//NOI18N
258:                        return;
259:                    }
260:
261:                    Lookup.Item<HtmlBrowser.Factory> item = Lookup.getDefault()
262:                            .lookupItem(
263:                                    new Lookup.Template<HtmlBrowser.Factory>(
264:                                            HtmlBrowser.Factory.class, null,
265:                                            brow));
266:                    if (item != null) {
267:                        getPreferences().put(PROP_WWWBROWSER, item.getId());
268:                    } else {
269:                        // strange
270:                        Logger.getLogger(IDESettings.class.getName()).warning(
271:                                "IDESettings: Cannot find browser in lookup");// NOI18N
272:                        getPreferences().put(PROP_WWWBROWSER, "");//NOI18N
273:                    }
274:                } catch (Exception ex) {
275:                    Exceptions.printStackTrace(ex);
276:                }
277:            }
278:
279:            // PRIVATE METHODS
280:
281:            public String getIgnoredFiles() {
282:                return getPreferences()
283:                        .get(
284:                                PROP_IGNORED_FILES,
285:                                "^(CVS|SCCS|vssver.?\\.scc|#.*#|%.*%|\\.(cvsignore|svn|DS_Store)|_svn)$|~$|^\\..*$"); //NOI18N
286:            }
287:
288:            public void setIgnoredFiles(String ignoredFiles)
289:                    throws IllegalArgumentException {
290:                try {
291:                    Pattern.compile(ignoredFiles);
292:                    getPreferences().put(PROP_IGNORED_FILES, ignoredFiles); //NOI18N
293:                } catch (PatternSyntaxException e) {
294:                    IllegalArgumentException iae = new IllegalArgumentException();
295:                    iae.initCause(e);
296:                    UIExceptions.annotateUser(iae, e.getMessage(), e
297:                            .getLocalizedMessage(), null, null);
298:                    throw iae;
299:                }
300:            }
301:
302:            private static BeanNode createViewNode()
303:                    throws java.beans.IntrospectionException {
304:                return new BeanNode(IDESettings.getInstance());
305:            }
306:
307:            private static org.netbeans.beaninfo.editors.HtmlBrowser.FactoryEditor createHtmlBrowserFactoryEditor() {
308:                return new org.netbeans.beaninfo.editors.HtmlBrowser.FactoryEditor() {
309:                    public void setValue(Object value) {
310:                        setWWWBrowser((HtmlBrowser.Factory) value);
311:                    }
312:
313:                    public Object getValue() {
314:                        return getWWWBrowser();
315:                    }
316:                };
317:            }
318:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.