PageRenderTime 18ms CodeModel.GetById 9ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/options/ViewOptionPane.java

#
Java | 172 lines | 123 code | 17 blank | 32 comment | 34 complexity | 6a1c6ec624554ec70ec519e939c711ca MD5 | raw file
  1/*
  2 * ViewOptionPane.java - Editor window options
  3 * :tabSize=8:indentSize=8:noTabs=false:
  4 * :folding=explicit:collapseFolds=1:
  5 *
  6 * Copyright (C) 2003 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.border.*;
 26import javax.swing.*;
 27import java.awt.event.*;
 28import java.awt.*;
 29import java.io.*;
 30import org.gjt.sp.jedit.*;
 31import org.gjt.sp.util.Log;
 32
 33public class ViewOptionPane extends AbstractOptionPane
 34{
 35	//{{{ ViewOptionPane constructor
 36	public ViewOptionPane()
 37	{
 38		super("view");
 39	} //}}}
 40
 41	//{{{ _init() method
 42	protected void _init()
 43	{
 44		/* View dock layout */
 45		layoutIcon1 = GUIUtilities.loadIcon("dock_layout1.png");
 46		layoutIcon2 = GUIUtilities.loadIcon("dock_layout2.png");
 47		layoutIcon3 = GUIUtilities.loadIcon("dock_layout3.png");
 48		layoutIcon4 = GUIUtilities.loadIcon("dock_layout4.png");
 49
 50		JPanel layoutPanel = new JPanel(new BorderLayout(12,12));
 51
 52		if(jEdit.getBooleanProperty("view.docking.alternateLayout"))
 53		{
 54			layout = new JLabel(jEdit.getBooleanProperty(
 55				"view.toolbar.alternateLayout")
 56				? layoutIcon4 : layoutIcon2);
 57		}
 58		else
 59		{
 60			layout = new JLabel(jEdit.getBooleanProperty(
 61				"view.toolbar.alternateLayout")
 62				? layoutIcon3 : layoutIcon1);
 63		}
 64
 65		layout.setBorder(new EmptyBorder(12,12,12,12));
 66		layoutPanel.add(BorderLayout.CENTER,layout);
 67
 68		JPanel buttons = new JPanel(new GridLayout(2,1,12,12));
 69		buttons.setBorder(new EmptyBorder(0,12,12,12));
 70		buttons.add(alternateDockingLayout = new JButton(jEdit.getProperty(
 71			"options.view.alternateDockingLayout")));
 72		alternateDockingLayout.addActionListener(new ActionHandler());
 73		buttons.add(alternateToolBarLayout = new JButton(jEdit.getProperty(
 74			"options.view.alternateToolBarLayout")));
 75		alternateToolBarLayout.addActionListener(new ActionHandler());
 76		layoutPanel.add(BorderLayout.SOUTH,buttons);
 77
 78		TitledBorder border = new TitledBorder(jEdit.getProperty(
 79			"options.view.viewLayout"));
 80		border.setTitleJustification(TitledBorder.CENTER);
 81		layoutPanel.setBorder(border);
 82
 83		addComponent(layoutPanel);
 84
 85		/* Show full path */
 86		showFullPath = new JCheckBox(jEdit.getProperty(
 87			"options.view.showFullPath"));
 88		showFullPath.setSelected(jEdit.getBooleanProperty(
 89			"view.showFullPath"));
 90		addComponent(showFullPath);
 91
 92		/* Show search bar */
 93		showSearchbar = new JCheckBox(jEdit.getProperty(
 94			"options.view.showSearchbar"));
 95		showSearchbar.setSelected(jEdit.getBooleanProperty(
 96			"view.showSearchbar"));
 97		addComponent(showSearchbar);
 98
 99		/* Beep on search auto wrap */
100		beepOnSearchAutoWrap = new JCheckBox(jEdit.getProperty(
101			"options.view.beepOnSearchAutoWrap"));
102		beepOnSearchAutoWrap.setSelected(jEdit.getBooleanProperty(
103			"search.beepOnSearchAutoWrap"));
104		addComponent(beepOnSearchAutoWrap);
105
106		/* Show buffer switcher */
107		showBufferSwitcher = new JCheckBox(jEdit.getProperty(
108			"options.view.showBufferSwitcher"));
109		showBufferSwitcher.setSelected(jEdit.getBooleanProperty(
110			"view.showBufferSwitcher"));
111		addComponent(showBufferSwitcher);
112	} //}}}
113
114	//{{{ _save() method
115	protected void _save()
116	{
117		jEdit.setBooleanProperty("view.docking.alternateLayout",
118			layout.getIcon() == layoutIcon2
119			|| layout.getIcon() == layoutIcon4);
120		jEdit.setBooleanProperty("view.toolbar.alternateLayout",
121			layout.getIcon() == layoutIcon3
122			|| layout.getIcon() == layoutIcon4);
123		jEdit.setBooleanProperty("view.showFullPath",showFullPath
124			.isSelected());
125		jEdit.setBooleanProperty("view.showSearchbar",showSearchbar
126			.isSelected());
127		jEdit.setBooleanProperty("search.beepOnSearchAutoWrap",beepOnSearchAutoWrap
128			.isSelected());
129		jEdit.setBooleanProperty("view.showBufferSwitcher",
130			showBufferSwitcher.isSelected());
131	} //}}}
132
133	//{{{ Private members
134	private JLabel layout;
135	private Icon layoutIcon1, layoutIcon2, layoutIcon3, layoutIcon4;
136	private JButton alternateDockingLayout, alternateToolBarLayout;
137	private JCheckBox showFullPath;
138	private JCheckBox showSearchbar;
139	private JCheckBox beepOnSearchAutoWrap;
140	private JCheckBox showBufferSwitcher;
141	//}}}
142
143	//{{{ ActionHandler class
144	class ActionHandler implements ActionListener
145	{
146		public void actionPerformed(ActionEvent evt)
147		{
148			if(evt.getSource() == alternateDockingLayout)
149			{
150				if(layout.getIcon() == layoutIcon1)
151					layout.setIcon(layoutIcon2);
152				else if(layout.getIcon() == layoutIcon2)
153					layout.setIcon(layoutIcon1);
154				else if(layout.getIcon() == layoutIcon3)
155					layout.setIcon(layoutIcon4);
156				else if(layout.getIcon() == layoutIcon4)
157					layout.setIcon(layoutIcon3);
158			}
159			else if(evt.getSource() == alternateToolBarLayout)
160			{
161				if(layout.getIcon() == layoutIcon1)
162					layout.setIcon(layoutIcon3);
163				else if(layout.getIcon() == layoutIcon3)
164					layout.setIcon(layoutIcon1);
165				else if(layout.getIcon() == layoutIcon2)
166					layout.setIcon(layoutIcon4);
167				else if(layout.getIcon() == layoutIcon4)
168					layout.setIcon(layoutIcon2);
169			}
170		}
171	} //}}}
172}