edu.rice.cs.drjava.model.definitions.indent
Class ActionStartPrevLinePlusMultiline

java.lang.Object
  extended by edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
      extended by edu.rice.cs.drjava.model.definitions.indent.IndentRuleAction
          extended by edu.rice.cs.drjava.model.definitions.indent.ActionStartPrevLinePlusMultiline
All Implemented Interfaces:
IndentRule

 class ActionStartPrevLinePlusMultiline
extends IndentRuleAction

Indents the current line in the document to the indent level of the start of the previous line, adds several lines of text at that indent level, and moves the cursor to a particular line and position.

Version:
$Id: ActionStartPrevLinePlusMultiline.java 5236 2010-04-27 01:43:36Z mgricken $

Field Summary
private  int _line
           
private  int _offset
           
private  java.lang.String[] _suffices
           
 
Fields inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
NO, TERMINUS_RULE, YES
 
Constructor Summary
ActionStartPrevLinePlusMultiline(java.lang.String[] suffices, int line, int position)
          Creates a multiline insert rule.
 
Method Summary
 boolean indentLine(AbstractDJDocument doc, Indenter.IndentReason reason)
          Indents the line according to the previous line, with the suffix lines added and the cursor moved to a specific location.
 
Methods inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRuleWithTrace
_addToIndentTrace, getRuleName, getTrace, indentLine, printLastIndentTrace, setRuleTraceEnabled, testIndentLine, testIndentLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_suffices

private java.lang.String[] _suffices

_line

private int _line

_offset

private int _offset
Constructor Detail

ActionStartPrevLinePlusMultiline

public ActionStartPrevLinePlusMultiline(java.lang.String[] suffices,
                                        int line,
                                        int position)
Creates a multiline insert rule. It should be noted that although the suffices are referred to as "lines", this class simply appends the strings with a number of spaces for padding. Any newline characters you intend to place in the document must be explicitly placed within the input strings. Typically, all but the last "line" will have a '\n' character at the end.

Parameters:
suffices - the new lines to be added
line - the line on which to place the cursor
position - the character within the line string before which to place the cursor
Throws:
java.lang.IllegalArgumentException - if the integer params are negative or outside the appropriate bounds
Method Detail

indentLine

public boolean indentLine(AbstractDJDocument doc,
                          Indenter.IndentReason reason)
Indents the line according to the previous line, with the suffix lines added and the cursor moved to a specific location. If on the first line, indent is set to 0. Only runs in event thread.

Specified by:
indentLine in interface IndentRule
Overrides:
indentLine in class IndentRuleWithTrace
Parameters:
doc - AbstractDJDocument containing the line to be indented.
reason - The reason that the indentation is taking place
Returns:
this is always false, since we are updating the cursor location