1 19 20 package org.netbeans.modules.xml.wsdl.ui.netbeans.module; 21 22 import java.io.IOException ; 23 import java.io.ObjectInput ; 24 import org.openide.util.HelpCtx; 25 import org.openide.util.NbBundle; 26 import org.openide.util.NbPreferences; 27 28 33 public class WSDLSettings { 34 35 private static WSDLSettings INSTANCE = new WSDLSettings(); 36 37 public static final String PROP_VIEW_MODE = "viewMode"; 38 39 42 public static enum ViewMode { 43 TREE, COLUMN 44 }; 45 46 public String displayName() { 47 return NbBundle.getMessage(WSDLSettings.class, 48 "CTL_WSDLSettings_name"); 49 } 50 51 private WSDLSettings() { 52 setDefaults(); 53 } 54 55 60 public static WSDLSettings getDefault() { 61 return INSTANCE; 62 } 63 64 public HelpCtx getHelpCtx() { 65 return HelpCtx.DEFAULT_HELP; 66 } 67 68 73 public ViewMode getViewMode() { 74 String mode = (String ) getProperty(PROP_VIEW_MODE); 75 if(mode == null) 76 return ViewMode.COLUMN; 77 78 return ViewMode.valueOf(mode); 79 } 80 81 public void readExternal(ObjectInput in) throws 82 IOException , ClassNotFoundException { 83 setDefaults(); 86 } 87 88 91 private void setDefaults() { 92 if (getProperty(PROP_VIEW_MODE) == null) { 93 putProperty(PROP_VIEW_MODE, ViewMode.TREE.toString()); 94 } 95 } 96 97 102 public void setViewMode(ViewMode mode) { 103 putProperty(PROP_VIEW_MODE, mode.toString()); 105 } 106 107 protected final String putProperty(String key, String value) { 108 String retval = NbPreferences.forModule(WSDLSettings.class).get(key, null); 109 if (value != null) { 110 NbPreferences.forModule(WSDLSettings.class).put(key, value); 111 } else { 112 NbPreferences.forModule(WSDLSettings.class).remove(key); 113 } 114 return retval; 115 } 116 117 protected final String getProperty(String key) { 118 return NbPreferences.forModule(WSDLSettings.class).get(key, ViewMode.TREE.toString()); 119 } 120 } 121 | Popular Tags |