Changeset 9611 in josm
- Timestamp:
- 2016-01-24T15:06:37+01:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 6 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 } -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/MapViewMock.java
r8949 r9611 52 52 @Override 53 53 public Point2D getPoint2D(EastNorth p) { 54 return new Point2D.Double(p.getX(), p.getY());54 return p != null ? new Point2D.Double(p.getX(), p.getY()) : null; 55 55 } 56 56 -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java
r9607 r9611 12 12 import org.openstreetmap.josm.JOSMFixture; 13 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.data.coor.LatLon; 14 15 import org.openstreetmap.josm.data.osm.Node; 15 16 import org.openstreetmap.josm.data.osm.Relation; … … 54 55 ConflictPainter cp = new ConflictPainter(Main.map.mapView, new BufferedImage(800, 600, BufferedImage.TYPE_3BYTE_BGR).createGraphics()); 55 56 Node n1 = new Node(1, 1); 57 n1.setCoor(new LatLon(1, 1)); 56 58 Node n2 = new Node(2, 1); 59 n2.setCoor(new LatLon(2, 2)); 57 60 Way w = new Way(1, 1); 58 61 w.addNode(n1); -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java
r9585 r9611 2 2 package org.openstreetmap.josm.gui.preferences.plugin; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.Assert.assertNotNull; 6 7 import java.io.File; 8 import java.util.Arrays; 9 import java.util.Collection; 10 import java.util.Collections; 5 11 6 12 import org.junit.BeforeClass; 7 13 import org.junit.Test; 8 14 import org.openstreetmap.josm.JOSMFixture; 15 import org.openstreetmap.josm.TestUtils; 16 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 18 import org.openstreetmap.josm.plugins.PluginDownloadTask; 19 import org.openstreetmap.josm.plugins.PluginInformation; 9 20 10 21 /** … … 28 39 assertNotNull(new PluginPreference.Factory().createPreferenceSetting()); 29 40 } 41 42 /** 43 * Unit test of {@link PluginPreference#buildDownloadSummary}. 44 * @throws Exception if an error occurs 45 */ 46 @Test 47 public void testBuildDownloadSummary() throws Exception { 48 final PluginInformation dummy = new PluginInformation( 49 new File(TestUtils.getTestDataRoot() + "plugin/dummy_plugin.jar"), "dummy_plugin"); 50 assertEquals("", PluginPreference.buildDownloadSummary( 51 new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), ""))); 52 assertEquals("", PluginPreference.buildDownloadSummary( 53 new PluginDownloadTask(NullProgressMonitor.INSTANCE, Arrays.asList(dummy), ""))); 54 assertEquals("The following plugin has been downloaded <strong>successfully</strong>:<ul><li>dummy_plugin (31772)</li></ul>"+ 55 "Downloading the following plugin has <strong>failed</strong>:<ul><li>dummy_plugin</li></ul>", 56 PluginPreference.buildDownloadSummary( 57 new PluginDownloadTask(NullProgressMonitor.INSTANCE, Arrays.asList(dummy), "") { 58 @Override 59 public Collection<PluginInformation> getFailedPlugins() { 60 return Collections.singleton(dummy); 61 } 62 63 @Override 64 public Collection<PluginInformation> getDownloadedPlugins() { 65 return Collections.singleton(dummy); 66 } 67 })); 68 } 69 70 /** 71 * Unit test of {@link PluginPreference#notifyDownloadResults}. 72 */ 73 @Test 74 public void testNotifyDownloadResults() { 75 PluginDownloadTask task = new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), ""); 76 PluginPreference.notifyDownloadResults(null, task, false); 77 PluginPreference.notifyDownloadResults(null, task, true); 78 } 79 80 /** 81 * Unit test of {@link PluginPreference#addGui}. 82 */ 83 @Test 84 public void testAddGui() { 85 new PluginPreference.Factory().createPreferenceSetting().addGui(new PreferenceTabbedPane()); 86 } 30 87 }
Note:
See TracChangeset
for help on using the changeset viewer.