001: /*
002: * ViewOptionPane.java - Editor window options
003: * :tabSize=8:indentSize=8:noTabs=false:
004: * :folding=explicit:collapseFolds=1:
005: *
006: * Copyright (C) 2003 Slava Pestov
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: */
022:
023: package org.gjt.sp.jedit.options;
024:
025: import javax.swing.border.*;
026: import javax.swing.*;
027: import java.awt.event.*;
028: import java.awt.*;
029: import org.gjt.sp.jedit.*;
030:
031: public class ViewOptionPane extends AbstractOptionPane {
032: //{{{ ViewOptionPane constructor
033: public ViewOptionPane() {
034: super ("view");
035: } //}}}
036:
037: //{{{ _init() method
038: protected void _init() {
039: /* View dock layout */
040: layoutIcon1 = GUIUtilities.loadIcon("dock_layout1.png");
041: layoutIcon2 = GUIUtilities.loadIcon("dock_layout2.png");
042: layoutIcon3 = GUIUtilities.loadIcon("dock_layout3.png");
043: layoutIcon4 = GUIUtilities.loadIcon("dock_layout4.png");
044:
045: JPanel layoutPanel = new JPanel(new BorderLayout(12, 12));
046:
047: if (jEdit.getBooleanProperty("view.docking.alternateLayout")) {
048: layout = new JLabel(
049: jEdit
050: .getBooleanProperty("view.toolbar.alternateLayout") ? layoutIcon4
051: : layoutIcon2);
052: } else {
053: layout = new JLabel(
054: jEdit
055: .getBooleanProperty("view.toolbar.alternateLayout") ? layoutIcon3
056: : layoutIcon1);
057: }
058:
059: layout.setBorder(new EmptyBorder(12, 12, 12, 12));
060: layoutPanel.add(BorderLayout.CENTER, layout);
061:
062: JPanel buttons = new JPanel(new GridLayout(2, 1, 12, 12));
063: buttons.setBorder(new EmptyBorder(0, 12, 12, 12));
064: buttons.add(alternateDockingLayout = new JButton(jEdit
065: .getProperty("options.view.alternateDockingLayout")));
066: ActionHandler actionHandler = new ActionHandler();
067: alternateDockingLayout.addActionListener(actionHandler);
068: buttons.add(alternateToolBarLayout = new JButton(jEdit
069: .getProperty("options.view.alternateToolBarLayout")));
070: alternateToolBarLayout.addActionListener(actionHandler);
071: layoutPanel.add(BorderLayout.SOUTH, buttons);
072:
073: TitledBorder border = new TitledBorder(jEdit
074: .getProperty("options.view.viewLayout"));
075: border.setTitleJustification(TitledBorder.CENTER);
076: layoutPanel.setBorder(border);
077:
078: addComponent(layoutPanel);
079:
080: /* Show full path */
081: showFullPath = new JCheckBox(jEdit
082: .getProperty("options.view.showFullPath"));
083: showFullPath.setSelected(jEdit
084: .getBooleanProperty("view.showFullPath"));
085: addComponent(showFullPath);
086:
087: /* Show search bar */
088: showSearchbar = new JCheckBox(jEdit
089: .getProperty("options.view.showSearchbar"));
090: showSearchbar.setSelected(jEdit
091: .getBooleanProperty("view.showSearchbar"));
092: addComponent(showSearchbar);
093:
094: /* Beep on search auto wrap */
095: beepOnSearchAutoWrap = new JCheckBox(jEdit
096: .getProperty("options.view.beepOnSearchAutoWrap"));
097: beepOnSearchAutoWrap.setSelected(jEdit
098: .getBooleanProperty("search.beepOnSearchAutoWrap"));
099: addComponent(beepOnSearchAutoWrap);
100:
101: /* Show buffer switcher */
102: showBufferSwitcher = new JCheckBox(jEdit
103: .getProperty("options.view.showBufferSwitcher"));
104: showBufferSwitcher.setSelected(jEdit
105: .getBooleanProperty("view.showBufferSwitcher"));
106: addComponent(showBufferSwitcher);
107: showBufferSwitcher.addActionListener(actionHandler);
108:
109: /* Buffer switcher max row count */
110: bufferSwitcherMaxRowCount = new JTextField(jEdit
111: .getProperty("bufferSwitcher.maxRowCount"));
112: addComponent(
113: jEdit
114: .getProperty("options.view.bufferSwitcherMaxRowsCount"),
115: bufferSwitcherMaxRowCount);
116: bufferSwitcherMaxRowCount.setEditable(showBufferSwitcher
117: .isSelected());
118: } //}}}
119:
120: //{{{ _save() method
121: protected void _save() {
122: jEdit.setBooleanProperty("view.docking.alternateLayout", layout
123: .getIcon() == layoutIcon2
124: || layout.getIcon() == layoutIcon4);
125: jEdit.setBooleanProperty("view.toolbar.alternateLayout", layout
126: .getIcon() == layoutIcon3
127: || layout.getIcon() == layoutIcon4);
128: jEdit.setBooleanProperty("view.showFullPath", showFullPath
129: .isSelected());
130: jEdit.setBooleanProperty("view.showSearchbar", showSearchbar
131: .isSelected());
132: jEdit.setBooleanProperty("search.beepOnSearchAutoWrap",
133: beepOnSearchAutoWrap.isSelected());
134: jEdit.setBooleanProperty("view.showBufferSwitcher",
135: showBufferSwitcher.isSelected());
136: jEdit.setProperty("bufferSwitcher.maxRowCount",
137: bufferSwitcherMaxRowCount.getText());
138: } //}}}
139:
140: //{{{ Private members
141: private JLabel layout;
142: private Icon layoutIcon1, layoutIcon2, layoutIcon3, layoutIcon4;
143: private JButton alternateDockingLayout, alternateToolBarLayout;
144: private JCheckBox showFullPath;
145: private JCheckBox showSearchbar;
146: private JCheckBox beepOnSearchAutoWrap;
147: private JCheckBox showBufferSwitcher;
148: private JTextField bufferSwitcherMaxRowCount;
149:
150: //}}}
151:
152: //{{{ ActionHandler class
153: private class ActionHandler implements ActionListener {
154: public void actionPerformed(ActionEvent evt) {
155: if (evt.getSource() == alternateDockingLayout) {
156: if (layout.getIcon() == layoutIcon1)
157: layout.setIcon(layoutIcon2);
158: else if (layout.getIcon() == layoutIcon2)
159: layout.setIcon(layoutIcon1);
160: else if (layout.getIcon() == layoutIcon3)
161: layout.setIcon(layoutIcon4);
162: else if (layout.getIcon() == layoutIcon4)
163: layout.setIcon(layoutIcon3);
164: } else if (evt.getSource() == alternateToolBarLayout) {
165: if (layout.getIcon() == layoutIcon1)
166: layout.setIcon(layoutIcon3);
167: else if (layout.getIcon() == layoutIcon3)
168: layout.setIcon(layoutIcon1);
169: else if (layout.getIcon() == layoutIcon2)
170: layout.setIcon(layoutIcon4);
171: else if (layout.getIcon() == layoutIcon4)
172: layout.setIcon(layoutIcon2);
173: } else if (evt.getSource() == showBufferSwitcher) {
174: bufferSwitcherMaxRowCount
175: .setEditable(showBufferSwitcher.isSelected());
176: }
177: }
178: } //}}}
179: }
|