1 19 20 package org.netbeans.modules.welcome; 21 22 import java.io.IOException ; 23 import java.util.logging.Level ; 24 import java.util.logging.Logger ; 25 import org.openide.filesystems.FileObject; 26 import org.openide.filesystems.Repository; 27 28 32 public class WelcomeOptions { 33 34 private static WelcomeOptions theInstance; 35 36 private static final String PROP_SHOW_ON_STARTUP = "showOnStartup"; 37 private static final String PROP_FIRST_TIME_START = "firstTimeStart"; 38 39 private static final String FOLDER_NAME = "WelcomePage"; 40 41 private Logger log = Logger.getLogger( WelcomeOptions.class.getName() ); 42 43 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 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 val = fo.getAttribute( PROP_SHOW_ON_STARTUP ); 69 if( null != val && val instanceof Boolean ) { 70 return ((Boolean )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 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 val = fo.getAttribute( PROP_FIRST_TIME_START ); 91 if( null != val && val instanceof Boolean ) { 92 return ((Boolean )val).booleanValue(); 93 } 94 } 95 return true; 96 } 97 } 98 | Popular Tags |