|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.droplets.client.ComponentAdapter
Adapter class to encapsulate an AWT Component
so the
Droplets Client can use it as a custom component.
A custom component for the Droplets Platform is implemented in three classes:
Component
that will be loaded and run by the
Droplets ClientComponent
and the Droplets ClientCustomComponent
The first two classes are loaded by the Droplets Client, and need to be installed in a zip file in the DropletsComponent folder.
The third class, the server-side proxy, is deployed on the server.
The ComponentAdapter
class is loaded by the Droplets Client,
and is responsible for handling the communications between the AWT Component,
and the Droplets Client. None of the com.droplets.api
classes
are available to the ComponentAdapter
.
If the ComponentAdapter
is not installed on the client machine,
a default ComponentAdapter
will be created, displaying a cyan
box with a black X through it. An error dialog will also be displayed.
Because the ComponentAdapter
and its associated classes are
run on the client machine, the developer must handle all of the unpleasant
porting issues that the Droplets Platform normally shelters developers
from.
When developing for Microsoft Windows, the ComponentAdapter
and
associated classes should be built with JDK 1.1.8, with the
dropletcc.zip
library added to the classpath. The resulting class
files should be placed into a zip file (not a jar).
The resulting zip file should be installed in the Components
directory, which is itself in the same directory as the DropletClient.
Constructor Summary | |
protected |
ComponentAdapter()
Constructs the ComponentAdapter. |
Method Summary | |
abstract boolean |
canStart(java.lang.String hostname,
java.lang.String application,
boolean isSecure)
Checks to see if the AWT Component should be created. |
abstract java.awt.Component |
getAwtComponent()
Get the AWT Component that this CustomComponent is implementing. |
java.awt.Image |
getImage(java.lang.String imageName)
Gets an Image, either from the Droplet Application's image jar, image directory, or an arbitrary URL. |
java.lang.String |
getParameter(java.lang.String parameterName,
java.lang.String defaultValue)
Gets a parameter from the params.txt file in the
Droplet Application's image directory. |
java.lang.String |
getVar(java.lang.String varName,
java.lang.String defaultValue)
Gets a value from the vars tag in Droplet DRP file, or the
Applet tags. |
void |
onCustomAction(java.lang.String actionName,
java.lang.String actionArgs)
Template method called by the Droplets Client when a custom action has been recieved. |
void |
onCustomAttributeChanged(java.lang.String attributeName,
java.lang.String attributeValue)
Template method called by the Droplets Client when a custom attribute has been changed. |
void |
sendCustomAction(java.lang.String actionName,
java.lang.String actionArgs)
Sends a custom action, notifying the server's CustomComponent object. |
void |
setCustomAttribute(java.lang.String attributeName,
java.lang.String attributeValue)
Sets a custom attribute, and notifies the server's CustomComponent object. |
void |
setServices(ComponentServices services)
Sets the ComponentServices for this ComponentAdapter. |
void |
start()
Initializes the ComponentAdapter, and creates the AWT Component that the adapter is providing. |
boolean |
waitForImage(java.awt.Image image,
boolean widthAndHeightOnly)
Waits until an Image previously returned by getImage
has actually loaded. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected ComponentAdapter()
start()
method.
All subclasses are required to have a default public constructor.
Method Detail |
public final void setServices(ComponentServices services)
canStart(java.lang.String, java.lang.String, boolean)
method.
services
- The ComponentServices for this ComponentAdapterpublic abstract boolean canStart(java.lang.String hostname, java.lang.String application, boolean isSecure)
Because custom components can contain any code, care should be taken to avoid exposing potentially dangerous behaviors to unknown servers.
hostname
- The hostname of the Droplets Server.application
- The name of the Droplet Application.isSecure
- true
if the connection is
secure (SSL, HTTPS), false
otherwise.true
if the AWT Component should be
created, false
otherwise.public void start()
public abstract java.awt.Component getAwtComponent()
public void onCustomAttributeChanged(java.lang.String attributeName, java.lang.String attributeValue)
This method is called in response to
CustomComponent.setStringCustomAttribute(java.lang.String, java.lang.String, java.lang.String)
. Attributes
are subject to skinning, so the value sent from the server-side proxy
may have been overridden by the params.txt
file.
attributeName
- The name of the custom attributeattributeValue
- The new value of the custom attributeCustomComponent.setStringCustomAttribute(java.lang.String, java.lang.String, java.lang.String)
public void onCustomAction(java.lang.String actionName, java.lang.String actionArgs)
actionName
- The name of the actionactionArgs
- Any additional arguments for the action.public java.awt.Image getImage(java.lang.String imageName)
If the imageName
unqualified name, such as myimage
,
this method will load myimage.gif
from the image jar,
or the image directory if there is no image jar.
If the imageName
is a URL, the image will be loaded from
that URL. The Droplets Redirector will be used, so it is safe to call
this method from within an applet.
imageName
- The name or URL of the imagenull
if the image cannot
be loadedpublic java.lang.String getParameter(java.lang.String parameterName, java.lang.String defaultValue)
params.txt
file in the
Droplet Application's image directory.
parameterName
- The name of the parameterdefaultValue
- The default valuepublic java.lang.String getVar(java.lang.String varName, java.lang.String defaultValue)
vars
tag in Droplet DRP file, or the
Applet tags.
varName
- The name of the vardefaultValue
- The default valuepublic boolean waitForImage(java.awt.Image image, boolean widthAndHeightOnly)
getImage
has actually loaded. Call this method when you are ready to draw the
image, or need to get its width or height. This method is provided as
a convenience for components that do not want to use Java's standard
asynchronous image-loading behavior.image
- The imagewidthAndHeightOnly
- True if you only need the width and height
at this point; false if you need the entire image to be readypublic final void setCustomAttribute(java.lang.String attributeName, java.lang.String attributeValue)
attributeName
- The name of the attributesttributeValue
- The new value for the attributepublic final void sendCustomAction(java.lang.String actionName, java.lang.String actionArgs)
actionName
- The name of the actionactionArgs
- Any additional arguments for the action
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |