org.fife.ui.rsyntaxtextarea.SpellingOptionPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rtext Show documentation
Show all versions of rtext Show documentation
RText is a powerful, cross-platform programmer's text editor written in Java. It is designed
to be easy to use, highly customizable and flexible. Part of RText's design is for the source code
to be simple, easy to understand, and well documented, so that other programmers can look into its
inner-workings and figure out how RText ticks with ease. A good place to start (besides the source
code) is the Javadoc for all classes used in the project.
/*
* 10/10/2009
*
* SpellingOptionPanel.java - An option panel for the spelling checker.
* Copyright (C) 2009 Robert Futrell
* robert_futrell at users.sourceforge.net
* http://rtext.fifesoft.com
*
* This file is a part of RText.
*
* RText is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* RText is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.fife.ui.rsyntaxtextarea;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.ResourceBundle;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.AbstractDocument;
import org.fife.rtext.NumberDocumentFilter;
import org.fife.rtext.RText;
import org.fife.rtext.RTextPreferences;
import org.fife.rtext.RTextUtilities;
import org.fife.rtext.SpellingSupport;
import org.fife.ui.FSATextField;
import org.fife.ui.OptionsDialogPanel;
import org.fife.ui.RButton;
import org.fife.ui.RColorButton;
import org.fife.ui.RColorSwatchesButton;
import org.fife.ui.SelectableLabel;
import org.fife.ui.SpecialValueComboBox;
import org.fife.ui.UIUtil;
import org.fife.ui.rtextfilechooser.RTextFileChooser;
/**
* Options panel for the spelling checker.
*
* @author Robert Futrell
* @version 1.0
*/
public class SpellingOptionPanel extends OptionsDialogPanel {
private JCheckBox enabledCB;
private JLabel dictLabel;
private SpecialValueComboBox dictCombo;
private JLabel userDictLabel;
private FSATextField userDictField;
private SelectableLabel userDictDescField;
private RButton userDictBrowse;
private RTextFileChooser chooser;
private JLabel colorLabel;
private RColorSwatchesButton spellingColorButton;
private JLabel errorsPerFileLabel;
private JTextField maxErrorsField;
private JCheckBox viewSpellingWindowCB;
private Listener listener;
private ResourceBundle msg;
private static final String[][] DICTIONARIES = {
{ "English (United Kingdom)", SpellingSupport.DICTIONARIES[0] },
{ "English (United States)", SpellingSupport.DICTIONARIES[1] },
};
private static final String MISC_PROPERTY = "Miscellaneous";
public SpellingOptionPanel() {
ComponentOrientation orientation = ComponentOrientation.
getOrientation(getLocale());
listener = new Listener();
msg = ResourceBundle.getBundle(
"org.fife.ui.rsyntaxtextarea.SpellingOptionPanel");
setName(msg.getString("Title"));
setLayout(new BorderLayout());
setBorder(UIUtil.getEmpty5Border());
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setBorder(new OptionPanelBorder(msg.getString("Spelling")));
add(contentPane);
Box temp = Box.createVerticalBox();
contentPane.add(temp, BorderLayout.NORTH);
enabledCB = new JCheckBox(msg.getString("Enabled"));
enabledCB.setActionCommand("Enabled");
enabledCB.addActionListener(listener);
addLeftAligned(temp, enabledCB);
temp.add(Box.createVerticalStrut(5));
dictLabel = new JLabel(msg.getString("Dictionary"));
dictCombo = new SpecialValueComboBox();
for (int i=0; i