KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

32 public class StatusBarOptionPane extends AbstractOptionPane
33 {
34     //{{{ StatusBarOptionPane constructor
35
public StatusBarOptionPane()
36     {
37         super("status");
38     } //}}}
39

40     //{{{ _init() method
41
protected void _init()
42     {
43         /* Status bar visible */
44         statusVisible = new JCheckBox(jEdit.getProperty(
45             "options.status.visible"));
46         statusVisible.setSelected(jEdit.getBooleanProperty(
47             "view.status.visible"));
48         statusVisible.addActionListener(new ActionHandler());
49         addComponent(statusVisible);
50
51         /* Foreground color */
52         addComponent(jEdit.getProperty("options.status.foreground"),
53             foregroundColor = new ColorWellButton(
54             jEdit.getColorProperty("view.status.foreground")),
55             GridBagConstraints.VERTICAL);
56
57         /* Background color */
58         addComponent(jEdit.getProperty("options.status.background"),
59             backgroundColor = new ColorWellButton(
60             jEdit.getColorProperty("view.status.background")),
61             GridBagConstraints.VERTICAL);
62
63         /* Caret status */
64         showCaretStatus = new JCheckBox(jEdit.getProperty(
65             "options.status.show-caret-status"));
66         showCaretStatus.setSelected(jEdit.getBooleanProperty(
67             "view.status.show-caret-status"));
68         addComponent(showCaretStatus);
69
70         /* Edit mode */
71         showEditMode = new JCheckBox(jEdit.getProperty(
72             "options.status.show-edit-mode"));
73         showEditMode.setSelected(jEdit.getBooleanProperty(
74             "view.status.show-edit-mode"));
75         addComponent(showEditMode);
76
77         /* Fold mode */
78         showFoldMode = new JCheckBox(jEdit.getProperty(
79             "options.status.show-fold-mode"));
80         showFoldMode.setSelected(jEdit.getBooleanProperty(
81             "view.status.show-fold-mode"));
82         addComponent(showFoldMode);
83
84         /* Encoding */
85         showEncoding = new JCheckBox(jEdit.getProperty(
86             "options.status.show-encoding"));
87         showEncoding.setSelected(jEdit.getBooleanProperty(
88             "view.status.show-encoding"));
89         addComponent(showEncoding);
90
91         /* Wrap */
92         showWrap = new JCheckBox(jEdit.getProperty(
93             "options.status.show-wrap"));
94         showWrap.setSelected(jEdit.getBooleanProperty(
95             "view.status.show-wrap"));
96         addComponent(showWrap);
97
98         /* Multi select */
99         showMultiSelect = new JCheckBox(jEdit.getProperty(
100             "options.status.show-multi-select"));
101         showMultiSelect.setSelected(jEdit.getBooleanProperty(
102             "view.status.show-multi-select"));
103         addComponent(showMultiSelect);
104
105         /* Rect select */
106         showRectSelect = new JCheckBox(jEdit.getProperty(
107             "options.status.show-rect-select"));
108         showRectSelect.setSelected(jEdit.getBooleanProperty(
109             "view.status.show-rect-select"));
110         addComponent(showRectSelect);
111
112         /* Overwrite */
113         showOverwrite = new JCheckBox(jEdit.getProperty(
114             "options.status.show-overwrite"));
115         showOverwrite.setSelected(jEdit.getBooleanProperty(
116             "view.status.show-overwrite"));
117         addComponent(showOverwrite);
118
119         /* Line seperator */
120         showLineSeperator = new JCheckBox(jEdit.getProperty(
121             "options.status.show-line-seperator"));
122         showLineSeperator.setSelected(jEdit.getBooleanProperty(
123             "view.status.show-line-seperator"));
124         addComponent(showLineSeperator);
125
126         /* Memory status */
127         showMemory = new JCheckBox(jEdit.getProperty(
128             "options.status.show-memory"));
129         showMemory.setSelected(jEdit.getBooleanProperty(
130             "view.status.show-memory"));
131         showMemory.addActionListener(new ActionHandler());
132         addComponent(showMemory);
133
134         /* Memory foreground color */
135         addComponent(jEdit.getProperty("options.status.memory.foreground"),
136             memForegroundColor = new ColorWellButton(
137             jEdit.getColorProperty("view.status.memory.foreground")),
138             GridBagConstraints.VERTICAL);
139
140         /* Memory background color */
141         addComponent(jEdit.getProperty("options.status.memory.background"),
142             memBackgroundColor = new ColorWellButton(
143             jEdit.getColorProperty("view.status.memory.background")),
144             GridBagConstraints.VERTICAL);
145
146         /* Clock */
147         showClock = new JCheckBox(jEdit.getProperty(
148             "options.status.show-clock"));
149         showClock.setSelected(jEdit.getBooleanProperty(
150             "view.status.show-clock"));
151         showClock.addActionListener(new ActionHandler());
152         addComponent(showClock);
153
154         updateEnabled();
155     } //}}}
156

157     //{{{ _save() method
158
protected void _save()
159     {
160         jEdit.setBooleanProperty("view.status.visible",
161             statusVisible.isSelected());
162         jEdit.setColorProperty("view.status.foreground",foregroundColor
163             .getSelectedColor());
164         jEdit.setColorProperty("view.status.background",backgroundColor
165             .getSelectedColor());
166         jEdit.setBooleanProperty("view.status.show-caret-status",
167             showCaretStatus.isSelected());
168         jEdit.setBooleanProperty("view.status.show-edit-mode",
169             showEditMode.isSelected());
170         jEdit.setBooleanProperty("view.status.show-fold-mode",
171             showFoldMode.isSelected());
172         jEdit.setBooleanProperty("view.status.show-encoding",
173             showEncoding.isSelected());
174         jEdit.setBooleanProperty("view.status.show-wrap",
175             showWrap.isSelected());
176         jEdit.setBooleanProperty("view.status.show-multi-select",
177             showMultiSelect.isSelected());
178         jEdit.setBooleanProperty("view.status.show-rect-select",
179             showRectSelect.isSelected());
180         jEdit.setBooleanProperty("view.status.show-overwrite",
181             showOverwrite.isSelected());
182         jEdit.setBooleanProperty("view.status.show-line-seperator",
183             showLineSeperator.isSelected());
184         jEdit.setBooleanProperty("view.status.show-memory",
185             showMemory.isSelected());
186         jEdit.setColorProperty("view.status.memory.foreground",memForegroundColor
187             .getSelectedColor());
188         jEdit.setColorProperty("view.status.memory.background",memBackgroundColor
189             .getSelectedColor());
190         jEdit.setBooleanProperty("view.status.show-clock",
191             showClock.isSelected());
192     } //}}}
193

194     //{{{ Private members
195
private JCheckBox statusVisible;
196     private ColorWellButton foregroundColor;
197     private ColorWellButton backgroundColor;
198     private JCheckBox showCaretStatus;
199     private JCheckBox showEditMode;
200     private JCheckBox showFoldMode;
201     private JCheckBox showEncoding;
202     private JCheckBox showWrap;
203     private JCheckBox showMultiSelect;
204     private JCheckBox showRectSelect;
205     private JCheckBox showOverwrite;
206     private JCheckBox showLineSeperator;
207     private JCheckBox showMemory;
208     private ColorWellButton memForegroundColor;
209     private ColorWellButton memBackgroundColor;
210     private JCheckBox showClock;
211
212     private void updateEnabled()
213     {
214         boolean enabled = statusVisible.isSelected();
215         showCaretStatus.setEnabled(enabled);
216         showEditMode.setEnabled(enabled);
217         showFoldMode.setEnabled(enabled);
218         showEncoding.setEnabled(enabled);
219         showWrap.setEnabled(enabled);
220         showMultiSelect.setEnabled(enabled);
221         showRectSelect.setEnabled(enabled);
222         showOverwrite.setEnabled(enabled);
223         showLineSeperator.setEnabled(enabled);
224         showMemory.setEnabled(enabled);
225         memForegroundColor.setEnabled(enabled && showMemory.isSelected());
226         memBackgroundColor.setEnabled(enabled && showMemory.isSelected());
227         showClock.setEnabled(enabled);
228     }
229     //}}}
230

231     //{{{ ActionHandler class
232
class ActionHandler implements ActionListener
233     {
234         public void actionPerformed(ActionEvent evt)
235         {
236             updateEnabled();
237         }
238     } //}}}
239
}
240
Popular Tags