1 19 20 package org.netbeans.modules.javadoc.settings; 21 22 import java.lang.reflect.Modifier ; 23 24 import org.openide.options.SystemOption; 25 import org.openide.util.HelpCtx; 26 import org.openide.util.NbBundle; 27 import org.openide.ServiceType; 28 29 import org.netbeans.modules.javadoc.search.JavadocSearchType; 31 import org.netbeans.modules.javadoc.*; 32 import org.openide.util.Lookup; 33 34 38 public class DocumentationSettings extends SystemOption { 39 40 private static final String PROP_SEARCH_SORT = "idxSearchSort"; private static final String PROP_SEARCH_NO_HTML = "idxSearchNoHtml"; private static final String PROP_SEARCH_SPLIT = "idxSearchSplit"; private static final String PROP_AUTOCOMENT_SPLIT = "autocommentSplit"; private static final String PROP_AUTOCOMENT_MOD_MASK = "autocommentModifierMask"; private static final String PROP_AUTOCOMENT_PACKAGE = "autocommentPackage"; private static final String PROP_AUTOCOMENT_ERR_MASK = "autocommentErrorMask"; private static final String PROP_SEARCH = "searchEngine"; private static final String PROP_FS_SETTING = "fileSystemSettings"; 50 static final long serialVersionUID =-574331845406968391L; 51 52 private transient boolean initializing = false; 53 54 55 protected void initialize () { 56 super.initialize (); 57 initializing = true; 58 if( getProperty( PROP_SEARCH_SORT ) == null ) 59 setIdxSearchSort("A"); if( getProperty( PROP_SEARCH_NO_HTML ) == null ) 61 setIdxSearchNoHtml(false); 62 if( getProperty( PROP_SEARCH_SPLIT ) == null ) 63 setIdxSearchSplit(50); 64 if( getProperty( PROP_AUTOCOMENT_SPLIT ) == null ) 65 setAutocommentSplit(35); 66 if( getProperty( PROP_AUTOCOMENT_MOD_MASK ) == null ) 67 setAutocommentModifierMask(Modifier.PROTECTED | Modifier.PUBLIC); 68 if( getProperty( PROP_AUTOCOMENT_PACKAGE ) == null ) 69 setAutocommentPackage(false); 70 if( getProperty( PROP_AUTOCOMENT_ERR_MASK ) == null ) 71 setAutocommentErrorMask(7); 74 initializing = false; 75 } 76 77 public static DocumentationSettings getDefault(){ 78 return (DocumentationSettings)DocumentationSettings.findObject(DocumentationSettings.class,true); 79 } 80 81 82 public String displayName() { 83 return NbBundle.getBundle(DocumentationSettings.class).getString("CTL_Documentation_settings"); } 85 86 public HelpCtx getHelpCtx () { 87 return new HelpCtx (DocumentationSettings.class); 88 } 89 90 92 public int getAutocommentModifierMask() { 93 return ((Integer )getProperty( PROP_AUTOCOMENT_MOD_MASK )).intValue(); 94 } 96 97 99 public void setAutocommentModifierMask(int mask) { 100 putProperty( PROP_AUTOCOMENT_MOD_MASK, new Integer (mask), !(initializing || isReadExternal()) ); 101 } 103 104 106 public boolean getAutocommentPackage() { 107 return ((Boolean )getProperty( PROP_AUTOCOMENT_PACKAGE )).booleanValue(); 108 } 110 111 113 public void setAutocommentPackage(boolean pckg) { 114 putProperty( PROP_AUTOCOMENT_PACKAGE, pckg ? Boolean.TRUE : Boolean.FALSE, !(initializing || isReadExternal()) ); 115 } 117 118 119 121 public int getAutocommentErrorMask() { 122 return ((Integer )getProperty( PROP_AUTOCOMENT_ERR_MASK )).intValue(); 123 } 125 126 128 public void setAutocommentErrorMask(int mask) { 129 putProperty( PROP_AUTOCOMENT_ERR_MASK, new Integer (mask), !(initializing || isReadExternal()) ); 130 } 132 133 136 public String getIdxSearchSort() { 137 return (String )getProperty( PROP_SEARCH_SORT ); 138 } 140 141 144 public void setIdxSearchSort(String idxSearchSort) { 145 putProperty( PROP_SEARCH_SORT , idxSearchSort, !(initializing || isReadExternal()) ); 146 } 148 149 152 public boolean isIdxSearchNoHtml() { 153 return ((Boolean )getProperty( PROP_SEARCH_NO_HTML )).booleanValue(); 154 } 156 157 160 public void setIdxSearchNoHtml(boolean idxSearchNoHtml) { 161 putProperty( PROP_SEARCH_NO_HTML, idxSearchNoHtml ? Boolean.TRUE : Boolean.FALSE, !(initializing || isReadExternal()) ); 162 } 164 165 168 public int getIdxSearchSplit() { 169 return ((Integer )getProperty( PROP_SEARCH_SPLIT )).intValue(); 170 } 172 173 176 public void setIdxSearchSplit(int idxSearchSplit) { 177 putProperty( PROP_SEARCH_SPLIT , new Integer (idxSearchSplit), !(initializing || isReadExternal()) ); 178 } 180 181 184 public int getAutocommentSplit() { 185 return ((Integer )getProperty( PROP_AUTOCOMENT_SPLIT )).intValue(); 186 } 188 191 public void setAutocommentSplit(int autocommentSplit) { 192 putProperty( PROP_AUTOCOMENT_SPLIT , new Integer (autocommentSplit), !(initializing || isReadExternal()) ); 193 } 195 196 199 public ServiceType getSearchEngine() { 200 JavadocSearchType.Handle searchType = (JavadocSearchType.Handle)getProperty( PROP_SEARCH ); 201 JavadocSearchType type = null; 202 203 if (searchType != null) { 204 type = (JavadocSearchType)searchType.getServiceType(); 205 } 206 if (type == null) { 207 if (isWriteExternal()) { 208 return null; 209 } 210 type = (JavadocSearchType)Lookup.getDefault().lookup(org.netbeans.modules.javadoc.search.Jdk12SearchType.class); 211 if (type != null) 212 return type; 213 type = (JavadocSearchType)Lookup.getDefault().lookup(JavadocSearchType.class); 215 } 216 return type; 217 } 218 219 222 public void setSearchEngine(ServiceType search) { 223 if (search == null && 224 isReadExternal()) { 225 putProperty(PROP_SEARCH, null, false); 226 } else { 227 putProperty( PROP_SEARCH , new JavadocSearchType.Handle( search ), !(initializing || isReadExternal())); 228 } 229 } 230 231 232 public java.util.HashMap getFileSystemSettings(){ 233 java.util.HashMap map = (java.util.HashMap )getProperty( PROP_FS_SETTING ); 234 235 if (map == null) { 236 if (isWriteExternal()) { 237 return null; 238 } 239 return new java.util.HashMap (); 240 } 241 return map; 242 } 243 244 public void setFileSystemSettings(java.util.HashMap map){ 245 if (map == null && 246 isReadExternal()) { 247 putProperty( PROP_FS_SETTING, null, false); 248 } else { 249 java.util.HashMap old = (java.util.HashMap )putProperty( PROP_FS_SETTING , map, !(initializing || isReadExternal())); 250 if( old != null && old.equals(map) ) 251 firePropertyChange(PROP_FS_SETTING, null, null); 252 } 253 } 254 255 } 256 | Popular Tags |