1 19 20 package org.netbeans.modules.languages.dataobject; 21 22 import org.netbeans.editor.SettingsNames; 23 import org.netbeans.modules.editor.options.BaseOptions; 24 import org.netbeans.modules.editor.options.OptionSupport; 25 import org.netbeans.modules.languages.dataobject.LanguagesEditorKit; 26 import org.openide.util.HelpCtx; 27 import org.openide.util.NbBundle; 28 import java.util.MissingResourceException ; 29 import org.openide.filesystems.FileObject; 30 31 35 public class LanguagesOptions extends BaseOptions { 36 37 public static String LANGUAGES = "Languages"; 39 public static final String CODE_FOLDING_ENABLE_PROP = "codeFoldingEnable"; 41 private static LanguagesOptions defaultInstance; 42 43 static final String [] LANGUAGES_PROP_NAMES = OptionSupport.mergeStringArrays ( 44 BaseOptions.BASE_PROP_NAMES, 45 new String [] { 46 CODE_FOLDING_ENABLE_PROP 47 } 48 ); 49 50 public static final LanguagesOptions create(FileObject fo) { 51 if (defaultInstance == null) { 52 String mimeType = fo.getParent().getPath().substring(8); defaultInstance = new LanguagesOptions(mimeType); 55 } 56 return defaultInstance; 57 } 58 59 60 private static final String HELP_ID = "editing.editor.php"; 62 63 private String mimeType; 64 65 public LanguagesOptions(String mimeType) { 66 super(LanguagesEditorKit.class, LANGUAGES); 67 this.mimeType = mimeType; 68 } 71 72 protected String getContentType() { 73 return mimeType; 74 } 75 76 public boolean getCodeFoldingEnable() { 77 return getSettingBoolean(SettingsNames.CODE_FOLDING_ENABLE); 78 } 79 80 public void setCodeFoldingEnable(boolean state) { 81 setSettingBoolean(SettingsNames.CODE_FOLDING_ENABLE, state, CODE_FOLDING_ENABLE_PROP); 82 } 83 84 88 92 95 public HelpCtx getHelpCtx() { 96 return new HelpCtx(HELP_ID); 97 } 98 99 103 protected String getString(String key) { 104 try { 105 return NbBundle.getMessage(LanguagesOptions.class, key); 106 } catch (MissingResourceException e) { 107 return super.getString(key); 108 } 109 } 110 111 } | Popular Tags |