scriptedtabbing
Class TabOperation

java.lang.Object
  extended by com.wrq.vhi.script.api.OperationEventHandler
      extended by scriptedtabbing.TabOperation
All Implemented Interfaces:
com.wrq.vhi.script.api.EventHandler

public class TabOperation
extends com.wrq.vhi.script.api.OperationEventHandler

Move the cursor between tabstops by overriding the cursor tab operation.

This event handler is used to override the LineUp and LineDown operations to move between tabstops. LineUp sends a cursor-up command to the host; LineDown sends a cursor-down command.

This event handler's implementation strategy is to first execute the default cursor movement operation, chosen by the Verastream server, and to wait for the cursor to move to a location defined as a tabstop.

The Verastream tabstop movement algorithm tries to move the cursor in one direction until the cursor position doesn't change. At that point the cursor movement is reversed. This occurs without any action on the part of the event handler.

Issuing a cursor down or cursor up command will usually move the cursor from its current location. An exception to this rule occurs when:

  1. The cursor is moving forward, and
  2. The cursor is at the last attribute (Address), and
  3. More data needs to be written to attributes located above the Address attribute, and
  4. No data was actually written to the Address attribute.

If data is written to the Address attribute, writing the data will move the cursor from the leftmost character in the field, which is defined as a tabstop. Issuing the LineDown operation causes Pine to first print an error message and then to move the cursor back to the leftmost character in the Address attribute: that is the cursor moves and ends up at a tabstop. The event handler notices that the cursor has moved to a tabstop, at which point it returns.

If the cursor starts at the Address attribute tabstop, issuing a line down command leaves the cursor where it started. The Pine application first writes an error message when the cursor-down key is sent, and then promptly moves the cursor back to its original location (the tabstop!). In this case the event handler doesn't think that the cursor has moved at all, so it waits some more for the cursor to move. This results in a timeout, because Pine is now waiting for more input. The event handler catches the timeout, suppresses it, and returns to Verastream as if nothing happened. Verastream notices that the cursor hasn't moved from its starting point, and reverses the tab direction.

One alternative to waiting for a timeout is to notice that Verastream is trying to move the cursor in the forward direction when the cursor is already at the last attribute. Set the optimizeCursorMovement variable true to use this optimization.


Field Summary
private static java.lang.String cursorForward
          The name of the "cursor forward" operation.
static java.lang.String description
           
private static int errWaitEventTimeout
          Event timeout error code.
static int executeOperationTimeout
          Timeout in seconds for the executeOperation() event.
private static int lastAttributeRow
          The row containing the last attribute.
private static boolean optimizeCursorMovement
          Control whether or not to use cursor forward optimization.
 
Fields inherited from interface com.wrq.vhi.script.api.EventHandler
DEFAULT_TIMEOUT
 
Constructor Summary
TabOperation()
           
 
Method Summary
 void executeOperation(com.wrq.vhi.script.api.ExecuteOperationEvent event)
          Execute a line up or line down operation to tab between attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

description

public static final java.lang.String description
See Also:
Constant Field Values

executeOperationTimeout

public static final int executeOperationTimeout
Timeout in seconds for the executeOperation() event. A value of DEFAULT_TIMEOUT means the event will use the model defined default event timeout.

See Also:
Constant Field Values

errWaitEventTimeout

private static final int errWaitEventTimeout
Event timeout error code.

See Also:
Constant Field Values

lastAttributeRow

private static final int lastAttributeRow
The row containing the last attribute. Reaching this row requires reversing the cursor direction.

See Also:
Constant Field Values

cursorForward

private static final java.lang.String cursorForward
The name of the "cursor forward" operation.

See Also:
Constant Field Values

optimizeCursorMovement

private static final boolean optimizeCursorMovement
Control whether or not to use cursor forward optimization.

Set this value true to test for reaching the last attribute in the forward direction without waiting and catching a timeout.

Set this value false to always issue cursor movement commands without testing for reaching the forward limit first.

See Also:
Constant Field Values
Constructor Detail

TabOperation

public TabOperation()
Method Detail

executeOperation

public void executeOperation(com.wrq.vhi.script.api.ExecuteOperationEvent event)
                      throws com.wrq.apptrieve.agent.ApptrieveException
Execute a line up or line down operation to tab between attributes.

Overrides:
executeOperation in class com.wrq.vhi.script.api.OperationEventHandler
Parameters:
event - the event instance
Throws:
com.wrq.apptrieve.agent.ApptrieveException - other than a wait event timeout