org.fife.rtext.SpellingErrorWindow 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/17/2009
*
* SpellingErrorWindow.java - A dockable window that lists spelling errors in
* currently open files.
* 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.rtext;
import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JTable;
import org.fife.ui.RScrollPane;
import org.fife.ui.dockablewindows.DockableWindowScrollPane;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.parser.ParserNotice;
import org.fife.ui.rsyntaxtextarea.spell.SpellingParser;
/**
* A window that displays the spelling errors for the currently active
* text area.
*
* @author Robert Futrell
* @version 1.0
*/
class SpellingErrorWindow extends AbstractParserNoticeWindow
implements PropertyChangeListener {
private SpellingTableModel model;
public SpellingErrorWindow(RText rtext) {
super(rtext);
AbstractMainView mainView = rtext.getMainView();
mainView.addPropertyChangeListener(AbstractMainView.TEXT_AREA_ADDED_PROPERTY, this);
mainView.addPropertyChangeListener(AbstractMainView.TEXT_AREA_REMOVED_PROPERTY, this);
model = new SpellingTableModel(rtext.getString("SpellingErrorList.Word"));
JTable table = createTable(model);
RScrollPane sp = new DockableWindowScrollPane(table);
setLayout(new BorderLayout());
add(sp);
setPosition(BOTTOM);
setActive(true);
setDockableWindowName(rtext.getString("SpellingErrorList.Spelling"));
URL url = getClass().getResource("graphics/spellcheck.png");
setIcon(new ImageIcon(url));
// Start listening to any already-opened files.
for (int i=0; i