GLG Toolkit, Java Class Library  Version 4.6
Installing and Uninstalling

Detailed Description

Functions

static void IHInit ()
 Initializes installable handler utilities, must be invoked after Init, but before any installable handler methods are used. More...
 
static GlgObject IHInstall (GlgIHHandlerInterface handler_interface)
 Creates an interface handler with the specified handler interface and installs it. More...
 
static void IHResetup (GlgObject ih)
 Reinitializes the current handler that have already been installed to "restart" its logic. More...
 
static void IHStart ()
 Initializes and starts the current handler after it has been installed with IHInstall. More...
 
static void IHTerminate ()
 Terminates installable handler utilities. More...
 
static void IHUninstall ()
 Uninstalls the current handler (the last handler on the handler stack). More...
 
static void IHUninstallWithEvent (GlgIHCallEvent call_event)
 Uninstalls the current handler and passes an event to the previous handler. More...
 
static void IHUninstallWithToken (int token)
 Uninstalls the current handler and passes a token to the previous handler. More...
 

Function Documentation

◆ IHInit()

static void IHInit ( )
static

Initializes installable handler utilities, must be invoked after Init, but before any installable handler methods are used.

◆ IHInstall()

static GlgObject IHInstall ( GlgIHHandlerInterface  handler_interface)
static

Creates an interface handler with the specified handler interface and installs it.

Parameters
handler_interfaceAn interface object that implements the handler's interaction logic.
Returns
Installed handler object.

This method creates an interface handler, adds it to a stack of handlers and returns created handler object. A stack of handlers is used to keep track of nested handlers; the last handler pushed onto the stack becomes the active handler, referred to as the current handler in the rest of this section.

After the handler has been installed, parameters can be passed to it by using its data storage. See IHStart for an example of a handler code.

◆ IHResetup()

static void IHResetup ( GlgObject  ih)
static

Reinitializes the current handler that have already been installed to "restart" its logic.

For example, if a handler handles selecting a text object with the mouse, and a user selects an a polygon, the handler can issue an error message and restart its operation by invoking IHResetup.

Parameters
ihHandler ID.

This method invokes the handler's entry point with the HI_RESETUP_EVENT event. This can be used to reinitialize the handler by sharing some of the code of the HI_SETUP_EVENT case. The following handler example reuses handler initialization code that pops up a dialog when the handler starts up or restarts:

import com.genlogic.*;
import static com.genlogic.GlgObject.*;
class ConfirmIH implements GlgIHHandlerInterface
{
public void EntryPoint( GlgObject ih, GlgIHCallEvent call_event )
{
// Retrieve the OK dialog ID provided as a parameter when the handler was installed.
GlgObject ok_dialog = IHGetOParameter( ih, "ok_dialog" );
GlgCallEventType event_type = IHGetType( call_event );
switch( event_type )
{
// Retrieve the dialog message provided as a parameter when the handler was installed.
String message = IHGetOptSParameter( ih, "message" );
// Set the dialog's message to the requested message.
message.SetSResource( ok_dialog, "DialogMessageString" );
// Fall through to popup the dialog.
case HI_RESETUP_EVENT: // Popup the dialog again.
ok_dialog.SetDResource( "Visibility", 1. );
ok_dialog.Update();
break;
...
}
}
}
static final int HI_RESETUP_EVENT
Invoked only on re-setup of an interface handler.
Definition: GlgObject.java:7044
static final int HI_SETUP_EVENT
Invoked on the initial setup of an interface handler.
Definition: GlgObject.java:7042
static GlgCallEventType IHGetType(GlgIHCallEvent call_event)
Returns an event's type.
Definition: GlgObject.java:22374
static String IHGetOptSParameter(GlgObject ih, String name, String default_value)
Returns a string stored in an optional named parameter.
Definition: GlgObject.java:23635
static GlgObject IHGetOParameter(GlgObject ih, String name)
Returns a GLG object stored in a named parameter.
Definition: GlgObject.java:23501

Refer to the DEMOS_JAVA/GlgDiagram.java file in the GLG installation directory for a source code example of using this method.

◆ IHStart()

static void IHStart ( )
static

Initializes and starts the current handler after it has been installed with IHInstall.

This method invokes the handler's entry point with the HI_SETUP_EVENT event, which allows the handler to perform any desired initialization, such as displaying a dialog associated with the handler, if any.

Parameters can be passed to a handler by storing them in the installed handler's data storage via the SetParameter methods prior to invoking IHStart, as shown in the following example:

