com.wirefusion.project
Class WobProperties

java.lang.Object
  extended by com.wirefusion.project.WobProperties
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public abstract class WobProperties
extends java.lang.Object
implements java.io.Externalizable

If you want your Wob to be configurable in the WireFusion Designer, then create a subclass of this class. This class has for example the responsibility of the Properties GUI of the object (seen when selecting the Wob in WireFusion Designer), reading and writing the current configuration of the Wob to the project file and also for writing the configuration to the data file read by the corresponding player object.

See Also:
Serialized Form

Field Summary
static int LOAD_AS_CLASS_LIBRARY
          A resource file loading mode.
static int LOAD_BEFORE_START
          A resource file loading mode.
static int LOAD_ON_REQUEST
          A resource file loading mode.
 
Method Summary
 java.io.File addPlayerResource(java.io.File resourceFile, java.lang.String resourceId, boolean addChecksumToFilename, int loadingMode)
          Adds a player resource to this Wob.
 java.io.File addPlayerResource(java.lang.String filenameOfResourceInWobFolder, java.lang.String resourceId, int loadingMode)
          Adds a player resource to this Wob.
 java.io.File addProjectResource(java.io.File resourceFile, java.lang.String resourceId, boolean addChecksumToFilename)
          Adds a project resource to this Wob.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds a ChangeListener to this object.
 WobPort createPort(java.lang.String portId)
          Creates and adds a port that is configured according to its corresponding port template in config.xml.
 void destroyPropertyEditorCollection(PropertyEditorCollection propertyEditorCollection)
          Many subclasses of WobProperties implements the PropertyEditorCollectionFactory interface, which contains the two methods createPropertyEditorCollection and destroyPropertyEditorCollection.
 void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Notifies all listeners that have registered interest for notification on this event type.
 java.io.File getFileInWobFolder(java.lang.String resourceName)
          Returns a resource located in the Wob Folder (the same folder that contains the config.xml file)
 java.io.File getPlayerResourceById(java.lang.String resourceId)
          Returns the resource file with the given resource ID, or null if no resource with the given ID exists.
 WobPort getPort(java.lang.String portId)
          Returns the created port with the specified id.
 java.util.Enumeration getPorts()
          Returns an enumeration all the ports (WobPort) of this Wob.
 java.io.File getProjectResourceById(java.lang.String resourceId)
          Returns the dependency file with the given dependency ID, or null if no dependency with the given ID exists.
 double getSerializedWobVersion()
          This method can be called from inside the readExternal method of WobProperties objects.
 TargetArea getTargetArea()
          Returns the Target Area of this Wob, or null if it doesn't have a Target Area.
 WfUndoManager getUndoManager()
          Returns the Undo Manager
 java.lang.String getWobName()
          Returns the current label of the Wob, as specified by the user in the Script area.
 void init()
          This method is always executed when a wob is loaded (from a project file, a .wob file or when it is dragged in from the Wob library).
 void openDialog()
          This method is called when the Wob is double clicked.
 void readExternal(java.io.ObjectInput in)
          Override to load the current state of the object from the project data file.
 void removePlayerResourceById(java.lang.String dependencyId)
          Removes a player resource.
 void removeProjectResourceById(java.lang.String dependencyId)
          Removes a project resource.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes a ChangeListener from this object.
 java.lang.String toString()
          Override if you want the WireFusion Designer to be able to present a string representing the objects state (in the Details view in the Script area for example).
 void updatePropertyEditors()
          Updates all property editors associated with this Wob by destroying them and recreating them.
abstract  void writeData(java.io.DataOutputStream dos)
          Override to write the data that the corresponding Wob object will read in its readData method.
 void writeExternal(java.io.ObjectOutput out)
          Override to save the current state of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOAD_ON_REQUEST

public static final int LOAD_ON_REQUEST
A resource file loading mode. Indicates that the resource should not be downloaded until it is requested

See Also:
Constant Field Values

