1 22 23 package org.gjt.sp.jedit.options; 24 25 import javax.swing.*; 27 import java.awt.event.ActionEvent ; 28 import java.awt.event.ActionListener ; 29 import java.awt.*; 30 import org.gjt.sp.jedit.textarea.AntiAlias; 31 import org.gjt.sp.jedit.jEdit; 32 import org.gjt.sp.jedit.AbstractOptionPane; 33 import org.gjt.sp.jedit.gui.FontSelector; 34 import org.gjt.sp.jedit.gui.ColorWellButton; 35 37 41 public class TextAreaOptionPane extends AbstractOptionPane 42 { 43 public TextAreaOptionPane() 45 { 46 super("textarea"); 47 } 49 public void _init() 51 { 52 53 font = new FontSelector(jEdit.getFontProperty("view.font")); 54 55 addComponent(jEdit.getProperty("options.textarea.font"),font); 56 57 58 addComponent(jEdit.getProperty("options.textarea.foreground"), 59 foregroundColor = new ColorWellButton( 60 jEdit.getColorProperty("view.fgColor")), 61 GridBagConstraints.VERTICAL); 62 63 64 addComponent(jEdit.getProperty("options.textarea.background"), 65 backgroundColor = new ColorWellButton( 66 jEdit.getColorProperty("view.bgColor")), 67 GridBagConstraints.VERTICAL); 68 69 70 blinkCaret = new JCheckBox(jEdit.getProperty("options.textarea" 71 + ".blinkCaret")); 72 blinkCaret.setSelected(jEdit.getBooleanProperty("view.caretBlink")); 73 74 blockCaret = new JCheckBox(jEdit.getProperty("options.textarea" 75 + ".blockCaret")); 76 blockCaret.setSelected(jEdit.getBooleanProperty("view.blockCaret")); 77 78 Box caretSettings = new Box(BoxLayout.X_AXIS); 79 caretSettings.add(new JLabel(jEdit.getProperty( 80 "options.textarea.caret"))); 81 caretSettings.add(Box.createHorizontalStrut(6)); 82 caretSettings.add(blinkCaret); 83 caretSettings.add(blockCaret); 84 85 addComponent(caretSettings,caretColor = new ColorWellButton( 86 jEdit.getColorProperty("view.caretColor")), 87 GridBagConstraints.VERTICAL); 88 89 90 addComponent(jEdit.getProperty("options.textarea.selection"), 91 selectionColor = new ColorWellButton( 92 jEdit.getColorProperty("view.selectionColor")), 93 GridBagConstraints.VERTICAL); 94 95 96 addComponent(jEdit.getProperty("options.textarea.multipleSelection"), 97 multipleSelectionColor = new ColorWellButton( 98 jEdit.getColorProperty("view.multipleSelectionColor")), 99 GridBagConstraints.VERTICAL); 100 101 102 lineHighlight = new JCheckBox(jEdit.getProperty("options.textarea" 103 + ".lineHighlight")); 104 lineHighlight.setSelected(jEdit.getBooleanProperty("view.lineHighlight")); 105 addComponent(lineHighlight,lineHighlightColor = new ColorWellButton( 106 jEdit.getColorProperty("view.lineHighlightColor")), 107 GridBagConstraints.VERTICAL); 108 109 110 structureHighlight = new JCheckBox(jEdit.getProperty("options.textarea" 111 + ".structureHighlight")); 112 structureHighlight.setSelected(jEdit.getBooleanProperty( 113 "view.structureHighlight")); 114 addComponent(structureHighlight,structureHighlightColor = new ColorWellButton( 115 jEdit.getColorProperty("view.structureHighlightColor")), 116 GridBagConstraints.VERTICAL); 117 118 119 eolMarkers = new JCheckBox(jEdit.getProperty("options.textarea" 120 + ".eolMarkers")); 121 eolMarkers.setSelected(jEdit.getBooleanProperty("view.eolMarkers")); 122 addComponent(eolMarkers,eolMarkerColor =new ColorWellButton( 123 jEdit.getColorProperty("view.eolMarkerColor")), 124 GridBagConstraints.VERTICAL); 125 126 127 wrapGuide = new JCheckBox(jEdit.getProperty("options.textarea" 128 + ".wrapGuide")); 129 wrapGuide.setSelected(jEdit.getBooleanProperty("view.wrapGuide")); 130 addComponent(wrapGuide,wrapGuideColor = new ColorWellButton( 131 jEdit.getColorProperty("view.wrapGuideColor")), 132 GridBagConstraints.VERTICAL); 133 134 135 electricBorders = new JCheckBox(jEdit.getProperty("options.textarea" 136 + ".electricBorders")); 137 electricBorders.setSelected(!"0".equals(jEdit.getProperty( 138 "view.electricBorders"))); 139 addComponent(electricBorders); 140 141 142 143 antiAlias = new JComboBox(AntiAlias.comboChoices); 144 antiAlias.setToolTipText(jEdit.getProperty("options.textarea.antiAlias.tooltip")); 145 AntiAlias antiAliasValue = new AntiAlias(jEdit.getProperty("view.antiAlias")); 146 font.setAntiAliasEnabled(antiAliasValue.val()>0); 147 antiAlias.addActionListener(new ActionListener () 148 { 149 public void actionPerformed(ActionEvent evt) 150 { 151 int idx = antiAlias.getSelectedIndex(); 152 font.setAntiAliasEnabled(idx > 0); 153 font.repaint(); 154 } 155 }); 156 antiAlias.setSelectedIndex(antiAliasValue.val()); 157 addComponent(jEdit.getProperty("options.textarea"+ ".antiAlias"), antiAlias); 158 159 160 fracFontMetrics = new JCheckBox(jEdit.getProperty("options.textarea" 161 + ".fracFontMetrics")); 162 fracFontMetrics.setSelected(jEdit.getBooleanProperty("view.fracFontMetrics")); 163 addComponent(fracFontMetrics); 164 165 166 stripTrailingEOL = new JCheckBox(jEdit.getProperty( 167 "options.textArea.stripTrailingEOL")); 168 stripTrailingEOL.setSelected(jEdit.getBooleanProperty("stripTrailingEOL")); 169 addComponent(stripTrailingEOL); 170 171 } 173 public void _save() 175 { 176 jEdit.setFontProperty("view.font",font.getFont()); 177 178 jEdit.setColorProperty("view.fgColor",foregroundColor 179 .getSelectedColor()); 180 jEdit.setColorProperty("view.bgColor",backgroundColor 181 .getSelectedColor()); 182 jEdit.setBooleanProperty("view.caretBlink",blinkCaret.isSelected()); 183 jEdit.setBooleanProperty("view.blockCaret",blockCaret.isSelected()); 184 jEdit.setColorProperty("view.caretColor",caretColor 185 .getSelectedColor()); 186 jEdit.setColorProperty("view.selectionColor",selectionColor 187 .getSelectedColor()); 188 jEdit.setColorProperty("view.multipleSelectionColor",multipleSelectionColor 189 .getSelectedColor()); 190 jEdit.setBooleanProperty("view.lineHighlight",lineHighlight 191 .isSelected()); 192 jEdit.setColorProperty("view.lineHighlightColor", 193 lineHighlightColor.getSelectedColor()); 194 jEdit.setBooleanProperty("view.structureHighlight",structureHighlight 195 .isSelected()); 196 jEdit.setColorProperty("view.structureHighlightColor", 197 structureHighlightColor.getSelectedColor()); 198 jEdit.setBooleanProperty("view.eolMarkers",eolMarkers 199 .isSelected()); 200 jEdit.setColorProperty("view.eolMarkerColor", 201 eolMarkerColor.getSelectedColor()); 202 jEdit.setBooleanProperty("view.wrapGuide",wrapGuide 203 .isSelected()); 204 jEdit.setColorProperty("view.wrapGuideColor", 205 wrapGuideColor.getSelectedColor()); 206 jEdit.setIntegerProperty("view.electricBorders",electricBorders 207 .isSelected() ? 3 : 0); 208 AntiAlias nv = new AntiAlias(jEdit.getProperty("view.antiAlias")); 209 nv.set(antiAlias.getSelectedIndex()); 210 jEdit.setProperty("view.antiAlias", nv.toString()); 211 jEdit.setBooleanProperty("view.fracFontMetrics",fracFontMetrics.isSelected()); 212 jEdit.setBooleanProperty("stripTrailingEOL", stripTrailingEOL.isSelected()); 213 } 215 private FontSelector font; 217 private ColorWellButton foregroundColor; 218 private ColorWellButton backgroundColor; 219 private JCheckBox blinkCaret; 220 private JCheckBox blockCaret; 221 private ColorWellButton caretColor; 222 private ColorWellButton selectionColor; 223 private ColorWellButton multipleSelectionColor; 224 private JCheckBox lineHighlight; 225 private ColorWellButton lineHighlightColor; 226 private JCheckBox structureHighlight; 227 private ColorWellButton structureHighlightColor; 228 private JCheckBox eolMarkers; 229 private ColorWellButton eolMarkerColor; 230 private JCheckBox wrapGuide; 231 private ColorWellButton wrapGuideColor; 232 private JCheckBox electricBorders; 233 private JComboBox antiAlias; 235 private JCheckBox fracFontMetrics; 236 private JCheckBox stripTrailingEOL; 237 } 239 | Popular Tags |