Class TLcyWorkspaceManager
- All Implemented Interfaces:
ILcdPropertyChangeSource
- accounting the
ALcyWorkspaceCodec
- accounting the registered
ALcyWorkspaceCodecDelegate
s - accounting the registered
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 Summary
ConstructorDescriptionTLcyWorkspaceManager
(ILcyLucyEnv aLucyEnv) Creates a newTLcyWorkspaceManager
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(PropertyChangeListener aPropertyChangeListener) Registers the givenPropertyChangeListener
to be notified when this object's properties change.void
Registers aALcyWorkspaceCodecDelegate
to the framework.void
Adds a workspace manager listener.void
addWorkspaceObjectCodec
(ALcyWorkspaceObjectCodec aObjectCodec) Registers aALcyWorkspaceObjectCodec
to the framework.boolean
canDecodeWorkspace
(String aSourceName) Returns true if the setALcyWorkspaceCodec
returns true forALcyWorkspaceCodec.canDecodeWorkspace(String)
.boolean
canDecodeWorkspace
(String aSourceName, List<String> aReasonsSFCT) Returns true if the setALcyWorkspaceCodec
returns true forALcyWorkspaceCodec.canDecodeWorkspace(String, List)
.boolean
canEncodeWorkspace
(String aDestinationName) Returns true if the setALcyWorkspaceCodec
returns true forALcyWorkspaceCodec.canEncodeWorkspace(String)
.void
decodeWorkspace
(String aSourceName) Decodes the workspace usingALcyWorkspaceCodec.decodeWorkspace(String)
of the setALcyWorkspaceCodec
.void
encodeWorkspace
(String aDestinationName) Encodes the workspace usingALcyWorkspaceCodec.encodeWorkspace(String)
of the setALcyWorkspaceCodec
.Returns theALcyWorkspaceCodec
.getWorkspaceCodecDelegate
(int aIndex) Returns theALcyWorkspaceCodecDelegate
at the given index.int
Returns the amount of registeredALcyWorkspaceCodecDelegate
s.getWorkspaceObjectCodec
(int aIndex) Returns theALcyWorkspaceObjectCodec
at the given index.int
Returns the amount of registeredALcyWorkspaceObjectCodec
s.Short forALcyWorkspaceCodec.getWorkspaceStorageName()
.boolean
Returns true if a workspace is currently being decoded, false otherwise.boolean
Returns true if a workspace is currently being encoded, false otherwise.boolean
Returns true if the workspace has changed since the last encoding/decoding.void
Use this method to notify that the workspace has changed since the last encoding/decoding.void
removePropertyChangeListener
(PropertyChangeListener aPropertyChangeListener) De-registers the givenPropertyChangeListener
from receiving property change events for this object.void
Unregisters the givenALcyWorkspaceCodecDelegate
from the framework.void
Removes the givenILcyWorkspaceManagerListener
, it will no longer receive any events.void
removeWorkspaceObjectCodec
(ALcyWorkspaceObjectCodec aObjectCodec) Unregisters the givenALcyWorkspaceObjectCodec
from the framework.void
setWorkspaceChanged
(boolean aWorkspaceChanged) Sets the workspace changed status.void
setWorkspaceCodec
(ALcyWorkspaceCodec aWorkspaceCodec) Sets theALcyWorkspaceCodec
.
-
Constructor Details
-
TLcyWorkspaceManager
Creates a newTLcyWorkspaceManager
. This constructor must not be used, instead theTLcyWorkspaceManager
must be retrieved usingILcyLucyEnv.getWorkspaceManager()
.- Parameters:
aLucyEnv
- The lucy environment.
-
-
Method Details
-
addPropertyChangeListener
Description copied from interface: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.- Specified by:
addPropertyChangeListener
in interfaceILcdPropertyChangeSource
- Parameters:
aPropertyChangeListener
- The listener to be notified- See Also:
-
removePropertyChangeListener
Description copied from interface: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.- Specified by:
removePropertyChangeListener
in interfaceILcdPropertyChangeSource
- Parameters:
aPropertyChangeListener
- the listener that should no longer be notified of changes of this object's properties- See Also:
-
addWorkspaceManagerListener
Adds a workspace manager listener. This allows to receive an event when workspace de/encoding starts/ends. To know if a workspace is being de/encoded at a certain moment, it is also possible to useisEncodingWorkspace()
orisDecodingWorkspace()
.- Parameters:
aListener
- The listener to add.- See Also:
-
removeWorkspaceManagerListener
Removes the givenILcyWorkspaceManagerListener
, it will no longer receive any events. Does nothing if the given listener was never added or already removed.- Parameters:
aListener
- The listener to remove- See Also:
-
addWorkspaceCodecDelegate
Registers aALcyWorkspaceCodecDelegate
to the framework. When a workspace is encoded/decoded, the given aDelegate will be asked to encode/decode part of it.- Parameters:
aDelegate
- TheALcyWorkspaceCodecDelegate
to register.- See Also:
-
removeWorkspaceCodecDelegate
Unregisters the givenALcyWorkspaceCodecDelegate
from the framework. It will no longer be part of workspace encoding/decoding.- Parameters:
aDelegate
- TheALcyWorkspaceCodecDelegate
to remove.- See Also:
-
getWorkspaceCodecDelegateCount
public int getWorkspaceCodecDelegateCount()Returns the amount of registeredALcyWorkspaceCodecDelegate
s.- Returns:
- the amount of registered
ALcyWorkspaceCodecDelegate
s.
-
getWorkspaceCodecDelegate
Returns theALcyWorkspaceCodecDelegate
at the given index.- Parameters:
aIndex
- The index to get theALcyWorkspaceCodecDelegate
for.- Returns:
- the
ALcyWorkspaceCodecDelegate
at the given index.
-
addWorkspaceObjectCodec
Registers aALcyWorkspaceObjectCodec
to the framework. When theALcyWorkspaceCodec
needs to encode an object reference, it might ask this aObjectCodec to do it, depending on whataObjectCodec.canEncodeObject
returns.- Parameters:
aObjectCodec
- TheALcyWorkspaceObjectCodec
to register.- See Also:
-
removeWorkspaceObjectCodec
Unregisters the givenALcyWorkspaceObjectCodec
from the framework. It will no longer be part of workspace encoding/decoding.- Parameters:
aObjectCodec
- TheALcyWorkspaceObjectCodec
to remove.- See Also:
-
getWorkspaceObjectCodecCount
public int getWorkspaceObjectCodecCount()Returns the amount of registeredALcyWorkspaceObjectCodec
s.- Returns:
- the amount of registered
ALcyWorkspaceObjectCodec
s.
-
getWorkspaceObjectCodec
Returns theALcyWorkspaceObjectCodec
at the given index.- Parameters:
aIndex
- The index to get theALcyWorkspaceObjectCodec
for.- Returns:
- the
ALcyWorkspaceObjectCodec
at the given index.
-
getWorkspaceCodec
Returns theALcyWorkspaceCodec
. By default anALcyWorkspaceCodec
is returned that stores the workspace to a file.- Returns:
- the
ALcyWorkspaceCodec
. - See Also:
-
setWorkspaceCodec
Sets theALcyWorkspaceCodec
. This defaultALcyWorkspaceCodec
that writes to a file can be replaced with a custom one. This allows to implement e.g. aALcyWorkspaceCodec
that writes to a database.- Parameters:
aWorkspaceCodec
- TheALcyWorkspaceCodec
to use.- See Also:
-
isDecodingWorkspace
public boolean isDecodingWorkspace()Returns true if a workspace is currently being decoded, false otherwise. Changes to this value can be received by usingaddWorkspaceManagerListener(ILcyWorkspaceManagerListener)
.- Returns:
- true if a workspace is currently being decoded, false otherwise.
-
isEncodingWorkspace
public boolean isEncodingWorkspace()Returns true if a workspace is currently being encoded, false otherwise. Changes to this value can be received by usingaddWorkspaceManagerListener(ILcyWorkspaceManagerListener)
.- Returns:
- true if a workspace is currently being encoded, false otherwise.
-
isWorkspaceChanged
public boolean isWorkspaceChanged()Returns true if the workspace has changed since the last encoding/decoding. It is the responsibility of the
ALcyWorkspaceCodecDelegate
s and theALcyWorkspaceObjectCodec
s to usenotifyWorkspaceChanged()
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.
- Returns:
- true if the workspace has changed since the last encoding/decoding.
- See Also:
-
setWorkspaceChanged
public void setWorkspaceChanged(boolean aWorkspaceChanged) Sets the workspace changed status. Setting the changed status totrue
can also be done usingnotifyWorkspaceChanged()
. Setting the status tofalse
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 ofisWorkspaceChanged()
has changed.- Parameters:
aWorkspaceChanged
- True to set the workspace to 'changed', false otherwise.
-
notifyWorkspaceChanged
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)
withtrue
.It is the responsibility of the
ALcyWorkspaceCodecDelegate
s and theALcyWorkspaceObjectCodec
s to use this method.Sends a property change event if the result of
isWorkspaceChanged()
has changed. -
getWorkspaceStorageName
Short forALcyWorkspaceCodec.getWorkspaceStorageName()
. A property change event informs about changes to this value.- Returns:
- the current storage name of the workspace.
-
canEncodeWorkspace
Returns true if the setALcyWorkspaceCodec
returns true forALcyWorkspaceCodec.canEncodeWorkspace(String)
.- Parameters:
aDestinationName
- The destination name to check.- Returns:
- true if the set
ALcyWorkspaceCodec
returns true forALcyWorkspaceCodec.canEncodeWorkspace(String)
.
-
encodeWorkspace
public void encodeWorkspace(String aDestinationName) throws IOException, TLcyWorkspaceAbortedException Encodes the workspace usingALcyWorkspaceCodec.encodeWorkspace(String)
of the setALcyWorkspaceCodec
. Fires an event with idTLcyWorkspaceManagerEvent.STARTING_WORKSPACE_ENCODING
before actually encoding the workspace. Fires an event with idTLcyWorkspaceManagerEvent.WORKSPACE_ENCODING_ENDED
after the workspace is encoded.- Parameters:
aDestinationName
- The destination name to encode to.- Throws:
IOException
- In case of fatal IO failure.TLcyWorkspaceAbortedException
- In case the operation is aborted, e.g. because the user canceled it.
-
canDecodeWorkspace
Returns true if the setALcyWorkspaceCodec
returns true forALcyWorkspaceCodec.canDecodeWorkspace(String)
.- Parameters:
aSourceName
- The source name to check.- Returns:
- true if the set
ALcyWorkspaceCodec
returns true forALcyWorkspaceCodec.canDecodeWorkspace(String)
.
-
canDecodeWorkspace
Returns true if the setALcyWorkspaceCodec
returns true forALcyWorkspaceCodec.canDecodeWorkspace(String, List)
.- Parameters:
aSourceName
- The source name to checkaReasonsSFCT
- A side-effect parameter to which this method may add reasons on why it returnedtrue
orfalse
- Returns:
- true if the set
ALcyWorkspaceCodec
returns true forALcyWorkspaceCodec.canDecodeWorkspace(String, List)
. - Since:
- 2015.1
-
decodeWorkspace
Decodes the workspace usingALcyWorkspaceCodec.decodeWorkspace(String)
of the setALcyWorkspaceCodec
. Fires an event with idTLcyWorkspaceManagerEvent.STARTING_WORKSPACE_DECODING
before actually decoding the workspace. Fires an event with idTLcyWorkspaceManagerEvent.WORKSPACE_DECODING_ENDED
after the workspace is decoded.- Parameters:
aSourceName
- The source name to decode from.- Throws:
IOException
- In case of fatal IO failure.TLcyWorkspaceAbortedException
- In case the operation is aborted, e.g. because the user canceled it.
-