1 19 20 package org.netbeans.modules.form; 21 22 import java.util.*; 23 import org.netbeans.modules.form.project.ClassPathUtils; 24 25 30 public class FormSettings { 31 private FormModel formModel; 32 private Map settings = new TreeMap(); 33 34 FormSettings(FormModel formModel) { 35 this.formModel = formModel; 36 37 int variablesModifier = FormLoaderSettings.getInstance().getVariablesModifier(); 39 settings.put(FormLoaderSettings.PROP_VARIABLES_MODIFIER, new Integer (variablesModifier)); 40 41 boolean localVariables = FormLoaderSettings.getInstance().getVariablesLocal(); 43 settings.put(FormLoaderSettings.PROP_VARIABLES_LOCAL, Boolean.valueOf(localVariables)); 44 45 boolean generateMnemonicsCode = FormLoaderSettings.getInstance().getGenerateMnemonicsCode(); 47 settings.put(FormLoaderSettings.PROP_GENERATE_MNEMONICS, Boolean.valueOf(generateMnemonicsCode)); 48 49 int listenerGenerationStyle = FormLoaderSettings.getInstance().getListenerGenerationStyle(); 51 settings.put(FormLoaderSettings.PROP_LISTENER_GENERATION_STYLE, new Integer (listenerGenerationStyle)); 52 } 53 54 57 public int getVariablesModifier() { 58 Integer variablesModifier = (Integer )settings.get(FormLoaderSettings.PROP_VARIABLES_MODIFIER); 59 return variablesModifier.intValue(); 60 } 61 62 public void setVariablesModifier(int value) { 63 settings.put(FormLoaderSettings.PROP_VARIABLES_MODIFIER, new Integer (value)); 64 } 65 66 public boolean getVariablesLocal() { 67 Boolean variablesLocal = (Boolean )settings.get(FormLoaderSettings.PROP_VARIABLES_LOCAL); 68 return variablesLocal.booleanValue(); 69 } 70 71 public void setVariablesLocal(boolean value) { 72 settings.put(FormLoaderSettings.PROP_VARIABLES_LOCAL, Boolean.valueOf(value)); 73 } 74 75 public boolean getGenerateMnemonicsCode() { 76 Boolean generateMnemonicsCode = (Boolean )settings.get(FormLoaderSettings.PROP_GENERATE_MNEMONICS); 77 return generateMnemonicsCode.booleanValue(); 78 } 79 80 public void setGenerateMnemonicsCode(boolean value) { 81 settings.put(FormLoaderSettings.PROP_GENERATE_MNEMONICS, Boolean.valueOf(value)); 82 } 83 84 public int getListenerGenerationStyle() { 85 Integer listenerGenerationStyle = (Integer )settings.get(FormLoaderSettings.PROP_LISTENER_GENERATION_STYLE); 86 return listenerGenerationStyle.intValue(); 87 } 88 89 public void setListenerGenerationStyle(int value) { 90 settings.put(FormLoaderSettings.PROP_LISTENER_GENERATION_STYLE, new Integer (value)); 91 } 92 93 public int getLayoutCodeTarget() { 94 return checkLayoutCodeTarget(); 95 } 96 97 public void setLayoutCodeTarget(int value) { 98 settings.put(FormLoaderSettings.PROP_LAYOUT_CODE_TARGET, new Integer (value)); 99 } 100 101 private int checkLayoutCodeTarget() { 102 Integer lctSetting = (Integer )settings.get(FormLoaderSettings.PROP_LAYOUT_CODE_TARGET); 103 int layoutCodeTarget; 104 if (lctSetting != null) { 105 layoutCodeTarget = lctSetting.intValue(); 106 } 107 else { layoutCodeTarget = FormEditor.getFormEditor(formModel).needPostCreationUpdate() ? 109 JavaCodeGenerator.LAYOUT_CODE_AUTO : JavaCodeGenerator.LAYOUT_CODE_LIBRARY; } 112 if (layoutCodeTarget == JavaCodeGenerator.LAYOUT_CODE_AUTO) { 113 int globalLCT = FormLoaderSettings.getInstance().getLayoutCodeTarget(); 114 if (globalLCT == JavaCodeGenerator.LAYOUT_CODE_AUTO) { 115 layoutCodeTarget = ClassPathUtils.isJava6ProjectPlatform( 116 FormEditor.getFormDataObject(formModel).getPrimaryFile()) ? 117 JavaCodeGenerator.LAYOUT_CODE_JDK6 : JavaCodeGenerator.LAYOUT_CODE_LIBRARY; 118 } 119 else layoutCodeTarget = globalLCT; 120 setLayoutCodeTarget(layoutCodeTarget); 121 } 122 else if (lctSetting == null) { 123 setLayoutCodeTarget(layoutCodeTarget); 124 } 125 126 return layoutCodeTarget; 127 } 128 129 132 public void setI18nAutoMode(boolean value) { 133 settings.put(FormLoaderSettings.PROP_AUTO_I18N, value ? Boolean.TRUE : Boolean.FALSE); 134 } 135 136 public boolean getI18nAutoMode() { 137 Boolean i18nSetting = (Boolean ) settings.get(FormLoaderSettings.PROP_AUTO_I18N); 138 boolean i18nAutoMode; 139 if (i18nSetting != null) { 140 i18nAutoMode = i18nSetting.booleanValue(); 141 } 142 else { if (FormEditor.getFormEditor(formModel).needPostCreationUpdate()) { 144 int globalI18nAutoMode = FormLoaderSettings.getInstance().getI18nAutoMode(); 145 if (globalI18nAutoMode == FormLoaderSettings.AUTO_I18N_DEFAULT) { i18nAutoMode = FormEditor.getI18nSupport(formModel).isDefaultInternationalizableProject(); 147 } 148 else i18nAutoMode = (globalI18nAutoMode == FormLoaderSettings.AUTO_I18N_ON); 149 } 150 else i18nAutoMode = false; 151 setI18nAutoMode(i18nAutoMode); 152 } 153 return i18nAutoMode; 154 } 155 156 public void setFormBundle(String bundleName) { 157 settings.put(I18nSupport.PROP_FORM_BUNDLE, bundleName); 158 } 159 160 public String getFormBundle() { 161 return (String ) settings.get(I18nSupport.PROP_FORM_BUNDLE); 162 } 163 164 166 void set(String name, Object value) { 167 settings.put(name, value); 168 } 169 170 Map allSettings() { 171 return Collections.unmodifiableMap(settings); 172 } 173 174 } 175 | Popular Tags |