PageRenderTime 93ms CodeModel.GetById 78ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/bundles/plugins-trunk/InfoViewer/infoviewer/InfoViewerOptionPane.java

#
Java | 149 lines | 81 code | 30 blank | 38 comment | 5 complexity | 734401ba4c992b8bd1738498fc5971bd MD5 | raw file
  1/*
  2 * InfoViewerOptionPane.java - InfoViewer options panel
  3 * Copyright (C) 1999-2001 Dirk Moebius
  4 *
  5 * :tabSize=4:indentSize=4:noTabs=true:maxLineLen=0:
  6 *
  7 * This program is free software; you can redistribute it and/or
  8 * modify it under the terms of the GNU General Public License
  9 * as published by the Free Software Foundation; either version 2
 10 * of the License, or any later version.
 11 *
 12 * This program is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15 * GNU General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program; if not, write to the Free Software
 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 20 */
 21
 22package infoviewer;
 23
 24import java.awt.event.ActionEvent;
 25import java.awt.event.ActionListener;
 26import javax.swing.*;
 27import org.gjt.sp.jedit.AbstractOptionPane;
 28import org.gjt.sp.jedit.jEdit;
 29
 30public class InfoViewerOptionPane extends AbstractOptionPane implements ActionListener
 31{
 32
 33	private static final long serialVersionUID = -8581345434069856402L;
 34
 35	public InfoViewerOptionPane()
 36	{
 37		super("chooseBrowser");
 38	}
 39
 40	public void _init()
 41	{
 42
 43		useForHelp = new JCheckBox(jEdit.getProperty("options.infoviewer.useforhelp.label"));
 44		useForHelp.setSelected(jEdit.getBooleanProperty("infoviewer.useforhelp"));
 45		addComponent(useForHelp);
 46		// "Choose Preferred Browser"
 47		addSeparator("options.infoviewer.browser.label");
 48
 49		// "Internal (InfoViewer)"
 50		rbInternal = new JRadioButton(jEdit
 51			.getProperty("options.infoviewer.browser.internal"));
 52		rbInternal.addActionListener(this);
 53		addComponent(rbInternal);
 54
 55		// "Class in classpath"
 56		rbClass = new JRadioButton(jEdit.getProperty("options.infoviewer.browser.class"));
 57		rbClass.addActionListener(this);
 58		addComponent(rbClass);
 59
 60		// "Firefox"
 61		rbFirefox = new JRadioButton(jEdit
 62			.getProperty("options.infoviewer.browser.firefox"));
 63		rbFirefox.addActionListener(this);
 64		// addComponent(rbFirefox);
 65
 66		// "External browser"
 67		rbOther = new JRadioButton(jEdit.getProperty("options.infoviewer.browser.other"));
 68		rbOther.addActionListener(this);
 69		addComponent(rbOther);
 70
 71		ButtonGroup browserGroup = new ButtonGroup();
 72		browserGroup.add(rbInternal);
 73		browserGroup.add(rbClass);
 74		browserGroup.add(rbFirefox);
 75		browserGroup.add(rbOther);
 76
 77		String browserType = jEdit.getProperty("infoviewer.browsertype");
 78		if ("firefox".equals(browserType))
 79			rbFirefox.setSelected(true);
 80		else if ("class".equals(browserType))
 81			rbClass.setSelected(true);
 82		else if ("external".equals(browserType))
 83			rbOther.setSelected(true);
 84		else
 85			rbInternal.setSelected(true);
 86
 87		// "Browser settings:"
 88		addComponent(Box.createVerticalStrut(20));
 89		addSeparator("options.infoviewer.browser.settings.label");
 90
 91		// "Class:"
 92		tClass = new JTextField(jEdit.getProperty("infoviewer.class"), 15);
 93		addComponent(jEdit.getProperty("options.infoviewer.browser.class.label"), tClass);
 94
 95		// "Method:"
 96		tMethod = new JTextField(jEdit.getProperty("infoviewer.method"), 15);
 97		addComponent(jEdit.getProperty("options.infoviewer.browser.method.label"), tMethod);
 98
 99		// "External browser command:"
100		tBrowser = new JTextField(jEdit.getProperty("infoviewer.otherBrowser"), 15);
101		addComponent(jEdit.getProperty("options.infoviewer.browser.other.label"), tBrowser);
102
103		// init:
104		actionPerformed(null);
105	}
106
107	/**
108	 * Called when the options dialog's `OK' button is pressed. This saves
109	 * any properties saved in this option pane.
110	 */
111	public void _save()
112	{
113		jEdit.setProperty("infoviewer.browsertype", rbInternal.isSelected() ? "internal"
114			: rbClass.isSelected() ? "class" : rbFirefox.isSelected() ? "firefox"
115				: "external");
116
117		jEdit.setBooleanProperty("infoviewer.useforhelp", useForHelp.isSelected());
118		jEdit.setProperty("infoviewer.otherBrowser", tBrowser.getText());
119		jEdit.setProperty("infoviewer.class", tClass.getText());
120		jEdit.setProperty("infoviewer.method", tMethod.getText());
121	}
122
123	/**
124	 * Called when one of the radio buttons is clicked.
125	 */
126	public void actionPerformed(ActionEvent e)
127	{
128		tClass.setEnabled(rbClass.isSelected());
129		tMethod.setEnabled(rbClass.isSelected());
130		tBrowser.setEnabled(rbOther.isSelected());
131	}
132
133	private JRadioButton rbInternal;
134
135	private JRadioButton rbOther;
136
137	private JRadioButton rbClass;
138
139	private JRadioButton rbFirefox;
140
141	private JCheckBox useForHelp;
142
143	private JTextField tBrowser;
144
145	private JTextField tClass;
146
147	private JTextField tMethod;
148
149}