PageRenderTime 31ms CodeModel.GetById 11ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 133 lines | 97 code | 15 blank | 21 comment | 3 complexity | 33d7d552e49dff392037ad86f000dd49 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1/*
  2 * GutterOptionPane.java - Gutter options panel
  3 * Copyright (C) 2000 mike dillon
  4 * Portions copyright (C) 2001 Slava Pestov
  5 *
  6 * This program is free software; you can redistribute it and/or
  7 * modify it under the terms of the GNU General Public License
  8 * as published by the Free Software Foundation; either version 2
  9 * of the License, or any later version.
 10 *
 11 * This program is distributed in the hope that it will be useful,
 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14 * GNU General Public License for more details.
 15 *
 16 * You should have received a copy of the GNU General Public License
 17 * along with this program; if not, write to the Free Software
 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 19 */
 20
 21package org.gjt.sp.jedit.options;
 22
 23import javax.swing.*;
 24import java.awt.*;
 25import org.gjt.sp.jedit.gui.FontSelector;
 26import org.gjt.sp.jedit.*;
 27
 28public class GutterOptionPane extends AbstractOptionPane
 29{
 30	public GutterOptionPane()
 31	{
 32		super("gutter");
 33	}
 34
 35	public void _init()
 36	{
 37		lineNumbersEnabled = new JCheckBox(jEdit.getProperty(
 38			"options.gutter.lineNumbers"));
 39		lineNumbersEnabled.setSelected(jEdit.getBooleanProperty(
 40			"view.gutter.lineNumbers"));
 41		addComponent(lineNumbersEnabled);
 42
 43		/* Font */
 44		gutterFont = new FontSelector(
 45			jEdit.getFontProperty("view.gutter.font",
 46			new Font("Monospaced",Font.PLAIN,10)));
 47
 48		addComponent(jEdit.getProperty("options.gutter.font"),gutterFont);
 49
 50		gutterBorderWidth = new JTextField(jEdit.getProperty(
 51			"view.gutter.borderWidth"));
 52		addComponent(jEdit.getProperty("options.gutter.borderWidth"),
 53			gutterBorderWidth);
 54
 55		gutterHighlightInterval = new JTextField(jEdit.getProperty(
 56			"view.gutter.highlightInterval"));
 57		addComponent(jEdit.getProperty("options.gutter.interval"),
 58			gutterHighlightInterval);
 59
 60		String[] alignments = new String[] {
 61			"Left", "Center", "Right"
 62		};
 63		gutterNumberAlignment = new JComboBox(alignments);
 64		String alignment = jEdit.getProperty("view.gutter.numberAlignment");
 65		if("right".equals(alignment))
 66			gutterNumberAlignment.setSelectedIndex(2);
 67		else if("center".equals(alignment))
 68			gutterNumberAlignment.setSelectedIndex(1);
 69		else
 70			gutterNumberAlignment.setSelectedIndex(0);
 71		addComponent(jEdit.getProperty("options.gutter.numberAlignment"),
 72			gutterNumberAlignment);
 73
 74		gutterCurrentLineHighlightEnabled = new JCheckBox(jEdit.getProperty(
 75			"options.gutter.currentLineHighlight"));
 76		gutterCurrentLineHighlightEnabled.setSelected(jEdit.getBooleanProperty(
 77			"view.gutter.highlightCurrentLine"));
 78		addComponent(gutterCurrentLineHighlightEnabled);
 79
 80		gutterBracketHighlightEnabled = new JCheckBox(jEdit.getProperty(
 81			"options.gutter.bracketHighlight"));
 82		gutterBracketHighlightEnabled.setSelected(jEdit.getBooleanProperty(
 83			"view.gutter.bracketHighlight"));
 84		addComponent(gutterBracketHighlightEnabled);
 85
 86		gutterMarkerHighlightEnabled = new JCheckBox(jEdit.getProperty(
 87			"options.gutter.markerHighlight"));
 88		gutterMarkerHighlightEnabled.setSelected(jEdit.getBooleanProperty(
 89			"view.gutter.markerHighlight"));
 90		addComponent(gutterMarkerHighlightEnabled);
 91	}
 92
 93	public void _save()
 94	{
 95		jEdit.setFontProperty("view.gutter.font",gutterFont.getFont());
 96
 97		jEdit.setProperty("view.gutter.borderWidth",
 98			gutterBorderWidth.getText());
 99		jEdit.setProperty("view.gutter.highlightInterval",
100			gutterHighlightInterval.getText());
101		String alignment = null;
102		switch(gutterNumberAlignment.getSelectedIndex())
103		{
104		case 2:
105			alignment = "right";
106			break;
107		case 1:
108			alignment = "center";
109			break;
110		case 0: default:
111			alignment = "left";
112		}
113		jEdit.setProperty("view.gutter.numberAlignment", alignment);
114		jEdit.setBooleanProperty("view.gutter.lineNumbers", lineNumbersEnabled
115			.isSelected());
116		jEdit.setBooleanProperty("view.gutter.highlightCurrentLine",
117			gutterCurrentLineHighlightEnabled.isSelected());
118		jEdit.setBooleanProperty("view.gutter.bracketHighlight",
119			gutterBracketHighlightEnabled.isSelected());
120		jEdit.setBooleanProperty("view.gutter.markerHighlight",
121			gutterMarkerHighlightEnabled.isSelected());
122	}
123
124	// private members
125	private FontSelector gutterFont;
126	private JTextField gutterBorderWidth;
127	private JTextField gutterHighlightInterval;
128	private JComboBox gutterNumberAlignment;
129	private JCheckBox lineNumbersEnabled;
130	private JCheckBox gutterCurrentLineHighlightEnabled;
131	private JCheckBox gutterBracketHighlightEnabled;
132	private JCheckBox gutterMarkerHighlightEnabled;
133}