KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * GutterOptionPane.java - Gutter options panel
3  * :tabSize=8:indentSize=8:noTabs=false:
4  * :folding=explicit:collapseFolds=1:
5  *
6  * Copyright (C) 2000 mike dillon
7  * Portions copyright (C) 2001, 2002 Slava Pestov
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22  */

23
24 package org.gjt.sp.jedit.options;
25
26 //{{{ Imports
27
import javax.swing.*;
28 import java.awt.*;
29 import org.gjt.sp.jedit.gui.*;
30 import org.gjt.sp.jedit.*;
31 //}}}
32

33 public class GutterOptionPane extends AbstractOptionPane
34 {
35     //{{{ GutterOptionPane constructor
36
public GutterOptionPane()
37     {
38         super("gutter");
39     } //}}}
40

41     //{{{ _init() method
42
public void _init()
43     {
44         /* Line numbering */
45         lineNumbersEnabled = new JCheckBox(jEdit.getProperty(
46             "options.gutter.lineNumbers"));
47         lineNumbersEnabled.setSelected(jEdit.getBooleanProperty(
48             "view.gutter.lineNumbers"));
49         addComponent(lineNumbersEnabled);
50
51         /* Text font */
52         gutterFont = new FontSelector(
53             jEdit.getFontProperty("view.gutter.font",
54             new Font("Monospaced",Font.PLAIN,10)));
55
56         addComponent(jEdit.getProperty("options.gutter.font"),gutterFont);
57
58         /* Text color */
59         addComponent(jEdit.getProperty("options.gutter.foreground"),
60             gutterForeground = new ColorWellButton(
61             jEdit.getColorProperty("view.gutter.fgColor")),
62             GridBagConstraints.VERTICAL);
63
64         /* Background color */
65         addComponent(jEdit.getProperty("options.gutter.background"),
66             gutterBackground = new ColorWellButton(
67             jEdit.getColorProperty("view.gutter.bgColor")),
68             GridBagConstraints.VERTICAL);
69
70         /* Border width */
71         /* gutterBorderWidth = new JTextField(jEdit.getProperty(
72             "view.gutter.borderWidth"));
73         addComponent(jEdit.getProperty("options.gutter.borderWidth"),
74             gutterBorderWidth); */

75
76         /* Number alignment */
77         /* String[] alignments = new String[] {
78             "Left", "Center", "Right"
79         };
80         gutterNumberAlignment = new JComboBox(alignments);
81         String alignment = jEdit.getProperty("view.gutter.numberAlignment");
82         if("right".equals(alignment))
83             gutterNumberAlignment.setSelectedIndex(2);
84         else if("center".equals(alignment))
85             gutterNumberAlignment.setSelectedIndex(1);
86         else
87             gutterNumberAlignment.setSelectedIndex(0);
88         addComponent(jEdit.getProperty("options.gutter.numberAlignment"),
89             gutterNumberAlignment); */

90
91         /* Current line highlight */
92         gutterCurrentLineHighlightEnabled = new JCheckBox(jEdit.getProperty(
93             "options.gutter.currentLineHighlight"));
94         gutterCurrentLineHighlightEnabled.setSelected(jEdit.getBooleanProperty(
95             "view.gutter.highlightCurrentLine"));
96         addComponent(gutterCurrentLineHighlightEnabled,
97             gutterCurrentLineHighlight = new ColorWellButton(
98             jEdit.getColorProperty("view.gutter.currentLineColor")),
99             GridBagConstraints.VERTICAL);
100
101         /* Highlight interval and color */
102         gutterHighlightInterval = new JTextField(jEdit.getProperty(
103             "view.gutter.highlightInterval"),3);
104
105         Box gutterHighlightBox = new Box(BoxLayout.X_AXIS);
106         gutterHighlightBox.add(new JLabel(jEdit.getProperty(
107             "options.gutter.interval-1")));
108         gutterHighlightBox.add(Box.createHorizontalStrut(3));
109         gutterHighlightBox.add(gutterHighlightInterval);
110         gutterHighlightBox.add(Box.createHorizontalStrut(3));
111         gutterHighlightBox.add(new JLabel(jEdit.getProperty(
112             "options.gutter.interval-2")));
113         gutterHighlightBox.add(Box.createHorizontalStrut(12));
114
115         addComponent(gutterHighlightBox,gutterHighlightColor
116             = new ColorWellButton(jEdit.getColorProperty(
117             "view.gutter.highlightColor")),
118             GridBagConstraints.VERTICAL);
119
120         /* Structure highlight */
121         gutterStructureHighlightEnabled = new JCheckBox(jEdit.getProperty(
122             "options.gutter.structureHighlight"));
123         gutterStructureHighlightEnabled.setSelected(jEdit.getBooleanProperty(
124             "view.gutter.structureHighlight"));
125         addComponent(gutterStructureHighlightEnabled,
126             gutterStructureHighlight = new ColorWellButton(
127             jEdit.getColorProperty("view.gutter.structureHighlightColor")),
128             GridBagConstraints.VERTICAL);
129
130         /* Marker highlight */
131         gutterMarkerHighlightEnabled = new JCheckBox(jEdit.getProperty(
132             "options.gutter.markerHighlight"));
133         gutterMarkerHighlightEnabled.setSelected(jEdit.getBooleanProperty(
134             "view.gutter.markerHighlight"));
135         addComponent(gutterMarkerHighlightEnabled,
136             gutterMarkerHighlight = new ColorWellButton(
137             jEdit.getColorProperty("view.gutter.markerColor")),
138             GridBagConstraints.VERTICAL);
139
140         /* Fold marker color */
141         addComponent(jEdit.getProperty("options.gutter.foldColor"),
142             gutterFoldMarkers = new ColorWellButton(
143             jEdit.getColorProperty("view.gutter.foldColor")),
144             GridBagConstraints.VERTICAL);
145
146         /* Focused border color */
147         addComponent(jEdit.getProperty("options.gutter.focusBorderColor"),
148             gutterFocusBorder = new ColorWellButton(
149             jEdit.getColorProperty("view.gutter.focusBorderColor")),
150             GridBagConstraints.VERTICAL);
151
152         /* unfocused border color */
153         addComponent(jEdit.getProperty("options.gutter.noFocusBorderColor"),
154             gutterNoFocusBorder = new ColorWellButton(
155             jEdit.getColorProperty("view.gutter.noFocusBorderColor")),
156             GridBagConstraints.VERTICAL);
157     } //}}}
158

159     //{{{ _save() method
160
public void _save()
161     {
162         jEdit.setBooleanProperty("view.gutter.lineNumbers", lineNumbersEnabled
163             .isSelected());
164
165         jEdit.setFontProperty("view.gutter.font",gutterFont.getFont());
166         jEdit.setColorProperty("view.gutter.fgColor",gutterForeground
167             .getSelectedColor());
168         jEdit.setColorProperty("view.gutter.bgColor",gutterBackground
169             .getSelectedColor());
170
171         /* jEdit.setProperty("view.gutter.borderWidth",
172             gutterBorderWidth.getText());
173
174         String alignment = null;
175         switch(gutterNumberAlignment.getSelectedIndex())
176         {
177         case 2:
178             alignment = "right";
179             break;
180         case 1:
181             alignment = "center";
182             break;
183         case 0: default:
184             alignment = "left";
185         }
186         jEdit.setProperty("view.gutter.numberAlignment", alignment); */

187
188         jEdit.setBooleanProperty("view.gutter.highlightCurrentLine",
189             gutterCurrentLineHighlightEnabled.isSelected());
190         jEdit.setColorProperty("view.gutter.currentLineColor",
191             gutterCurrentLineHighlight.getSelectedColor());
192         jEdit.setProperty("view.gutter.highlightInterval",
193             gutterHighlightInterval.getText());
194         jEdit.setColorProperty("view.gutter.highlightColor",
195             gutterHighlightColor.getSelectedColor());
196
197         jEdit.setBooleanProperty("view.gutter.structureHighlight",
198             gutterStructureHighlightEnabled.isSelected());
199         jEdit.setColorProperty("view.gutter.structureHighlightColor",
200             gutterStructureHighlight.getSelectedColor());
201         jEdit.setBooleanProperty("view.gutter.markerHighlight",
202             gutterMarkerHighlightEnabled.isSelected());
203         jEdit.setColorProperty("view.gutter.markerColor",
204             gutterMarkerHighlight.getSelectedColor());
205         jEdit.setColorProperty("view.gutter.foldColor",
206             gutterFoldMarkers.getSelectedColor());
207         jEdit.setColorProperty("view.gutter.focusBorderColor",
208             gutterFocusBorder.getSelectedColor());
209         jEdit.setColorProperty("view.gutter.noFocusBorderColor",
210             gutterNoFocusBorder.getSelectedColor());
211     } //}}}
212

213     //{{{ Private members
214
private FontSelector gutterFont;
215     private ColorWellButton gutterForeground;
216     private ColorWellButton gutterBackground;
217     private JTextField gutterHighlightInterval;
218     private ColorWellButton gutterHighlightColor;
219     private JCheckBox lineNumbersEnabled;
220     private JCheckBox gutterCurrentLineHighlightEnabled;
221     private ColorWellButton gutterCurrentLineHighlight;
222     private JCheckBox gutterStructureHighlightEnabled;
223     private ColorWellButton gutterStructureHighlight;
224     private JCheckBox gutterMarkerHighlightEnabled;
225     private ColorWellButton gutterMarkerHighlight;
226     private ColorWellButton gutterFoldMarkers;
227     private ColorWellButton gutterFocusBorder;
228     private ColorWellButton gutterNoFocusBorder;
229     //}}}
230
}
231
Popular Tags