Class TLcyWorkspaceManager
- All Implemented Interfaces:
ILcdPropertyChangeSource
- accounting the
ALcyWorkspaceCodec - accounting the registered
ALcyWorkspaceCodecDelegates - accounting the registered
ALcyWorkspaceObjectCodecs
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
ALcyWorkspaceCodecDelegates and ALcyWorkspaceObjectCodecs to inform the
TLcyWorkspaceManager that the workspace has changed by using
notifyWorkspaceChanged().-
Constructor Summary
ConstructorsConstructorDescriptionTLcyWorkspaceManager(ILcyLucyEnv aLucyEnv) Creates a newTLcyWorkspaceManager. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Registers the givenPropertyChangeListenerto be notified when this object's properties change.voidRegisters aALcyWorkspaceCodecDelegateto the framework.voidAdds a workspace manager listener.voidaddWorkspaceObjectCodec(ALcyWorkspaceObjectCodec aObjectCodec) Registers aALcyWorkspaceObjectCodecto the framework.booleancanDecodeWorkspace(String aSourceName) Returns true if the setALcyWorkspaceCodecreturns true forALcyWorkspaceCodec.canDecodeWorkspace(String).booleancanDecodeWorkspace(String aSourceName, List<String> aReasonsSFCT) Returns true if the setALcyWorkspaceCodecreturns true forALcyWorkspaceCodec.canDecodeWorkspace(String, List).booleancanEncodeWorkspace(String aDestinationName) Returns true if the setALcyWorkspaceCodecreturns true forALcyWorkspaceCodec.canEncodeWorkspace(String).voiddecodeWorkspace(String aSourceName) Decodes the workspace usingALcyWorkspaceCodec.decodeWorkspace(String)of the setALcyWorkspaceCodec.voidencodeWorkspace(String aDestinationName) Encodes the workspace usingALcyWorkspaceCodec.encodeWorkspace(String)of the setALcyWorkspaceCodec.Returns theALcyWorkspaceCodec.getWorkspaceCodecDelegate(int aIndex) Returns theALcyWorkspaceCodecDelegateat the given index.intReturns the amount of registeredALcyWorkspaceCodecDelegates.getWorkspaceObjectCodec(int aIndex) Returns theALcyWorkspaceObjectCodecat the given index.intReturns the amount of registeredALcyWorkspaceObjectCodecs.Short forALcyWorkspaceCodec.getWorkspaceStorageName().booleanReturns true if a workspace is currently being decoded, false otherwise.booleanReturns true if a workspace is currently being encoded, false otherwise.booleanReturns true if the workspace has changed since the last encoding/decoding.voidUse this method to notify that the workspace has changed since the last encoding/decoding.voidremovePropertyChangeListener(PropertyChangeListener aPropertyChangeListener) De-registers the givenPropertyChangeListenerfrom receiving property change events for this object.voidUnregisters the givenALcyWorkspaceCodecDelegatefrom the framework.voidRemoves the givenILcyWorkspaceManagerListener, it will no longer receive any events.voidremoveWorkspaceObjectCodec(ALcyWorkspaceObjectCodec aObjectCodec) Unregisters the givenALcyWorkspaceObjectCodecfrom the framework.voidsetWorkspaceChanged(boolean aWorkspaceChanged) Sets the workspace changed status.voidsetWorkspaceCodec(ALcyWorkspaceCodec aWorkspaceCodec) Sets theALcyWorkspaceCodec.
-
Constructor Details
-
TLcyWorkspaceManager
Creates a newTLcyWorkspaceManager. This constructor must not be used, instead theTLcyWorkspaceManagermust be retrieved usingILcyLucyEnv.getWorkspaceManager().- Parameters:
aLucyEnv- The lucy environment.
-
-
Method Details
-
addPropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceRegisters the given
PropertyChangeListenerto 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
ALcdWeakPropertyChangeListenerinstance as property change listener.- Specified by:
addPropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aPropertyChangeListener- The listener to be notified- See Also:
-
removePropertyChangeListener
Description copied from interface:ILcdPropertyChangeSourceDe-registers the given
PropertyChangeListenerfrom 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:
removePropertyChangeListenerin 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 aALcyWorkspaceCodecDelegateto the framework. When a workspace is encoded/decoded, the given aDelegate will be asked to encode/decode part of it.- Parameters:
aDelegate- TheALcyWorkspaceCodecDelegateto register.- See Also:
-
removeWorkspaceCodecDelegate
Unregisters the givenALcyWorkspaceCodecDelegatefrom the framework. It will no longer be part of workspace encoding/decoding.- Parameters:
aDelegate- TheALcyWorkspaceCodecDelegateto remove.- See Also:
-
getWorkspaceCodecDelegateCount
public int getWorkspaceCodecDelegateCount()Returns the amount of registeredALcyWorkspaceCodecDelegates.- Returns:
- the amount of registered
ALcyWorkspaceCodecDelegates.
-
getWorkspaceCodecDelegate
Returns theALcyWorkspaceCodecDelegateat the given index.- Parameters:
aIndex- The index to get theALcyWorkspaceCodecDelegatefor.- Returns:
- the
ALcyWorkspaceCodecDelegateat the given index.
-
addWorkspaceObjectCodec
Registers aALcyWorkspaceObjectCodecto the framework. When theALcyWorkspaceCodecneeds to encode an object reference, it might ask this aObjectCodec to do it, depending on whataObjectCodec.canEncodeObjectreturns.- Parameters:
aObjectCodec- TheALcyWorkspaceObjectCodecto register.- See Also:
-
removeWorkspaceObjectCodec
Unregisters the givenALcyWorkspaceObjectCodecfrom the framework. It will no longer be part of workspace encoding/decoding.- Parameters:
aObjectCodec- TheALcyWorkspaceObjectCodecto remove.- See Also:
-
getWorkspaceObjectCodecCount
public int getWorkspaceObjectCodecCount()Returns the amount of registeredALcyWorkspaceObjectCodecs.- Returns:
- the amount of registered
ALcyWorkspaceObjectCodecs.
-
getWorkspaceObjectCodec
Returns theALcyWorkspaceObjectCodecat the given index.- Parameters:
aIndex- The index to get theALcyWorkspaceObjectCodecfor.- Returns:
- the
ALcyWorkspaceObjectCodecat the given index.
-
getWorkspaceCodec
Returns theALcyWorkspaceCodec. By default anALcyWorkspaceCodecis returned that stores the workspace to a file.- Returns:
- the
ALcyWorkspaceCodec. - See Also:
-
setWorkspaceCodec
Sets theALcyWorkspaceCodec. This defaultALcyWorkspaceCodecthat writes to a file can be replaced with a custom one. This allows to implement e.g. aALcyWorkspaceCodecthat writes to a database.- Parameters:
aWorkspaceCodec- TheALcyWorkspaceCodecto 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
ALcyWorkspaceCodecDelegates and theALcyWorkspaceObjectCodecs 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 totruecan also be done usingnotifyWorkspaceChanged(). Setting the status tofalseusually 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
ALcyWorkspaceCodecDelegates and theALcyWorkspaceObjectCodecs 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 setALcyWorkspaceCodecreturns true forALcyWorkspaceCodec.canEncodeWorkspace(String).- Parameters:
aDestinationName- The destination name to check.- Returns:
- true if the set
ALcyWorkspaceCodecreturns 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_ENCODINGbefore actually encoding the workspace. Fires an event with idTLcyWorkspaceManagerEvent.WORKSPACE_ENCODING_ENDEDafter 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 setALcyWorkspaceCodecreturns true forALcyWorkspaceCodec.canDecodeWorkspace(String).- Parameters:
aSourceName- The source name to check.- Returns:
- true if the set
ALcyWorkspaceCodecreturns true forALcyWorkspaceCodec.canDecodeWorkspace(String).
-
canDecodeWorkspace
Returns true if the setALcyWorkspaceCodecreturns 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 returnedtrueorfalse- Returns:
- true if the set
ALcyWorkspaceCodecreturns 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_DECODINGbefore actually decoding the workspace. Fires an event with idTLcyWorkspaceManagerEvent.WORKSPACE_DECODING_ENDEDafter 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.
-