public abstract class WorkspaceComponent
extends java.lang.Object
Workspace
. Extend this class to create your own component type. Gui representations of
a workspace component should extend
GuiComponent
.Constructor and Description |
---|
WorkspaceComponent(java.lang.String name)
Construct a workspace component.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttributeListener(AttributeListener listener)
Adds a AttributeListener to this component.
|
void |
addConsumerType(AttributeType type)
Add a new type of consumer.
|
void |
addProducerType(AttributeType type)
Add a new type of producer.
|
void |
addWorkspaceComponentListener(WorkspaceComponentListener listener)
Adds a WorkspaceComponentListener to this component.
|
void |
close()
Closes the WorkspaceComponent.
|
protected abstract void |
closing()
Perform cleanup after closing.
|
void |
couplingAdded(Coupling<?> coupling)
Called when a coupling is attached to this component.
|
void |
couplingRemoved(Coupling<?> coupling)
Called when a coupling attached to this component is removed.
|
(package private) void |
doStopped()
Called after a global update ends.
|
void |
fireAttributeObjectRemoved(java.lang.Object object)
Fire attribute object removed event (when the base object of an attribute
is removed).
|
void |
fireAttributeTypeVisibilityChanged(AttributeType type)
Fire attribute type visibility changed event.
|
void |
fireComponentToggleEvent()
Notify all workspaceComponentListeners of a component has been turned on
or off.
|
void |
fireGuiToggleEvent()
Notify all workspaceComponentListeners that the gui has been turned on or
off.
|
void |
firePotentialAttributesChanged()
Fire potential attributes changed event.
|
void |
fireUpdateEvent()
Notify all workspaceComponentListeners of a componentUpdated event.
|
AttributeManager |
getAttributeManager() |
java.util.List<AttributeType> |
getConsumerTypes() |
java.io.File |
getCurrentFile() |
java.lang.String |
getDefaultFormat()
The file extension for a component type, e.g.
|
java.util.List<? extends java.lang.String> |
getFormats()
Returns a list of the formats that this component supports.
|
java.lang.String |
getKeyFromObject(java.lang.Object object)
Returns a unique key associated with an object.
|
java.util.Collection<? extends java.lang.Object> |
getLocks()
Returns the locks for the update parts.
|
org.apache.log4j.Logger |
getLogger() |
java.lang.String |
getName()
Returns the name of this component.
|
java.lang.Object |
getObjectFromKey(java.lang.String objectKey)
Finds objects based on a key.
|
java.util.List<PotentialConsumer> |
getPotentialConsumers()
Return the potential consumers associated with this component.
|
java.util.List<PotentialProducer> |
getPotentialProducers()
Return the potential producers associated with this component.
|
java.util.List<AttributeType> |
getProducerTypes() |
protected int |
getSerializePriority() |
java.lang.String |
getSimpleName()
Retrieves a simple version of a component name from its class, e.g.
|
java.lang.Boolean |
getUpdateOn() |
java.util.Collection<ComponentUpdatePart> |
getUpdateParts()
Returns the collection of update parts for this component.
|
java.util.List<AttributeType> |
getVisibleConsumerTypes()
Return visible consumer types.
|
java.util.List<AttributeType> |
getVisibleProducerTypes()
Return visible producer types.
|
Workspace |
getWorkspace()
Returns the workspace associated with this component.
|
java.util.Collection<WorkspaceComponentListener> |
getWorkspaceComponentListeners()
Returns the WorkspaceComponentListeners on this component.
|
java.lang.String |
getXML()
Override for use with open service.
|
boolean |
hasChangedSinceLastSave()
Returns true if it's changed since the last save.
|
java.lang.Boolean |
isGuiOn() |
void |
removeAttributeListener(AttributeListener listener)
Removes an AttributeListener from this component.
|
void |
removeWorkspaceComponentListener(WorkspaceComponentListener listener)
Adds a WorkspaceComponentListener to this component.
|
abstract void |
save(java.io.OutputStream output,
java.lang.String format)
Used when saving a workspace.
|
void |
setChangedSinceLastSave(boolean changedSinceLastSave)
Set to true when a component changes, set to false after a component is
saved.
|
void |
setCurrentFile(java.io.File currentFile) |
void |
setGuiOn(java.lang.Boolean guiOn) |
void |
setLogger(org.apache.log4j.Logger logger) |
void |
setName(java.lang.String name) |
protected void |
setSerializePriority(int serializePriority) |
void |
setUpdateOn(java.lang.Boolean updateOn) |
void |
setWorkspace(Workspace workspace)
Sets the workspace for this component.
|
protected void |
stopped()
Called by Workspace to notify that updates have stopped.
|
java.lang.String |
toString() |
void |
update()
Called by Workspace to update the state of the component.
|
public WorkspaceComponent(java.lang.String name)
name
- The name of the component.public abstract void save(java.io.OutputStream output, java.lang.String format)
output
- the stream of data to write the data to.format
- a key used to define the requested format.public java.util.List<? extends java.lang.String> getFormats()
The default behavior is to return an empty list. This means that there is one format.
public void close()
protected abstract void closing()
public void update()
public java.util.List<PotentialConsumer> getPotentialConsumers()
public java.util.List<PotentialProducer> getPotentialProducers()
public void fireAttributeObjectRemoved(java.lang.Object object)
object
- the object which was removedpublic void firePotentialAttributesChanged()
public void fireAttributeTypeVisibilityChanged(AttributeType type)
type
- the type whose visibility changed.public void addAttributeListener(AttributeListener listener)
listener
- the AttributeListener to add.public void removeAttributeListener(AttributeListener listener)
listener
- the AttributeListener to remove.public void addProducerType(AttributeType type)
type
- type to addpublic void addConsumerType(AttributeType type)
type
- type to addpublic java.lang.Object getObjectFromKey(java.lang.String objectKey)
objectKey
- String keypublic java.lang.String getKeyFromObject(java.lang.Object object)
object
- object which should be associated with a keypublic java.util.Collection<ComponentUpdatePart> getUpdateParts()
public java.util.Collection<? extends java.lang.Object> getLocks()
protected void stopped()
public final void fireUpdateEvent()
public final void fireGuiToggleEvent()
public final void fireComponentToggleEvent()
final void doStopped()
public java.util.Collection<WorkspaceComponentListener> getWorkspaceComponentListeners()
public void addWorkspaceComponentListener(WorkspaceComponentListener listener)
listener
- the WorkspaceComponentListener to add.public void removeWorkspaceComponentListener(WorkspaceComponentListener listener)
listener
- the WorkspaceComponentListener to add.public java.lang.String getName()
public java.lang.String toString()
toString
in class java.lang.Object
public void setName(java.lang.String name)
name
- the name to setpublic java.lang.String getSimpleName()
public java.lang.String getXML()
public void setWorkspace(Workspace workspace)
workspace
- The workspace for this component.public Workspace getWorkspace()
public void couplingRemoved(Coupling<?> coupling)
coupling
- The coupling that has been removed.public void couplingAdded(Coupling<?> coupling)
coupling
- The coupling that is being addedpublic java.lang.String getDefaultFormat()
public void setChangedSinceLastSave(boolean changedSinceLastSave)
changedSinceLastSave
- whether this component has changed since the
last save.public boolean hasChangedSinceLastSave()
public java.io.File getCurrentFile()
public void setCurrentFile(java.io.File currentFile)
currentFile
- the currentFile to setpublic org.apache.log4j.Logger getLogger()
public void setLogger(org.apache.log4j.Logger logger)
logger
- the logger to setpublic java.lang.Boolean isGuiOn()
public void setGuiOn(java.lang.Boolean guiOn)
guiOn
- the guiOn to setpublic java.lang.Boolean getUpdateOn()
public void setUpdateOn(java.lang.Boolean updateOn)
updateOn
- the updateOn to setpublic java.util.List<AttributeType> getProducerTypes()
public java.util.List<AttributeType> getConsumerTypes()
public java.util.List<AttributeType> getVisibleProducerTypes()
public java.util.List<AttributeType> getVisibleConsumerTypes()
public AttributeManager getAttributeManager()
protected int getSerializePriority()
protected void setSerializePriority(int serializePriority)
serializePriority
- the serializePriority to set