IHInstall( ConfirmIH )
IHSetOParameter( IH_NEW, "ok_dialog", ok_dialog );
IHSetSParameter( IH_NEW, "message", "OK to discard changes?" );
static GlgObject IHInstall(GlgIHHandlerInterface handler_interface)
Creates an interface handler with the specified handler interface and installs it.
Definition: GlgObject.java:22482
static void IHStart()
Initializes and starts the current handler after it has been installed with IHInstall.
Definition: GlgObject.java:22701
static void IHSetOParameter(GlgObject ih, String name, GlgObject value)
Creates and stores a named parameter that holds a GLG object.
Definition: GlgObject.java:23276
static void IHSetSParameter(GlgObject ih, String name, String value)
Creates and stores a named string parameter.
Definition: GlgObject.java:23251
static GlgObject IH_NEW
ID of the last installed installable interface handler.
Definition: GlgObject.java:6949

The first argument of the SetParameter methods defines the handler to add parameters to. For convenience, the IH_NEW object can be used to supply the ID of the just installed handler instead of using the handler ID returned by IHInstall, as shown in the above example.

The following shows an example of a handler code that uses parameters from the above example to initialize the handler. The handler displays a confirmation dialog with a supplied message on start up and closes it when the handler is uninstalled. An optional modal parameter specifies if the dialog is modal.

import com.genlogic.*;
import static com.genlogic.GlgObject.*;
class ConfirmIH implements GlgIHHandlerInterface
{
public void EntryPoint( GlgObject ih, GlgIHCallEvent call_event )
{
// Retrieve the OK dialog object provided as a parameter when the handler was installed.
GlgObject ok_dialog = IHGetOParameter( ih, "ok_dialog" );
GlgCallEventType event_type = IHGetType( call_event );
switch( event_type )
{
// Retrieve the dialog message provided as a parameter when the handler was installed.
String message = IHGetOptSParameter( ih, "message" );
// Display a dialog with the requested message.
ok_dialog.SetSResource( "DialogMessageString", message );
ok_dialog.SetDResource( "Visibility", 1. );
ok_dialog.Update();
break;
int token = IHGetToken( call_event );
switch( token )
{
case IH_OK:
case IH_CANCEL:
// Uninstall the handler and pass selection to the parent.
break;
default: // Some other event.
if( IHGetOptIParameter( ih, "modal_dialog", False ) )
Bell(); // Don't allow to leave in a modal mode.
else
// Uninstall the handler and pass event to the parent.
IHUninstallWithEvent( call_event );
break;
}
break;
ok_dialog.SetDResource( "Visibility", 0. ); // Erase the dialog.
ok_dialog.Update();
break;
}
}
static final int MESSAGE_EVENT
Invoked to handle tokens sent to an interface handler , or to handle messages sent to an interaction ...
Definition: GlgObject.java:7050
static final int CLEANUP_EVENT
Invoked on the handler reset.
Definition: GlgObject.java:7046
static void IHUninstallWithEvent(GlgIHCallEvent call_event)
Uninstalls the current handler and passes an event to the previous handler.
Definition: GlgObject.java:22891
static void IHUninstallWithToken(int token)
Uninstalls the current handler and passes a token to the previous handler.
Definition: GlgObject.java:22868
static int IHGetToken(GlgIHCallEvent call_event)
Returns a token associated with the MESSAGE_EVENT event.
Definition: GlgObject.java:22434
static int IHGetOptIParameter(GlgObject ih, String name, int default_value)
Returns an integer value stored in an optional named parameter.
Definition: GlgObject.java:23551
static void Bell()
Emits an audio beep.
Definition: GlgObject.java:12968

The IH_OK and IH_CANCEL tokens used in the above example are generated by the GLG Input callback that converts interface events to integer tokens for efficiency. The tokens are then passed to the currently active handler via a call to the IHCallCurrIHWithToken method.

Refer to the DEMOS_JAVA/GlgDiagram.java file in the GLG installation directory for a complete source code example.

◆ IHTerminate()

static void IHTerminate ( )
static

Terminates installable handler utilities.

All currently installed handlers must be uninstalled before invoking this method.

◆ IHUninstall()

static void IHUninstall ( )
static

Uninstalls the current handler (the last handler on the handler stack).

The handler's entry point is invoked with the CLEANUP_EVENT event prior to uninstalling to let the handler perform any required cleanup. After the handler is uninstalled, a previous handler in the handler stack (if any) becomes the current active handler. Uninstalling a handler deletes its stored data and invalidates its ID; the ID should not be used after the handler has been uninstalled.

◆ IHUninstallWithEvent()

static void IHUninstallWithEvent ( GlgIHCallEvent  call_event)
static

Uninstalls the current handler and passes an event to the previous handler.

Parameters
call_eventThe even that will be passed to the previous handler.

If a handler receives an event that is not related to the handler's logic, this method can be used to uninstall the handler and pass the event to the previous handler.

This method uninstalls the current handler using IHUninstall and passes the event to the previous handler (which becomes current after IHUninstall is invoked).

◆ IHUninstallWithToken()

static void IHUninstallWithToken ( int  token)
static

Uninstalls the current handler and passes a token to the previous handler.

Parameters
tokenThe token that will be passed to the previous handler.

The method uninstalls the handler using IHUninstall and invokes the previous handler (which becomes current after IHUninstall is invoked) with the specified token.