001: /*
002: * Gruntspud
003: *
004: * Copyright (C) 2002 Brett Smith.
005: *
006: * Written by: Brett Smith <t_magicthize@users.sourceforge.net>
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public License
010: * as published by the Free Software Foundation; either version 2 of
011: * the License, or (at your option) any later version.
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU Library General Public License for more details.
016: *
017: * You should have received a copy of the GNU Library General Public
018: * License along with this program; if not, write to the Free Software
019: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
020: */
021:
022: package gruntspud.ui.preferences;
023:
024: import gruntspud.Constants;
025: import gruntspud.GruntspudContext;
026: import gruntspud.ui.CharSetComboBox;
027: import gruntspud.ui.FileNameTextField;
028: import gruntspud.ui.UIUtil;
029: import gruntspud.ui.XTextField;
030:
031: import java.awt.Color;
032: import java.awt.GridBagConstraints;
033: import java.awt.GridBagLayout;
034: import java.awt.Insets;
035: import java.awt.event.ActionEvent;
036: import java.awt.event.ActionListener;
037: import java.io.File;
038:
039: import javax.swing.BorderFactory;
040: import javax.swing.JCheckBox;
041: import javax.swing.JLabel;
042: import javax.swing.JPanel;
043:
044: /**
045: * Description of the Class
046: *
047: *@author magicthize
048: *@created 26 May 2002
049: */
050: public class SystemOptionsTab extends AbstractOptionsTab implements
051: ActionListener {
052: private JCheckBox debug;
053: private JCheckBox debugToConsole;
054: private JCheckBox hideMenuIcons;
055: private JCheckBox disableNativePermissionHandler;
056: private JCheckBox logCVSIO;
057: private XTextField userIgnoreFile, pluginUpdatesURL;
058: private JCheckBox disableKeyboardAccelerators;
059: private CharSetComboBox defaultEncoding;
060:
061: /**
062: * Constructor for the SystemOptionsTab object
063: */
064: public SystemOptionsTab() {
065: super ("System", UIUtil
066: .getCachedIcon(Constants.ICON_TOOL_SYSTEM));
067: }
068:
069: /**
070: * DOCUMENT ME!
071: *
072: * @param context DOCUMENT ME!
073: */
074: public void init(GruntspudContext context) {
075: super .init(context);
076:
077: setTabToolTipText("System related options.");
078: setTabLargeIcon(UIUtil
079: .getCachedIcon(Constants.ICON_TOOL_LARGE_SYSTEM));
080: setTabMnemonic('s');
081: setTabContext("Advanced");
082:
083: // Paths
084: JPanel s = new JPanel(new GridBagLayout());
085:
086: GridBagConstraints gbc1 = new GridBagConstraints();
087: gbc1.insets = new Insets(3, 3, 3, 3);
088: gbc1.anchor = GridBagConstraints.NORTHWEST;
089: gbc1.fill = GridBagConstraints.HORIZONTAL;
090:
091: gbc1.weightx = 0.0;
092: UIUtil.jGridBagAdd(s, new JLabel("User .cvsignore file:"),
093: gbc1, GridBagConstraints.RELATIVE);
094: userIgnoreFile = new FileNameTextField(null, context.getHost()
095: .getProperty(
096: Constants.OPTIONS_SYSTEM_USER_IGNORE_FILE,
097: System.getProperty("user.home")
098: + File.separator + ".cvsignore"), 0,
099: true, true);
100: gbc1.weightx = 1.0;
101: UIUtil.jGridBagAdd(s, userIgnoreFile, gbc1,
102: GridBagConstraints.REMAINDER);
103:
104: gbc1.weighty = 1.0;
105: gbc1.weightx = 0.0;
106:
107: pluginUpdatesURL = new XTextField(context.getHost()
108: .getProperty(
109: Constants.OPTIONS_SYSTEM_PLUGIN_UPDATES_URL,
110: "http://gruntspud.sourceforge.net/plugins"), 20);
111: UIUtil.jGridBagAdd(s, new JLabel("Plugin updates URL "), gbc1,
112: GridBagConstraints.RELATIVE);
113: gbc1.weightx = 1.0;
114: UIUtil.jGridBagAdd(s, pluginUpdatesURL, gbc1,
115: GridBagConstraints.REMAINDER);
116:
117: gbc1.weightx = 0.0;
118:
119: defaultEncoding = new CharSetComboBox();
120: defaultEncoding
121: .setSelectedEncoding(context.getHost().getProperty(
122: Constants.OPTIONS_SYSTEM_DEFAULT_ENCODING));
123: UIUtil.jGridBagAdd(s, new JLabel("Default encoding "), gbc1,
124: GridBagConstraints.RELATIVE);
125: gbc1.weightx = 1.0;
126: UIUtil.jGridBagAdd(s, defaultEncoding, gbc1,
127: GridBagConstraints.REMAINDER);
128:
129: // General output options
130: JPanel p = new JPanel(new GridBagLayout());
131: GridBagConstraints gbc = new GridBagConstraints();
132: gbc.insets = new Insets(3, 3, 3, 3);
133: gbc.anchor = GridBagConstraints.NORTHWEST;
134: gbc.fill = GridBagConstraints.HORIZONTAL;
135: gbc.weightx = 2.0;
136:
137: debug = new JCheckBox("Enable debugging", context.getHost()
138: .getBooleanProperty(Constants.OPTIONS_SYSTEM_DEBUG,
139: false));
140: debug.setMnemonic('d');
141: debug.addActionListener(this );
142: UIUtil.jGridBagAdd(p, debug, gbc, GridBagConstraints.REMAINDER);
143:
144: debugToConsole = new JCheckBox("Debug to console", context
145: .getHost().getBooleanProperty(
146: Constants.OPTIONS_SYSTEM_DEBUG_TO_CONSOLE,
147: false));
148: debugToConsole.setMnemonic('d');
149: UIUtil.jGridBagAdd(p, debugToConsole, gbc,
150: GridBagConstraints.REMAINDER);
151:
152: logCVSIO = new JCheckBox(
153: "Log CVS I/O (~/GRUNTSPUD.in and ~/GRUNTSPUD.out)",
154: context.getHost().getBooleanProperty(
155: Constants.OPTIONS_SYSTEM_LOG_CVS_IO, false));
156: logCVSIO.setMnemonic('c');
157: UIUtil.jGridBagAdd(p, logCVSIO, gbc,
158: GridBagConstraints.REMAINDER);
159:
160: gbc.weighty = 1.0;
161: disableNativePermissionHandler = new JCheckBox(
162: "Disable native file permissions handler",
163: context
164: .getHost()
165: .getBooleanProperty(
166: Constants.OPTIONS_SYSTEM_DISABLE_NATIVE_PERMISSION_HANDLER,
167: false));
168: disableNativePermissionHandler.setMnemonic('d');
169: UIUtil.jGridBagAdd(p, disableNativePermissionHandler, gbc,
170: GridBagConstraints.REMAINDER);
171: disableKeyboardAccelerators = new JCheckBox(
172: "Disable keyboard accelerators",
173: context
174: .getHost()
175: .getBooleanProperty(
176: Constants.OPTIONS_SYSTEM_DISABLE_KEYBOARD_ACCELERATORS,
177: false));
178: disableKeyboardAccelerators.setMnemonic('k');
179: UIUtil.jGridBagAdd(p, disableKeyboardAccelerators, gbc,
180: GridBagConstraints.REMAINDER);
181: hideMenuIcons = new JCheckBox(
182: "Hide menu icons",
183: context
184: .getHost()
185: .getBooleanProperty(
186: Constants.OPTIONS_SYSTEM_HIDE_MENU_ICONS,
187: false));
188: hideMenuIcons.setMnemonic('h');
189: UIUtil.jGridBagAdd(p, hideMenuIcons, gbc,
190: GridBagConstraints.REMAINDER);
191:
192: JLabel l = new JLabel(
193: "Changing these options require that you restart "
194: + context.getHost().getName());
195: l.setForeground(Color.red);
196: l.setHorizontalAlignment(JLabel.CENTER);
197:
198: setLayout(new GridBagLayout());
199:
200: GridBagConstraints gbc2 = new GridBagConstraints();
201: gbc2.anchor = GridBagConstraints.WEST;
202: gbc2.fill = GridBagConstraints.HORIZONTAL;
203: gbc2.weightx = 1.0;
204: UIUtil.jGridBagAdd(this , s, gbc2, GridBagConstraints.REMAINDER);
205: gbc2.insets = new Insets(2, 40, 2, 2);
206: UIUtil.jGridBagAdd(this , p, gbc2, GridBagConstraints.REMAINDER);
207: gbc2.weighty = 1.0;
208: gbc2.anchor = GridBagConstraints.SOUTH;
209: UIUtil.jGridBagAdd(this , l, gbc2, GridBagConstraints.REMAINDER);
210: }
211:
212: /**
213: * DOCUMENT ME!
214: *
215: * @param evt DOCUMENT ME!
216: */
217: public void actionPerformed(ActionEvent evt) {
218: setAvailableActions();
219: }
220:
221: private void setAvailableActions() {
222: debugToConsole.setEnabled(debug.isSelected());
223: }
224:
225: /**
226: * Description of the Method
227: *
228: *@return Description of the Return Value
229: */
230: public boolean validateTab() {
231: return true;
232: }
233:
234: /**
235: * Description of the Method
236: */
237: public void tabSelected() {
238: }
239:
240: /**
241: * Description of the Method
242: */
243: public void applyTab() {
244: getContext().getHost().setBooleanProperty(
245: Constants.OPTIONS_SYSTEM_DEBUG, debug.isSelected());
246: getContext().getHost().setBooleanProperty(
247: Constants.OPTIONS_SYSTEM_DEBUG_TO_CONSOLE,
248: debugToConsole.isSelected());
249: getContext().getHost().setProperty(
250: Constants.OPTIONS_SYSTEM_DEFAULT_ENCODING,
251: defaultEncoding.getSelectedEncoding());
252: getContext()
253: .getHost()
254: .setBooleanProperty(
255: Constants.OPTIONS_SYSTEM_DISABLE_NATIVE_PERMISSION_HANDLER,
256: disableNativePermissionHandler.isSelected());
257: getContext().getHost().setProperty(
258: Constants.OPTIONS_SYSTEM_USER_IGNORE_FILE,
259: userIgnoreFile.getText());
260: getContext().getHost().setBooleanProperty(
261: Constants.OPTIONS_SYSTEM_LOG_CVS_IO,
262: logCVSIO.isSelected());
263: getContext().getHost().setProperty(
264: Constants.OPTIONS_SYSTEM_PLUGIN_UPDATES_URL,
265: pluginUpdatesURL.getText());
266: getContext().getHost().setBooleanProperty(
267: Constants.OPTIONS_SYSTEM_DISABLE_KEYBOARD_ACCELERATORS,
268: disableKeyboardAccelerators.isSelected());
269: getContext().getHost().setBooleanProperty(
270: Constants.OPTIONS_SYSTEM_HIDE_MENU_ICONS,
271: hideMenuIcons.isSelected());
272:
273: }
274: }
|