Changeset 806 in josm for trunk/src/org/openstreetmap/josm/gui/download
- Timestamp:
- 2008-08-18T12:12:40+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r627 r806 24 24 /** 25 25 * Main download dialog. 26 * 26 * 27 27 * Can be extended by plugins in two ways: 28 28 * (1) by adding download tasks that are then called with the selected bounding box 29 29 * (2) by adding "DownloadSelection" objects that implement different ways of selecting a bounding box 30 * 30 * 31 31 * @author Frederik Ramm <frederik@remote.org> 32 32 * 33 33 */ 34 34 public class DownloadDialog extends JPanel { 35 35 36 36 // the JOptionPane that contains this dialog. required for the closeDialog() method. 37 37 private JOptionPane optionPane; 38 38 39 39 public interface DownloadTask { 40 40 /** … … 63 63 public final JTabbedPane tabpane = new JTabbedPane(); 64 64 public final JCheckBox newLayer; 65 65 66 66 public double minlon; 67 67 public double minlat; 68 68 public double maxlon; 69 69 public double maxlat; 70 71 70 71 72 72 public DownloadDialog() { 73 73 setLayout(new GridBagLayout()); 74 74 75 75 downloadTasks.add(new DownloadOsmTask()); 76 76 downloadTasks.add(new DownloadGpsTask()); 77 77 78 78 // adding the download tasks 79 79 add(new JLabel(tr("Data Sources and Types")), GBC.eol().insets(0,5,0,0)); … … 85 85 } 86 86 } 87 87 88 88 // predefined download selections 89 89 downloadSelections.add(new BoundingBoxSelection()); 90 downloadSelections.add(new BookmarkSelection()); 90 downloadSelections.add(new BookmarkSelection()); 91 91 downloadSelections.add(new WorldChooser()); 92 92 93 93 // add selections from plugins 94 94 for (PluginProxy p : Main.plugins) { 95 95 p.addDownloadSelection(downloadSelections); 96 96 } 97 97 98 98 // now everybody may add their tab to the tabbed pane 99 99 // (not done right away to allow plugins to remove one of … … 102 102 s.addGui(this); 103 103 } 104 104 105 105 if (Main.map != null) { 106 106 MapView mv = Main.map.mapView; … … 111 111 boundingBoxChanged(null); 112 112 } 113 else if (Main.pref.hasKey("osm-download.bounds")) { 114 // read the bounding box from the preferences 115 try { 116 String bounds[] = Main.pref.get("osm-download.bounds").split(";"); 117 minlat = Double.parseDouble(bounds[0]); 118 minlon = Double.parseDouble(bounds[1]); 119 maxlat = Double.parseDouble(bounds[2]); 120 maxlon = Double.parseDouble(bounds[3]); 121 boundingBoxChanged(null); 122 } 123 catch (Exception e) { 124 e.printStackTrace(); 125 } 126 } 113 127 114 128 newLayer = new JCheckBox(tr("Download as new layer"), Main.pref.getBoolean("download.newlayer", false)); … … 117 131 add(new JLabel(tr("Download Area")), GBC.eol().insets(0,5,0,0)); 118 132 add(tabpane, GBC.eol().fill()); 119 133 120 134 try { 121 135 tabpane.setSelectedIndex(Integer.parseInt(Main.pref.get("download.tab", "0"))); … … 124 138 } 125 139 } 126 140 127 141 /** 128 * Distributes a "bounding box changed" from one DownloadSelection 129 * object to the others, so they may update or clear their input 142 * Distributes a "bounding box changed" from one DownloadSelection 143 * object to the others, so they may update or clear their input 130 144 * fields. 131 * 145 * 132 146 * @param eventSource - the DownloadSelection object that fired this notification. 133 147 */ … … 135 149 for (DownloadSelection s : downloadSelections) { 136 150 if (s != eventSource) s.boundingBoxChanged(this); 137 } 151 } 138 152 } 139 153 … … 144 158 return tabpane.getSelectedIndex(); 145 159 } 146 160 147 161 /** 148 162 * Closes the download dialog. This is intended to be called by one of 149 163 * the various download area selection "plugins". 150 * 164 * 151 165 * @param download true to download selected data, false to cancel download 152 166 */ … … 160 174 */ 161 175 public void setOptionPane(JOptionPane optionPane) { 162 163 176 this.optionPane = optionPane; 177 } 164 178 }
Note:
See TracChangeset
for help on using the changeset viewer.