PageRenderTime 40ms CodeModel.GetById 29ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 180 lines | 110 code | 20 blank | 50 comment | 2 complexity | ddd05e70cc4348045cc01e6561d3db11 MD5 | raw file
  1/*
  2 * EditingOptionPane.java - Editing options panel
  3 * :tabSize=8:indentSize=8:noTabs=false:
  4 * :folding=explicit:collapseFolds=1:
  5 *
  6 * Copyright (C) 1998, 1999, 2000, 2001, 2002 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
 23package org.gjt.sp.jedit.options;
 24
 25import javax.swing.*;
 26import java.awt.event.*;
 27import java.awt.*;
 28import org.gjt.sp.jedit.*;
 29
 30public class EditingOptionPane extends AbstractOptionPane
 31{
 32	//{{{ EditingOptionPane constructor
 33	public EditingOptionPane()
 34	{
 35		super("editing");
 36	} //}}}
 37
 38	//{{{ _init() method
 39	protected void _init()
 40	{
 41		//{{{ Modes
 42		Mode[] modes = jEdit.getModes();
 43		String defaultModeString = jEdit.getProperty("buffer.defaultMode");
 44		String[] modeNames = new String[modes.length];
 45		int index = 0;
 46		for(int i = 0; i < modes.length; i++)
 47		{
 48			Mode _mode = modes[i];
 49			modeNames[i] = _mode.getName();
 50			if(defaultModeString.equals(_mode.getName()))
 51				index = i;
 52		}
 53		defaultMode = new JComboBox(modeNames);
 54		defaultMode.setSelectedIndex(index);
 55		addComponent(jEdit.getProperty("options.editing.defaultMode"),
 56			defaultMode);
 57		//}}}
 58
 59		//{{{ Undo queue size
 60		undoCount = new JTextField(jEdit.getProperty("buffer.undoCount"));
 61		addComponent(jEdit.getProperty("options.editing.undoCount"),undoCount);
 62		//}}}
 63
 64		//{{{ Extra word characters
 65		defaultNoWordSep = new JTextField(jEdit.getProperty("buffer.noWordSep"));
 66		addComponent(jEdit.getProperty("options.editing.noWordSep"),defaultNoWordSep);
 67		//}}}
 68
 69		//{{{ Default fold mode
 70		String[] foldModes = {
 71			"none",
 72			"indent",
 73			"explicit"
 74		};
 75		addComponent(jEdit.getProperty("options.editing.folding"),
 76			defaultFolding = new JComboBox(foldModes));
 77
 78		defaultFolding.setSelectedItem(jEdit.getProperty("buffer.folding"));
 79		//}}}
 80
 81		//{{{ Default fold level
 82		defaultCollapseFolds = new JTextField(jEdit.getProperty("buffer.collapseFolds"));
 83		addComponent(jEdit.getProperty("options.editing.collapseFolds"),defaultCollapseFolds);
 84		//}}}
 85
 86		//{{{ Default wrap mode
 87		String[] wrapModes = {
 88			"none",
 89			"soft",
 90			"hard"
 91		};
 92		addComponent(jEdit.getProperty("options.editing.wrap"),
 93			defaultWrap = new JComboBox(wrapModes));
 94
 95		defaultWrap.setSelectedItem(jEdit.getProperty("buffer.wrap"));
 96		//}}}
 97
 98		//{{{ Max line length
 99		String[] lineLens = { "0", "72", "76", "80" };
100		defaultMaxLineLen = new JComboBox(lineLens);
101		defaultMaxLineLen.setEditable(true);
102		defaultMaxLineLen.setSelectedItem(jEdit.getProperty("buffer.maxLineLen"));
103		addComponent(jEdit.getProperty("options.editing.maxLineLen"),defaultMaxLineLen);
104		//}}}
105
106		//{{{ Tab size
107		String[] tabSizes = { "2", "4", "8" };
108		defaultTabSize = new JComboBox(tabSizes);
109		defaultTabSize.setEditable(true);
110		defaultTabSize.setSelectedItem(jEdit.getProperty("buffer.tabSize"));
111		addComponent(jEdit.getProperty("options.editing.tabSize"),defaultTabSize);
112
113		//}}}
114
115		//{{{ Indent size
116		defaultIndentSize = new JComboBox(tabSizes);
117		defaultIndentSize.setEditable(true);
118		defaultIndentSize.setSelectedItem(jEdit.getProperty("buffer.indentSize"));
119		addComponent(jEdit.getProperty("options.editing.indentSize"),defaultIndentSize);
120		//}}}
121
122		//{{{ Soft tabs
123		defaultNoTabs = new JCheckBox(jEdit.getProperty("options.editing"
124			+ ".noTabs"));
125		defaultNoTabs.setSelected(jEdit.getBooleanProperty("buffer.noTabs"));
126		addComponent(defaultNoTabs);
127		//}}}
128
129		//{{{ Indent on tab
130		defaultIndentOnTab = new JCheckBox(jEdit.getProperty("options.editing"
131			+ ".indentOnTab"));
132		defaultIndentOnTab.setSelected(jEdit.getBooleanProperty("buffer.indentOnTab"));
133		addComponent(defaultIndentOnTab);
134		//}}}
135
136		//{{{ Indent on enter
137		defaultIndentOnEnter = new JCheckBox(jEdit.getProperty("options.editing"
138			+ ".indentOnEnter"));
139		defaultIndentOnEnter.setSelected(jEdit.getBooleanProperty("buffer.indentOnEnter"));
140		addComponent(defaultIndentOnEnter);
141		//}}}
142	} //}}}
143
144	//{{{ _save() method
145	protected void _save()
146	{
147		jEdit.setProperty("buffer.defaultMode",
148			(String)defaultMode.getSelectedItem());
149		jEdit.setProperty("buffer.undoCount",undoCount.getText());
150		jEdit.setProperty("buffer.noWordSep",defaultNoWordSep.getText());
151		jEdit.setProperty("buffer.folding",(String)defaultFolding.getSelectedItem());
152		jEdit.setProperty("buffer.collapseFolds",defaultCollapseFolds.getText());
153		jEdit.setProperty("buffer.wrap",(String)defaultWrap.getSelectedItem());
154		jEdit.setProperty("buffer.maxLineLen",(String)defaultMaxLineLen.getSelectedItem());
155		jEdit.setProperty("buffer.tabSize",(String)defaultTabSize
156			.getSelectedItem());
157		jEdit.setProperty("buffer.indentSize",(String)defaultIndentSize
158			.getSelectedItem());
159		jEdit.setBooleanProperty("buffer.noTabs",defaultNoTabs.isSelected());
160		jEdit.setBooleanProperty("buffer.indentOnTab",defaultIndentOnTab
161			.isSelected());
162		jEdit.setBooleanProperty("buffer.indentOnEnter",defaultIndentOnEnter
163			.isSelected());
164	} //}}}
165
166	//{{{ Private members
167	private JComboBox defaultMode;
168	private JTextField undoCount;
169	private JTextField defaultNoWordSep;
170	private JComboBox defaultFolding;
171	private JTextField defaultCollapseFolds;
172	private JComboBox defaultWrap;
173	private JComboBox defaultMaxLineLen;
174	private JComboBox defaultTabSize;
175	private JComboBox defaultIndentSize;
176	private JCheckBox defaultNoTabs;
177	private JCheckBox defaultIndentOnTab;
178	private JCheckBox defaultIndentOnEnter;
179	//}}}
180}