KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > sp > jedit > options > TextAreaOptionPane


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
23 package org.gjt.sp.jedit.options;
24
25 //{{{ Imports
26
import javax.swing.*;
27 import java.awt.event.ActionEvent JavaDoc;
28 import java.awt.event.ActionListener JavaDoc;
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 //}}}
36

37 /**
38  * @author Slava Pestov
39  * @version $Id: TextAreaOptionPane.java 7143 2006-09-29 09:08:24Z kpouer $
40  */

41 public class TextAreaOptionPane extends AbstractOptionPane
42 {
43     //{{{ TextAreaOptionPane constructor
44
public TextAreaOptionPane()
45     {
46         super("textarea");
47     } //}}}
48

49     //{{{ _init() method
50
public void _init()
51     {
52         /* Font */
53         font = new FontSelector(jEdit.getFontProperty("view.font"));
54
55         addComponent(jEdit.getProperty("options.textarea.font"),font);
56
57         /* Text color */
58         addComponent(jEdit.getProperty("options.textarea.foreground"),
59             foregroundColor = new ColorWellButton(
60             jEdit.getColorProperty("view.fgColor")),
61             GridBagConstraints.VERTICAL);
62
63         /* Background color */
64         addComponent(jEdit.getProperty("options.textarea.background"),
65             backgroundColor = new ColorWellButton(
66             jEdit.getColorProperty("view.bgColor")),
67             GridBagConstraints.VERTICAL);
68
69         /* Caret color, caret blink, block caret */
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         /* Selection color */
90         addComponent(jEdit.getProperty("options.textarea.selection"),
91             selectionColor = new ColorWellButton(
92             jEdit.getColorProperty("view.selectionColor")),
93             GridBagConstraints.VERTICAL);
94
95         /* Multiple selection color */
96         addComponent(jEdit.getProperty("options.textarea.multipleSelection"),
97             multipleSelectionColor = new ColorWellButton(
98             jEdit.getColorProperty("view.multipleSelectionColor")),
99             GridBagConstraints.VERTICAL);
100
101         /* Line highlight */
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         /* Structure highlight */
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         /* EOL markers */
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         /* Wrap guide */
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         /* Electric borders */
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         /* Anti-aliasing */
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 JavaDoc()
148             {
149                 public void actionPerformed(ActionEvent JavaDoc 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         /* Fractional font metrics */
160         fracFontMetrics = new JCheckBox(jEdit.getProperty("options.textarea"
161             + ".fracFontMetrics"));
162         fracFontMetrics.setSelected(jEdit.getBooleanProperty("view.fracFontMetrics"));
163         addComponent(fracFontMetrics);
164
165         /* Strip trailing EOL */
166         stripTrailingEOL = new JCheckBox(jEdit.getProperty(
167             "options.textArea.stripTrailingEOL"));
168         stripTrailingEOL.setSelected(jEdit.getBooleanProperty("stripTrailingEOL"));
169         addComponent(stripTrailingEOL);
170
171     } //}}}
172

173     //{{{ _save() method
174
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     } //}}}
214

215     //{{{ Private members
216
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 JCheckBox antiAlias;
234
private JComboBox antiAlias;
235     private JCheckBox fracFontMetrics;
236     private JCheckBox stripTrailingEOL;
237     //}}}
238
}
239
Popular Tags