PageRenderTime 111ms CodeModel.GetById 93ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 209 lines | 147 code | 21 blank | 41 comment | 2 complexity | 44ed6ce2d3fcd633271875b1849eedae MD5 | raw file
  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
 22package org.gjt.sp.jedit.options;
 23
 24//{{{ Imports
 25import javax.swing.*;
 26import java.awt.event.*;
 27import java.awt.*;
 28import org.gjt.sp.jedit.gui.ColorWellButton;
 29import org.gjt.sp.jedit.*;
 30//}}}
 31
 32public 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		/* Caret status */
 52		showCaretStatus = new JCheckBox(jEdit.getProperty(
 53			"options.status.show-caret-status"));
 54		showCaretStatus.setSelected(jEdit.getBooleanProperty(
 55			"view.status.show-caret-status"));
 56		addComponent(showCaretStatus);
 57
 58		/* Edit mode */
 59		showEditMode = new JCheckBox(jEdit.getProperty(
 60			"options.status.show-edit-mode"));
 61		showEditMode.setSelected(jEdit.getBooleanProperty(
 62			"view.status.show-edit-mode"));
 63		addComponent(showEditMode);
 64
 65		/* Fold mode */
 66		showFoldMode = new JCheckBox(jEdit.getProperty(
 67			"options.status.show-fold-mode"));
 68		showFoldMode.setSelected(jEdit.getBooleanProperty(
 69			"view.status.show-fold-mode"));
 70		addComponent(showFoldMode);
 71
 72		/* Encoding */
 73		showEncoding = new JCheckBox(jEdit.getProperty(
 74			"options.status.show-encoding"));
 75		showEncoding.setSelected(jEdit.getBooleanProperty(
 76			"view.status.show-encoding"));
 77		addComponent(showEncoding);
 78
 79		/* Wrap */
 80		showWrap = new JCheckBox(jEdit.getProperty(
 81			"options.status.show-wrap"));
 82		showWrap.setSelected(jEdit.getBooleanProperty(
 83			"view.status.show-wrap"));
 84		addComponent(showWrap);
 85
 86		/* Multi select */
 87		showMultiSelect = new JCheckBox(jEdit.getProperty(
 88			"options.status.show-multi-select"));
 89		showMultiSelect.setSelected(jEdit.getBooleanProperty(
 90			"view.status.show-multi-select"));
 91		addComponent(showMultiSelect);
 92
 93		/* Rect select */
 94		showRectSelect = new JCheckBox(jEdit.getProperty(
 95			"options.status.show-rect-select"));
 96		showRectSelect.setSelected(jEdit.getBooleanProperty(
 97			"view.status.show-rect-select"));
 98		addComponent(showRectSelect);
 99
100		/* Overwrite */
101		showOverwrite = new JCheckBox(jEdit.getProperty(
102			"options.status.show-overwrite"));
103		showOverwrite.setSelected(jEdit.getBooleanProperty(
104			"view.status.show-overwrite"));
105		addComponent(showOverwrite);
106
107		/* Line seperator */
108		showLineSeperator = new JCheckBox(jEdit.getProperty(
109			"options.status.show-line-seperator"));
110		showLineSeperator.setSelected(jEdit.getBooleanProperty(
111			"view.status.show-line-seperator"));
112		addComponent(showLineSeperator);
113
114		/* Memory status */
115		showMemory = new JCheckBox(jEdit.getProperty(
116			"options.status.show-memory"));
117		showMemory.setSelected(jEdit.getBooleanProperty(
118			"view.status.show-memory"));
119		showMemory.addActionListener(new ActionHandler());
120		addComponent(showMemory);
121
122		/* Memory foreground color */
123		addComponent(jEdit.getProperty("options.status.memory.foreground"),
124			memForegroundColor = new ColorWellButton(
125			jEdit.getColorProperty("view.status.memory.foreground")),
126			GridBagConstraints.VERTICAL);
127
128		/* Memory background color */
129		addComponent(jEdit.getProperty("options.status.memory.background"),
130			memBackgroundColor = new ColorWellButton(
131			jEdit.getColorProperty("view.status.memory.background")),
132			GridBagConstraints.VERTICAL);
133
134		updateEnabled();
135	} //}}}
136
137	//{{{ _save() method
138	protected void _save()
139	{
140		jEdit.setBooleanProperty("view.status.visible",
141			statusVisible.isSelected());
142		jEdit.setBooleanProperty("view.status.show-caret-status",
143			showCaretStatus.isSelected());
144		jEdit.setBooleanProperty("view.status.show-edit-mode",
145			showEditMode.isSelected());
146		jEdit.setBooleanProperty("view.status.show-fold-mode",
147			showFoldMode.isSelected());
148		jEdit.setBooleanProperty("view.status.show-encoding",
149			showEncoding.isSelected());
150		jEdit.setBooleanProperty("view.status.show-wrap",
151			showWrap.isSelected());
152		jEdit.setBooleanProperty("view.status.show-multi-select",
153			showMultiSelect.isSelected());
154		jEdit.setBooleanProperty("view.status.show-rect-select",
155			showRectSelect.isSelected());
156		jEdit.setBooleanProperty("view.status.show-overwrite",
157			showOverwrite.isSelected());
158		jEdit.setBooleanProperty("view.status.show-line-seperator",
159			showLineSeperator.isSelected());
160		jEdit.setBooleanProperty("view.status.show-memory",
161			showMemory.isSelected());
162		jEdit.setColorProperty("view.status.memory.foreground",memForegroundColor
163			.getSelectedColor());
164		jEdit.setColorProperty("view.status.memory.background",memBackgroundColor
165			.getSelectedColor());
166	} //}}}
167
168	//{{{ Private members
169	private JCheckBox statusVisible;
170	private JCheckBox showCaretStatus;
171	private JCheckBox showEditMode;
172	private JCheckBox showFoldMode;
173	private JCheckBox showEncoding;
174	private JCheckBox showWrap;
175	private JCheckBox showMultiSelect;
176	private JCheckBox showRectSelect;
177	private JCheckBox showOverwrite;
178	private JCheckBox showLineSeperator;
179	private JCheckBox showMemory;
180	private ColorWellButton memForegroundColor;
181	private ColorWellButton memBackgroundColor;
182
183	private void updateEnabled()
184	{
185		boolean enabled = statusVisible.isSelected();
186		showCaretStatus.setEnabled(enabled);
187		showEditMode.setEnabled(enabled);
188		showFoldMode.setEnabled(enabled);
189		showEncoding.setEnabled(enabled);
190		showWrap.setEnabled(enabled);
191		showMultiSelect.setEnabled(enabled);
192		showRectSelect.setEnabled(enabled);
193		showOverwrite.setEnabled(enabled);
194		showLineSeperator.setEnabled(enabled);
195		showMemory.setEnabled(enabled);
196		memForegroundColor.setEnabled(enabled && showMemory.isSelected());
197		memBackgroundColor.setEnabled(enabled && showMemory.isSelected());
198	}
199	//}}}
200
201	//{{{ ActionHandler class
202	class ActionHandler implements ActionListener
203	{
204		public void actionPerformed(ActionEvent evt)
205		{
206			updateEnabled();
207		}
208	} //}}}
209}