PageRenderTime 37ms CodeModel.GetById 28ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 173 lines | 104 code | 19 blank | 50 comment | 2 complexity | 113914816a9d836e693ba23a441e840c 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 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		//{{{ Tab size
 60		String[] tabSizes = { "2", "4", "8" };
 61		defaultTabSize = new JComboBox(tabSizes);
 62		defaultTabSize.setEditable(true);
 63		defaultTabSize.setSelectedItem(jEdit.getProperty("buffer.tabSize"));
 64		addComponent(jEdit.getProperty("options.editing.tabSize"),defaultTabSize);
 65
 66		//}}}
 67
 68		//{{{ Indent size
 69		defaultIndentSize = new JComboBox(tabSizes);
 70		defaultIndentSize.setEditable(true);
 71		defaultIndentSize.setSelectedItem(jEdit.getProperty("buffer.indentSize"));
 72		addComponent(jEdit.getProperty("options.editing.indentSize"),defaultIndentSize);
 73		//}}}
 74
 75		//{{{ Max line length
 76		String[] lineLens = { "0", "72", "76", "80" };
 77		defaultMaxLineLen = new JComboBox(lineLens);
 78		defaultMaxLineLen.setEditable(true);
 79		defaultMaxLineLen.setSelectedItem(jEdit.getProperty("buffer.maxLineLen"));
 80		addComponent(jEdit.getProperty("options.editing.maxLineLen"),defaultMaxLineLen);
 81		//}}}
 82
 83		//{{{ Word break chars
 84		defaultWordBreakChars = new JTextField(jEdit.getProperty("buffer.wordBreakChars"));
 85		addComponent(jEdit.getProperty("options.editing.wordBreakChars"),defaultWordBreakChars);
 86		//}}}
 87
 88		//{{{ Extra word characters
 89		defaultNoWordSep = new JTextField(jEdit.getProperty("buffer.noWordSep"));
 90		addComponent(jEdit.getProperty("options.editing.noWordSep"),defaultNoWordSep);
 91		//}}}
 92
 93		//{{{ Default fold mode
 94		String[] foldModes = {
 95			"none",
 96			"indent",
 97			"explicit"
 98		};
 99		addComponent(jEdit.getProperty("options.editing.folding"),
100			defaultFolding = new JComboBox(foldModes));
101
102		defaultFolding.setSelectedItem(jEdit.getProperty("buffer.folding"));
103		//}}}
104
105		//{{{ Default fold level
106		defaultCollapseFolds = new JTextField(jEdit.getProperty("buffer.collapseFolds"));
107		addComponent(jEdit.getProperty("options.editing.collapseFolds"),defaultCollapseFolds);
108		//}}}
109
110		//{{{ Undo queue size
111		undoCount = new JTextField(jEdit.getProperty("buffer.undoCount"));
112		addComponent(jEdit.getProperty("options.editing.undoCount"),undoCount);
113		//}}}
114
115		//{{{ Indent on tab
116		defaultIndentOnTab = new JCheckBox(jEdit.getProperty("options.editing"
117			+ ".indentOnTab"));
118		defaultIndentOnTab.setSelected(jEdit.getBooleanProperty("buffer.indentOnTab"));
119		addComponent(defaultIndentOnTab);
120		//}}}
121
122		//{{{ Indent on enter
123		defaultIndentOnEnter = new JCheckBox(jEdit.getProperty("options.editing"
124			+ ".indentOnEnter"));
125		defaultIndentOnEnter.setSelected(jEdit.getBooleanProperty("buffer.indentOnEnter"));
126		addComponent(defaultIndentOnEnter);
127		//}}}
128
129		//{{{ Soft tabs
130		defaultNoTabs = new JCheckBox(jEdit.getProperty("options.editing"
131			+ ".noTabs"));
132		defaultNoTabs.setSelected(jEdit.getBooleanProperty("buffer.noTabs"));
133		addComponent(defaultNoTabs);
134		//}}}
135	} //}}}
136
137	//{{{ _save() method
138	protected void _save()
139	{
140		jEdit.setProperty("buffer.defaultMode",
141			(String)defaultMode.getSelectedItem());
142		jEdit.setProperty("buffer.tabSize",(String)defaultTabSize
143			.getSelectedItem());
144		jEdit.setProperty("buffer.indentSize",(String)defaultIndentSize
145			.getSelectedItem());
146		jEdit.setProperty("buffer.maxLineLen",(String)defaultMaxLineLen.getSelectedItem());
147		jEdit.setProperty("buffer.wordBreakChars",defaultWordBreakChars.getText());
148		jEdit.setProperty("buffer.noWordSep",defaultNoWordSep.getText());
149		jEdit.setProperty("buffer.folding",(String)defaultFolding.getSelectedItem());
150		jEdit.setProperty("buffer.collapseFolds",defaultCollapseFolds.getText());
151		jEdit.setProperty("buffer.undoCount",undoCount.getText());
152		jEdit.setBooleanProperty("buffer.indentOnTab",defaultIndentOnTab
153			.isSelected());
154		jEdit.setBooleanProperty("buffer.indentOnEnter",defaultIndentOnEnter
155			.isSelected());
156		jEdit.setBooleanProperty("buffer.noTabs",defaultNoTabs.isSelected());
157	} //}}}
158
159	//{{{ Private members
160	private JComboBox defaultMode;
161	private JComboBox defaultTabSize;
162	private JComboBox defaultIndentSize;
163	private JComboBox defaultMaxLineLen;
164	private JTextField defaultWordBreakChars;
165	private JTextField defaultNoWordSep;
166	private JComboBox defaultFolding;
167	private JTextField defaultCollapseFolds;
168	private JTextField undoCount;
169	private JCheckBox defaultIndentOnTab;
170	private JCheckBox defaultIndentOnEnter;
171	private JCheckBox defaultNoTabs;
172	//}}}
173}