Class FileExporter

java.lang.Object
org.openstreetmap.josm.gui.io.importexport.FileExporter
All Implemented Interfaces:
MainLayerManager.ActiveLayerChangeListener
Direct Known Subclasses:
GeoJSONExporter, GpxExporter, NoteExporter, OsmExporter, ValidatorErrorExporter, WMSLayerExporter

public abstract class FileExporter extends Object implements MainLayerManager.ActiveLayerChangeListener
Abstract base class for file exporters - IO classes that save layers to a file.
  • Field Details

  • Constructor Details

  • Method Details

    • acceptFile

      public boolean acceptFile(File pathname, Layer layer)
      Check if this exporter can export a certain layer to a certain file. Most exporters support just a single layer type.
      Parameters:
      pathname - the target file name (check file extension using the filter
      layer - the layer requested for export
      Returns:
      true, if the exporter can handle the layer and filename is okay
    • exportData

      public void exportData(File file, Layer layer) throws IOException
      Execute the data export. (To be overridden by subclasses.)
      Parameters:
      file - target file
      layer - the layer to export
      Throws:
      IOException - in case of an IO error
    • exportDataQuiet

      public void exportDataQuiet(File file, Layer layer) throws IOException
      Execute the data export without prompting the user. (To be overridden by subclasses.)
      Parameters:
      file - target file
      layer - the layer to export
      Throws:
      IOException - in case of an IO error
      Since:
      15496
    • isEnabled

      public final boolean isEnabled()
      Returns the enabled state of this FileExporter. When enabled, it is listed and usable in "File → Save" dialogs.
      Returns:
      true if this FileExporter is enabled
      Since:
      5459
    • setEnabled

      public final void setEnabled(boolean enabled)
      Sets the enabled state of the FileExporter. When enabled, it is listed and usable in "File → Save" dialogs.
      Parameters:
      enabled - true to enable this FileExporter, false to disable it
      Since:
      5459
    • activeOrEditLayerChanged

      Description copied from interface: MainLayerManager.ActiveLayerChangeListener
      Called whenever the active or edit layer changed.

      You can be sure that this layer is still contained in this set.

      Listeners are called in the EDT thread and you can manipulate the layer manager in the current thread.

      Specified by:
      activeOrEditLayerChanged in interface MainLayerManager.ActiveLayerChangeListener
      Parameters:
      e - The change event.
    • isCanceled

      public final boolean isCanceled()
      Determines if this exporter has been canceled during export.
      Returns:
      true if this FileExporter has been canceled
      Since:
      6815
    • setCanceled

      public final void setCanceled(boolean canceled)
      Marks this exporter as canceled.
      Parameters:
      canceled - true to mark this exporter as canceled, false otherwise
      Since:
      6815