LPEX
3.6.6

com.ibm.lpex.core
Interface LpexAction

All Known Implementing Classes:
BlockNewMarkToMouseAction, BlockTransferAction, ComposeAction, ComposeHebrewAction, CopyLineAction, FindNextDefaultAction, KeyReferenceAction, LpexBaseAction, SetDateAction, TestAction, TestUserProfile.CloseJoin, TestUserProfile.FindNextSelection, ZoomAction

public interface LpexAction

Interface LpexAction can be implemented to define a user action.

The code sample below is used inside a document parser to define the insertAmp editor action (which inserts the string "&" at the cursor), and associate it with the Ctrl+& key in the text area:

 
 lpexView.defineAction("insertAmp", new LpexAction() {
  public void doAction(LpexView view)
  {
   view.doDefaultCommand("insertText &");
  }
  public boolean available(LpexView view)
  {
   return !view.queryOn("readonly") &&
          view.currentElement() != 0;
  }
 });

 if (!lpexView.keyAssigned("c-ampersand.t"))
  {
   lpexView.doCommand("set keyAction.c-ampersand.t insertAmp"); 
  } 

The user action may be a new editor action, or it may redefine or extend a default editor action.

An action can be assigned to a key or series of keys with the set keyAction editor command, or to a mouse event with the set mouseAction editor command.

See Also:
LpexView.defineAction(java.lang.String, com.ibm.lpex.core.LpexAction), LpexBaseAction, Samples

Method Summary
 boolean available(LpexView lpexView)
          This method in the defined action will be called to query its availability.
 void doAction(LpexView lpexView)
          This method in the defined action will be called to run it.
 

Method Detail

doAction

void doAction(LpexView lpexView)
This method in the defined action will be called to run it.

An action may be run (for example, from the LPEX command line) with the action editor command, by selecting an associated menu item, or by activating the key or the mouse event to which the action is assigned.

Parameters:
lpexView - the document view in which the action is issued

available

boolean available(LpexView lpexView)
This method in the defined action will be called to query its availability.

When this method returns false, menu items associated with this user action will be disabled, the key or mouse event to which this action is assigned will not run it, and neither will the action command.

Parameters:
lpexView - the document view for which the action availability is queried

LPEX
3.6.6

Copyright © 2012 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.