LOAD_BEFORE_START

public static final int LOAD_BEFORE_START
A resource file loading mode. Indicates that the resource should be downloaded before the presentation is started. The resource will be available in the Resource Manager and users can later switch loading mode between "Preloaded" (this mode) and "Streamed".

See Also:
Constant Field Values

LOAD_AS_CLASS_LIBRARY

public static final int LOAD_AS_CLASS_LIBRARY
A resource file loading mode. The file will be loaded as a class library and the classes in the library will be available to the player. Only applicable to JAR and ZIP files.

See Also:
Constant Field Values
Method Detail

init

public void init()
This method is always executed when a wob is loaded (from a project file, a .wob file or when it is dragged in from the Wob library). When init is called, the parent/children structure and ports have already been constructed and is accessible. If the object is read from a project or .wob file, readExternal() has been called before init is called.


toString

public java.lang.String toString()
Override if you want the WireFusion Designer to be able to present a string representing the objects state (in the Details view in the Script area for example). En empty string is returned by default.

Overrides:
toString in class java.lang.Object
Returns:
a string representing the current state/value of the object

writeExternal

public void writeExternal(java.io.ObjectOutput out)
Override to save the current state of the object. In the overridden method you must call super.writeExternal(out) before performing any write operations.

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - The ObjectOutput object
See Also:
Externalizable.writeExternal(ObjectOutput)

readExternal

public void readExternal(java.io.ObjectInput in)
Override to load the current state of the object from the project data file. In the overridden method, you must call super.readExternal(in) before performing any write operations.

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - The ObjectInput object
See Also:
Externalizable.readExternal(ObjectInput)

writeData

public abstract void writeData(java.io.DataOutputStream dos)
Override to write the data that the corresponding Wob object will read in its readData method.

Parameters:
dos - a DataOutputStream

openDialog

public void openDialog()
This method is called when the Wob is double clicked. It can be used for opening a custom dialog. It will not be called if you have specified a WobPropertiesPanel for this Wob.


getUndoManager

public WfUndoManager getUndoManager()
Returns the Undo Manager

Returns:
the Undo Manager

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a ChangeListener to this object.

Parameters:
l - the listener to be added

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes a ChangeListener from this object.

Parameters:
l - the listener to be removed

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

See Also:
EventListenerList

addPlayerResource

public java.io.File addPlayerResource(java.io.File resourceFile,
                                      java.lang.String resourceId,
                                      boolean addChecksumToFilename,
                                      int loadingMode)
Adds a player resource to this Wob. The file will, after it has been added, be available to the player Wob through the getResourceById method. You will most likely want a checksum to be added to the filename, otherwise you may get problem if two different files with the same filename is selected by a user.

Parameters:
resourceFile - a File
resourceId - You must give the resource an id that is unique among the player and project resources of this Wob.
addChecksumToFilename - true if a checksum should be added to the filename, otherwise false.
loadingMode - Specifies how the resource should be loaded into the player. Choose between the WobProperties constants LOAD_ON_REQUEST, LOAD_BEFORE_START and LOAD_AS_CLASS_LIBRARY.
Returns:
a resource file. It will have a different name (if checksum added) and location than the original file.

addPlayerResource

public java.io.File addPlayerResource(java.lang.String filenameOfResourceInWobFolder,
                                      java.lang.String resourceId,
                                      int loadingMode)
Adds a player resource to this Wob. The file will, after it has been added, be available to the player Wob through the getResourceById method. The file must exist in the Wob folder. The file will not be saved in the project file, instead the project assumes the file will be available in the Wob folder the next time it is loaded, so to preserve backward compatibility, make sure to include the file in future versions of the Wob.

Parameters:
filenameOfResourceInWobFolder - the name of a resource file located in the Wob folder (do not include the path).
resourceId - You must give the resource an id that is unique among the player and project resources of this Wob.
loadingMode - Specifies how the resource should be loaded into the player. Choose between the WobProperties constants LOAD_ON_REQUEST, LOAD_BEFORE_START and LOAD_AS_CLASS_LIBRARY.
Returns:
a resource file

addProjectResource

public java.io.File addProjectResource(java.io.File resourceFile,
                                       java.lang.String resourceId,
                                       boolean addChecksumToFilename)
Adds a project resource to this Wob. The file will, after it has been added, be available in this project. It will not be available to the player Wob. You will most likely want a checksum to be added to the file name, otherwise you may get problem if two different files with the same filename is selected by a user.

Parameters:
resourceFile - a File
resourceId - You must give the resource an id that is unique among the player and project resources of this Wob.
addChecksumToFilename - true if a checksum should be added to the filename, otherwise false.
Returns:
a resource file. It will have a different name (if checksum added) and location than the original file.

getPlayerResourceById

public java.io.File getPlayerResourceById(java.lang.String resourceId)
Returns the resource file with the given resource ID, or null if no resource with the given ID exists.

Parameters:
resourceId - A resource id.
Returns:
the resource file with the given resource ID, or null if no resource with the given ID exists.

getProjectResourceById

public java.io.File getProjectResourceById(java.lang.String resourceId)
Returns the dependency file with the given dependency ID, or null if no dependency with the given ID exists.

Parameters:
resourceId - A dependency id.
Returns:
the dependency file with the given dependency ID, or null if no dependency with the given ID exists.

removePlayerResourceById

public void removePlayerResourceById(java.lang.String dependencyId)
Removes a player resource.

Parameters:
dependencyId - The id of the resource to remove

removeProjectResourceById

public void removeProjectResourceById(java.lang.String dependencyId)
Removes a project resource.

Parameters:
dependencyId - The id of the resource to remove

createPort

public WobPort createPort(java.lang.String portId)
Creates and adds a port that is configured according to its corresponding port template in config.xml. Note that ports are automatically created if specified in config.xml (if the autocreate attribute of the port element has not been specified as "false").

Parameters:
portId - the port id
Returns:
the port

getPort

public WobPort getPort(java.lang.String portId)
Returns the created port with the specified id. If multiple ports have the same id, then and arbitrary port of these ports will be returned.

Parameters:
portId -
Returns:
the port with the specified id or null if no matching port is found.

getPorts

public java.util.Enumeration getPorts()
Returns an enumeration all the ports (WobPort) of this Wob.

Returns:
an enumeration of all created ports of this Wob.

getFileInWobFolder

public java.io.File getFileInWobFolder(java.lang.String resourceName)
Returns a resource located in the Wob Folder (the same folder that contains the config.xml file)

Parameters:
resourceName - the resource name.
Returns:
a File object.

getSerializedWobVersion

public double getSerializedWobVersion()
This method can be called from inside the readExternal method of WobProperties objects. It returns the version the Wob had when it was previously saved. It is usefull for maintaining backwards compatibility when you change the "fileformat" in new versions of a wob and its readExternal/writeExternal methods change.

Returns:
the version of the Wob being loaded

getWobName

public java.lang.String getWobName()
Returns the current label of the Wob, as specified by the user in the Script area.

Returns:
the current label of the Wob

getTargetArea

public TargetArea getTargetArea()
Returns the Target Area of this Wob, or null if it doesn't have a Target Area.


destroyPropertyEditorCollection

public void destroyPropertyEditorCollection(PropertyEditorCollection propertyEditorCollection)
Many subclasses of WobProperties implements the PropertyEditorCollectionFactory interface, which contains the two methods createPropertyEditorCollection and destroyPropertyEditorCollection. This is an implementation of the destroyPropertyEditorCollection method, so that subclasses wont have to implement this method.

Parameters:
propertyEditorCollection -

updatePropertyEditors

public void updatePropertyEditors()
Updates all property editors associated with this Wob by destroying them and recreating them. Can be usefull if the existence the property editor for a property depends on another property.