KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > welcome > WelcomeOptions


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.welcome;
21
22 import java.io.IOException JavaDoc;
23 import java.util.logging.Level JavaDoc;
24 import java.util.logging.Logger JavaDoc;
25 import org.openide.filesystems.FileObject;
26 import org.openide.filesystems.Repository;
27
28 /**
29  *
30  * @author S. Aubrecht
31  */

32 public class WelcomeOptions {
33
34     private static WelcomeOptions theInstance;
35     
36     private static final String JavaDoc PROP_SHOW_ON_STARTUP = "showOnStartup";
37     private static final String JavaDoc PROP_FIRST_TIME_START = "firstTimeStart";
38     
39     private static final String JavaDoc FOLDER_NAME = "WelcomePage";
40     
41     private Logger JavaDoc log = Logger.getLogger( WelcomeOptions.class.getName() );
42
43     /** Creates a new instance of WelcomeOptions */
44     private WelcomeOptions() {
45     }
46
47     public static synchronized WelcomeOptions getDefault() {
48         if( null == theInstance ) {
49             theInstance = new WelcomeOptions();
50         }
51         return theInstance;
52     }
53  
54     public void setShowOnStartup( boolean show ) {
55         FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource( FOLDER_NAME );
56         if( null != fo ) {
57             try {
58                 fo.setAttribute( PROP_SHOW_ON_STARTUP, Boolean.valueOf(show) );
59             } catch (IOException JavaDoc ex) {
60                 log.log( Level.INFO, ex.getMessage(), ex );
61             }
62         }
63     }
64
65     public boolean isShowOnStartup() {
66         FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource( FOLDER_NAME );
67         if( null != fo ) {
68             Object JavaDoc val = fo.getAttribute( PROP_SHOW_ON_STARTUP );
69             if( null != val && val instanceof Boolean JavaDoc ) {
70                 return ((Boolean JavaDoc)val).booleanValue();
71             }
72         }
73         return true;
74     }
75
76     public void setFirstTimeStart( boolean firstTime ) {
77         FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource( FOLDER_NAME );
78         if( null != fo ) {
79             try {
80                 fo.setAttribute( PROP_FIRST_TIME_START, Boolean.valueOf(firstTime) );
81             } catch (IOException JavaDoc ex) {
82                 log.log( Level.INFO, ex.getMessage(), ex );
83             }
84         }
85     }
86
87     public boolean isFirstTimeStart() {
88         FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource( FOLDER_NAME );
89         if( null != fo ) {
90             Object JavaDoc val = fo.getAttribute( PROP_FIRST_TIME_START );
91             if( null != val && val instanceof Boolean JavaDoc ) {
92                 return ((Boolean JavaDoc)val).booleanValue();
93             }
94         }
95         return true;
96     }
97 }
98
Popular Tags