public class TLcyWorkspaceManager extends Object implements ILcdPropertyChangeSource
ALcyWorkspaceCodec
ALcyWorkspaceCodecDelegate
s
ALcyWorkspaceObjectCodec
s
canEncodeWorkspace(String)
and encodeWorkspace(String)
.
To decode a workspace, use canDecodeWorkspace(String)
and decodeWorkspace(String)
.
One can be notified when the workspace encoding/decoded starts/ends by using
addWorkspaceManagerListener(ILcyWorkspaceManagerListener)
.
Furthermore, this TLcyWorkspaceManager
stores whether the workspace has been changed
since it was last encoded/decoded. It is the responsibility of the
ALcyWorkspaceCodecDelegate
s and ALcyWorkspaceObjectCodec
s to inform the
TLcyWorkspaceManager
that the workspace has changed by using
notifyWorkspaceChanged()
.Constructor and Description |
---|
TLcyWorkspaceManager(ILcyLucyEnv aLucyEnv)
Creates a new
TLcyWorkspaceManager . |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
Registers the given
PropertyChangeListener to be notified when this object's
properties change. |
void |
addWorkspaceCodecDelegate(ALcyWorkspaceCodecDelegate aDelegate)
Registers a
ALcyWorkspaceCodecDelegate to the framework. |
void |
addWorkspaceManagerListener(ILcyWorkspaceManagerListener aListener)
Adds a workspace manager listener.
|
void |
addWorkspaceObjectCodec(ALcyWorkspaceObjectCodec aObjectCodec)
Registers a
ALcyWorkspaceObjectCodec to the framework. |
boolean |
canDecodeWorkspace(String aSourceName)
Returns true if the set
ALcyWorkspaceCodec returns true for ALcyWorkspaceCodec.canDecodeWorkspace(String) . |
boolean |
canDecodeWorkspace(String aSourceName,
List<String> aReasonsSFCT)
Returns true if the set
ALcyWorkspaceCodec returns true
for ALcyWorkspaceCodec.canDecodeWorkspace(String, List) . |
boolean |
canEncodeWorkspace(String aDestinationName)
Returns true if the set
ALcyWorkspaceCodec returns true for ALcyWorkspaceCodec.canEncodeWorkspace(String) . |
void |
decodeWorkspace(String aSourceName)
Decodes the workspace using
ALcyWorkspaceCodec.decodeWorkspace(String) of the set
ALcyWorkspaceCodec . |
void |
encodeWorkspace(String aDestinationName)
Encodes the workspace using
ALcyWorkspaceCodec.encodeWorkspace(String) of the set
ALcyWorkspaceCodec . |
ALcyWorkspaceCodec |
getWorkspaceCodec()
Returns the
ALcyWorkspaceCodec . |
ALcyWorkspaceCodecDelegate |
getWorkspaceCodecDelegate(int aIndex)
Returns the
ALcyWorkspaceCodecDelegate at the given index. |
int |
getWorkspaceCodecDelegateCount()
Returns the amount of registered
ALcyWorkspaceCodecDelegate s. |
ALcyWorkspaceObjectCodec |
getWorkspaceObjectCodec(int aIndex)
Returns the
ALcyWorkspaceObjectCodec at the given index. |
int |
getWorkspaceObjectCodecCount()
Returns the amount of registered
ALcyWorkspaceObjectCodec s. |
String |
getWorkspaceStorageName()
Short for
ALcyWorkspaceCodec.getWorkspaceStorageName() . |
boolean |
isDecodingWorkspace()
Returns true if a workspace is currently being decoded, false otherwise.
|
boolean |
isEncodingWorkspace()
Returns true if a workspace is currently being encoded, false otherwise.
|
boolean |
isWorkspaceChanged()
Returns true if the workspace has changed since the last encoding/decoding.
|
void |
notifyWorkspaceChanged()
Use this method to notify that the workspace has changed
since the last encoding/decoding.
|
void |
removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
De-registers the given
PropertyChangeListener from receiving property change events
for this object. |
void |
removeWorkspaceCodecDelegate(ALcyWorkspaceCodecDelegate aDelegate)
Unregisters the given
ALcyWorkspaceCodecDelegate from the framework. |
void |
removeWorkspaceManagerListener(ILcyWorkspaceManagerListener aListener)
Removes the given
ILcyWorkspaceManagerListener , it will no longer receive any
events. |
void |
removeWorkspaceObjectCodec(ALcyWorkspaceObjectCodec aObjectCodec)
Unregisters the given
ALcyWorkspaceObjectCodec from the framework. |
void |
setWorkspaceChanged(boolean aWorkspaceChanged)
Sets the workspace changed status.
|
void |
setWorkspaceCodec(ALcyWorkspaceCodec aWorkspaceCodec)
Sets the
ALcyWorkspaceCodec . |
public TLcyWorkspaceManager(ILcyLucyEnv aLucyEnv)
TLcyWorkspaceManager
. This constructor must not be used, instead
the TLcyWorkspaceManager
must be retrieved using ILcyLucyEnv.getWorkspaceManager()
.aLucyEnv
- The lucy environment.public void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
ILcdPropertyChangeSource
Registers the given PropertyChangeListener
to be notified when this object's
properties change.
In case you need to register a listener which keeps a reference to an object with a shorter life-time than this change source,
you can use a ALcdWeakPropertyChangeListener
instance as property change listener.
addPropertyChangeListener
in interface ILcdPropertyChangeSource
aPropertyChangeListener
- The listener to be notifiedALcdWeakPropertyChangeListener
,
ILcdPropertyChangeSource.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
ILcdPropertyChangeSource
De-registers the given PropertyChangeListener
from receiving property change events
for this object.
If the listener was added more than once, it will be notified one less time after being
removed.
If the listener is null
, or was never added, no exception is thrown and no action is taken.
removePropertyChangeListener
in interface ILcdPropertyChangeSource
aPropertyChangeListener
- the listener that should no longer be notified of changes of
this object's propertiesILcdPropertyChangeSource.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void addWorkspaceManagerListener(ILcyWorkspaceManagerListener aListener)
isEncodingWorkspace()
or isDecodingWorkspace()
.aListener
- The listener to add.removeWorkspaceManagerListener(ILcyWorkspaceManagerListener)
public void removeWorkspaceManagerListener(ILcyWorkspaceManagerListener aListener)
ILcyWorkspaceManagerListener
, it will no longer receive any
events. Does nothing if the given listener was never added or already removed.aListener
- The listener to removeaddWorkspaceManagerListener(ILcyWorkspaceManagerListener)
public void addWorkspaceCodecDelegate(ALcyWorkspaceCodecDelegate aDelegate)
ALcyWorkspaceCodecDelegate
to the framework. When a workspace is
encoded/decoded, the given aDelegate will be asked to encode/decode part of it.aDelegate
- The ALcyWorkspaceCodecDelegate
to register.ALcyWorkspaceCodecDelegate
public void removeWorkspaceCodecDelegate(ALcyWorkspaceCodecDelegate aDelegate)
ALcyWorkspaceCodecDelegate
from the framework. It will no longer
be part of workspace encoding/decoding.aDelegate
- The ALcyWorkspaceCodecDelegate
to remove.ALcyWorkspaceCodecDelegate
public int getWorkspaceCodecDelegateCount()
ALcyWorkspaceCodecDelegate
s.ALcyWorkspaceCodecDelegate
s.public ALcyWorkspaceCodecDelegate getWorkspaceCodecDelegate(int aIndex)
ALcyWorkspaceCodecDelegate
at the given index.aIndex
- The index to get the ALcyWorkspaceCodecDelegate
for.ALcyWorkspaceCodecDelegate
at the given index.public void addWorkspaceObjectCodec(ALcyWorkspaceObjectCodec aObjectCodec)
ALcyWorkspaceObjectCodec
to the framework. When the ALcyWorkspaceCodec
needs to encode an object reference, it might ask this aObjectCodec to do it, depending
on what aObjectCodec.canEncodeObject
returns.aObjectCodec
- The ALcyWorkspaceObjectCodec
to register.ALcyWorkspaceObjectCodec
public void removeWorkspaceObjectCodec(ALcyWorkspaceObjectCodec aObjectCodec)
ALcyWorkspaceObjectCodec
from the framework. It will no longer
be part of workspace encoding/decoding.aObjectCodec
- The ALcyWorkspaceObjectCodec
to remove.ALcyWorkspaceObjectCodec
public int getWorkspaceObjectCodecCount()
ALcyWorkspaceObjectCodec
s.ALcyWorkspaceObjectCodec
s.public ALcyWorkspaceObjectCodec getWorkspaceObjectCodec(int aIndex)
ALcyWorkspaceObjectCodec
at the given index.aIndex
- The index to get the ALcyWorkspaceObjectCodec
for.ALcyWorkspaceObjectCodec
at the given index.public ALcyWorkspaceCodec getWorkspaceCodec()
ALcyWorkspaceCodec
. By default an ALcyWorkspaceCodec
is returned that stores the workspace to a file.ALcyWorkspaceCodec
.setWorkspaceCodec(ALcyWorkspaceCodec)
public void setWorkspaceCodec(ALcyWorkspaceCodec aWorkspaceCodec)
ALcyWorkspaceCodec
. This default ALcyWorkspaceCodec
that writes
to a file can be replaced with a custom one. This allows to implement e.g. a
ALcyWorkspaceCodec
that writes to a database.aWorkspaceCodec
- The ALcyWorkspaceCodec
to use.getWorkspaceCodec()
public boolean isDecodingWorkspace()
addWorkspaceManagerListener(ILcyWorkspaceManagerListener)
.public boolean isEncodingWorkspace()
addWorkspaceManagerListener(ILcyWorkspaceManagerListener)
.public boolean isWorkspaceChanged()
Returns true if the workspace has changed since the last encoding/decoding. It is the
responsibility of the ALcyWorkspaceCodecDelegate
s and the ALcyWorkspaceObjectCodec
s to use notifyWorkspaceChanged()
to inform about changes
in the workspace. A property change event informs about changes to this value.
A typical use of this property would be to inform an end user that changes were made to the workspace, before loading another workspace or quiting the application.
notifyWorkspaceChanged()
public void setWorkspaceChanged(boolean aWorkspaceChanged)
true
can
also be done using notifyWorkspaceChanged()
. Setting the status to false
usually isn't needed, as the workspace changed flag is automatically updated when loading or
saving a workspace.
Sends a property change event if the result of isWorkspaceChanged()
has changed.aWorkspaceChanged
- True to set the workspace to 'changed', false otherwise.public void notifyWorkspaceChanged()
Use this method to notify that the workspace has changed
since the last encoding/decoding. This is equivalent to calling
setWorkspaceChanged(boolean)
with true
.
It is the responsibility of the ALcyWorkspaceCodecDelegate
s and the ALcyWorkspaceObjectCodec
s to use this method.
Sends a property change event if the result of isWorkspaceChanged()
has changed.
public String getWorkspaceStorageName()
ALcyWorkspaceCodec.getWorkspaceStorageName()
.
A property change event informs about changes to this value.public boolean canEncodeWorkspace(String aDestinationName)
ALcyWorkspaceCodec
returns true for ALcyWorkspaceCodec.canEncodeWorkspace(String)
.aDestinationName
- The destination name to check.ALcyWorkspaceCodec
returns true for ALcyWorkspaceCodec.canEncodeWorkspace(String)
.public void encodeWorkspace(String aDestinationName) throws IOException, TLcyWorkspaceAbortedException
ALcyWorkspaceCodec.encodeWorkspace(String)
of the set
ALcyWorkspaceCodec
.
Fires an event with id TLcyWorkspaceManagerEvent.STARTING_WORKSPACE_ENCODING
before actually encoding the workspace. Fires an event with id TLcyWorkspaceManagerEvent.WORKSPACE_ENCODING_ENDED
after the workspace is encoded.aDestinationName
- The destination name to encode to.IOException
- In case of fatal IO failure.TLcyWorkspaceAbortedException
- In case the operation is aborted, e.g. because the user canceled it.public boolean canDecodeWorkspace(String aSourceName)
ALcyWorkspaceCodec
returns true for ALcyWorkspaceCodec.canDecodeWorkspace(String)
.aSourceName
- The source name to check.ALcyWorkspaceCodec
returns true for ALcyWorkspaceCodec.canDecodeWorkspace(String)
.public boolean canDecodeWorkspace(String aSourceName, List<String> aReasonsSFCT)
ALcyWorkspaceCodec
returns true
for ALcyWorkspaceCodec.canDecodeWorkspace(String, List)
.aSourceName
- The source name to checkaReasonsSFCT
- A side-effect parameter to which this method may add reasons on why it returned true
or false
ALcyWorkspaceCodec
returns true
for ALcyWorkspaceCodec.canDecodeWorkspace(String, List)
.public void decodeWorkspace(String aSourceName) throws IOException, TLcyWorkspaceAbortedException
ALcyWorkspaceCodec.decodeWorkspace(String)
of the set
ALcyWorkspaceCodec
.
Fires an event with id TLcyWorkspaceManagerEvent.STARTING_WORKSPACE_DECODING
before actually decoding the workspace. Fires an event with id TLcyWorkspaceManagerEvent.WORKSPACE_DECODING_ENDED
after the workspace is decoded.aSourceName
- The source name to decode from.IOException
- In case of fatal IO failure.TLcyWorkspaceAbortedException
- In case the operation is aborted, e.g. because the user canceled it.