Changeset 9611 in josm for trunk/src/org
- Timestamp:
- 2016-01-24T15:06:37+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ExpertToggleAction.java
r7025 r9611 124 124 ); 125 125 putValue("toolbar", "expertmode"); 126 Main.toolbar.register(this); 126 if (Main.toolbar != null) { 127 Main.toolbar.register(this); 128 } 127 129 setSelected(Main.pref.getBoolean("expert", false)); 128 130 notifySelectedState(); -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r8846 r9611 74 74 } 75 75 76 private JosmTextField tfFilter; 77 private PluginListPanel pnlPluginPreferences; 78 private PluginPreferencesModel model; 79 private JScrollPane spPluginPreferences; 80 private PluginUpdatePolicyPanel pnlPluginUpdatePolicy; 81 82 /** 83 * is set to true if this preference pane has been selected by the user 84 */ 85 private boolean pluginPreferencesActivated; 86 76 87 private PluginPreference() { 77 88 super(/* ICON(preferences/) */ "plugin", tr("Plugins"), tr("Configure available plugins."), false, new JTabbedPane()); … … 146 157 } 147 158 148 private JosmTextField tfFilter;149 private PluginListPanel pnlPluginPreferences;150 private PluginPreferencesModel model;151 private JScrollPane spPluginPreferences;152 private PluginUpdatePolicyPanel pnlPluginUpdatePolicy;153 154 /**155 * is set to true if this preference pane has been selected156 * by the user157 */158 private boolean pluginPreferencesActivated;159 160 159 protected JPanel buildSearchFieldPanel() { 161 JPanel pnl 160 JPanel pnl = new JPanel(new GridBagLayout()); 162 161 pnl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); 163 162 GridBagConstraints gc = new GridBagConstraints(); … … 268 267 269 268 /** 270 * Replies the list of plugins waiting for update or download269 * Replies the set of plugins waiting for update or download 271 270 * 272 * @return the list of plugins waiting for update or download271 * @return the set of plugins waiting for update or download 273 272 */ 274 273 public Set<PluginInformation> getPluginsScheduledForUpdateOrDownload() { … … 276 275 } 277 276 277 /** 278 * Replies the list of plugins which have been added by the user to the set of activated plugins 279 * 280 * @return the list of newly activated plugins 281 */ 278 282 public List<PluginInformation> getNewlyActivatedPlugins() { 279 283 return model != null ? model.getNewlyActivatedPlugins() : null; … … 289 293 Collections.sort(l); 290 294 Main.pref.putCollection("plugins", l); 291 if (!model.getNewlyDeactivatedPlugins().isEmpty()) return true; 295 if (!model.getNewlyDeactivatedPlugins().isEmpty()) 296 return true; 292 297 for (PluginInformation pi : model.getNewlyActivatedPlugins()) { 293 if (!pi.canloadatruntime) return true; 298 if (!pi.canloadatruntime) 299 return true; 294 300 } 295 301 } … … 308 314 @Override 309 315 public void run() { 310 if (task.isCanceled()) return; 311 SwingUtilities.invokeLater(new Runnable() { 312 @Override 313 public void run() { 314 model.setAvailablePlugins(task.getAvailablePlugins()); 315 pnlPluginPreferences.refreshView(); 316 } 317 }); 316 if (!task.isCanceled()) { 317 SwingUtilities.invokeLater(new Runnable() { 318 @Override 319 public void run() { 320 model.setAvailablePlugins(task.getAvailablePlugins()); 321 pnlPluginPreferences.refreshView(); 322 } 323 }); 324 } 318 325 } 319 326 }; … … 346 353 @Override 347 354 public void run() { 348 if (task.isCanceled()) return; 349 SwingUtilities.invokeLater(new Runnable() { 350 @Override 351 public void run() { 352 model.updateAvailablePlugins(task.getAvailablePlugins()); 353 pnlPluginPreferences.refreshView(); 354 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); // fix #7030 355 } 356 }); 355 if (!task.isCanceled()) { 356 SwingUtilities.invokeLater(new Runnable() { 357 @Override 358 public void run() { 359 model.updateAvailablePlugins(task.getAvailablePlugins()); 360 pnlPluginPreferences.refreshView(); 361 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); // fix #7030 362 } 363 }); 364 } 357 365 } 358 366 }; … … 512 520 private static class PluginConfigurationSitesPanel extends JPanel { 513 521 514 private DefaultListModel<String> model;515 516 protected final void build() {517 s etLayout(new GridBagLayout());522 private final DefaultListModel<String> model = new DefaultListModel<>(); 523 524 PluginConfigurationSitesPanel() { 525 super(new GridBagLayout()); 518 526 add(new JLabel(tr("Add JOSM Plugin description URL.")), GBC.eol()); 519 model = new DefaultListModel<>();520 527 for (String s : Main.pref.getPluginSites()) { 521 528 model.addElement(s); … … 582 589 } 583 590 584 PluginConfigurationSitesPanel() {585 build();586 }587 588 591 public List<String> getUpdateSites() { 589 if (model.getSize() == 0) return Collections.emptyList(); 592 if (model.getSize() == 0) 593 return Collections.emptyList(); 590 594 List<String> ret = new ArrayList<>(model.getSize()); 591 595 for (int i = 0; i < model.getSize(); i++) { -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
r9078 r9611 83 83 activePlugins.addAll(Main.pref.getCollection("plugins", activePlugins)); 84 84 for (PluginInformation pi: availablePlugins) { 85 if (selectedPluginsMap.get(pi) == null) { 86 if (activePlugins.contains(pi.name)) { 87 selectedPluginsMap.put(pi, Boolean.TRUE); 88 } 85 if (selectedPluginsMap.get(pi) == null && activePlugins.contains(pi.name)) { 86 selectedPluginsMap.put(pi, Boolean.TRUE); 89 87 } 90 88 } … … 94 92 95 93 protected void updateAvailablePlugin(PluginInformation other) { 96 if (other == null) return; 97 PluginInformation pi = getPluginInformation(other.name); 98 if (pi == null) { 99 availablePlugins.add(other); 100 return; 101 } 102 pi.updateFromPluginSite(other); 94 if (other != null) { 95 PluginInformation pi = getPluginInformation(other.name); 96 if (pi == null) { 97 availablePlugins.add(other); 98 return; 99 } 100 pi.updateFromPluginSite(other); 101 } 103 102 } 104 103 … … 216 215 */ 217 216 public void clearPendingPlugins(Collection<PluginInformation> plugins) { 218 if (plugins == null || plugins.isEmpty()) return; 219 for (PluginInformation pi: plugins) { 220 pendingDownloads.remove(pi.name); 217 if (plugins != null) { 218 for (PluginInformation pi: plugins) { 219 pendingDownloads.remove(pi.name); 220 } 221 221 } 222 222 } … … 264 264 public boolean isSelectedPlugin(String name) { 265 265 PluginInformation pi = getPluginInformation(name); 266 if (pi == null ) return false;267 if (selectedPluginsMap.get(pi) == null)return false;266 if (pi == null || selectedPluginsMap.get(pi) == null) 267 return false; 268 268 return selectedPluginsMap.get(pi); 269 269 } … … 273 273 * the set of activated plugins. 274 274 * 275 * @return the set of newly deactivated plugins275 * @return the set of newly activated plugins 276 276 */ 277 277 public List<PluginInformation> getNewlyActivatedPlugins() { … … 289 289 /** 290 290 * Replies the set of plugins which have been removed by the user from 291 * the set of activated plugins.291 * the set of deactivated plugins. 292 292 * 293 293 * @return the set of newly deactivated plugins … … 349 349 */ 350 350 public void refreshLocalPluginVersion(Collection<PluginInformation> plugins) { 351 if (plugins == null) return; 352 for (PluginInformation pi : plugins) { 353 File downloadedPluginFile = PluginHandler.findUpdatedJar(pi.name); 354 if (downloadedPluginFile == null) { 355 continue; 356 } 357 try { 358 PluginInformation newinfo = new PluginInformation(downloadedPluginFile, pi.name); 359 PluginInformation oldinfo = getPluginInformation(pi.name); 360 if (oldinfo == null) { 361 // should not happen 351 if (plugins != null) { 352 for (PluginInformation pi : plugins) { 353 File downloadedPluginFile = PluginHandler.findUpdatedJar(pi.name); 354 if (downloadedPluginFile == null) { 362 355 continue; 363 356 } 364 oldinfo.updateLocalInfo(newinfo); 365 } catch (PluginException e) { 366 Main.error(e); 357 try { 358 PluginInformation newinfo = new PluginInformation(downloadedPluginFile, pi.name); 359 PluginInformation oldinfo = getPluginInformation(pi.name); 360 if (oldinfo != null) { 361 oldinfo.updateLocalInfo(newinfo); 362 } 363 } catch (PluginException e) { 364 Main.error(e); 365 } 367 366 } 368 367 }
Note:
See TracChangeset
for help on using the changeset viewer.