Changeset 2702 in josm for trunk/src/org/openstreetmap/josm/io
- Timestamp:
- 2009-12-29T23:31:57+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/FileImporter.java
r2181 r2702 6 6 import java.io.File; 7 7 import java.io.IOException; 8 import java.util.List; 8 9 10 import javax.swing.JOptionPane; 11 12 import org.openstreetmap.josm.Main; 9 13 import org.openstreetmap.josm.actions.ExtensionFileFilter; 10 14 11 public abstract class FileImporter {15 public abstract class FileImporter implements Comparable<FileImporter> { 12 16 13 17 public ExtensionFileFilter filter; … … 21 25 } 22 26 27 /** 28 * A batch importer is a file importer that preferes to read multiple files at the same time. 29 */ 30 public boolean isBatchImporter() { 31 return false; 32 } 33 34 /** 35 * Needs to be implemented if isBatchImporter() returns false. 36 */ 23 37 public void importData(File file) throws IOException, IllegalDataException { 24 throw new IOException(tr("Could not read''{0}''.", file.getName()));38 throw new IOException(tr("Could not import ''{0}''.", file.getName())); 25 39 } 26 40 41 /** 42 * Needs to be implemented if isBatchImporter() returns true. 43 */ 44 public void importData(List<File> files) throws IOException, IllegalDataException { 45 throw new IOException(tr("Could not import Files.")); 46 } 47 48 /** 49 * Wrapper to give meaningful output if things go wrong. 50 */ 51 public void importDataHandleExceptions(File f) { 52 try { 53 System.out.println("Open file: " + f.getAbsolutePath() + " (" + f.length() + " bytes)"); 54 importData(f); 55 } catch (Exception e) { 56 e.printStackTrace(); 57 JOptionPane.showMessageDialog( 58 Main.parent, 59 tr("<html>Could not read file ''{0}\''.<br> Error is: <br>{1}</html>", f.getName(), e.getMessage()), 60 tr("Error"), 61 JOptionPane.ERROR_MESSAGE 62 ); 63 } 64 } 65 public void importDataHandleExceptions(List<File> files) { 66 try { 67 System.out.println("Open "+files.size()+" files"); 68 importData(files); 69 } catch (Exception e) { 70 e.printStackTrace(); 71 JOptionPane.showMessageDialog( 72 Main.parent, 73 tr("<html>Could not read files.<br> Error is: <br>{0}</html>", e.getMessage()), 74 tr("Error"), 75 JOptionPane.ERROR_MESSAGE 76 ); 77 } 78 } 79 80 /** 81 * If multiple files (with multiple file formats) are selected, 82 * they are opened in the order of their priorities. 83 * Highest priority comes first. 84 */ 85 public double getPriority() { 86 return 0; 87 } 88 89 public int compareTo(FileImporter other) { 90 return (new Double(this.getPriority())).compareTo(other.getPriority()); 91 } 27 92 }
Note:
See TracChangeset
for help on using the changeset viewer.