1 19 20 package org.netbeans.modules.editor.options; 21 22 import java.util.Map ; 23 import org.netbeans.editor.Settings; 24 import org.netbeans.editor.SettingsNames; 25 import org.netbeans.editor.SettingsUtil; 26 import org.netbeans.editor.BaseKit; 27 import org.netbeans.modules.editor.NbEditorSettingsInitializer; 28 import org.openide.text.PrintSettings; 29 import org.openide.util.HelpCtx; 30 31 36 public class BasePrintOptions extends OptionSupport { 37 38 public static final String BASE = "base"; 40 public static final String PRINT_PREFIX = "print_"; 42 public static final String PRINT_COLORING_MAP_PROP = "printColoringMap"; 44 private static final String HELP_ID = "editing.fontsandcolors"; 46 static final String [] BASE_PROP_NAMES = { 47 PRINT_COLORING_MAP_PROP, 48 }; 49 50 static final long serialVersionUID =7740651671176408299L; 51 public BasePrintOptions() { 52 this(BaseKit.class, BASE); 53 } 54 55 private transient Settings.Initializer printColoringMapInitializer; 56 57 public BasePrintOptions(Class kitClass, String typeName) { 58 super(kitClass, typeName); 59 } 60 61 public String displayName() { 62 63 String name; 64 try { 65 name = getString(OPTIONS_PREFIX + PRINT_PREFIX + getTypeName()); 66 } catch (Throwable t) { 67 name = super.displayName(); 68 } 69 return name; 70 } 71 72 public void init(){ 73 refreshContextListeners(); 74 } 75 76 private void refreshContextListeners() { 77 PrintSettings ps = (PrintSettings) PrintSettings.findObject(PrintSettings.class, true); 78 ContextOptionsListener.processExistingAndListen(ps); 80 } 81 82 public HelpCtx getHelpCtx () { 83 return new HelpCtx (HELP_ID); 84 } 85 86 89 protected String getSettingsInitializerName() { 90 return getTypeName() + "-print-options-initalizer"; } 92 93 protected void updateSettingsMap(Class kitClass, Map settingsMap) { 94 super.updateSettingsMap(kitClass, settingsMap); 95 96 if (printColoringMapInitializer != null) { 97 printColoringMapInitializer.updateSettingsMap(kitClass, settingsMap); 98 } 99 } 100 101 102 public boolean getPrintLineNumberVisible() { 103 return ((Boolean )getSettingValue(SettingsNames.LINE_NUMBER_VISIBLE)).booleanValue(); 104 } 105 public void setPrintLineNumberVisible(boolean b) { 106 } 107 108 public Map getPrintColoringMap() { 109 NbEditorSettingsInitializer.init(); 110 Map cm = SettingsUtil.getColoringMap(getKitClass(), true, true); 111 cm.put(null, getKitClass().getName() ); return cm; 113 } 114 public void setPrintColoringMap(Map coloringMap) { 115 NbEditorSettingsInitializer.init(); 116 if (coloringMap != null) { 117 coloringMap.remove(null); SettingsUtil.setColoringMap( getKitClass(), coloringMap, true ); 119 120 printColoringMapInitializer = SettingsUtil.getColoringMapInitializer( 121 getKitClass(), coloringMap, true, 122 getTypeName() + "-print-coloring-map-initializer" ); 124 125 126 firePropertyChange(PRINT_COLORING_MAP_PROP, null, null); 127 } 128 } 129 130 } 131 | Popular Tags |