Class JSOperation
java.lang.Object
ro.sync.ecss.extensions.commons.operations.JSOperation
- All Implemented Interfaces:
AuthorOperation
,Extension
An implementation of an operation that allows you to call the Java API from custom JavaScript content.
This operation has the following parameters:
- script: the JavaScript content to execute.
It must have a function called doOperation(), which can use the predefined authorAccess variable. The authorAccess variable has access to the
AuthorAccess
instance. The following example is a script that can be used to move the caret location after the current element:function doOperation(){ caretOffset = authorAccess.getEditorAccess().getCaretOffset(); currentNode = authorAccess.getDocumentController().getNodeAtOffset(caretOffset); //Move caret after current node authorAccess.getEditorAccess().setCaretPosition(currentNode.getEndOffset() + 1); }
Note: If you have a script called commons.js in the framework directory, you can call functions defined inside it from your custom script content so that you can use that external script file as a library of functions.
-
Field Summary
Fields inherited from interface ro.sync.ecss.extensions.api.AuthorOperation
NAMESPACE_ARGUMENT, NAMESPACE_ARGUMENT_DESCRIPTOR, SCHEMA_AWARE_ARGUMENT, SCHEMA_AWARE_ARGUMENT_DESCRIPTOR
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
doOperation
(AuthorAccess authorAccess, ArgumentsMap args) Perform the actual operation.
-
Constructor Details
-
JSOperation
public JSOperation()
-
-
Method Details
-
getDescription
- Specified by:
getDescription
in interfaceExtension
- Returns:
- The description of the extension.
- See Also:
-
doOperation
public void doOperation(AuthorAccess authorAccess, ArgumentsMap args) throws AuthorOperationException Description copied from interface:AuthorOperation
Perform the actual operation. You can check if the operation was invoked from the oXygen standalone application or from the oXygen plugin for Eclipse by using the method:ApplicationInformationAccess.getPlatform()
. To get to theWorkspace
you may use:AuthorAccess.getWorkspaceAccess()
.- Specified by:
doOperation
in interfaceAuthorOperation
- Parameters:
authorAccess
- The author access. Provides access to specific informations and actions for editor, document, workspace, tables, change tracking, utility a.s.o.args
- The map of arguments. All the arguments defined by methodAuthorOperation.getArguments()
must be present in the map of arguments.- Throws:
AuthorOperationException
- Thrown when the operation fails.- See Also:
-
getArguments
- Specified by:
getArguments
in interfaceAuthorOperation
- Returns:
- An array of
ArgumentDescriptor
representing the arguments this operation uses. - See Also:
-