Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.elexis.text
Class TextSaveDaemon

java.lang.Object
  extended by Job
      extended by ch.elexis.text.TextSaveDaemon

public class TextSaveDaemon
extends Job

The TextSaveDaemnon can be set on a BaseRichTextDisplay. After "start" it will lock its resource. If the resource is already locked by a different process, it will put the BaseRichTExtDisplay into "read only" mode. The caller can setup a save-strategy. It is possible to save after each keystroke or on Focus lost or on stop() or never at all.

Author:
gerry

Field Summary
static int STRATEGY_LOAD_ON_START
          load contents on call to start()
static int STRATEGY_SAVE_ON_FOCUS_LOST
          save contents if component loses focus
static int STRATEGY_SAVE_ON_KEYSTROKE
          save contents after each keystroke
static int STRATEGY_SAVE_ON_STOP
          save contents on call to stop()
static int STRATEGY_SAVE_ON_TIMER
          save contents on timer ticks
 
Constructor Summary
TextSaveDaemon(BaseRichTextDisplay brd, java.lang.String lockname)
          Create a new TextSaveDaemon
 
Method Summary
 void setStrategy(int strategy, boolean bWriteHeaders, java.lang.Object parameter, int timerclicks)
          Set a strategy for manamegemt of the contents.
 void start()
          Begin protecting the resource.
 void stop()
          Stop protecting the resource.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRATEGY_LOAD_ON_START

public static final int STRATEGY_LOAD_ON_START
load contents on call to start()

See Also:
Constant Field Values

STRATEGY_SAVE_ON_STOP

public static final int STRATEGY_SAVE_ON_STOP
save contents on call to stop()

See Also:
Constant Field Values

STRATEGY_SAVE_ON_KEYSTROKE

public static final int STRATEGY_SAVE_ON_KEYSTROKE
save contents after each keystroke

See Also:
Constant Field Values

STRATEGY_SAVE_ON_FOCUS_LOST

public static final int STRATEGY_SAVE_ON_FOCUS_LOST
save contents if component loses focus

See Also:
Constant Field Values

STRATEGY_SAVE_ON_TIMER

public static final int STRATEGY_SAVE_ON_TIMER
save contents on timer ticks

See Also:
Constant Field Values
Constructor Detail

TextSaveDaemon

public TextSaveDaemon(BaseRichTextDisplay brd,
                      java.lang.String lockname)
Create a new TextSaveDaemon

Parameters:
brd - BaseRichTextDisplay to observe
lockname - name of the resource to protect. Arbitrary name that identifies the resource. The name must be the same for all clients competing for the same resource but must be different for different resources.
Method Detail

setStrategy

public void setStrategy(int strategy,
                        boolean bWriteHeaders,
                        java.lang.Object parameter,
                        int timerclicks)
Set a strategy for manamegemt of the contents. Note: If a strategy is set, there MUST be an IPersistenceProvider attached to the BaseRichTextDisplay's Contents.

Parameters:
strategy - An OR'ed combination of the STRATEGY_xxx values explained above
bWriteHeaders - if true will write an XML header to every entry
parameter - parameter for the IPersistenceProvider. May be null
timerclicks - save interval for STRATEGY_SAVE_ON_TIMER. Not used if this strategy is not chosen.

start

public void start()
Begin protecting the resource. After the call, will set up a lock and re-lock once in a second until stop() is called


stop

public void stop()
Stop protecting the resource. If STRATEGY_SAVE_ON_STOP was selected, the contents is saved. Then the lock is released.


Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis