ice.storm
Class CallbackAdapter

java.lang.Object
  extended byice.storm.CallbackAdapter
All Implemented Interfaces:
ScripterCallback, ViewportCallback

public class CallbackAdapter
extends Object
implements ViewportCallback, ScripterCallback

Default implementation of ViewportCallback and ScripterCallback interfaces. If new methods would be added to ViewportCallback or ScripterCallback, this class would provide a default implementation for them.

See Also:
ViewportCallback, ScripterCallback

Constructor Summary
CallbackAdapter()
           
 
Method Summary
 boolean allowScriptClose(Viewport vp, boolean openedByScript)
          Query application if script should be able to close top-level window.
static BoxedCode box_allowScriptClose(ScripterCallback sc, Viewport vp, boolean openedByScript)
           
static BoxedCode box_createTopLevelContainer(ViewportCallback viewportCallback, Viewport vp)
           
static BoxedCode box_disposeTopLevelContainer(ViewportCallback viewportCallback, Viewport vp)
           
static BoxedCode box_getMaxScriptRunningTime(ScripterCallback sc)
           
static BoxedCode box_interruptLongRunningScript(ScripterCallback sc, Viewport vp, long scriptRunTime)
           
static BoxedCode box_reportScriptError(ScripterCallback sc, Viewport vp, boolean justWarning, String errorMessage, String url, int lineNumber, String lineSource, int lineOffset)
           
static BoxedCode box_scriptAlert(ScripterCallback sc, Viewport vp, String msg)
           
static BoxedCode box_scriptConfirm(ScripterCallback sc, Viewport vp, String msg)
           
static BoxedCode box_scriptPrint(ScripterCallback sc, Viewport vp)
           
static BoxedCode box_scriptPrompt(ScripterCallback sc, Viewport vp, String msg, String defVal)
           
 Container createTopLevelContainer(Viewport vp)
          Create a new top-level browser window and return an awt container that can be used by StormBase for placing pilots.
 void disposeTopLevelContainer(Viewport vp)
          When the StormBase wants to close the viewport, the application is notified about this so it can terminate the browser window associated with this viewport.
 long getMaxScriptRunningTime()
          Maximum time in milliseconds for script to run on the event thread.
 void init(StormBase base)
          When the callback is given to StormBase, it initializes the callback with this call.
 boolean interruptLongRunningScript(Viewport vp, long scriptRunTime)
          Notify about long running script that blocks user input.
 void processViewportMessage(Viewport view, String messageName, Object addArg, Object value)
           
 void registerWith(StormBase storm)
          Register with storm as viewport and scripter callback.
 void reportScriptError(Viewport vp, boolean justWarning, String errorMessage, String url, int lineNumber, String lineSource, int lineOffset)
          Notify about errors during script execution.
 void scriptAlert(Viewport vp, String msg)
          Implement script alert method
 boolean scriptConfirm(Viewport vp, String msg)
          Implement script confirm method
 void scriptPrint(Viewport vp)
          Implement script print method
 String scriptPrompt(Viewport vp, String msg, String defVal)
          Implement script prompt method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallbackAdapter

public CallbackAdapter()
Method Detail

init

public void init(StormBase base)
Description copied from interface: ViewportCallback
When the callback is given to StormBase, it initializes the callback with this call.

Specified by:
init in interface ViewportCallback
See Also:
ViewportCallback.init(ice.storm.StormBase)

createTopLevelContainer

public Container createTopLevelContainer(Viewport vp)
Description copied from interface: ViewportCallback
Create a new top-level browser window and return an awt container that can be used by StormBase for placing pilots. If the application does not want a new window to be displayed, it can return null.

Specified by:
createTopLevelContainer in interface ViewportCallback
Parameters:
vp - the viewport that will be associated with this awt container. The viewport object may contain some parameters describing how the new browser window should look like (for example, from window.open() in JavaScript)
Returns:
an awt container (light or heavy) that the browser can use, or null if the window should not be popped up.
See Also:
ViewportCallback.createTopLevelContainer(ice.storm.Viewport)

disposeTopLevelContainer

public void disposeTopLevelContainer(Viewport vp)
Description copied from interface: ViewportCallback
When the StormBase wants to close the viewport, the application is notified about this so it can terminate the browser window associated with this viewport.

Specified by:
disposeTopLevelContainer in interface ViewportCallback
See Also:
ViewportCallback.disposeTopLevelContainer(ice.storm.Viewport)

processViewportMessage

public void processViewportMessage(Viewport view,
                                   String messageName,
                                   Object addArg,
                                   Object value)
Specified by:
processViewportMessage in interface ViewportCallback
See Also:
ViewportCallback.processViewportMessage(ice.storm.Viewport, java.lang.String, java.lang.Object, java.lang.Object)

getMaxScriptRunningTime

public long getMaxScriptRunningTime()
Description copied from interface: ScripterCallback
Maximum time in milliseconds for script to run on the event thread. When script code is executed on the application event thread which is the case for DOM event handlers, it blocks a user input until it finishes. This method allows to specify a time period after which the script can be terminated.

Specified by:
getMaxScriptRunningTime in interface ScripterCallback
Returns:
time in milliseconds before the script subsystem calls interruptLongRunningScript. If returns 0, monitoring of long running scripts would be disabled.
See Also:
ScripterCallback.getMaxScriptRunningTime()

