Changeset 2331 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2009-10-27T14:51:46+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/DownloadAction.java
r2330 r2331 35 35 public class DownloadAction extends JosmAction { 36 36 private static final Logger logger = Logger.getLogger(DownloadAction.class.getName()); 37 38 private DownloadDialog dialog; 39 private ExtendedDialog downloadDialog; 40 37 41 38 public DownloadAction() { 42 39 super(tr("Download from OSM..."), "download", tr("Download map data from the OSM server."), … … 45 42 } 46 43 47 /**48 * Creates the download dialog49 *50 * @return the downlaod dialog51 */52 protected ExtendedDialog createDownloadDialog() {53 if (dialog == null)54 dialog = new DownloadDialog();55 dialog.restoreSettings();56 57 final String prefName = dialog.getClass().getName()+ ".geometry";58 final WindowGeometry wg = WindowGeometry.centerInWindow(Main.parent,59 new Dimension(1000,600));60 61 if (downloadDialog == null) {62 JPanel downPanel = new JPanel(new BorderLayout());63 downPanel.add(dialog, BorderLayout.CENTER);64 downloadDialog= new ExtendedDialog(Main.parent,65 tr("Download"),66 new String[] {tr("OK"), tr("Cancel")});67 downloadDialog.setContent(downPanel, false /* don't use a scroll pane inside the dialog */);68 downloadDialog.setButtonIcons(new String[] {"ok", "cancel"});69 downloadDialog.setRememberWindowGeometry(prefName, wg);70 }71 return downloadDialog;72 }73 74 44 public void actionPerformed(ActionEvent e) { 75 ExtendedDialog dlg = createDownloadDialog(); 76 boolean finish = false; 77 while (!finish) { 78 dlg.showDialog(); 79 if (dlg.getValue() == 1 /* OK */) { 80 dialog.rememberSettings(); 81 Bounds area = dialog.getSelectedDownloadArea(); 82 if (dialog.isDownloadOsmData()) { 83 DownloadOsmTask task = new DownloadOsmTask(); 84 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null); 85 Main.worker.submit(new PostDownloadHandler(task, future)); 86 finish = true; 87 } 88 if (dialog.isDownloadGpxData()) { 89 DownloadGpsTask task = new DownloadGpsTask(); 90 Future<?> future = task.download(dialog.isNewLayerRequired(),area, null); 91 Main.worker.submit(new PostDownloadHandler(task, future)); 92 finish = true; 93 } 94 } else { 95 finish = true; 45 DownloadDialog dialog = DownloadDialog.getInstance(); 46 dialog.setVisible(true); 47 if (! dialog.isCanceled()) { 48 dialog.rememberSettings(); 49 Bounds area = dialog.getSelectedDownloadArea(); 50 if (dialog.isDownloadOsmData()) { 51 DownloadOsmTask task = new DownloadOsmTask(); 52 Future<?> future = task.download(dialog.isNewLayerRequired(), area, null); 53 Main.worker.submit(new PostDownloadHandler(task, future)); 96 54 } 97 if (!finish) { 98 JOptionPane.showMessageDialog( 99 Main.parent, 100 tr("Please select at least one task to download"), 101 tr("Error"), 102 JOptionPane.ERROR_MESSAGE 103 ); 55 if (dialog.isDownloadGpxData()) { 56 DownloadGpsTask task = new DownloadGpsTask(); 57 Future<?> future = task.download(dialog.isNewLayerRequired(),area, null); 58 Main.worker.submit(new PostDownloadHandler(task, future)); 104 59 } 105 } 106 } 60 } 61 } 107 62 }
Note:
See TracChangeset
for help on using the changeset viewer.