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
changeSupportFields inherited from interface com.luciad.gui.ILcdAction
DEFAULT, LONG_DESCRIPTION, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SHOW_ACTION_NAME, SMALL_ICON, VISIBLE -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.TLcdOpenAction(Frame aParentFrame) Constructs a newTLcdOpenActionwith a given parent Frame. -
Method Summary
Modifier and TypeMethodDescriptionvoidactionPerformed(ActionEvent aActionEvent) Lets the user select from the list of the predefined files, if it has been set, or from a file dialog otherwise.voidAdds anILcdModelProducerListenerto thisILcdModelProducer.protected ILcdModelDecoderchooseModelDecoder(Vector aVectorOfModelDecoder, String aFullPathSourceName) Is called by the loadFile( String aFullPathSourceName, boolean ) method when more than oneILcdModelDecoderaccepts to decode aFullPathSourceName.Returns the current list ofILcdModelDecoderobjects.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 ComponentReturns the Component from which the ActionEvent has been generated, if this one could be found, or null.protected ILcdModelhandleDecodeException(ILcdModelDecoder aModelDecoder, String aFullPathSourceName, Exception aException) Is called by the loadFile( String aFullPathSourceName, boolean ) method when a validILcdModelDecoderhas been found to decode aFullPathSourceName, and an Exception has occurred when decoding aFullPathSourceName.protected ILcdModelIs called by the loadFile( String aSourceName, boolean ) method when no validILcdModelDecoderhas been found to decode aSourceName.booleanReturns whether the data is loaded in a thread different from the AWT thread.booleanDeprecated.This method has been deprecated.Loads the file which full path name is given, and sends out events to theILcdModelProducerListenerobjects.Loads the file which full path file name is given, and sends out events to theILcdModelProducerListenerobjects.Loads the file which full path name is given, and sends out events to theILcdModelProducerListenerobjects.Loads the file which full path name is given, and sends out events to theILcdModelProducerListenerobjects.voidLets the user select a file from a file dialog, loads it, and sends out events to theILcdModelProducerListenerobjects.voidLoads the files whose full path names are given, and sends out events to theILcdModelProducerListenerobjects.voidLoads the files whose full path names are given, and sends out events to theILcdModelProducerListenerobjects.protected voidloadingTerminated(String aFullPathSourceName, ILcdModelDecoder aModelDecoder, boolean aIsAdjusting) Is being called just after aModelDecoder.decode(aFullPathSourceName).voidLets the user select from the list of the predefined files, loads it, and sends out events to theILcdModelProducerListenerobjects.voidRemoves anILcdModelProducerListenerfrom thisILcdModelProducer.voidsetFirstInitialPath(String aPath) Sets the initial path to be used by a file browser.voidsetLoadInSeparateThread(boolean aLoadInSeparateThread) When true, the decoding of aILcdModelfrom 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.voidsetModelDecoder(ILcdModelDecoder[] aModelDecoder) Sets the list ofILcdModelDecoderobjects.voidsetParentFrame(Frame aFrame) Sets a parentFramefor thisTLcdOpendAction.voidsetPredefinedFileNames(String[] aPredefinedFileNames) Sets the list of predefined files names to choose from.voidsetPredefinedFilesFormatter(ILcdFormatter aPredefinedFilesFormatter) Sets the formatter to display the predefined files in a dialog.voidsetPredinedFileNames(String[] aPredefinedFileNames) Deprecated.voidsetTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated.protected voidstartLoading(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, setShortDescriptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.gui.ILcdAction
getValue, isEnabled, putValue, setEnabledMethods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
TLcdOpenAction
public TLcdOpenAction()Default constructor. -
TLcdOpenAction
Constructs a newTLcdOpenActionwith 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 eithertrueorfalseas argument automatically turns off tracing for all other class instances for whichsetTraceOnhas not been called. If the argument isfalsethen only the informative, warning and error log messages are recorded.- Overrides:
setTraceOnin 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.Returnstrueif tracing is enabled for this class.- Overrides:
isTraceOnin classALcdAction- Returns:
- true if tracing is enabled for this class, false otherwise.
-
setLoadInSeparateThread
public void setLoadInSeparateThread(boolean aLoadInSeparateThread) When true, the decoding of aILcdModelfrom 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:ILcdModelProducerAdds anILcdModelProducerListenerto thisILcdModelProducer.- Specified by:
addModelProducerListenerin interfaceILcdModelProducer- Parameters:
aListener- the listener to be added.- See Also:
-
removeModelProducerListener
Description copied from interface:ILcdModelProducerRemoves anILcdModelProducerListenerfrom thisILcdModelProducer.- Specified by:
removeModelProducerListenerin interfaceILcdModelProducer- Parameters:
aListener- the listener to be removed.- See Also:
-
setModelDecoder
Sets the list ofILcdModelDecoderobjects.- Parameters:
aModelDecoder- the list ofILcdModelDecoderobjects that can be used to open data sources.- See Also:
-
getModelDecoder
Returns the current list ofILcdModelDecoderobjects.- Returns:
- the current list of
ILcdModelDecoderobjects. - 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 theILcdModelProducerListenerobjects. 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 theILcdModelProducerListenerobjects. 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 theILcdModelProducerListenerobjects.- 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 theILcdModelProducerListenerobjects.- 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 theILcdModelProducerListenerobjects.- 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 theILcdModelProducerListenerobjects.- Parameters:
aFullPathSourceName- the full path source name.isAdjusting- indicates whether more similar calls will follow immediately after this one.- Returns:
- the new
ILcdModelor the value returned by the handleNoValidDecoder method if no no validILcdModelDecoderhas 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 oneILcdModelDecoderaccepts 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
ILcdModelDecoderor null.
-
handleDecodeException
protected ILcdModel handleDecodeException(ILcdModelDecoder aModelDecoder, String aFullPathSourceName, Exception aException) Is called by the loadFile( String aFullPathSourceName, boolean ) method when a validILcdModelDecoderhas 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 validILcdModelDecoderhas 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-nullILcdModeland/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 theILcdModelProducerListenerobjects.- 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 theILcdModelProducerListenerobjects. -
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 theILcdModelProducerListenerobjects.- Specified by:
actionPerformedin interfaceActionListener
-
setParentFrame
Sets a parentFramefor 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()