source: josm/trunk/src/org/openstreetmap/josm/io/FileExporter.java@ 6388

Last change on this file since 6388 was 6070, checked in by stoecker, 11 years ago

see #8853 remove tabs, trailing spaces, windows line ends, strange characters

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.io.File;
7import java.io.IOException;
8
9import org.openstreetmap.josm.actions.ExtensionFileFilter;
10import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
11import org.openstreetmap.josm.gui.layer.Layer;
12
13public abstract class FileExporter implements LayerChangeListener {
14
15 public final ExtensionFileFilter filter;
16
17 private boolean enabled;
18
19 public FileExporter(ExtensionFileFilter filter) {
20 this.filter = filter;
21 this.enabled = true;
22 }
23
24 public boolean acceptFile(File pathname, Layer layer) {
25 return filter.acceptName(pathname.getName());
26 }
27
28 public void exportData(File file, Layer layer) throws IOException {
29 throw new IOException(tr("Could not export ''{0}''.", file.getName()));
30 }
31
32 /**
33 * Returns the enabled state of this {@code FileExporter}. When enabled, it is listed and usable in "File->Save" dialogs.
34 * @return true if this {@code FileExporter} is enabled
35 * @since 5459
36 */
37 public final boolean isEnabled() {
38 return enabled;
39 }
40
41 /**
42 * Sets the enabled state of the {@code FileExporter}. When enabled, it is listed and usable in "File->Save" dialogs.
43 * @param enabled true to enable this {@code FileExporter}, false to disable it
44 * @since 5459
45 */
46 public final void setEnabled(boolean enabled) {
47 this.enabled = enabled;
48 }
49
50 @Override
51 public void activeLayerChange(Layer oldLayer, Layer newLayer) {
52 // To be overriden by subclasses if their enabled state depends of the active layer nature
53 }
54
55 @Override
56 public void layerAdded(Layer newLayer) {
57 // To be overriden by subclasses if needed
58 }
59
60 @Override
61 public void layerRemoved(Layer oldLayer) {
62 // To be overriden by subclasses if needed
63 }
64}
Note: See TracBrowser for help on using the repository browser.