Changeset 26896 in osm for applications/editors/josm/plugins/imagery-xml-bounds/src/org
- Timestamp:
- 2011-10-17T01:40:35+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds
- Files:
-
- 4 added
- 2 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/ImageryXmlBoundsPlugin.java
r26808 r26896 25 25 import org.openstreetmap.josm.plugins.imageryxmlbounds.actions.ShowBoundsPropertiesAction; 26 26 import org.openstreetmap.josm.plugins.imageryxmlbounds.actions.ShowBoundsSelectionAction; 27 import org.openstreetmap.josm.plugins.imageryxmlbounds.actions.downloadtask.DownloadXmlBoundsTask; 28 import org.openstreetmap.josm.plugins.imageryxmlbounds.io.XmlBoundsExporter; 29 import org.openstreetmap.josm.plugins.imageryxmlbounds.io.XmlBoundsImporter; 27 30 28 31 /** 29 32 * Main class of Imagery XML bounds plugin. 30 33 * @author Don-vip 31 * @version 1. 134 * @version 1.2 32 35 * History: 36 * 1.2 17-Oct-2011 Update for #6960 and JOSM 4523 (allow to download imagery XML bounds with Ctrl-L) 33 37 * 1.1 08-Oct-2011 Update for #6934 and JOSM 4506, code refactorisation, removing debug code 34 38 * 1.0 03-Oct-2011 first version … … 69 73 DataSet.addSelectionListener(selectionAction); 70 74 Main.toolbar.register(selectionAction); 75 // Allow JOSM to download *.imagery.xml files 76 Main.main.menu.openLocation.addDownloadTaskClass(DownloadXmlBoundsTask.class); 71 77 } 72 78 -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/XmlBoundsConstants.java
r26808 r26896 33 33 * Plugin version. 34 34 */ 35 public static final String PLUGIN_VERSION = "1. 1";35 public static final String PLUGIN_VERSION = "1.2"; 36 36 37 37 /** … … 39 39 */ 40 40 public static final String XML_NAMESPACE = "http://josm.openstreetmap.de/maps-1.0"; 41 41 42 /** 43 * XML file location. 44 */ 45 public static final String XML_LOCATION = "http://josm.openstreetmap.de/maps"; 46 42 47 /** 43 48 * XML Schema -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/io/ValidatingImageryReader.java
r26892 r26896 2 2 * 3 3 */ 4 package org.openstreetmap.josm.plugins.imageryxmlbounds; 4 package org.openstreetmap.josm.plugins.imageryxmlbounds.io; 5 5 6 6 import java.io.IOException; … … 13 13 import org.openstreetmap.josm.io.MirroredInputStream; 14 14 import org.openstreetmap.josm.io.imagery.ImageryReader; 15 import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsConstants; 15 16 import org.xml.sax.SAXException; 16 17 -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/io/XmlBoundsExporter.java
r26892 r26896 14 14 // You should have received a copy of the GNU General Public License 15 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 package org.openstreetmap.josm.plugins.imageryxmlbounds; 16 package org.openstreetmap.josm.plugins.imageryxmlbounds.io; 17 17 18 18 import java.io.BufferedWriter; … … 26 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 27 import org.openstreetmap.josm.io.FileExporter; 28 import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsConstants; 28 29 import org.openstreetmap.josm.plugins.imageryxmlbounds.actions.ComputeBoundsAction; 29 30 -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/io/XmlBoundsImporter.java
r26892 r26896 14 14 // You should have received a copy of the GNU General Public License 15 15 // along with this program. If not, see <http://www.gnu.org/licenses/>. 16 package org.openstreetmap.josm.plugins.imageryxmlbounds; 16 package org.openstreetmap.josm.plugins.imageryxmlbounds.io; 17 17 18 18 import static org.openstreetmap.josm.tools.I18n.tr; … … 44 44 import org.openstreetmap.josm.io.IllegalDataException; 45 45 import org.openstreetmap.josm.io.imagery.ImageryReader; 46 import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsConstants; 47 import org.openstreetmap.josm.plugins.imageryxmlbounds.XmlBoundsLayer; 46 48 import org.xml.sax.SAXException; 47 49 … … 163 165 } 164 166 167 public DataSet parseDataSet(final String source) throws IOException, SAXException { 168 return parseDataSet(source, null); 169 } 170 171 public DataSet parseDataSet(final File file) throws IOException, SAXException { 172 return parseDataSet(null, file); 173 } 174 175 protected DataSet parseDataSet(final String source, final File file) throws IOException, SAXException { 176 ImageryReader reader = null; 177 178 try { 179 reader = new ValidatingImageryReader(source != null ? source : file.getAbsolutePath()); 180 } catch (SAXException e) { 181 if (JOptionPane.showConfirmDialog( 182 Main.parent, 183 tr("Validating error in file {0}:\n{1}\nDo you want to continue without validating the file ?", 184 source != null ? source : file.getPath(), e.getLocalizedMessage()), 185 tr("Open Imagery XML file"), 186 JOptionPane.YES_NO_CANCEL_OPTION) != JOptionPane.YES_OPTION) { 187 return null; 188 } 189 190 reader = new ImageryReader(source != null ? source : file.getAbsolutePath()); 191 } 192 193 return convertImageryEntries(reader.parse()); 194 } 195 196 protected void importData(final String source, final String layerName, final File file, ProgressMonitor progressMonitor) 197 throws IOException, IllegalDataException { 198 try { 199 final DataSet dataSet = parseDataSet(source, file); 200 final XmlBoundsLayer layer = new XmlBoundsLayer(dataSet, source != null ? layerName : file.getName(), file); 201 Runnable uiStuff = new Runnable() { 202 @Override 203 public void run() { 204 if (dataSet.allPrimitives().isEmpty()) { 205 JOptionPane.showMessageDialog( 206 Main.parent, tr("No data found in file {0}.", source != null ? source : file.getPath()), 207 tr("Open Imagery XML file"), JOptionPane.INFORMATION_MESSAGE); 208 } 209 Main.main.addLayer(layer); 210 layer.onPostLoadFromFile(); 211 } 212 }; 213 if (SwingUtilities.isEventDispatchThread()) { 214 uiStuff.run(); 215 } else { 216 SwingUtilities.invokeLater(uiStuff); 217 } 218 } catch (SAXException e) { 219 e.printStackTrace(); 220 } 221 } 222 165 223 /* (non-Javadoc) 166 224 * @see org.openstreetmap.josm.io.FileImporter#importData(java.io.File, org.openstreetmap.josm.gui.progress.ProgressMonitor) … … 169 227 public void importData(final File file, ProgressMonitor progressMonitor) 170 228 throws IOException, IllegalDataException { 171 try { 172 ImageryReader reader = null; 173 174 try { 175 reader = new ValidatingImageryReader(file.getAbsolutePath()); 176 } catch (SAXException e) { 177 if (JOptionPane.showConfirmDialog( 178 Main.parent, 179 tr("Validating error in file {0}:\n{1}\nDo you want to continue without validating the file ?", file.getPath(), e.getLocalizedMessage()), 180 tr("Open Imagery XML file"), 181 JOptionPane.YES_NO_CANCEL_OPTION) != JOptionPane.YES_OPTION) { 182 return; 183 } 184 185 reader = new ImageryReader(file.getAbsolutePath()); 186 } 187 188 final DataSet dataSet = convertImageryEntries(reader.parse()); 189 190 final XmlBoundsLayer layer = new XmlBoundsLayer(dataSet, file.getName(), file); 191 Runnable uiStuff = new Runnable() { 192 @Override 193 public void run() { 194 if (dataSet.allPrimitives().isEmpty()) { 195 JOptionPane.showMessageDialog( 196 Main.parent, 197 tr("No data found in file {0}.", file.getPath()), 198 tr("Open Imagery XML file"), 199 JOptionPane.INFORMATION_MESSAGE); 200 } 201 Main.main.addLayer(layer); 202 layer.onPostLoadFromFile(); 203 } 204 }; 205 if (SwingUtilities.isEventDispatchThread()) { 206 uiStuff.run(); 207 } else { 208 SwingUtilities.invokeLater(uiStuff); 209 } 210 } catch (SAXException e) { 211 e.printStackTrace(); 212 } 213 } 229 importData(null, null, file, progressMonitor); 230 } 231 232 public void importData(final String source, final String layerName, ProgressMonitor progressMonitor) 233 throws IOException, IllegalDataException { 234 importData(source, layerName, null, progressMonitor); 235 } 214 236 215 237 /* (non-Javadoc)
Note:
See TracChangeset
for help on using the changeset viewer.