PageRenderTime 68ms CodeModel.GetById 27ms app.highlight 22ms RepoModel.GetById 11ms app.codeStats 1ms

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

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