Package com.luciad.model
Class TLcdOpenAction
java.lang.Object
com.luciad.gui.ALcdAction
com.luciad.model.TLcdOpenAction
- All Implemented Interfaces:
ILcdAction
,ILcdModelProducer
,ILcdPropertyChangeSource
,ActionListener
,Serializable
,EventListener
This
ILcdAction
is an ILcdModelProducer
. It can
load an ILcdModel
from a local or distant source and send events
to its listeners, notifying them that an ILcdModel
has been
created.
A list of ILcdModelDecoder
objects must be set. When a source
is chosen, it is proposed to each ILcdModelDecoder
to know
which one can decode it. If more than
one ILcdModelDecoder
can decode the source, the
chooseModelDecoder method is called to allow the user to select one.
An optional list of predefined source names can be set to this
ILcdAction
. This list will be presented to the user to choose
one of the source. If this list has not been set,
a FileDialog is shown to select a source to be opened. This list would be
typically used for loading data through the internet from a browser. Indeed,
the java security manager does not generally allow to open a FileDialog on
a client browser.
- See Also:
-
Field Summary
Fields inherited from class com.luciad.gui.ALcdAction
changeSupport
Fields inherited from interface com.luciad.gui.ILcdAction
DEFAULT, LONG_DESCRIPTION, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SHOW_ACTION_NAME, SMALL_ICON, VISIBLE
-
Constructor Summary
ConstructorDescriptionDefault constructor.TLcdOpenAction
(Frame aParentFrame) Constructs a newTLcdOpenAction
with a given parent Frame. -
Method Summary
Modifier and TypeMethodDescriptionvoid
actionPerformed
(ActionEvent aActionEvent) Lets the user select from the list of the predefined files, if it has been set, or from a file dialog otherwise.void
Adds anILcdModelProducerListener
to thisILcdModelProducer
.protected ILcdModelDecoder
chooseModelDecoder
(Vector aVectorOfModelDecoder, String aFullPathSourceName) Is called by the loadFile( String aFullPathSourceName, boolean ) method when more than oneILcdModelDecoder
accepts to decode aFullPathSourceName.Returns the current list ofILcdModelDecoder
objects.Returns the parent frame to be used to display dialogs in.String[]
Gets the list of predefined files names to choose from.String[]
Deprecated.protected Component
Returns the Component from which the ActionEvent has been generated, if this one could be found, or null.protected ILcdModel
handleDecodeException
(ILcdModelDecoder aModelDecoder, String aFullPathSourceName, Exception aException) Is called by the loadFile( String aFullPathSourceName, boolean ) method when a validILcdModelDecoder
has been found to decode aFullPathSourceName, and an Exception has occurred when decoding aFullPathSourceName.protected ILcdModel
Is called by the loadFile( String aSourceName, boolean ) method when no validILcdModelDecoder
has been found to decode aSourceName.boolean
Returns whether the data is loaded in a thread different from the AWT thread.boolean
Deprecated.This method has been deprecated.Loads the file which full path name is given, and sends out events to theILcdModelProducerListener
objects.Loads the file which full path file name is given, and sends out events to theILcdModelProducerListener
objects.Loads the file which full path name is given, and sends out events to theILcdModelProducerListener
objects.Loads the file which full path name is given, and sends out events to theILcdModelProducerListener
objects.void
Lets the user select a file from a file dialog, loads it, and sends out events to theILcdModelProducerListener
objects.void
Loads the files whose full path names are given, and sends out events to theILcdModelProducerListener
objects.void
Loads the files whose full path names are given, and sends out events to theILcdModelProducerListener
objects.protected void
loadingTerminated
(String aFullPathSourceName, ILcdModelDecoder aModelDecoder, boolean aIsAdjusting) Is being called just after aModelDecoder.decode(aFullPathSourceName).void
Lets the user select from the list of the predefined files, loads it, and sends out events to theILcdModelProducerListener
objects.void
Removes anILcdModelProducerListener
from thisILcdModelProducer
.void
setFirstInitialPath
(String aPath) Sets the initial path to be used by a file browser.void
setLoadInSeparateThread
(boolean aLoadInSeparateThread) When true, the decoding of aILcdModel
from the loadFileFromDialog method will be performed in a separate Thread, except for the delivery of the event that will be done in the AWT event queue.void
setModelDecoder
(ILcdModelDecoder[] aModelDecoder) Sets the list ofILcdModelDecoder
objects.void
setParentFrame
(Frame aFrame) Sets a parentFrame
for thisTLcdOpendAction
.void
setPredefinedFileNames
(String[] aPredefinedFileNames) Sets the list of predefined files names to choose from.void
setPredefinedFilesFormatter
(ILcdFormatter aPredefinedFilesFormatter) Sets the formatter to display the predefined files in a dialog.void
setPredinedFileNames
(String[] aPredefinedFileNames) Deprecated.void
setTraceOn
(boolean aTraceOn) Deprecated.This method has been deprecated.protected void
startLoading
(String aFullPathSourceName, ILcdModelDecoder aModelDecoder, boolean aIsAdjusting) Is being called just before aModelDecoder.decode(aFullPathSourceName).Methods inherited from class com.luciad.gui.ALcdAction
addPropertyChangeListener, firePropertyChange, getDisplayName, getIcon, getLongDescription, getName, getShortDescription, getValue, isEnabled, putValue, registerInstance, removePropertyChangeListener, setClassTraceOn, setDisplayName, setEnabled, setIcon, setLongDescription, setName, setShortDescription
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.gui.ILcdAction
getValue, isEnabled, putValue, setEnabled
Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
TLcdOpenAction
public TLcdOpenAction()Default constructor. -
TLcdOpenAction
Constructs a newTLcdOpenAction
with a given parent Frame. The parent frame is used by the FileDialog.- Parameters:
aParentFrame
- the parent frame.
-
-
Method Details
-
setTraceOn
public void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Overrides:
setTraceOn
in classALcdAction
- Parameters:
aTraceOn
- if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Overrides:
isTraceOn
in classALcdAction
- Returns:
- true if tracing is enabled for this class, false otherwise.
-
setLoadInSeparateThread
public void setLoadInSeparateThread(boolean aLoadInSeparateThread) When true, the decoding of aILcdModel
from the loadFileFromDialog method will be performed in a separate Thread, except for the delivery of the event that will be done in the AWT event queue. The startLoading and loadingPerformed methods can be overwritten for customization (waiting dialog, etc ...)- Parameters:
aLoadInSeparateThread
- default value is true.- See Also:
-
isLoadInSeparateThread
public boolean isLoadInSeparateThread()Returns whether the data is loaded in a thread different from the AWT thread.- Returns:
- whether the data is loaded in a thread different from the AWT thread.
- See Also:
-
getSourceComponent
Returns the Component from which the ActionEvent has been generated, if this one could be found, or null.- Returns:
- the Component from which the ActionEvent has been generated, if this one could be found, or null.
-
addModelProducerListener
Description copied from interface:ILcdModelProducer
Adds anILcdModelProducerListener
to thisILcdModelProducer
.- Specified by:
addModelProducerListener
in interfaceILcdModelProducer
- Parameters:
aListener
- the listener to be added.- See Also:
-
removeModelProducerListener
Description copied from interface:ILcdModelProducer
Removes anILcdModelProducerListener
from thisILcdModelProducer
.- Specified by:
removeModelProducerListener
in interfaceILcdModelProducer
- Parameters:
aListener
- the listener to be removed.- See Also:
-
setModelDecoder
Sets the list ofILcdModelDecoder
objects.- Parameters:
aModelDecoder
- the list ofILcdModelDecoder
objects that can be used to open data sources.- See Also:
-
getModelDecoder
Returns the current list ofILcdModelDecoder
objects.- Returns:
- the current list of
ILcdModelDecoder
objects. - See Also:
-
setPredinedFileNames
Deprecated.This method is included for backward compatibility.- Parameters:
aPredefinedFileNames
- the list of predefined files names to choose from.
-
setPredefinedFileNames
Sets the list of predefined files names to choose from.- Parameters:
aPredefinedFileNames
- the list of predefined files names to choose from.- See Also:
-
getPredinedFileNames
Deprecated.This method is included for backward compatibility. -
getPredefinedFileNames
Gets the list of predefined files names to choose from.- Returns:
- the list of predefined files names to choose from.
- See Also:
-
loadFile
Loads the file which full path name is given, and sends out events to theILcdModelProducerListener
objects. This call is not expected to be followed by other calls immediately (seeloadFiles(java.lang.String[], java.lang.String[])
.- Parameters:
aPath
- the directory root name.aFileName
- the file name.- Returns:
- the new
ILcdModel
-
loadFile
Loads the file which full path name is given, and sends out events to theILcdModelProducerListener
objects. This call is not expected to be followed by other calls immediately (seeloadFiles(java.lang.String[], java.lang.String[])
.- Parameters:
aFullPathSourceName
- the full path to the file.- Returns:
- the new
ILcdModel
-
loadFiles
Loads the files whose full path names are given, and sends out events to theILcdModelProducerListener
objects.- Parameters:
aPathArray
- the list of directory root names.aFileNameArray
- the list of file names corresponding to the directory root names.
-
loadFiles
Loads the files whose full path names are given, and sends out events to theILcdModelProducerListener
objects.- Parameters:
aPath
- the common directory root name.aFileNameArray
- the list of file names.
-
loadFile
Loads the file which full path name is given, and sends out events to theILcdModelProducerListener
objects.- Parameters:
aPath
- the directory root name.aFileName
- the file name.isAdjusting
- indicates whether more similar calls will follow immediately after this one.- Returns:
- the new
ILcdModel
-
startLoading
protected void startLoading(String aFullPathSourceName, ILcdModelDecoder aModelDecoder, boolean aIsAdjusting) Is being called just before aModelDecoder.decode(aFullPathSourceName). Does nothing. Can be redefined.- Parameters:
aFullPathSourceName
- the full path to the source being decoded.aModelDecoder
- the decoder assigned to decode the source.aIsAdjusting
- indicates whether this call will be followed immediately by other similar calls.
-
loadingTerminated
protected void loadingTerminated(String aFullPathSourceName, ILcdModelDecoder aModelDecoder, boolean aIsAdjusting) Is being called just after aModelDecoder.decode(aFullPathSourceName). Does nothing. Can be redefined.- Parameters:
aFullPathSourceName
- the full path to the source being decoded.aModelDecoder
- the decoder assigned to decode the source.aIsAdjusting
- indicates whether this call will be followed immediately by other similar calls.
-
loadFile
Loads the file which full path file name is given, and sends out events to theILcdModelProducerListener
objects.- Parameters:
aFullPathSourceName
- the full path source name.isAdjusting
- indicates whether more similar calls will follow immediately after this one.- Returns:
- the new
ILcdModel
or the value returned by the handleNoValidDecoder method if no no validILcdModelDecoder
has been found to decode aSourceName
-
chooseModelDecoder
protected ILcdModelDecoder chooseModelDecoder(Vector aVectorOfModelDecoder, String aFullPathSourceName) Is called by the loadFile( String aFullPathSourceName, boolean ) method when more than oneILcdModelDecoder
accepts to decode aFullPathSourceName. It opens a Dialog to choose among theseILcdModelDecoder
. This method can be redefined.- Parameters:
aVectorOfModelDecoder
- the model decoders suited to decode the source.aFullPathSourceName
- the full path to the source.- Returns:
- a
ILcdModelDecoder
or null.
-
handleDecodeException
protected ILcdModel handleDecodeException(ILcdModelDecoder aModelDecoder, String aFullPathSourceName, Exception aException) Is called by the loadFile( String aFullPathSourceName, boolean ) method when a validILcdModelDecoder
has been found to decode aFullPathSourceName, and an Exception has occurred when decoding aFullPathSourceName. This method displays a message, logs an error message, and returns null. It can redefined for performing other operations.- Parameters:
aModelDecoder
- the decoder used to decode the source.aFullPathSourceName
- the full path to the source.aException
- the exception thrown while decoding the source.- Returns:
- null.
-
handleNoValidDecoder
Is called by the loadFile( String aSourceName, boolean ) method when no validILcdModelDecoder
has been found to decode aSourceName. This method display a message and returns null. The value returned is returned be the loadFile method. This method can be redefined to return a non-nullILcdModel
and/or perform another operation- Returns:
- null
-
loadPredefinedFile
public void loadPredefinedFile()Lets the user select from the list of the predefined files, loads it, and sends out events to theILcdModelProducerListener
objects.- See Also:
-
setPredefinedFilesFormatter
Sets the formatter to display the predefined files in a dialog.- Parameters:
aPredefinedFilesFormatter
- the formatter to use to display predefined files in a dialog.
-
loadFileFromDialog
public void loadFileFromDialog()Lets the user select a file from a file dialog, loads it, and sends out events to theILcdModelProducerListener
objects. -
actionPerformed
Lets the user select from the list of the predefined files, if it has been set, or from a file dialog otherwise. Then loads the file and sends out events to theILcdModelProducerListener
objects.- Specified by:
actionPerformed
in interfaceActionListener
-
setParentFrame
Sets a parentFrame
for thisTLcdOpendAction
.- Parameters:
aFrame
- the frame to display dialogs in.- See Also:
-
getParentFrame
Returns the parent frame to be used to display dialogs in.- Returns:
- the parent frame to be used to display dialogs in.
- See Also:
-
setFirstInitialPath
Sets the initial path to be used by a file browser. This can usually be an absolute path or a path relative to the working directory.- Parameters:
aPath
- the initial path to be used by a file browser.
-
getPredefinedFileNames()