ice.storm
Interface ScripterCallback

All Known Implementing Classes:
CallbackAdapter

public interface ScripterCallback


Method Summary
 boolean allowScriptClose(Viewport vp, boolean openedByScript)
          Query application if script should be able to close top-level window.
 long getMaxScriptRunningTime()
          Maximum time in milliseconds for script to run on the event thread.
 boolean interruptLongRunningScript(Viewport vp, long scriptRunTime)
          Notify about long running script that blocks user input.
 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
 

Method Detail

getMaxScriptRunningTime

public long getMaxScriptRunningTime()
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.

Returns:
time in milliseconds before the script subsystem calls interruptLongRunningScript. If returns 0, monitoring of long running scripts would be disabled.
See Also:
interruptLongRunningScript(ice.storm.Viewport, long)

interruptLongRunningScript

public boolean interruptLongRunningScript(Viewport vp,
                                          long scriptRunTime)
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.

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:
getMaxScriptRunningTime()

allowScriptClose

public boolean allowScriptClose(Viewport vp,
                                boolean openedByScript)
Query application if script should be able to close top-level window.

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;
        }

reportScriptError

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

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

scriptPrompt

public String scriptPrompt(Viewport vp,
                           String msg,
                           String defVal)
Implement script prompt method


scriptConfirm

public boolean scriptConfirm(Viewport vp,
                             String msg)
Implement script confirm method


scriptAlert

public void scriptAlert(Viewport vp,
                        String msg)
Implement script alert method


scriptPrint

public void scriptPrint(Viewport vp)
Implement script print method