edu.rice.cs.drjava.ui
Class DefinitionsPane.IndentKeyAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by edu.rice.cs.drjava.ui.DefinitionsPane.IndentKeyAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action
Enclosing class:
DefinitionsPane

private class DefinitionsPane.IndentKeyAction
extends AbstractAction

Used for indent action spawned by pressing the enter key, '{', or '}'.


Field Summary
private  Action _defaultAction
          The default action to take when the specified key is pressed.
private  boolean _indentNonCode
          Whether to perform the indent if the caret is in a String or comment.
private  String _key
          The key string ("\n"|"{"|"}") for the key pressed that invokes this instance.
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
DefinitionsPane.IndentKeyAction(String key, Action defaultAction)
          Creates an IndentKeyAction which only invokes indent if the caret is in code, and not Strings or comments.
DefinitionsPane.IndentKeyAction(String key, Action defaultAction, boolean indentNonCode)
          Creates a new IndentKeyAction with the specified parameters.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Handle the "key typed" event from the text field.
protected  Indenter.IndentReason getIndentReason()
          This method tells what the reason should be for spawning this indent event Defaults to Indenter.IndentReason.OTHER
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_key

private final String _key
The key string ("\n"|"{"|"}") for the key pressed that invokes this instance. Not used currently, but there for readability and possible future use, e.g., debugging add-ons or the rewrite of the indention code.


_defaultAction

private final Action _defaultAction
The default action to take when the specified key is pressed.


_indentNonCode

private final boolean _indentNonCode
Whether to perform the indent if the caret is in a String or comment.

Constructor Detail

DefinitionsPane.IndentKeyAction

DefinitionsPane.IndentKeyAction(String key,
                                Action defaultAction)
Creates an IndentKeyAction which only invokes indent if the caret is in code, and not Strings or comments.


DefinitionsPane.IndentKeyAction

DefinitionsPane.IndentKeyAction(String key,
                                Action defaultAction,
                                boolean indentNonCode)
Creates a new IndentKeyAction with the specified parameters.

Parameters:
key - name of the key, for debugging purposes
defaultAction - action to perform in addition to indenting
indentNonCode - whether to indent Strings and comments
Method Detail

getIndentReason

protected Indenter.IndentReason getIndentReason()
This method tells what the reason should be for spawning this indent event Defaults to Indenter.IndentReason.OTHER


actionPerformed

public void actionPerformed(ActionEvent e)
Handle the "key typed" event from the text field. Calls the default action to make sure the right things happen, then makes a call to indentLine().