Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.elexis.text
Interface ITextPlugin

All Known Implementing Classes:
ElexisTextPlugin, ETFTextPlugin, OOText

public interface ITextPlugin

Contract for embedding a text plugin Warning: Preliminary interface


Nested Class Summary
static interface ITextPlugin.ICallback
          Callback interface for save operations
static class ITextPlugin.PageFormat
           
 
Field Summary
static java.lang.String ENTRY_TYPE_TABLE
           
static java.lang.String ENTRY_TYPE_TEXT
           
static int FIRST_ROW_IS_HEADER
           
static int GRID_VISIBLE
           
 
Method Summary
 boolean clear()
          clear the document
 Composite createContainer(Composite parent, ITextPlugin.ICallback handler)
          Create and return an SWT Coomposite that holds the editor
 boolean createEmptyDocument()
          Create an empty document inside the container
 void dispose()
          Text component is disposed.
 boolean findOrReplace(java.lang.String pattern, ReplaceCallback cb)
          Find a pattern (regular expression) in the document, and call ReplaceCallback with each match.
 ITextPlugin.PageFormat getFormat()
          Return format of the page
 java.lang.String getMimeType()
          Default Mimettype of the documents that this implementation creates
 boolean insertTable(java.lang.String place, int properties, java.lang.String[][] contents, int[] columnSizes)
          Insert a table in the document
 java.lang.Object insertText(java.lang.Object pos, java.lang.String text, int adjust)
          Insert text at the position described by the implemetation specific cursor
 java.lang.Object insertText(java.lang.String marke, java.lang.String text, int adjust)
          Insert text at a position specified by a regular expression
 java.lang.Object insertTextAt(int x, int y, int w, int h, java.lang.String text, int adjust)
          Position text into a rectangular area.
 boolean isDirectOutput()
          does the plugin want to output the document immediately after creating
 boolean loadFromByteArray(byte[] bs, boolean asTemplate)
          create a document from a byte array.
 boolean loadFromStream(java.io.InputStream is, boolean asTemplate)
          create a document from an InputStream that vontains the contents in the specific formar of the text component.
 boolean print(java.lang.String toPrinter, java.lang.String toTray, boolean waitUntilFinished)
          Print the document
 void setFocus()
          The text component receives the focus
 boolean setFont(java.lang.String name, int style, float size)
          Set font for all following operations (until the next call to setFont)
 void setFormat(ITextPlugin.PageFormat f)
          Set Format of the page
 void setSaveOnFocusLost(boolean bSave)
          Save contents on focus lost
 boolean setStyle(int style)
          Set style for all following operations (until the next call to setFont or setStyle)
 void showMenu(boolean b)
          Show or hide the component specific menu bar
 void showToolbar(boolean b)
          Show or hide the component specific toolbar
 byte[] storeToByteArray()
          Store the document into the byte array.
 

Field Detail

FIRST_ROW_IS_HEADER

static final int FIRST_ROW_IS_HEADER
See Also:
Constant Field Values

GRID_VISIBLE

static final int GRID_VISIBLE
See Also:
Constant Field Values

ENTRY_TYPE_TABLE

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

ENTRY_TYPE_TEXT

static final java.lang.String ENTRY_TYPE_TEXT
See Also:
Constant Field Values
Method Detail

getFormat

ITextPlugin.PageFormat getFormat()
Return format of the page


setFormat

void setFormat(ITextPlugin.PageFormat f)
Set Format of the page


createContainer

Composite createContainer(Composite parent,
                          ITextPlugin.ICallback handler)
Create and return an SWT Coomposite that holds the editor

Parameters:
parent - parent component
handler - Handler for saving the document
Returns:

setFocus

void setFocus()
The text component receives the focus


dispose

void dispose()
Text component is disposed. All ressources must be freed


showMenu

void showMenu(boolean b)
Show or hide the component specific menu bar

Parameters:
b - true: show

showToolbar

void showToolbar(boolean b)
Show or hide the component specific toolbar


setSaveOnFocusLost

void setSaveOnFocusLost(boolean bSave)
Save contents on focus lost

Parameters:
bSave - true: yes, else no.

createEmptyDocument

boolean createEmptyDocument()
Create an empty document inside the container

Returns:

loadFromByteArray

boolean loadFromByteArray(byte[] bs,
                          boolean asTemplate)
create a document from a byte array. The array contains the document in the (arbitrary) specific format of the text component. Prefarably, but not necessarily OpenDocumentFormat (odf)

Parameters:
bs - the byte array with the document in a fotmat the compnent can interpret
asTemplate - tru if the byte array is a template.
Returns:
true on success

loadFromStream

boolean loadFromStream(java.io.InputStream is,
                       boolean asTemplate)
create a document from an InputStream that vontains the contents in the specific formar of the text component.

Returns:
true on success

findOrReplace

boolean findOrReplace(java.lang.String pattern,
                      ReplaceCallback cb)
Find a pattern (regular expression) in the document, and call ReplaceCallback with each match. Replace the found pattern with the replacment String received from ReplaceCallback.

Parameters:
pattern - a regular expression
cb - a ReplaceCallback or null if no Replacement should be performed
Returns:
true if pattern was found at least once

storeToByteArray

byte[] storeToByteArray()
Store the document into the byte array. The format can be any component specific type. The only requiremend is, that loadFromByteArray() must be able to recreate the document out of this byte array identically.

Returns:
a Byte Array with the contents of the document.

insertTable

boolean insertTable(java.lang.String place,
                    int properties,
                    java.lang.String[][] contents,
                    int[] columnSizes)
Insert a table in the document

Parameters:
place - a regular expression in the document, that will be replaced by the table. Only the first match will be used.
properties - OR'ed property values
contents - the contents of the table
columnSizes - width of the columns or null: Autofit all columns.
Returns:
true on success.

insertTextAt

java.lang.Object insertTextAt(int x,
                              int y,
                              int w,
                              int h,
                              java.lang.String text,
                              int adjust)
Position text into a rectangular area.

Parameters:
adjust - SWT.LEFT, SWT.RIGHT, SWT.CENTER
x - ,y,w,h position and size of the rectangle relative to the page bounds. Measured as millimeters. The effective position and size must match the given values at +- 2mm.
text - the text to insert, which can contain '\n' that must be honored.
Returns:
an implementation specific cursor that allows a later insert at the same position (mit insertText(Object,text,adjust)

setFont

boolean setFont(java.lang.String name,
                int style,
                float size)
Set font for all following operations (until the next call to setFont)

Parameters:
name - name of the font
style - SWT.MIN, SWT.NORMAL, SWT.BOLD (thin, normal or bold)
size - font height in Pt
Returns:
false on error. True on success, what might mean however, that not the specified font but a similar font was set.

setStyle

boolean setStyle(int style)
Set style for all following operations (until the next call to setFont or setStyle)

Parameters:
style - SWT.MIN, SWT.NORMAL, SWT.BOLD (thin, normal or bold)
Returns:
false on error. True on success

insertText

java.lang.Object insertText(java.lang.String marke,
                            java.lang.String text,
                            int adjust)
Insert text at a position specified by a regular expression

Parameters:
marke - regular expression, that describes the insertion point. Only the first match will be used, and the inserted Text will replace the found string.
adjust - SWT.LEFT oder SWT.RIGHT
Returns:
An implementation specific cursor thar allows a later insert after that position

insertText

java.lang.Object insertText(java.lang.Object pos,
                            java.lang.String text,
                            int adjust)
Insert text at the position described by the implemetation specific cursor

Parameters:
pos - an implementation specific cursor
adjust - SWT.LEFT, SWT.CENTER, SWT.RIGHT
Returns:
a cursor that can be used for a subsequent insert.

clear

boolean clear()
clear the document

Returns:

print

boolean print(java.lang.String toPrinter,
              java.lang.String toTray,
              boolean waitUntilFinished)
Print the document

Parameters:
toPrinter - Name of the Printers or null (then to default printer)
toTray - Name of the tray or null (then tray as defined y the driver or the template)
waitUntilFinished - if true: return after the printJob ist finished
Returns:
true on success

getMimeType

java.lang.String getMimeType()
Default Mimettype of the documents that this implementation creates


isDirectOutput

boolean isDirectOutput()
does the plugin want to output the document immediately after creating

Returns:
true if output should start immerdiately, false if the user triggers output manually

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis