Class TLcdOpenAction

java.lang.Object
com.luciad.gui.ALcdAction
com.luciad.model.TLcdOpenAction
All Implemented Interfaces:
ILcdAction, ILcdModelProducer, ILcdPropertyChangeSource, ActionListener, Serializable, EventListener

public class TLcdOpenAction extends ALcdAction implements ILcdAction, ILcdModelProducer
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:
  • Constructor Details

    • TLcdOpenAction

      public TLcdOpenAction()
      Default constructor.
    • TLcdOpenAction

      public TLcdOpenAction(Frame aParentFrame)
      Constructs a new TLcdOpenAction 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 either 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.
      Overrides:
      setTraceOn in class ALcdAction
      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.
      Returns true if tracing is enabled for this class.
      Overrides:
      isTraceOn in class ALcdAction
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • setLoadInSeparateThread

      public 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. 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

      protected Component 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

      public void addModelProducerListener(ILcdModelProducerListener aListener)
      Description copied from interface: ILcdModelProducer
      Adds an ILcdModelProducerListener to this ILcdModelProducer.
      Specified by:
      addModelProducerListener in interface ILcdModelProducer
      Parameters:
      aListener - the listener to be added.
      See Also:
    • removeModelProducerListener

      public void removeModelProducerListener(ILcdModelProducerListener aListener)
      Description copied from interface: ILcdModelProducer
      Removes an ILcdModelProducerListener from this ILcdModelProducer.
      Specified by:
      removeModelProducerListener in interface ILcdModelProducer
      Parameters:
      aListener - the listener to be removed.
      See Also:
    • setModelDecoder

      public void setModelDecoder(ILcdModelDecoder[] aModelDecoder)
      Sets the list of ILcdModelDecoder objects.
      Parameters:
      aModelDecoder - the list of ILcdModelDecoder objects that can be used to open data sources.
      See Also:
    • getModelDecoder

      public ILcdModelDecoder[] getModelDecoder()
      Returns the current list of ILcdModelDecoder objects.
      Returns:
      the current list of ILcdModelDecoder objects.
      See Also:
    • setPredinedFileNames

      public void setPredinedFileNames(String[] aPredefinedFileNames)
      This method is included for backward compatibility.
      Parameters:
      aPredefinedFileNames - the list of predefined files names to choose from.
    • setPredefinedFileNames

      public void setPredefinedFileNames(String[] aPredefinedFileNames)
      Sets the list of predefined files names to choose from.
      Parameters:
      aPredefinedFileNames - the list of predefined files names to choose from.
      See Also:
    • getPredinedFileNames

      public String[] getPredinedFileNames()
      Deprecated.
      This method is included for backward compatibility.
    • getPredefinedFileNames

      public String[] getPredefinedFileNames()
      Gets the list of predefined files names to choose from.
      Returns:
      the list of predefined files names to choose from.
      See Also:
    • loadFile

      public ILcdModel loadFile(String aPath, String aFileName)
      Loads the file which full path name is given, and sends out events to the ILcdModelProducerListener objects. This call is not expected to be followed by other calls immediately (see loadFiles(java.lang.String[], java.lang.String[]).
      Parameters:
      aPath - the directory root name.
      aFileName - the file name.
      Returns:
      the new ILcdModel
    • loadFile

      public ILcdModel loadFile(String aFullPathSourceName)
      Loads the file which full path name is given, and sends out events to the ILcdModelProducerListener objects. This call is not expected to be followed by other calls immediately (see loadFiles(java.lang.String[], java.lang.String[]).
      Parameters:
      aFullPathSourceName - the full path to the file.
      Returns:
      the new ILcdModel
    • loadFiles

      public void loadFiles(String[] aPathArray, String[] aFileNameArray)
      Loads the files whose full path names are given, and sends out events to the ILcdModelProducerListener objects.
      Parameters:
      aPathArray - the list of directory root names.
      aFileNameArray - the list of file names corresponding to the directory root names.
    • loadFiles

      public void loadFiles(String aPath, String[] aFileNameArray)
      Loads the files whose full path names are given, and sends out events to the ILcdModelProducerListener objects.
      Parameters:
      aPath - the common directory root name.
      aFileNameArray - the list of file names.
    • loadFile

      public 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.
      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

      public ILcdModel loadFile(String aFullPathSourceName, boolean isAdjusting)
      Loads the file which full path file name is given, and sends out events to the ILcdModelProducerListener 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 valid ILcdModelDecoder 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 one ILcdModelDecoder accepts to decode aFullPathSourceName. It opens a Dialog to choose among these ILcdModelDecoder. 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 valid 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.
      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

      protected ILcdModel handleNoValidDecoder()
      Is called by the loadFile( String aSourceName, boolean ) method when no valid 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 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 the ILcdModelProducerListener objects.
      See Also:
    • setPredefinedFilesFormatter

      public void setPredefinedFilesFormatter(ILcdFormatter aPredefinedFilesFormatter)
      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 the ILcdModelProducerListener objects.
    • actionPerformed

      public 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. Then loads the file and sends out events to the ILcdModelProducerListener objects.
      Specified by:
      actionPerformed in interface ActionListener
    • setParentFrame

      public void setParentFrame(Frame aFrame)
      Sets a parent Frame for this TLcdOpendAction.
      Parameters:
      aFrame - the frame to display dialogs in.
      See Also:
    • getParentFrame

      public Frame 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

      public void setFirstInitialPath(String aPath)
      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.