Changeset 25754 in osm for applications/editors/josm
- Timestamp:
- 2011-03-31T12:02:52+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustLayer.java
r25656 r25754 89 89 90 90 /** 91 * Updates the <code>MapdustLayer</code> with the new 92 * <code>MapdustGUI</code> and <code>MapdustBug</code> list. 93 * 94 * @param mapdustGUI The <code>MapdustGUI</code> 95 * @param mapdustBugList The <code>MapdustBug</code> list 96 */ 97 public void update(MapdustGUI mapdustGUI, List<MapdustBug> mapdustBugList) { 98 this.mapdustGUI = mapdustGUI; 99 this.mapdustBugList = mapdustBugList; 100 this.bugSelected = null; 101 } 102 103 /** 91 104 * Returns the icon of the MapDust layer. 92 105 * … … 169 182 public void paint(Graphics2D g, MapView mv, Bounds bounds) { 170 183 JToolTip tooltip = new JToolTip(); 171 if (mapdustBugList != null && mapdustBugList.size() >0) {184 if (mapdustBugList != null && mapdustBugList.size() > 0) { 172 185 /* draw the current visible bugs */ 173 186 for (MapdustBug bug : mapdustBugList) { … … 203 216 MapdustBug bugSelected = getMapdustGUI().getSelectedBug(); 204 217 if (bugSelected == null) { 205 218 bugSelected = clickedBug; 206 219 } 207 220 setBugSelected(bugSelected); -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java
r25656 r25754 418 418 */ 419 419 @Override 420 public void layerAdded(Layer layer) { 421 if (layer instanceof MapdustLayer) { 422 /* download the MapDust bugs and update the plugin */ 423 if (mapdustBugList == null) { 424 updatePluginData(); 425 } 426 } 427 } 420 public void layerAdded(Layer layer) {} 428 421 429 422 /** … … 508 501 private BoundingBox getBBox() { 509 502 MapView mapView = Main.map.mapView; 510 Bounds bounds = 511 new Bounds(mapView.getLatLon(0, mapView.getHeight()), 512 mapView.getLatLon(mapView.getWidth(), 0)); 503 Bounds bounds = new Bounds(mapView.getLatLon(0, mapView.getHeight()), 504 mapView.getLatLon(mapView.getWidth(), 0)); 513 505 return new BoundingBox(bounds.getMin().lon(), bounds.getMin().lat(), 514 506 bounds.getMax().lon(), bounds.getMax().lat()); … … 522 514 private void updatePluginData() { 523 515 Main.worker.execute(new Runnable() { 524 525 516 @Override 526 517 public void run() { … … 549 540 /* update the view */ 550 541 SwingUtilities.invokeLater(new Runnable() { 551 552 542 @Override 553 543 public void run() { … … 562 552 } 563 553 554 564 555 /** 565 556 * Updates the current view ( map and MapDust bug list), with the given list … … 567 558 */ 568 559 protected void updateView() { 569 /* update the dialog with the new data */ 570 mapdustGUI.update(mapdustBugList, this); 571 /* update the MapdustLayer */ 572 if (mapdustLayer == null) { 573 /* create and add the layer */ 574 mapdustLayer = 575 new MapdustLayer("MapDust", mapdustGUI, mapdustBugList); 576 Main.main.addLayer(this.mapdustLayer); 577 Main.map.mapView.moveLayer(this.mapdustLayer, 0); 578 Main.map.mapView.addMouseListener(this); 579 NavigatableComponent.addZoomChangeListener(this); 580 } else { 581 /* re-set the properties */ 582 mapdustLayer.destroy(); 583 mapdustLayer.setMapdustGUI(mapdustGUI); 584 mapdustLayer.setMapdustBugList(mapdustBugList); 585 mapdustLayer.setBugSelected(null); 586 } 587 /* repaint */ 588 mapdustGUI.revalidate(); 589 Main.map.mapView.revalidate(); 590 Main.map.repaint(); 560 if (Main.map != null && Main.map.mapView != null) { 561 /* update the MapdustLayer */ 562 boolean needRepaint = false; 563 if (!containsMapdustLayer()) { 564 /* first start or layer was deleted */ 565 if (mapdustGUI.isDownloaded()) { 566 mapdustGUI.update(mapdustBugList, this); 567 /* create and add the layer */ 568 mapdustLayer = new MapdustLayer("MapDust", mapdustGUI, 569 mapdustBugList); 570 Main.main.addLayer(this.mapdustLayer); 571 Main.map.mapView.moveLayer(this.mapdustLayer, 0); 572 Main.map.mapView.addMouseListener(this); 573 NavigatableComponent.addZoomChangeListener(this); 574 needRepaint = true; 575 } 576 } else { 577 if (mapdustLayer != null) { 578 /* MapDust data was changed */ 579 mapdustGUI.update(mapdustBugList, this); 580 mapdustLayer.destroy(); 581 mapdustLayer.update(mapdustGUI, mapdustBugList); 582 needRepaint = true; 583 } 584 } 585 if (needRepaint) { 586 /* force repaint */ 587 mapdustGUI.revalidate(); 588 Main.map.mapView.revalidate(); 589 Main.map.repaint(); 590 } 591 } 592 } 593 594 /** 595 * Verifies if the <code>MapView</code> contains or not the 596 * <code>MapdustLayer</code> layer. 597 * 598 * @return true if the <code>MapView</code> contains the 599 * <code>MapdustLayer</code> false otherwise 600 */ 601 private boolean containsMapdustLayer() { 602 boolean contains = false; 603 List<Layer> all = Main.map.mapView.getAllLayersAsList(); 604 if (mapdustLayer != null && all.contains(mapdustLayer)) { 605 contains = true; 606 } 607 return contains; 591 608 } 592 609 -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/MapdustGUI.java
r25656 r25754 96 96 private boolean downloaded = false; 97 97 98 /** Specifies if the MapDust layer was or not before deleted */99 boolean wasDeleted = false;100 101 98 /** 102 99 * Builds a <code>MapdustGUi</code> based on the given parameters. … … 125 122 notifyObservers(null, true); 126 123 downloaded = true; 127 }128 if (wasDeleted) {129 notifyObservers(null, true);130 wasDeleted = false;131 124 } 132 125 super.showDialog(); … … 147 140 mainPanel = null; 148 141 panel = null; 142 actionPanel = null; 149 143 } else { 150 144 /* from online to offline */ 151 remove(mainPanel); 152 mainPanel = null; 153 panel = null; 154 } 155 wasDeleted = true; 145 if (mainPanel != null) { 146 remove(mainPanel); 147 mainPanel = null; 148 panel = null; 149 detailsPanel = null; 150 } 151 } 152 downloaded = false; 153 button.setSelected(false); 156 154 super.destroy(); 155 } 156 157 @Override 158 protected void toggleButtonHook() { 159 if (isVisible()) { 160 setVisible(false); 161 button.setSelected(false); 162 } else { 163 setVisible(true); 164 } 157 165 } 158 166 … … 168 176 actionList.add(action); 169 177 List<MapdustBug> mapdustBugs = panel.getMapdustBugsList(); 170 boolean showBug = 171 shouldDisplay(action.getMapdustBug(),mapdustPlugin.getFilter());178 boolean showBug = shouldDisplay(action.getMapdustBug(), 179 mapdustPlugin.getFilter()); 172 180 mapdustBugs = modifyBug(mapdustBugs, action.getMapdustBug(), showBug); 173 174 181 /* update panels */ 175 182 updateMapdustPanel(mapdustBugs); 176 183 updateMapdustActionPanel(actionList); 177 if (showBug 178 && !action.getCommand().equals(MapdustServiceCommand.ADD_BUG)) { 184 if (showBug && !action.getCommand().equals(MapdustServiceCommand.ADD_BUG)) { 179 185 panel.resetSelectedBug(0); 180 186 } else { … … 246 252 247 253 /* update panels */ 248 List<MapdustBug> bugs = 249 filterMapdustBugList(mapdustBugs, actionList, 250 mapdustPlugin.getFilter()); 254 List<MapdustBug> bugs = filterMapdustBugList(mapdustBugs, 255 actionList,mapdustPlugin.getFilter()); 251 256 updateMapdustPanel(bugs); 252 257 updateMapdustActionPanel(actionList); … … 256 261 } 257 262 } 258 259 263 260 264 /** … … 272 276 } 273 277 if (panel == null) { 274 panel = 275 new MapdustBugListPanel(mapdustBugs, "Bug reports", 276 mapdustPlugin); 278 panel = new MapdustBugListPanel(mapdustBugs, "Bug reports", 279 mapdustPlugin); 277 280 panel.addObserver(detailsPanel); 278 281 } else { … … 289 292 private void updateMapdustActionPanel(List<MapdustAction> actionList) { 290 293 if (actionPanel == null) { 291 actionPanel = 292 new MapdustActionPanel(actionList, "Offline Contribution", 293 mapdustPlugin); 294 actionPanel = new MapdustActionPanel(actionList, 295 "Offline Contribution", mapdustPlugin); 294 296 } else { 295 297 actionPanel.updateComponents(actionList); … … 446 448 } 447 449 450 448 451 /** 449 452 * Adds a new MapDust bug details observer to the list of observers. … … 516 519 this.initialUpdateObservers.iterator(); 517 520 while (elements.hasNext()) { 518 (elements.next()).update( null, true);521 (elements.next()).update(filter, first); 519 522 } 520 523 } … … 552 555 } 553 556 557 /** 558 * Returns the downloaded flag 559 * 560 * @return the downloaded 561 */ 562 public boolean isDownloaded() { 563 return downloaded; 564 } 565 554 566 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustButtonPanel.java
r25657 r25754 112 112 imagePath = "dialogs/online.png"; 113 113 } 114 AbstractAction action = 115 new ExecuteWorkOffline(mapdustPlugin.getMapdustGUI());114 AbstractAction action = new ExecuteWorkOffline( 115 mapdustPlugin.getMapdustGUI()); 116 116 ((ExecuteWorkOffline) action).addObserver(mapdustPlugin); 117 btnWorkOffline = 118 ComponentUtil.createJButton("Work offline", tooltipText, 119 imagePath, action); 117 btnWorkOffline = ComponentUtil.createJButton("Work offline", 118 tooltipText, imagePath, action); 120 119 btnWorkOffline.setSelected(false); 121 120 btnWorkOffline.setFocusTraversalKeysEnabled(false); … … 124 123 if (btnFilter == null) { 125 124 AbstractAction action = new ShowFilterBugAction(mapdustPlugin); 126 btnFilter = 127 ComponentUtil.createJButton("Filter bug reports", 128 "Filter bug reports", 129 "dialogs/mapdust_bug_filter.png", action); 125 btnFilter = ComponentUtil.createJButton("Filter bug reports", 126 "Filter bug reports", "dialogs/mapdust_bug_filter.png", 127 action); 130 128 btnFilter.setEnabled(true); 131 129 btnFilter.setFocusTraversalKeysEnabled(false); … … 134 132 if (btnAddComment == null) { 135 133 AbstractAction action = new ShowCommentBugAction(mapdustPlugin); 136 btnAddComment = 137 ComponentUtil 138 .createJButton("Comment bug report", 139 "Comment bug report", 140 "dialogs/comment.png", action); 134 btnAddComment = ComponentUtil.createJButton("Comment bug report", 135 "Comment bug report", "dialogs/comment.png", action); 141 136 btnAddComment.setEnabled(false); 142 137 btnAddComment.setFocusTraversalKeysEnabled(false); … … 145 140 if (btnFixBugReport == null) { 146 141 AbstractAction action = new ShowCloseBugAction(mapdustPlugin); 147 btnFixBugReport = 148 ComponentUtil.createJButton("Close bug report", 149 "Close bug report", "dialogs/fixed.png", action); 142 btnFixBugReport = ComponentUtil.createJButton("Close bug report", 143 "Close bug report", "dialogs/fixed.png", action); 150 144 btnFixBugReport.setEnabled(false); 151 145 btnFixBugReport.setFocusTraversalKeysEnabled(false); … … 154 148 if (btnInvalidateBugReport == null) { 155 149 AbstractAction action = new ShowInvalidateBugAction(mapdustPlugin); 156 btnInvalidateBugReport = 157 ComponentUtil.createJButton("Invalidate bug report", 158 "Invalidate bug report", "dialogs/invalid.png", 159 action); 150 btnInvalidateBugReport = ComponentUtil.createJButton( 151 "Invalidate bug report", "Invalidate bug report", 152 "dialogs/invalid.png", action); 160 153 btnInvalidateBugReport.setEnabled(false); 161 154 btnInvalidateBugReport.setFocusTraversalKeysEnabled(false); … … 164 157 if (btnReOpenBugReport == null) { 165 158 AbstractAction action = new ShowReOpenBugAction(mapdustPlugin); 166 btnReOpenBugReport = 167 ComponentUtil.createJButton("Re-open bug report",168 "Re-open bug report","dialogs/reopen.png", action);159 btnReOpenBugReport = ComponentUtil.createJButton( 160 "Re-open bug report", "Re-open bug report", 161 "dialogs/reopen.png", action); 169 162 btnReOpenBugReport.setEnabled(false); 170 163 btnReOpenBugReport.setFocusTraversalKeysEnabled(false); … … 175 168 AbstractAction action = new ExecuteRefresh(); 176 169 ((ExecuteRefresh) action).addObserver(mapdustPlugin); 177 btnRefresh = 178 ComponentUtil.createJButton("Refresh", "Refresh", 179 "dialogs/mapdust_refresh.png", action); 170 btnRefresh = ComponentUtil.createJButton("Refresh", "Refresh", 171 "dialogs/mapdust_refresh.png", action); 180 172 if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) { 181 173 btnRefresh.setEnabled(false); … … 241 233 * other buttons will be disabled. 242 234 * 243 * @param onlyBasic If true then the not basic buttons will be disabled235 * @param onlyBasic If true then the not basic buttons will be enabled 244 236 */ 245 237 public void enableBasicComponents(boolean onlyBasic) { -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustDescriptionPanel.java
r25591 r25754 80 80 */ 81 81 private void addComponents(String description) { 82 if (description != null && !description.isEmpty()) { 83 JTextArea txtDescription = new JTextArea(description); 84 txtDescription.setLineWrap(true); 85 txtDescription.setFont(new Font("Times New Roman", Font.BOLD, 12)); 86 txtDescription.setEditable(false); 87 JScrollPane cmpDescription = ComponentUtil.createJScrollPane( 88 txtDescription, null, Color.white, true, true); 89 cmpDescription.setPreferredSize(new Dimension(100, 100)); 90 add(cmpDescription, BorderLayout.CENTER); 91 } 82 description = (description != null ? description : ""); 83 JTextArea txtDescription = new JTextArea(description); 84 txtDescription.setLineWrap(true); 85 txtDescription.setFont(new Font("Times New Roman", Font.BOLD, 12)); 86 txtDescription.setEditable(false); 87 JScrollPane cmpDescription = ComponentUtil.createJScrollPane( 88 txtDescription, null, Color.white, true, true); 89 cmpDescription.setPreferredSize(new Dimension(100, 100)); 90 add(cmpDescription, BorderLayout.CENTER); 92 91 } 93 92 -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/MapdustUpdateObserver.java
r25591 r25754 47 47 * Updates the MapDust bugs based on the given filters. If the initialUpdate 48 48 * flag is true then the filters will not be applied to the MapDust bug 49 * data. 49 * data. The initialUpdate flag can be true in one the following cases: 50 * 1) After JOSM startup , 2) If the MapDust layer was re-added after a 51 * previous deletion. 50 52 * 51 53 * @param filter The <code>MapdustBugFilter</code> object
Note:
See TracChangeset
for help on using the changeset viewer.