adams.gui.tools
Class RConsoleFilter

java.lang.Object
  extended by javax.swing.text.DocumentFilter
      extended by adams.gui.tools.RConsoleFilter

public class RConsoleFilter
extends DocumentFilter

Filters input to a console to only allow edits after the prompt.

Version:
$Revision$
Author:
rsmith

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.DocumentFilter
DocumentFilter.FilterBypass
 
Field Summary
protected  RConsolePanel m_Console
           
protected  int m_DocLength
          Total length of the document.
protected  int m_PromptPosition
          Current position of the prompt.
 
Constructor Summary
RConsoleFilter(RConsolePanel console)
          Initializes the filter with a console.
 
Method Summary
 void insertString(DocumentFilter.FilterBypass fb, int off, String str, AttributeSet attr)
          Called when a string is about to be inserted into the Document.
 void remove(DocumentFilter.FilterBypass fb, int off, int len)
          Called when a string is to be removed from the Document.
 void replace(DocumentFilter.FilterBypass fb, int off, int len, String str, AttributeSet attr)
          Called when a string to be replaced within the Document.
 void setPromptPosition(int pos)
          Sets the position of the prompt.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_PromptPosition

protected int m_PromptPosition
Current position of the prompt.


m_DocLength

protected int m_DocLength
Total length of the document.


m_Console

protected RConsolePanel m_Console
Constructor Detail

RConsoleFilter

public RConsoleFilter(RConsolePanel console)
Initializes the filter with a console.

Parameters:
console - the console whose input this is filtering
Method Detail

setPromptPosition

public void setPromptPosition(int pos)
Sets the position of the prompt.

Parameters:
pos - position in the sequence of characters

insertString

public void insertString(DocumentFilter.FilterBypass fb,
                         int off,
                         String str,
                         AttributeSet attr)
                  throws BadLocationException
Called when a string is about to be inserted into the Document.

Overrides:
insertString in class DocumentFilter
Parameters:
fb - can use this to bypass the filter
off - where the string is to be inserted
str - the string to be inserted
attr - attributes to associate with the inserted content, may be null
Throws:
BadLocationException - when the offset is not a valid part of the document

remove

public void remove(DocumentFilter.FilterBypass fb,
                   int off,
                   int len)
            throws BadLocationException
Called when a string is to be removed from the Document.

Overrides:
remove in class DocumentFilter
Parameters:
fb - can use this to bypass the filter
off - where the string is to be removed from
len - how many characters are to be removed
Throws:
BadLocationException - when some of the range is not a valid part of the document

replace

public void replace(DocumentFilter.FilterBypass fb,
                    int off,
                    int len,
                    String str,
                    AttributeSet attr)
             throws BadLocationException
Called when a string to be replaced within the Document.

Overrides:
replace in class DocumentFilter
Parameters:
fb - can be used to bypass the filter
off - where string is to be inserted
len - how many characters are to be replaced
str - the string that is being inserted
attr - attributes to be associated with the inserted content, may be null
Throws:
BadLocationException - when some of the range is not a valid part of the Document


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.