Changeset 28010 in osm for applications/editors/josm
- Timestamp:
- 2012-03-07T00:40:39+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModulePreference.java
r28000 r28010 209 209 * @return the list of modules waiting for update or download 210 210 */ 211 /*public List<ModuleInformation> getModulesScheduledForUpdateOrDownload() {211 public List<ModuleInformation> getModulesScheduledForUpdateOrDownload() { 212 212 return model != null ? model.getModulesScheduledForUpdateOrDownload() : null; 213 } */213 } 214 214 215 215 public boolean ok() { -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/ModulePreferencesModel.java
r28000 r28010 190 190 * @return the list of modules waiting for update or download 191 191 */ 192 /*public List<ModuleInformation> getModulesScheduledForUpdateOrDownload() {192 public List<ModuleInformation> getModulesScheduledForUpdateOrDownload() { 193 193 List<ModuleInformation> ret = new ArrayList<ModuleInformation>(); 194 194 for (String module: pendingDownloads) { … … 200 200 } 201 201 return ret; 202 } */202 } 203 203 204 204 /** -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/gui/OdPreferenceSetting.java
r28000 r28010 27 27 import javax.swing.JCheckBox; 28 28 import javax.swing.JLabel; 29 import javax.swing.JOptionPane; 29 30 import javax.swing.JPanel; 30 31 import javax.swing.JScrollPane; … … 33 34 import javax.swing.JTextField; 34 35 import javax.swing.SwingConstants; 36 import javax.swing.SwingUtilities; 35 37 36 38 import org.openstreetmap.josm.Main; … … 38 40 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 39 41 import org.openstreetmap.josm.plugins.opendata.core.OdConstants; 42 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleDownloadTask; 43 import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleInformation; 40 44 import org.openstreetmap.josm.tools.GBC; 41 45 … … 142 146 @Override 143 147 public boolean ok() { 144 modulePref.ok();148 boolean result = modulePref.ok(); 145 149 //Main.pref.put(PREF_COORDINATES, rbWGS84.isSelected() ? VALUE_WGS84 : VALUE_CC9ZONES); 146 150 Main.pref.put(PREF_OAPI, oapi.getText()); 147 151 Main.pref.put(PREF_XAPI, xapi.getText()); 148 152 Main.pref.put(PREF_RAWDATA, rawData.isSelected()); 149 return false; 153 154 // create a task for downloading modules if the user has activated, yet not downloaded, 155 // new modules 156 // 157 final List<ModuleInformation> toDownload = modulePref.getModulesScheduledForUpdateOrDownload(); 158 final ModuleDownloadTask task; 159 if (toDownload != null && ! toDownload.isEmpty()) { 160 task = new ModuleDownloadTask(masterPanel, toDownload, tr("Download modules")); 161 } else { 162 task = null; 163 } 164 165 // this is the task which will run *after* the modules are downloaded 166 // 167 final Runnable continuation = new Runnable() { 168 public void run() { 169 boolean requiresRestart = false; 170 if (task != null && !task.isCanceled()) { 171 if (!task.getDownloadedModules().isEmpty()) { 172 requiresRestart = true; 173 } 174 } 175 176 // build the messages. We only display one message, including the status 177 // information from the module download task and - if necessary - a hint 178 // to restart JOSM 179 // 180 StringBuilder sb = new StringBuilder(); 181 sb.append("<html>"); 182 if (task != null && !task.isCanceled()) { 183 sb.append(ModulePreference.buildDownloadSummary(task)); 184 } 185 if (requiresRestart) { 186 sb.append(tr("You have to restart JOSM for some settings to take effect.")); 187 } 188 sb.append("</html>"); 189 190 // display the message, if necessary 191 // 192 if ((task != null && !task.isCanceled()) || requiresRestart) { 193 JOptionPane.showMessageDialog( 194 Main.parent, 195 sb.toString(), 196 tr("Warning"), 197 JOptionPane.WARNING_MESSAGE 198 ); 199 } 200 Main.parent.repaint(); 201 } 202 }; 203 204 if (task != null) { 205 // if we have to launch a module download task we do it asynchronously, followed 206 // by the remaining "save preferences" activites run on the Swing EDT. 207 // 208 Main.worker.submit(task); 209 Main.worker.submit( 210 new Runnable() { 211 public void run() { 212 SwingUtilities.invokeLater(continuation); 213 } 214 } 215 ); 216 } else { 217 // no need for asynchronous activities. Simply run the remaining "save preference" 218 // activities on this thread (we are already on the Swing EDT 219 // 220 continuation.run(); 221 } 222 223 return task == null ? result : false; 150 224 } 151 225 }
Note:
See TracChangeset
for help on using the changeset viewer.