PageRenderTime 335ms CodeModel.GetById 318ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre5/org/gjt/sp/jedit/options/GeneralOptionPane.java

#
Java | 185 lines | 131 code | 19 blank | 35 comment | 5 complexity | e4e988f64d7f02648914d37af107a677 MD5 | raw file
  1/*
  2 * GeneralOptionPane.java - General options panel
  3 * Copyright (C) 1998, 1999, 2000, 2001 Slava Pestov
  4 *
  5 * This program is free software; you can redistribute it and/or
  6 * modify it under the terms of the GNU General Public License
  7 * as published by the Free Software Foundation; either version 2
  8 * of the License, or any later version.
  9 *
 10 * This program is distributed in the hope that it will be useful,
 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 * GNU General Public License for more details.
 14 *
 15 * You should have received a copy of the GNU General Public License
 16 * along with this program; if not, write to the Free Software
 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 18 */
 19
 20package org.gjt.sp.jedit.options;
 21
 22import javax.swing.*;
 23import java.awt.event.*;
 24import java.awt.*;
 25import java.io.*;
 26import org.gjt.sp.jedit.*;
 27import org.gjt.sp.util.Log;
 28
 29public class GeneralOptionPane extends AbstractOptionPane
 30{
 31	public GeneralOptionPane()
 32	{
 33		super("general");
 34	}
 35
 36	// protected members
 37	protected void _init()
 38	{
 39		/* History count */
 40		history = new JTextField(jEdit.getProperty("history"));
 41		addComponent(jEdit.getProperty("options.general.history"),history);
 42
 43		/* Save caret positions */
 44		saveCaret = new JCheckBox(jEdit.getProperty(
 45			"options.general.saveCaret"));
 46		saveCaret.setSelected(jEdit.getBooleanProperty("saveCaret"));
 47		addComponent(saveCaret);
 48
 49		/* Sort buffers */
 50		sortBuffers = new JCheckBox(jEdit.getProperty(
 51			"options.general.sortBuffers"));
 52		sortBuffers.setSelected(jEdit.getBooleanProperty("sortBuffers"));
 53		sortBuffers.addActionListener(new ActionListener()
 54		{
 55			public void actionPerformed(ActionEvent evt)
 56			{
 57				sortByName.setEnabled(sortBuffers.isSelected());
 58			}
 59		});
 60
 61		addComponent(sortBuffers);
 62
 63		/* Sort buffers by names */
 64		sortByName = new JCheckBox(jEdit.getProperty(
 65			"options.general.sortByName"));
 66		sortByName.setSelected(jEdit.getBooleanProperty("sortByName"));
 67		sortByName.setEnabled(sortBuffers.isSelected());
 68		addComponent(sortByName);
 69
 70		/* Sort recent file list */
 71		sortRecent = new JCheckBox(jEdit.getProperty(
 72			"options.general.sortRecent"));
 73		sortRecent.setSelected(jEdit.getBooleanProperty("sortRecent"));
 74		addComponent(sortRecent);
 75
 76		/* Check mod status on focus */
 77		checkModStatus = new JCheckBox(jEdit.getProperty(
 78			"options.general.checkModStatus"));
 79		checkModStatus.setSelected(jEdit.getBooleanProperty(
 80			"view.checkModStatus"));
 81		addComponent(checkModStatus);
 82
 83		/* Show full path */
 84		showFullPath = new JCheckBox(jEdit.getProperty(
 85			"options.general.showFullPath"));
 86		showFullPath.setSelected(jEdit.getBooleanProperty(
 87			"view.showFullPath"));
 88		addComponent(showFullPath);
 89
 90		/* Show search bar */
 91		showSearchbar = new JCheckBox(jEdit.getProperty(
 92			"options.general.showSearchbar"));
 93		showSearchbar.setSelected(jEdit.getBooleanProperty(
 94			"view.showSearchbar"));
 95		addComponent(showSearchbar);
 96
 97		/* Beep on search auto wrap */
 98		beepOnSearchAutoWrap = new JCheckBox(jEdit.getProperty(
 99			"options.general.beepOnSearchAutoWrap"));
100		beepOnSearchAutoWrap.setSelected(jEdit.getBooleanProperty(
101			"search.beepOnSearchAutoWrap"));
102		addComponent(beepOnSearchAutoWrap);
103
104		/* Show buffer switcher */
105		showBufferSwitcher = new JCheckBox(jEdit.getProperty(
106			"options.general.showBufferSwitcher"));
107		showBufferSwitcher.setSelected(jEdit.getBooleanProperty(
108			"view.showBufferSwitcher"));
109		addComponent(showBufferSwitcher);
110
111		/* Show tip of the day */
112		showTips = new JCheckBox(jEdit.getProperty(
113			"options.general.showTips"));
114		showTips.setSelected(jEdit.getBooleanProperty("tip.show"));
115		addComponent(showTips);
116
117		/* Show splash screen */
118		showSplash = new JCheckBox(jEdit.getProperty(
119			"options.general.showSplash"));
120		String settingsDirectory = jEdit.getSettingsDirectory();
121		if(settingsDirectory == null)
122			showSplash.setSelected(true);
123		else
124			showSplash.setSelected(!new File(settingsDirectory,"nosplash").exists());
125		addComponent(showSplash);
126	}
127
128	protected void _save()
129	{
130		jEdit.setProperty("history",history.getText());
131		jEdit.setBooleanProperty("saveCaret",saveCaret.isSelected());
132		jEdit.setBooleanProperty("sortBuffers",sortBuffers.isSelected());
133		jEdit.setBooleanProperty("sortByName",sortByName.isSelected());
134		jEdit.setBooleanProperty("sortRecent",sortRecent.isSelected());
135		jEdit.setBooleanProperty("view.checkModStatus",checkModStatus
136			.isSelected());
137		jEdit.setBooleanProperty("view.showFullPath",showFullPath
138			.isSelected());
139		jEdit.setBooleanProperty("view.showSearchbar",showSearchbar
140			.isSelected());
141		jEdit.setBooleanProperty("search.beepOnSearchAutoWrap",beepOnSearchAutoWrap
142			.isSelected());
143		jEdit.setBooleanProperty("view.showBufferSwitcher",
144			showBufferSwitcher.isSelected());
145		jEdit.setBooleanProperty("tip.show",showTips.isSelected());
146
147		// this is handled a little differently from other jEdit settings
148		// as the splash screen flag needs to be known very early in the
149		// startup sequence, before the user properties have been loaded
150		String settingsDirectory = jEdit.getSettingsDirectory();
151		if(settingsDirectory != null)
152		{
153			File file = new File(settingsDirectory,"nosplash");
154			if(showSplash.isSelected())
155				file.delete();
156			else
157			{
158				try
159				{
160					FileOutputStream out = new FileOutputStream(file);
161					out.write('\n');
162					out.close();
163				}
164				catch(IOException io)
165				{
166					Log.log(Log.ERROR,this,io);
167				}
168			}
169		}
170	}
171
172	// private members
173	private JTextField history;
174	private JCheckBox saveCaret;
175	private JCheckBox sortBuffers;
176	private JCheckBox sortByName;
177	private JCheckBox sortRecent;
178	private JCheckBox checkModStatus;
179	private JCheckBox showFullPath;
180	private JCheckBox showSearchbar;
181  private JCheckBox beepOnSearchAutoWrap;
182	private JCheckBox showBufferSwitcher;
183	private JCheckBox showTips;
184	private JCheckBox showSplash;
185}