interruptLongRunningScript

public boolean interruptLongRunningScript(Viewport vp,
                                          long scriptRunTime)
Description copied from interface: ScripterCallback
Notify about long running script that blocks user input. This method is called when a script that runs on the application event thread exceeds time specified by getMaxScriptRunningTime. The script would be terminated if the method returns true. A possible way to implement the method is to present to a user a dialog asking to terminate or continue the long running script.

Specified by:
interruptLongRunningScript in interface ScripterCallback
Parameters:
vp - Viewport with code for long running script
scriptRunTime - Total time in milliseconds since scrip was started
Returns:
true to terminate the script, false to allow it to continue
See Also:
ScripterCallback.interruptLongRunningScript(ice.storm.Viewport, long)

allowScriptClose

public boolean allowScriptClose(Viewport vp,
                                boolean openedByScript)
Description copied from interface: ScripterCallback
Query application if script should be able to close top-level window.

Specified by:
allowScriptClose in interface ScripterCallback
Parameters:
openedByScript - specify whether viewport was created by script.
Returns:
true to proceed with window closing or false to ignore close call. Usage example that allows script to close window only if it was created from script (which is default behavior if script callback was not registered):
        public boolean allowScriptClose(Viewport view, boolean openedByScript) {
                return openedByScript;
        }
See Also:
ScripterCallback.allowScriptClose(ice.storm.Viewport, boolean)

reportScriptError

public void reportScriptError(Viewport vp,
                              boolean justWarning,
                              String errorMessage,
                              String url,
                              int lineNumber,
                              String lineSource,
                              int lineOffset)
Description copied from interface: ScripterCallback
Notify about errors during script execution.

Specified by:
reportScriptError in interface ScripterCallback
Parameters:
vp - Viewport containing error triggering script
justWarning - True if the reported problem does not prevent father execution of the script.
errorMessage - Text of error message
url - Point to url containing error triggering script code
lineNumber - If non-negative, gives number for line with error
lineSource - If not null, contains error line text
lineOffset - Offset in characters from line start for error-triggering code
See Also:
ScripterCallback.reportScriptError(ice.storm.Viewport, boolean, java.lang.String, java.lang.String, int, java.lang.String, int)

scriptPrompt

public String scriptPrompt(Viewport vp,
                           String msg,
                           String defVal)
Description copied from interface: ScripterCallback
Implement script prompt method

Specified by:
scriptPrompt in interface ScripterCallback
See Also:
ScripterCallback.scriptPrompt(ice.storm.Viewport, java.lang.String, java.lang.String)

scriptConfirm

public boolean scriptConfirm(Viewport vp,
                             String msg)
Description copied from interface: ScripterCallback
Implement script confirm method

Specified by:
scriptConfirm in interface ScripterCallback
See Also:
ScripterCallback.scriptConfirm(ice.storm.Viewport, java.lang.String)

scriptAlert

public void scriptAlert(Viewport vp,
                        String msg)
Description copied from interface: ScripterCallback
Implement script alert method

Specified by:
scriptAlert in interface ScripterCallback
See Also:
ScripterCallback.scriptAlert(ice.storm.Viewport, java.lang.String)

scriptPrint

public void scriptPrint(Viewport vp)
Description copied from interface: ScripterCallback
Implement script print method

Specified by:
scriptPrint in interface ScripterCallback
See Also:
ScripterCallback.scriptPrint(ice.storm.Viewport)

registerWith

public final void registerWith(StormBase storm)
Register with storm as viewport and scripter callback.

See Also:
StormBase.setViewportCallback(ice.storm.ViewportCallback), StormBase.setScripterCallback(ice.storm.ScripterCallback)

box_createTopLevelContainer

public static BoxedCode box_createTopLevelContainer(ViewportCallback viewportCallback,
                                                    Viewport vp)

box_disposeTopLevelContainer

public static BoxedCode box_disposeTopLevelContainer(ViewportCallback viewportCallback,
                                                     Viewport vp)

box_getMaxScriptRunningTime

public static BoxedCode box_getMaxScriptRunningTime(ScripterCallback sc)

box_interruptLongRunningScript

public static BoxedCode box_interruptLongRunningScript(ScripterCallback sc,
                                                       Viewport vp,
                                                       long scriptRunTime)

box_allowScriptClose

public static BoxedCode box_allowScriptClose(ScripterCallback sc,
                                             Viewport vp,
                                             boolean openedByScript)

box_reportScriptError

public static BoxedCode box_reportScriptError(ScripterCallback sc,
                                              Viewport vp,
                                              boolean justWarning,
                                              String errorMessage,
                                              String url,
                                              int lineNumber,
                                              String lineSource,
                                              int lineOffset)

box_scriptPrompt

public static BoxedCode box_scriptPrompt(ScripterCallback sc,
                                         Viewport vp,
                                         String msg,
                                         String defVal)

box_scriptConfirm

public static BoxedCode box_scriptConfirm(ScripterCallback sc,
                                          Viewport vp,
                                          String msg)

box_scriptAlert

public static BoxedCode box_scriptAlert(ScripterCallback sc,
                                        Viewport vp,
                                        String msg)

box_scriptPrint

public static BoxedCode box_scriptPrint(ScripterCallback sc,
                                        Viewport vp)