001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.io.session;
003
004import java.awt.Component;
005import java.io.IOException;
006import java.util.Collection;
007
008import org.openstreetmap.josm.gui.layer.Layer;
009import org.openstreetmap.josm.io.session.SessionWriter.ExportSupport;
010import org.w3c.dom.Element;
011
012/**
013 * Session layer exporter.
014 * @since 4685
015 */
016public interface SessionLayerExporter {
017
018    /**
019     * Return the Layers, this Layer depends on.
020     * @return the layer dependencies
021     */
022    Collection<Layer> getDependencies();
023
024    /**
025     * The GUI for exporting this layer.
026     * @return the export panel
027     */
028    Component getExportPanel();
029
030    /**
031     * Return true, if the layer should be included in the list of exported layers.
032     *
033     * The user can veto this in the export panel.
034     * @return {@code true} if the layer should be included in the list of exported layers, {@code false} otherwise.
035     */
036    boolean shallExport();
037
038    /**
039     * Return true, if some data needs to be included in the zip archive. This decision depends on the user
040     * selection in the export panel.
041     *
042     * If any layer requires zip, the user can only save as .joz. Otherwise both .jos and .joz are possible.
043     * @return {@code true} if some data needs to be included in the zip archive, {@code false} otherwise.
044     */
045    boolean requiresZip();
046
047    /**
048     * Save meta data to the .jos file. Return a layer XML element.
049     * Use <code>support</code> to save files in the zip archive as needed.
050     * @param support support class providing export utilities
051     * @return the resulting XML element
052     * @throws IOException  if any I/O error occurs
053     */
054    Element export(ExportSupport support) throws IOException;
055}