public class TLcdOpenAction extends ALcdAction implements ILcdAction, ILcdModelProducer
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.
changeSupport
DEFAULT, LONG_DESCRIPTION, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SHOW_ACTION_NAME, SMALL_ICON, VISIBLE
Constructor and Description |
---|
TLcdOpenAction()
Default constructor.
|
TLcdOpenAction(Frame aParentFrame)
Constructs a new
TLcdOpenAction with a given parent Frame. |
Modifier and Type | Method and Description |
---|---|
void |
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 |
addModelProducerListener(ILcdModelProducerListener aListener)
Adds an
ILcdModelProducerListener to this ILcdModelProducer . |
protected ILcdModelDecoder |
chooseModelDecoder(Vector aVectorOfModelDecoder,
String aFullPathSourceName)
Is called by the loadFile( String aFullPathSourceName, boolean ) method
when more than one
ILcdModelDecoder accepts to decode
aFullPathSourceName. |
ILcdModelDecoder[] |
getModelDecoder()
Returns the current list of
ILcdModelDecoder objects. |
Frame |
getParentFrame()
Returns the parent frame to be used to display dialogs in.
|
String[] |
getPredefinedFileNames()
Gets the list of predefined files names to choose from.
|
String[] |
getPredinedFileNames()
Deprecated.
|
protected Component |
getSourceComponent()
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 valid
ILcdModelDecoder has been found to decode
aFullPathSourceName, and an Exception has occurred when decoding
aFullPathSourceName. |
protected ILcdModel |
handleNoValidDecoder()
Is called by the loadFile( String aSourceName, boolean ) method when no valid
ILcdModelDecoder has been found to decode aSourceName. |
boolean |
isLoadInSeparateThread()
Returns whether the data is loaded in a thread different from the AWT thread.
|
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
ILcdModel |
loadFile(String aFullPathSourceName)
Loads the file which full path name is given, and
sends out events to the
ILcdModelProducerListener objects. |
ILcdModel |
loadFile(String aFullPathSourceName,
boolean isAdjusting)
Loads the file which full path file name is given, and
sends out events to the
ILcdModelProducerListener objects. |
ILcdModel |
loadFile(String aPath,
String aFileName)
Loads the file which full path name is given, and
sends out events to the
ILcdModelProducerListener objects. |
ILcdModel |
loadFile(String aPath,
String aFileName,
boolean isAdjusting)
Loads the file which full path name is given, and
sends out events to the
ILcdModelProducerListener objects. |
void |
loadFileFromDialog()
Lets the user select a file from a file dialog, loads it, and
sends out events to the
ILcdModelProducerListener objects. |
void |
loadFiles(String[] aPathArray,
String[] aFileNameArray)
Loads the files whose full path names are given, and
sends out events to the
ILcdModelProducerListener objects. |
void |
loadFiles(String aPath,
String[] aFileNameArray)
Loads the files whose full path names are given, and
sends out events to the
ILcdModelProducerListener objects. |
protected void |
loadingTerminated(String aFullPathSourceName,
ILcdModelDecoder aModelDecoder,
boolean aIsAdjusting)
Is being called just after aModelDecoder.decode(aFullPathSourceName).
|
void |
loadPredefinedFile()
Lets the user select from the list of the predefined files, loads it, and
sends out events to the
ILcdModelProducerListener objects. |
void |
removeModelProducerListener(ILcdModelProducerListener aListener)
Removes an
ILcdModelProducerListener from this ILcdModelProducer . |
void |
setFirstInitialPath(String aPath)
Sets the initial path to be used by a file browser.
|
void |
setLoadInSeparateThread(boolean aLoadInSeparateThread)
When true, the decoding of a
ILcdModel 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 of
ILcdModelDecoder objects. |
void |
setParentFrame(Frame aFrame)
Sets a parent
Frame for this TLcdOpendAction . |
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. It is recommended to use the
standard Java logging framework directly.
|
protected void |
startLoading(String aFullPathSourceName,
ILcdModelDecoder aModelDecoder,
boolean aIsAdjusting)
Is being called just before aModelDecoder.decode(aFullPathSourceName).
|
addPropertyChangeListener, firePropertyChange, getDisplayName, getIcon, getLongDescription, getName, getShortDescription, getValue, isEnabled, putValue, registerInstance, removePropertyChangeListener, setClassTraceOn, setDisplayName, setEnabled, setIcon, setLongDescription, setName, setShortDescription
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getValue, isEnabled, putValue, setEnabled
addPropertyChangeListener, removePropertyChangeListener
public TLcdOpenAction()
public TLcdOpenAction(Frame aParentFrame)
TLcdOpenAction
with a given parent Frame.
The parent frame is used by the FileDialog.aParentFrame
- the parent frame.public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.setTraceOn
in class ALcdAction
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.public boolean isTraceOn()
true
if tracing is enabled for this class.isTraceOn
in class ALcdAction
public void setLoadInSeparateThread(boolean aLoadInSeparateThread)
ILcdModel
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 ...)aLoadInSeparateThread
- default value is true.isLoadInSeparateThread()
public boolean isLoadInSeparateThread()
setLoadInSeparateThread(boolean)
protected Component getSourceComponent()
public void addModelProducerListener(ILcdModelProducerListener aListener)
ILcdModelProducer
ILcdModelProducerListener
to this ILcdModelProducer
.addModelProducerListener
in interface ILcdModelProducer
aListener
- the listener to be added.ILcdModelProducer.removeModelProducerListener(com.luciad.model.ILcdModelProducerListener)
public void removeModelProducerListener(ILcdModelProducerListener aListener)
ILcdModelProducer
ILcdModelProducerListener
from this ILcdModelProducer
.removeModelProducerListener
in interface ILcdModelProducer
aListener
- the listener to be removed.ILcdModelProducer.addModelProducerListener(com.luciad.model.ILcdModelProducerListener)
public void setModelDecoder(ILcdModelDecoder[] aModelDecoder)
ILcdModelDecoder
objects.aModelDecoder
- the list of ILcdModelDecoder
objects that can be used to
open data sources.getModelDecoder()
public ILcdModelDecoder[] getModelDecoder()
ILcdModelDecoder
objects.ILcdModelDecoder
objects.setModelDecoder(com.luciad.model.ILcdModelDecoder[])
public void setPredinedFileNames(String[] aPredefinedFileNames)
setPredefinedFileNames(String[])
aPredefinedFileNames
- the list of predefined files names to choose from.public void setPredefinedFileNames(String[] aPredefinedFileNames)
aPredefinedFileNames
- the list of predefined files names to choose from.getPredinedFileNames()
public String[] getPredinedFileNames()
getPredefinedFileNames()
public String[] getPredefinedFileNames()
setPredinedFileNames(java.lang.String[])
public ILcdModel loadFile(String aPath, String aFileName)
ILcdModelProducerListener
objects.
This call is not expected to be followed by other calls immediately (see loadFiles(java.lang.String[], java.lang.String[])
.aPath
- the directory root name.aFileName
- the file name.ILcdModel
public ILcdModel loadFile(String aFullPathSourceName)
ILcdModelProducerListener
objects.
This call is not expected to be followed by other calls immediately (see loadFiles(java.lang.String[], java.lang.String[])
.aFullPathSourceName
- the full path to the file.ILcdModel
public void loadFiles(String[] aPathArray, String[] aFileNameArray)
ILcdModelProducerListener
objects.aPathArray
- the list of directory root names.aFileNameArray
- the list of file names corresponding to the directory root names.public void loadFiles(String aPath, String[] aFileNameArray)
ILcdModelProducerListener
objects.aPath
- the common directory root name.aFileNameArray
- the list of file names.public ILcdModel loadFile(String aPath, String aFileName, boolean isAdjusting)
ILcdModelProducerListener
objects.aPath
- the directory root name.aFileName
- the file name.isAdjusting
- indicates whether more similar calls will follow immediately
after this one.ILcdModel
protected void startLoading(String aFullPathSourceName, ILcdModelDecoder aModelDecoder, boolean aIsAdjusting)
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.protected void loadingTerminated(String aFullPathSourceName, ILcdModelDecoder aModelDecoder, boolean aIsAdjusting)
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.public ILcdModel loadFile(String aFullPathSourceName, boolean isAdjusting)
ILcdModelProducerListener
objects.aFullPathSourceName
- the full path source name.isAdjusting
- indicates whether more similar calls will follow immediately
after this one.ILcdModel
or the value returned by the
handleNoValidDecoder method if no no valid ILcdModelDecoder
has been found to decode aSourceNameprotected ILcdModelDecoder chooseModelDecoder(Vector aVectorOfModelDecoder, String aFullPathSourceName)
ILcdModelDecoder
accepts to decode
aFullPathSourceName. It opens a Dialog to choose among these
ILcdModelDecoder
. This method can be redefined.aVectorOfModelDecoder
- the model decoders suited to decode the source.aFullPathSourceName
- the full path to the source.ILcdModelDecoder
or null.protected ILcdModel handleDecodeException(ILcdModelDecoder aModelDecoder, String aFullPathSourceName, Exception aException)
ILcdModelDecoder
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.aModelDecoder
- the decoder used to decode the source.aFullPathSourceName
- the full path to the source.aException
- the exception thrown while decoding the source.protected ILcdModel handleNoValidDecoder()
ILcdModelDecoder
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-null ILcdModel
and/or perform another operationpublic void loadPredefinedFile()
ILcdModelProducerListener
objects.setPredinedFileNames(java.lang.String[])
public void setPredefinedFilesFormatter(ILcdFormatter aPredefinedFilesFormatter)
aPredefinedFilesFormatter
- the formatter to use to display predefined files in a dialog.public void loadFileFromDialog()
ILcdModelProducerListener
objects.public void actionPerformed(ActionEvent aActionEvent)
ILcdModelProducerListener
objects.actionPerformed
in interface ActionListener
public void setParentFrame(Frame aFrame)
Frame
for this TLcdOpendAction
.aFrame
- the frame to display dialogs in.getParentFrame()
public Frame getParentFrame()
setParentFrame(java.awt.Frame)
public void setFirstInitialPath(String aPath)
aPath
- the initial path to be used by a file browser.