PageRenderTime 131ms CodeModel.GetById 120ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre4/org/gjt/sp/jedit/options/TextAreaOptionPane.java

#
Java | 225 lines | 157 code | 25 blank | 43 comment | 0 complexity | 2491a7464810edf16d55bffa4e64c02f MD5 | raw file
  1/*
  2 * TextAreaOptionPane.java - Text area options panel
  3 * :tabSize=8:indentSize=8:noTabs=false:
  4 * :folding=explicit:collapseFolds=1:
  5 *
  6 * Copyright (C) 1998, 1999, 2000 Slava Pestov
  7 *
  8 * This program is free software; you can redistribute it and/or
  9 * modify it under the terms of the GNU General Public License
 10 * as published by the Free Software Foundation; either version 2
 11 * of the License, or any later version.
 12 *
 13 * This program is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16 * GNU General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU General Public License
 19 * along with this program; if not, write to the Free Software
 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 21 */
 22
 23package org.gjt.sp.jedit.options;
 24
 25//{{{ Imports
 26import javax.swing.*;
 27import java.awt.*;
 28import org.gjt.sp.jedit.gui.*;
 29import org.gjt.sp.jedit.*;
 30//}}}
 31
 32public class TextAreaOptionPane extends AbstractOptionPane
 33{
 34	//{{{ TextAreaOptionPane constructor
 35	public TextAreaOptionPane()
 36	{
 37		super("textarea");
 38	} //}}}
 39
 40	//{{{ _init() method
 41	public void _init()
 42	{
 43		/* Font */
 44		font = new FontSelector(jEdit.getFontProperty("view.font"));
 45
 46		addComponent(jEdit.getProperty("options.textarea.font"),font);
 47
 48		/* Text color */
 49		addComponent(jEdit.getProperty("options.textarea.foreground"),
 50			foregroundColor = new ColorWellButton(
 51			jEdit.getColorProperty("view.fgColor")),
 52			GridBagConstraints.VERTICAL);
 53
 54		/* Background color */
 55		addComponent(jEdit.getProperty("options.textarea.background"),
 56			backgroundColor = new ColorWellButton(
 57			jEdit.getColorProperty("view.bgColor")),
 58			GridBagConstraints.VERTICAL);
 59
 60		/* Caret color, caret blink, block caret */
 61		blinkCaret = new JCheckBox(jEdit.getProperty("options.textarea"
 62			+ ".blinkCaret"));
 63		blinkCaret.setSelected(jEdit.getBooleanProperty("view.caretBlink"));
 64
 65		blockCaret = new JCheckBox(jEdit.getProperty("options.textarea"
 66			+ ".blockCaret"));
 67		blockCaret.setSelected(jEdit.getBooleanProperty("view.blockCaret"));
 68
 69		Box caretSettings = new Box(BoxLayout.X_AXIS);
 70		caretSettings.add(new JLabel(jEdit.getProperty(
 71			"options.textarea.caret")));
 72		caretSettings.add(Box.createHorizontalStrut(6));
 73		caretSettings.add(blinkCaret);
 74		caretSettings.add(blockCaret);
 75
 76		addComponent(caretSettings,caretColor = new ColorWellButton(
 77			jEdit.getColorProperty("view.caretColor")),
 78			GridBagConstraints.VERTICAL);
 79
 80		/* Selection color */
 81		addComponent(jEdit.getProperty("options.textarea.selection"),
 82			selectionColor = new ColorWellButton(
 83			jEdit.getColorProperty("view.selectionColor")),
 84			GridBagConstraints.VERTICAL);
 85
 86		/* Multiple selection color */
 87		addComponent(jEdit.getProperty("options.textarea.multipleSelection"),
 88			multipleSelectionColor = new ColorWellButton(
 89			jEdit.getColorProperty("view.multipleSelectionColor")),
 90			GridBagConstraints.VERTICAL);
 91
 92		/* Line highlight */
 93		lineHighlight = new JCheckBox(jEdit.getProperty("options.textarea"
 94			+ ".lineHighlight"));
 95		lineHighlight.setSelected(jEdit.getBooleanProperty("view.lineHighlight"));
 96		addComponent(lineHighlight,lineHighlightColor = new ColorWellButton(
 97			jEdit.getColorProperty("view.lineHighlightColor")),
 98			GridBagConstraints.VERTICAL);
 99
100		/* Structure highlight */
101		structureHighlight = new JCheckBox(jEdit.getProperty("options.textarea"
102			+ ".structureHighlight"));
103		structureHighlight.setSelected(jEdit.getBooleanProperty(
104			"view.structureHighlight"));
105		addComponent(structureHighlight,structureHighlightColor = new ColorWellButton(
106			jEdit.getColorProperty("view.structureHighlightColor")),
107			GridBagConstraints.VERTICAL);
108
109		/* EOL markers */
110		eolMarkers = new JCheckBox(jEdit.getProperty("options.textarea"
111			+ ".eolMarkers"));
112		eolMarkers.setSelected(jEdit.getBooleanProperty("view.eolMarkers"));
113		addComponent(eolMarkers,eolMarkerColor =new ColorWellButton(
114			jEdit.getColorProperty("view.eolMarkerColor")),
115			GridBagConstraints.VERTICAL);
116
117		/* Wrap guide */
118		wrapGuide = new JCheckBox(jEdit.getProperty("options.textarea"
119			+ ".wrapGuide"));
120		wrapGuide.setSelected(jEdit.getBooleanProperty("view.wrapGuide"));
121		addComponent(wrapGuide,wrapGuideColor = new ColorWellButton(
122			jEdit.getColorProperty("view.wrapGuideColor")),
123			GridBagConstraints.VERTICAL);
124
125		/* Electric borders */
126		electricBorders = new JCheckBox(jEdit.getProperty("options.textarea"
127			+ ".electricBorders"));
128		electricBorders.setSelected(!"0".equals(jEdit.getProperty(
129			"view.electricBorders")));
130		addComponent(electricBorders);
131
132		/* Non word character selection behavior */
133		joinNonWordChars = new JCheckBox(jEdit.getProperty(
134			"options.textarea.joinNonWordChars"));
135		joinNonWordChars.setSelected(jEdit.getBooleanProperty(
136			"view.joinNonWordChars"));
137		addComponent(joinNonWordChars);
138
139		/* Middle mouse button click pastes % register */
140		middleMousePaste = new JCheckBox(jEdit.getProperty("options.textarea"
141			+ ".middleMousePaste"));
142		middleMousePaste.setSelected(jEdit.getBooleanProperty(
143			"view.middleMousePaste"));
144		addComponent(middleMousePaste);
145
146		/* Anti-aliasing */
147		antiAlias = new JCheckBox(jEdit.getProperty("options.textarea"
148			+ ".antiAlias"));
149		antiAlias.setSelected(jEdit.getBooleanProperty("view.antiAlias"));
150		addComponent(antiAlias);
151
152		/* Fractional font metrics */
153		fracFontMetrics = new JCheckBox(jEdit.getProperty("options.textarea"
154			+ ".fracFontMetrics"));
155		fracFontMetrics.setSelected(jEdit.getBooleanProperty(
156			"view.fracFontMetrics"));
157		addComponent(fracFontMetrics);
158	} //}}}
159
160	//{{{ _save() method
161	public void _save()
162	{
163		jEdit.setFontProperty("view.font",font.getFont());
164
165		jEdit.setColorProperty("view.fgColor",foregroundColor
166			.getSelectedColor());
167		jEdit.setColorProperty("view.bgColor",backgroundColor
168			.getSelectedColor());
169		jEdit.setBooleanProperty("view.caretBlink",blinkCaret.isSelected());
170		jEdit.setBooleanProperty("view.blockCaret",blockCaret.isSelected());
171		jEdit.setColorProperty("view.caretColor",caretColor
172			.getSelectedColor());
173		jEdit.setColorProperty("view.selectionColor",selectionColor
174			.getSelectedColor());
175		jEdit.setColorProperty("view.multipleSelectionColor",multipleSelectionColor
176			.getSelectedColor());
177		jEdit.setBooleanProperty("view.lineHighlight",lineHighlight
178			.isSelected());
179		jEdit.setColorProperty("view.lineHighlightColor",
180			lineHighlightColor.getSelectedColor());
181		jEdit.setBooleanProperty("view.structureHighlight",structureHighlight
182			.isSelected());
183		jEdit.setColorProperty("view.structureHighlightColor",
184			structureHighlightColor.getSelectedColor());
185		jEdit.setBooleanProperty("view.eolMarkers",eolMarkers
186			.isSelected());
187		jEdit.setColorProperty("view.eolMarkerColor",
188			eolMarkerColor.getSelectedColor());
189		jEdit.setBooleanProperty("view.wrapGuide",wrapGuide
190			.isSelected());
191		jEdit.setColorProperty("view.wrapGuideColor",
192			wrapGuideColor.getSelectedColor());
193		jEdit.setIntegerProperty("view.electricBorders",electricBorders
194			.isSelected() ? 3 : 0);
195		jEdit.setBooleanProperty("view.joinNonWordChars",joinNonWordChars.isSelected());
196		jEdit.setBooleanProperty("view.middleMousePaste",
197			middleMousePaste.isSelected());
198		jEdit.setBooleanProperty("view.antiAlias",antiAlias.isSelected());
199		jEdit.setBooleanProperty("view.fracFontMetrics",fracFontMetrics.isSelected());
200	} //}}}
201
202	//{{{ Private members
203	private FontSelector font;
204	private ColorWellButton foregroundColor;
205	private ColorWellButton backgroundColor;
206	private JCheckBox blinkCaret;
207	private JCheckBox blockCaret;
208	private ColorWellButton caretColor;
209	private ColorWellButton selectionColor;
210	private ColorWellButton multipleSelectionColor;
211	private JCheckBox lineHighlight;
212	private ColorWellButton lineHighlightColor;
213	private JCheckBox structureHighlight;
214	private ColorWellButton structureHighlightColor;
215	private JCheckBox eolMarkers;
216	private ColorWellButton eolMarkerColor;
217	private JCheckBox wrapGuide;
218	private ColorWellButton wrapGuideColor;
219	private JCheckBox electricBorders;
220	private JCheckBox middleMousePaste;
221	private JCheckBox antiAlias;
222	private JCheckBox fracFontMetrics;
223	private JCheckBox joinNonWordChars;
224	//}}}
225}