Changeset 25591 in osm for applications/editors/josm/plugins/mapdust/src
- Timestamp:
- 2011-03-14T09:30:11+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust
- Files:
-
- 15 added
- 6 deleted
- 76 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustLayer.java
r25127 r25591 60 60 /** 61 61 * Defines the MapDust JOSM layer main functionality. 62 * 62 * 63 63 * @author Bea 64 64 */ 65 65 public class MapdustLayer extends Layer { 66 66 67 67 /** The <code>MapdustGUI</code> object */ 68 68 private MapdustGUI mapdustGUI; 69 69 70 70 /** The list of <code>MapdustBugList</code> objects */ 71 71 private List<MapdustBug> mapdustBugList; 72 72 73 73 /** The selected <code>MapdustBug</code> object */ 74 74 private MapdustBug bugSelected; 75 75 76 76 /** 77 77 * Builds a <code>MapdustLayer</code> object based on the given parameters. 78 * 78 * 79 79 * @param name The name of the layer 80 80 * @param mapdustGUI The <code>MapdustGUI</code> object … … 88 88 this.bugSelected = null; 89 89 } 90 90 91 91 /** 92 92 * Returns the icon of the MapDust layer. 93 * 93 * 94 94 * @return icon 95 95 */ … … 99 99 return layerIcon; 100 100 } 101 101 102 102 /** 103 103 * Returns the info components of the MapDust layer. 104 * 104 * 105 105 * @return object 106 106 */ … … 110 110 return tr(infoComponent); 111 111 } 112 112 113 113 /** 114 114 * Returns the menu entries of the MapDust layer. 115 * 115 * 116 116 * @return an array of <code>Action</code> objects. 117 117 */ … … 129 129 return menuEntries; 130 130 } 131 131 132 132 /** 133 133 * Returns the text of the tool tip of the MapDust layer. 134 * 134 * 135 135 * @return the tooltip text 136 136 */ … … 140 140 return tr(toolTipText); 141 141 } 142 142 143 143 /** 144 144 * Returns the image icon based on the given status and type. 145 * 145 * 146 146 * @param iconType The type of the bug 147 147 * @param status The status of the bug … … 158 158 return icon; 159 159 } 160 160 161 161 /** 162 162 * Draw the objects to the given map view. Also draws the MapDust bugs to 163 163 * the map, and the tooltip for the selected MapDust bug. 164 * 164 * 165 165 * @param g The <code>Graphics2D</code> object 166 166 * @param mv The <code>MapView</code> object … … 181 181 int width = icon.getIconWidth(); 182 182 int height = icon.getIconHeight(); 183 /* need to do drawing 2 times, because in some areas the bug 184 * image is invisible */ 183 /* 184 * need to do drawing 2 times, because in some areas the bug 185 * image is invisible 186 */ 185 187 for (int i = 0; i < 2; i++) { 186 188 g.drawImage(icon.getImage(), p.x - (width / 2), p.y 187 189 - (height / 2), new ImageObserver() { 190 188 191 @Override 189 192 public boolean imageUpdate(Image img, int infoflags, … … 194 197 } 195 198 } 196 199 197 200 /* draw the selected bug description */ 198 201 /* selected by clicking */ 199 202 MapdustBug bug1 = getBugSelected(); 200 203 /* selected from the list */ 201 MapdustBug bugSelected = 202 getMapdustGUI().getPanel().getSelectedBug(); 204 MapdustBug bugSelected = getMapdustGUI().getSelectedBug(); 203 205 if (bugSelected == null) { 204 206 if (Main.map.mapView.getActiveLayer() == this) { … … 206 208 } 207 209 } 210 setBugSelected(bugSelected); 208 211 if (bugSelected != null) { 209 212 LatLon ll = bugSelected.getLatLon(); … … 217 220 g.drawImage(icon.getImage(), p.x - (width / 2), p.y 218 221 - (height / 2), new ImageObserver() { 222 219 223 @Override 220 224 public boolean imageUpdate(Image img, int infoflags, int x, … … 242 246 } 243 247 } 244 248 245 249 /** 246 250 * No need to implement this. … … 250 254 return false; 251 255 } 252 256 253 257 /** 254 258 * No need to implement this. … … 256 260 @Override 257 261 public void mergeFrom(Layer layer) {} 258 262 259 263 /** 260 264 * Builds the text of the tooltip containing a short description of the 261 265 * given <code>MapdustBug</code> object. 262 * 266 * 263 267 * @param bug The <code>MapdustBug</code> object 264 268 * @return A string containing the description text … … 279 283 return text; 280 284 } 281 285 282 286 /** 283 287 * No need to implement this. … … 285 289 @Override 286 290 public void visitBoundingBox(BoundingXYVisitor arg0) {} 287 291 288 292 /** 289 293 * Returns the <code>MapdustGUI</code> object 290 * 294 * 291 295 * @return the mapdustGUI 292 296 */ … … 294 298 return mapdustGUI; 295 299 } 296 300 297 301 /** 298 302 * Sets the <code>MapdustGUI</code> object 299 * 303 * 300 304 * @param mapdustGUI the mapdustGUI to set 301 305 */ … … 303 307 this.mapdustGUI = mapdustGUI; 304 308 } 305 309 306 310 /** 307 311 * Returns the list of <code>MapdustBug</code> objects 308 * 312 * 309 313 * @return the mapdustBugList 310 314 */ … … 312 316 return mapdustBugList; 313 317 } 314 318 315 319 /** 316 320 * Returns the selected bug 317 * 321 * 318 322 * @return the bugSelected 319 323 */ … … 321 325 return bugSelected; 322 326 } 323 327 324 328 /** 325 329 * Sets the selected bug 326 * 330 * 327 331 * @param bugSelected the bugSelected to set 328 332 */ … … 330 334 this.bugSelected = bugSelected; 331 335 } 332 336 333 337 /** 334 338 * Sets the list of <code>MapdustBug</code> objects 335 * 339 * 336 340 * @param mapdustBugList the mapdustBugList to set 337 341 */ … … 339 343 this.mapdustBugList = mapdustBugList; 340 344 } 341 345 342 346 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java
r25312 r25591 37 37 import java.util.List; 38 38 import javax.swing.JOptionPane; 39 import javax.swing.SwingUtilities; 39 40 import org.openstreetmap.josm.Main; 40 41 import org.openstreetmap.josm.data.Bounds; … … 48 49 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; 49 50 import org.openstreetmap.josm.gui.layer.Layer; 50 import org.openstreetmap.josm.gui.layer.OsmDataLayer;51 51 import org.openstreetmap.josm.plugins.Plugin; 52 52 import org.openstreetmap.josm.plugins.PluginInformation; … … 54 54 import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.CreateIssueDialog; 55 55 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver; 56 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustInitialUpdateObserver; 57 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObserver; 56 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver; 58 57 import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustPluginState; 59 58 import org.openstreetmap.josm.plugins.mapdust.service.MapdustServiceHandler; 60 59 import org.openstreetmap.josm.plugins.mapdust.service.MapdustServiceHandlerException; 60 import org.openstreetmap.josm.plugins.mapdust.service.value.BoundingBox; 61 61 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug; 62 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter; 62 63 import org.openstreetmap.josm.tools.Shortcut; 63 64 … … 66 67 * This is the main class of the MapDust plug-in. Defines the MapDust plug-in 67 68 * main functionality. 68 * 69 * 69 70 * @author Bea 70 *71 71 */ 72 72 public class MapdustPlugin extends Plugin implements LayerChangeListener, 73 73 ZoomChangeListener, PreferenceChangedListener, MouseListener, 74 MapdustRefreshObserver, MapdustBugObserver, 75 MapdustInitialUpdateObserver { 76 74 MapdustUpdateObserver, MapdustBugObserver { 75 77 76 /** The graphical user interface of the plug-in */ 78 77 private MapdustGUI mapdustGUI; 79 78 80 79 /** The layer of the MapDust plug-in */ 81 80 private MapdustLayer mapdustLayer; 82 81 82 /** The <code>CreateIssueDialog</code> object */ 83 private CreateIssueDialog dialog; 84 85 /** The JOSM user identity manager, it is used for obtaining the username */ 86 private final JosmUserIdentityManager userIdentityManager; 87 83 88 /** The list of <code>MapdustBug</code> objects */ 84 89 private List<MapdustBug> mapdustBugList; 85 86 /** The <code>CreateIssueDialog</code> object */ 87 private CreateIssueDialog dialog; 88 90 91 /** The bounding box from where the MapDust bugs are downloaded */ 92 private BoundingBox bBox; 93 94 /** 95 * The <code>MapdustBugFilter</code> object representing the selected 96 * filters 97 */ 98 private MapdustBugFilter filter; 99 89 100 /** Specifies if there was or not an error downloading the data */ 90 101 private boolean wasError = false; 91 92 /** The JOSM user identity manager, it is used for obtaining the username */ 93 private final JosmUserIdentityManager userIdentityManager; 94 102 95 103 /** 96 104 * Builds a new <code>MapDustPlugin</code> object based on the given 97 105 * arguments. 98 * 106 * 99 107 * @param info The <code>MapDustPlugin</code> object 100 108 */ 101 109 public MapdustPlugin(PluginInformation info) { 102 110 super(info); 103 /* create instancefor JOSM user identity manager */104 userIdentityManager = JosmUserIdentityManager.getInstance();105 /* initialize the plugin */111 this.userIdentityManager = JosmUserIdentityManager.getInstance(); 112 this.filter = null; 113 this.bBox = null; 106 114 initializePlugin(); 107 115 } 108 116 109 117 /** 110 118 * Initialize the <code>MapdustPlugin</code> object. Creates the 111 119 * <code>MapdustGUI</code> and initializes the following variables with 112 120 * default values: 'mapdust.pluginState', 'mapdust.nickname', 113 * 'mapdust.showError'. 121 * 'mapdust.showError', 'mapdust.version' and 'mapdust.localVersion'. 114 122 */ 115 123 private void initializePlugin() { 116 124 /* create MapDust GUI */ 117 Shortcut shortcut = Shortcut.registerShortcut("mapdust", tr("Toggle: {0}", 118 tr("Open MapDust")), KeyEvent.VK_0, Shortcut.GROUP_MENU, 119 Shortcut.SHIFT_DEFAULT); 125 String shortTxt = "MapDust"; 126 String longTxt = tr("Toggle: {0}", tr("Open MapDust")); 127 Shortcut shortcut = Shortcut.registerShortcut(shortTxt, longTxt, 128 KeyEvent.VK_0, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT); 120 129 String name = "MapDust bug reports"; 121 130 String tooltip = "Activates the MapDust bug reporter plugin"; … … 123 132 shortcut, 150, this); 124 133 /* add default values for static variables */ 125 Main.pref.put("mapdust.pluginState", 126 MapdustPluginState.ONLINE.getValue()); 134 Main.pref.put("mapdust.pluginState", MapdustPluginState.ONLINE.getValue()); 127 135 Main.pref.put("mapdust.nickname", ""); 128 136 Main.pref.put("mapdust.showError", true); … … 131 139 getPluginInformation().localversion); 132 140 } 133 141 134 142 /** 135 143 * Initializes the new <code>MapFrame</code>. Adds the 136 144 * <code>MapdustGUI</code> to the new <code>MapFrame</code> and sets the 137 145 * observers/listeners. 138 * 146 * 139 147 * @param oldMapFrame The old <code>MapFrame</code> object 140 148 * @param newMapFrame The new <code>MapFrame</code> object … … 149 157 /* add MapDust dialog window */ 150 158 if (Main.map != null && Main.map.mapView != null) { 151 /* set bounds forMapdustGUI */159 /* add MapdustGUI */ 152 160 mapdustGUI.setBounds(newMapFrame.getBounds()); 153 /* add observer */154 161 mapdustGUI.addObserver(this); 155 /* add dialog to new MapFrame */156 162 newMapFrame.addToggleDialog(mapdustGUI); 157 /* add ZoomChangeListener */163 /* add Listeners */ 158 164 NavigatableComponent.addZoomChangeListener(this); 159 /* add LayerChangeListener */160 165 MapView.addLayerChangeListener(this); 161 /* add MouseListener */162 166 Main.map.mapView.addMouseListener(this); 163 167 Main.pref.addPreferenceChangeListener(this); 164 168 /* put username to preferences */ 165 Main.pref.put("mapdust.josmUserName", 169 Main.pref.put("mapdust.josmUserName", 166 170 userIdentityManager.getUserName()); 167 171 } 168 172 } 169 173 } 170 171 /** 172 * Refreshes the MapDust data. Downloads the data from the given area and 173 * updates the map and the MapDust list with this new data. This method is 174 * called whenever the 'Refresh' button is pressed by the user. 175 */ 176 @Override 177 public void refreshData() { 178 if (containsOsmDataLayer() && mapdustGUI.isShowing()) { 179 updatePluginData(); 180 } 181 } 182 183 /** 184 * Downloads the MapDust bugs from the current map view, and updates the 185 * plugin data with the new downloaded data. This method is called only 186 * once, before first showing the MapDust bugs. 187 */ 188 @Override 189 public void initialUpdate() { 190 if (containsOsmDataLayer()) { 191 updatePluginData(); 192 } 193 } 194 195 /** 196 * Updates the given <code>MapdustBug</code> object from the map and from 197 * the MapDust bugs list. 198 * 199 * @param mapdustBug The <code>MapdustBug</code> object 200 */ 201 @Override 202 public synchronized void changedData(MapdustBug mapdustBug) { 203 if (mapdustBugList == null) { 204 mapdustBugList = new ArrayList<MapdustBug>(); 205 } 206 if (getMapdustGUI().isDialogShowing()) { 207 if (Main.map != null && Main.map.mapView != null) { 208 /* if the layer was active , should be active after the update */ 209 boolean wasActive = false; 210 if (Main.map.mapView.getActiveLayer() == getMapdustLayer()) { 211 wasActive = true; 212 } 213 /* update the list with the modified MapDust bug */ 214 updateMapdustBugList(mapdustBug); 215 /* destroy the layer */ 216 mapdustLayer.destroy(); 217 Main.main.removeLayer(mapdustLayer); 218 mapdustLayer = null; 219 /* update the view, and activate the layer */ 220 updateView(); 221 if (wasActive) { 222 Main.map.mapView.setActiveLayer(getMapdustLayer()); 223 } 224 } 225 } 226 } 227 228 /** 229 * If the zoom was changed, download the bugs from the current map view. 230 * This method is called whenever the zoom was changed. 231 */ 232 @Override 233 public void zoomChanged() { 234 if (containsOsmDataLayer() && this.mapdustGUI.isShowing() && !wasError) { 235 updatePluginData(); 236 } 237 } 238 239 /** 240 * No need to implement this. 241 */ 242 @Override 243 public void activeLayerChange(Layer arg0, Layer arg1) {} 244 245 /** 246 * Adds the <code>MapdustLayer</code> to the JOSM editor. If the list of 247 * <code>MapdustBug</code>s is null then downloads the data from the MapDust 248 * Service and updates the editor with this new data. 249 * 250 * @param layer The <code>Layer</code> which will be added to the JOSM 251 * editor 252 */ 253 @Override 254 public void layerAdded(Layer layer) { 255 if (layer instanceof MapdustLayer) { 256 /* download the MapDust bugs and update the plugin */ 257 if (mapdustBugList == null) { 258 updateMapdustData(); 259 } 260 } 261 } 262 263 /** 264 * Removes the <code>MapdustLayer</code> from the JOSM editor. Also closes 265 * the MapDust plugin window. 266 * 267 * @param layer The <code>Layer</code> which will be removed from the JOSM 268 * editor 269 */ 270 @Override 271 public void layerRemoved(Layer layer) { 272 if (layer instanceof MapdustLayer) { 273 /* remove the layer */ 274 MapView.removeLayerChangeListener(this); 275 NavigatableComponent.removeZoomChangeListener(this); 276 Main.map.mapView.removeLayer(layer); 277 Main.map.remove(mapdustGUI); 278 if (mapdustGUI != null) { 279 mapdustGUI.update(new ArrayList<MapdustBug>(), this); 280 mapdustGUI.setVisible(false); 281 } 282 mapdustLayer = null; 283 } 284 } 285 286 /** 287 * No need to implement this. 288 */ 289 @Override 290 public void mouseEntered(MouseEvent event) {} 291 292 /** 293 * No need to implement this. 294 */ 295 @Override 296 public void mouseExited(MouseEvent arg0) {} 297 298 /** 299 * No need to implement this. 300 */ 301 @Override 302 public void mousePressed(MouseEvent event) {} 303 304 /** 305 * No need to implement this. 306 */ 307 @Override 308 public void mouseReleased(MouseEvent arg0) {} 309 310 /** 311 * At mouse click the following two actions can be done: adding a new bug, 312 * and selecting a bug from the map. A bug can be added if the plugin is the 313 * only active plugin and you double click on the map. You can select a bug 314 * from the map by clicking on it. 315 * 316 * @event The <code>MouseEvent</code> object 317 */ 318 @Override 319 public void mouseClicked(MouseEvent event) { 320 if (mapdustLayer != null && mapdustLayer.isVisible()) { 321 if (event.getButton() == MouseEvent.BUTTON1) { 322 if (event.getClickCount() == 2 && !event.isConsumed()) { 323 if (Main.map.mapView.getActiveLayer() == getMapdustLayer()) { 324 /* show add bug dialog */ 325 MapdustBug bug = mapdustGUI.getPanel().getSelectedBug(); 326 if (bug != null) { 327 Main.pref.put("selectedBug.status", bug.getStatus() 328 .getValue()); 329 } else { 330 Main.pref.put("selectedBug.status", "create"); 331 } 332 /* disable MapdustButtonPanel */ 333 mapdustGUI.disableBtnPanel(); 334 /* create and show dialog */ 335 dialog = new CreateIssueDialog(event.getPoint(), this); 336 dialog.showDialog(); 337 event.consume(); 338 return; 339 } 340 } 341 if (event.getClickCount() == 1 && !event.isConsumed()) { 342 /* allow click on the bug icon on the map */ 343 Point p = event.getPoint(); 344 MapdustBug nearestBug = getNearestBug(p); 345 if (nearestBug != null) { 346 mapdustLayer.setBugSelected(nearestBug); 347 /* set also in the list of bugs the element */ 348 mapdustGUI.getPanel().setSelectedBug(nearestBug); 349 Main.map.mapView.repaint(); 350 } 351 return; 352 } 353 } 354 } 355 } 356 174 357 175 /** 358 176 * Listens for the events of type <code>PreferenceChangeEvent</code> . If … … 362 180 * MapDust , re-set the 'mapdust.josmUserName' and 'mapdust.nickname' 363 181 * properties. 364 * 182 * 365 183 * @param event The <code>PreferenceChangeEvent</code> obejct 366 184 */ 367 185 @Override 368 186 public void preferenceChanged(PreferenceChangeEvent event) { 369 if ( this.mapdustGUI.isShowing() && !wasError && mapdustLayer != null187 if (mapdustGUI.isShowing() && !wasError && mapdustLayer != null 370 188 && mapdustLayer.isVisible()) { 371 189 if (event.getKey().equals("osm-server.username")) { … … 390 208 } 391 209 } 392 393 /** 394 * Updates the <code>MapdustPlugin</code> data. Downloads the 395 * <code>MapdustBug</code> objects from the current view, and updates the 396 * <code>MapdustGUI</code> and the map with the new data. 397 */ 398 private void updatePluginData() { 399 Main.worker.execute(new Runnable() { 400 @Override 401 public void run() { 402 updateMapdustData(); 403 } 404 }); 405 } 406 407 /** 408 * Returns the bounds of the current <code>MapView</code>. 409 * 410 * @return bounds 411 */ 412 private Bounds getBounds() { 413 MapView mapView = Main.map.mapView; 414 Bounds bounds = new Bounds(mapView.getLatLon(0, mapView.getHeight()), 415 mapView.getLatLon(mapView.getWidth(), 0)); 416 return bounds; 417 } 418 419 /** 420 * Updates the MapDust plugin data. Downloads the list of 421 * <code>MapdustBug</code> objects for the given area, and updates the map 422 * and the MapDust layer with the new data. 423 */ 424 private synchronized void updateMapdustData() { 425 if (Main.map != null && Main.map.mapView != null) { 426 /* download the MapDust data */ 427 try { 428 Bounds bounds = getBounds(); 429 MapdustServiceHandler handler = new MapdustServiceHandler(); 430 mapdustBugList = handler.getBugs(bounds.getMin().lon(), 431 bounds.getMin().lat(), bounds.getMax().lon(), 432 bounds.getMax().lat()); 433 wasError = false; 434 } catch (MapdustServiceHandlerException e) { 435 wasError = true; 436 mapdustBugList = new ArrayList<MapdustBug>(); 437 updateView(); 438 handleError(); 439 } 440 /* update the view */ 441 if (!wasError) { 442 updateView(); 443 } 444 } 445 } 446 447 /** 448 * Updates the current view ( map and MapDust bug list), with the given list 449 * of <code>MapdustBug</code> objects. 450 */ 451 private void updateView() { 452 /* update the dialog with the new data */ 453 mapdustGUI.update(mapdustBugList, this); 454 mapdustGUI.setVisible(true); 455 mapdustGUI.revalidate(); 456 /* update the MapdustLayer */ 457 if (mapdustLayer == null) { 458 /* create and add the layer */ 459 mapdustLayer = new MapdustLayer("MapDust", mapdustGUI, mapdustBugList); 460 Main.main.addLayer(this.mapdustLayer); 461 Main.map.mapView.moveLayer(this.mapdustLayer, 0); 462 Main.map.mapView.addMouseListener(this); 463 MapView.addLayerChangeListener(this); 464 NavigatableComponent.addZoomChangeListener(this); 465 } else { 466 /* re-set the properties */ 467 mapdustLayer.destroy(); 468 mapdustLayer.setMapdustGUI(mapdustGUI); 469 mapdustLayer.setMapdustBugList(mapdustBugList); 470 mapdustLayer.setBugSelected(null); 471 } 472 /* repaint */ 473 Main.map.mapView.revalidate(); 474 Main.map.repaint(); 475 } 476 477 /** 478 * Updates the MapDust bugs list with the given <code>MapdustBug</code> 479 * object. 480 * 210 211 /** 212 * Updates the map and the MapDust bugs list with the given 213 * <code>MapdustBug</code> object. If the bug is already contained in the 214 * list and map, then this object will be updated with the new properties. 215 * If the filter settings does not allow this new bug to be shown in the map 216 * and list, then it will be removed from the map and list. 217 * 481 218 * @param mapdustBug The <code>MapdustBug</code> object 482 219 */ 483 private void updateMapdustBugList(MapdustBug mapdustBug) { 484 MapdustBug oldBug = null; 485 for (MapdustBug bug : this.mapdustBugList) { 486 if (bug.getId().equals(mapdustBug.getId())) { 487 oldBug = bug; 488 } 489 } 490 if (oldBug != null) { 491 /* remove, add */ 492 this.mapdustBugList.remove(oldBug); 493 this.mapdustBugList.add(0, mapdustBug); 494 } else { 495 /* new add */ 496 this.mapdustBugList.add(0, mapdustBug); 497 } 498 } 499 220 @Override 221 public synchronized void changedData(MapdustBug mapdustBug) { 222 if (mapdustBugList == null) { 223 mapdustBugList = new ArrayList<MapdustBug>(); 224 } 225 if (getMapdustGUI().isDialogShowing()) { 226 if (Main.map != null && Main.map.mapView != null) { 227 MapdustBug oldBug = null; 228 for (MapdustBug bug : mapdustBugList) { 229 if (bug.getId().equals(mapdustBug.getId())) { 230 oldBug = bug; 231 } 232 } 233 boolean showBug = shouldDisplay(mapdustBug); 234 if (oldBug != null) { 235 /* remove, add */ 236 if (showBug) { 237 mapdustBugList.remove(oldBug); 238 mapdustBugList.add(0, mapdustBug); 239 } else { 240 mapdustBugList.remove(oldBug); 241 } 242 } else { 243 /* new add */ 244 if (showBug) { 245 mapdustBugList.add(0, mapdustBug); 246 } 247 } 248 mapdustGUI.update(mapdustBugList, this); 249 mapdustLayer.setMapdustGUI(mapdustGUI); 250 if (showBug) { 251 mapdustGUI.setSelectedBug(mapdustBugList.get(0)); 252 } else { 253 mapdustLayer.setBugSelected(null); 254 mapdustGUI.enableBtnPanel(true); 255 Main.map.mapView.repaint(); 256 String title = "MapDust"; 257 String message = "The operation was successful."; 258 JOptionPane.showMessageDialog(Main.parent, message, title, 259 JOptionPane.INFORMATION_MESSAGE); 260 } 261 } 262 } 263 } 264 265 /** 266 * Verifies if the given <code>MapdustBug</code> object should be displayed 267 * on the map and on the bugs list. A <code>MapdustBug</code> will be 268 * displayed on the map only if it is permitted by the selected filter 269 * settings. 270 * 271 * @param mapdustBug The <code>MapdustBug</code> object 272 * @return true if the given bug should be displayed false otherwise 273 */ 274 private boolean shouldDisplay(MapdustBug mapdustBug) { 275 boolean result = true; 276 if (filter != null) { 277 boolean containsStatus = false; 278 if (filter.getStatuses() != null && !filter.getStatuses().isEmpty()) { 279 Integer statusKey = mapdustBug.getStatus().getKey(); 280 if (filter.getStatuses().contains(statusKey)) { 281 containsStatus = true; 282 } 283 } else { 284 containsStatus = true; 285 } 286 boolean containsType = false; 287 if (filter.getTypes() != null && !filter.getTypes().isEmpty()) { 288 String typeKey = mapdustBug.getType().getKey(); 289 if (filter.getTypes().contains(typeKey)) { 290 containsType = true; 291 } 292 } else { 293 containsType = true; 294 } 295 if (filter.getDescr() != null && filter.getDescr()) { 296 if (!mapdustBug.getIsDefaultDescription()) { 297 result = false; 298 } 299 } else { 300 result = containsStatus && containsType; 301 } 302 } 303 return result; 304 } 305 306 /** 307 * No need to implement this. 308 */ 309 @Override 310 public void mouseEntered(MouseEvent event) {} 311 312 /** 313 * No need to implement this. 314 */ 315 @Override 316 public void mouseExited(MouseEvent arg0) {} 317 318 /** 319 * No need to implement this. 320 */ 321 @Override 322 public void mousePressed(MouseEvent event) {} 323 324 /** 325 * No need to implement this. 326 */ 327 @Override 328 public void mouseReleased(MouseEvent arg0) {} 329 330 /** 331 * At mouse click the following two actions can be done: adding a new bug, 332 * and selecting a bug from the map. A bug can be added if the plugin is the 333 * only active plugin and you double click on the map. You can select a bug 334 * from the map by clicking on it. 335 * 336 * @param event The <code>MouseEvent</code> object 337 */ 338 @Override 339 public void mouseClicked(MouseEvent event) { 340 if (mapdustLayer != null && mapdustLayer.isVisible()) { 341 if (event.getButton() == MouseEvent.BUTTON1) { 342 if (event.getClickCount() == 2 && !event.isConsumed()) { 343 if (Main.map.mapView.getActiveLayer() == getMapdustLayer()) { 344 /* show add bug dialog */ 345 MapdustBug bug = mapdustGUI.getSelectedBug(); 346 if (bug != null) { 347 Main.pref.put("selectedBug.status", bug.getStatus() 348 .getValue()); 349 } else { 350 Main.pref.put("selectedBug.status", "create"); 351 } 352 /* disable MapdustButtonPanel */ 353 mapdustGUI.getPanel().disableBtnPanel(); 354 /* create and show dialog */ 355 dialog = new CreateIssueDialog(event.getPoint(), this); 356 dialog.showDialog(); 357 event.consume(); 358 return; 359 } 360 } 361 if (event.getClickCount() == 1 && !event.isConsumed()) { 362 /* allow click on the bug icon on the map */ 363 Point p = event.getPoint(); 364 MapdustBug nearestBug = getNearestBug(p); 365 if (nearestBug != null) { 366 mapdustLayer.setBugSelected(nearestBug); 367 /* set also in the list of bugs the element */ 368 mapdustGUI.setSelectedBug(nearestBug); 369 Main.map.mapView.repaint(); 370 } 371 return; 372 } 373 } 374 } 375 } 376 500 377 /** 501 378 * Returns the nearest <code>MapdustBug</code> object to the given point on 502 379 * the map. 503 * 380 * 504 381 * @param p A <code>Point</code> object 505 382 * @return A <code>MapdustBug</code> object … … 521 398 return nearestBug; 522 399 } 523 524 /** 525 * Verifies if the <code>OsmDataLayer</code> layer has been added to the 526 * list of layers. 527 * 528 * @return true if the <code>OsmDataLayer</code> layer has been added false 529 * otherwise 530 */ 531 private boolean containsOsmDataLayer() { 532 boolean contains = false; 533 List<Layer> l = Main.map.mapView.getAllLayersAsList(); 534 for (Layer ll : l) { 535 if (ll instanceof OsmDataLayer) { 536 contains = true; 537 } 538 } 539 return contains; 540 } 541 400 401 /** 402 * No need to implement this. 403 */ 404 @Override 405 public void activeLayerChange(Layer arg0, Layer arg1) {} 406 407 /** 408 * Adds the <code>MapdustLayer</code> to the JOSM editor. If the list of 409 * <code>MapdustBug</code>s is null then downloads the data from the MapDust 410 * Service and updates the editor with this new data. 411 * 412 * @param layer The <code>Layer</code> which will be added to the JOSM 413 * editor 414 */ 415 @Override 416 public void layerAdded(Layer layer) { 417 if (layer instanceof MapdustLayer) { 418 /* download the MapDust bugs and update the plugin */ 419 if (mapdustBugList == null) { 420 updatePluginData(); 421 } 422 } 423 } 424 425 /** 426 * Removes the <code>MapdustLayer</code> from the JOSM editor. Also closes 427 * the MapDust plugin window. 428 * 429 * @param layer The <code>Layer</code> which will be removed from the JOSM 430 * editor 431 */ 432 @Override 433 public void layerRemoved(Layer layer) { 434 if (layer instanceof MapdustLayer) { 435 /* remove the layer */ 436 Main.pref.put("mapdust.pluginState", 437 MapdustPluginState.ONLINE.getValue()); 438 MapView.removeLayerChangeListener(this); 439 NavigatableComponent.removeZoomChangeListener(this); 440 Main.map.mapView.removeLayer(layer); 441 Main.map.remove(mapdustGUI); 442 if (mapdustGUI != null) { 443 mapdustGUI.update(new ArrayList<MapdustBug>(), this); 444 mapdustGUI.setVisible(false); 445 mapdustGUI.destroy(); 446 } 447 mapdustLayer = null; 448 filter = null; 449 mapdustBugList = null; 450 } 451 } 452 453 /** 454 * Listens for the zoom change event. If the zoom was changed, then it will 455 * download the MapDust bugs data from the current view. The new data will 456 * be downloaded only if the current bounding box is different from the 457 * previous one. 458 */ 459 @Override 460 public void zoomChanged() { 461 if (mapdustGUI.isShowing() && !wasError) { 462 boolean download = true; 463 BoundingBox curentBBox = getBBox(); 464 if (bBox != null) { 465 if (bBox.equals(curentBBox)) { 466 download = false; 467 } 468 } 469 bBox = curentBBox; 470 if (download) { 471 updatePluginData(); 472 } 473 } 474 } 475 476 /** 477 * Updates the plugin with a new MapDust bugs data. If the filters are set 478 * then the MapDust data will be filtered. If initialUpdate flag is true 479 * then the plugin is updated for the first time with the MapDust data. By 480 * default the first time there is no filter applied to the MapDust data. 481 * 482 * @param filter The <code>MapdustBugFilter</code> containing the filter 483 * settings 484 * @param initialUpdate If true then there will be no filter applied. 485 */ 486 @Override 487 public void update(MapdustBugFilter filter, boolean initialUpdate) { 488 bBox = getBBox(); 489 if (initialUpdate) { 490 updatePluginData(); 491 } else { 492 if (filter != null) { 493 this.filter = filter; 494 } 495 if (mapdustGUI.isShowing() && !wasError) { 496 updatePluginData(); 497 } 498 } 499 } 500 501 /** 502 * Returns the current bounding box. If the bounding box values are not in 503 * the limits, then it will normalized. 504 * 505 * @return A <code>BoundingBox</code> 506 */ 507 private BoundingBox getBBox() { 508 MapView mapView = Main.map.mapView; 509 Bounds bounds = 510 new Bounds(mapView.getLatLon(0, mapView.getHeight()), 511 mapView.getLatLon(mapView.getWidth(), 0)); 512 return new BoundingBox(bounds.getMin().lon(), bounds.getMin().lat(), 513 bounds.getMax().lon(), bounds.getMax().lat()); 514 } 515 516 /** 517 * Updates the <code>MapdustPlugin</code> data. Downloads the 518 * <code>MapdustBug</code> objects from the current view, and updates the 519 * <code>MapdustGUI</code> and the map with the new data. 520 */ 521 private void updatePluginData() { 522 Main.worker.execute(new Runnable() { 523 524 @Override 525 public void run() { 526 updateMapdustData(); 527 } 528 }); 529 530 } 531 532 /** 533 * Updates the MapDust plugin data. Downloads the list of 534 * <code>MapdustBug</code> objects for the given area, and updates the map 535 * and the MapDust layer with the new data. 536 */ 537 protected synchronized void updateMapdustData() { 538 if (Main.map != null && Main.map.mapView != null) { 539 /* download the MapDust data */ 540 try { 541 MapdustServiceHandler handler = new MapdustServiceHandler(); 542 mapdustBugList = handler.getBugs(bBox, filter); 543 wasError = false; 544 } catch (MapdustServiceHandlerException e) { 545 wasError = true; 546 mapdustBugList = new ArrayList<MapdustBug>(); 547 } 548 /* update the view */ 549 SwingUtilities.invokeLater(new Runnable() { 550 551 @Override 552 public void run() { 553 updateView(); 554 if (wasError) { 555 handleError(); 556 } 557 } 558 }); 559 560 } 561 } 562 563 /** 564 * Updates the current view ( map and MapDust bug list), with the given list 565 * of <code>MapdustBug</code> objects. 566 */ 567 protected void updateView() { 568 /* update the dialog with the new data */ 569 mapdustGUI.update(mapdustBugList, this); 570 /* update the MapdustLayer */ 571 if (mapdustLayer == null) { 572 /* create and add the layer */ 573 mapdustLayer = 574 new MapdustLayer("MapDust", mapdustGUI, mapdustBugList); 575 Main.main.addLayer(this.mapdustLayer); 576 Main.map.mapView.moveLayer(this.mapdustLayer, 0); 577 Main.map.mapView.addMouseListener(this); 578 MapView.addLayerChangeListener(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(); 591 } 592 542 593 /** 543 594 * Handles the <code>MapdustServiceHandlerException</code> error. 544 * 595 * 545 596 */ 546 597 private void handleError() { … … 555 606 } 556 607 } 557 608 558 609 /** 559 610 * Returns the <code>MapdustGUI</code> object 560 * 611 * 561 612 * @return the mapdustGUI 562 613 */ … … 564 615 return mapdustGUI; 565 616 } 566 617 567 618 /** 568 619 * Sets the <code>MapdustGUI</code> object. 569 * 620 * 570 621 * @param mapdustGUI the mapdustGUI to set 571 622 */ … … 573 624 this.mapdustGUI = mapdustGUI; 574 625 } 575 626 576 627 /** 577 628 * Returns the <code>MapdustLayer</code> object. 578 * 629 * 579 630 * @return the mapdustLayer 580 631 */ … … 582 633 return mapdustLayer; 583 634 } 584 635 585 636 /** 586 637 * Sets the <code>MapdustLayer</code> object. 587 * 638 * 588 639 * @param mapdustLayer the mapdustLayer to set 589 640 */ … … 591 642 this.mapdustLayer = mapdustLayer; 592 643 } 593 644 594 645 /** 595 646 * Returns the list of <code>MapdustBug</code> objects 596 * 647 * 597 648 * @return the mapdustBugList 598 649 */ … … 600 651 return mapdustBugList; 601 652 } 602 603 /** 604 * Sets the list of <code>MapdustBug</code> objects605 * 606 * @ param mapdustBugList the mapdustBugList to set607 */ 608 public void setMapdustBugList(List<MapdustBug> mapdustBugList) {609 this.mapdustBugList = mapdustBugList;610 } 611 653 654 /** 655 * Returns the MapDust bug filter 656 * 657 * @return the filter 658 */ 659 public MapdustBugFilter getFilter() { 660 return filter; 661 } 662 612 663 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/MapdustActionUploaderException.java
r24514 r25591 31 31 /** 32 32 * Specific exception for the <code>MapdustActionUploader</code> object 33 * 33 * 34 34 * @author Bea 35 35 * @version $Revision$ 36 36 */ 37 37 public class MapdustActionUploaderException extends Exception { 38 38 39 39 /** Serial version UID */ 40 private static final long serialVersionUID = 1L;41 40 private static final long serialVersionUID = -6128820229665805478L; 41 42 42 /** 43 43 * Builds an empty <code>MapdustActionUploaderException</code> object. … … 46 46 super(); 47 47 } 48 48 49 49 /** 50 50 * Builds a <code>MapdustActionUploaderException</code> object based on the 51 51 * given argument. 52 * 52 * 53 53 * @param message The message of the exception. 54 54 */ … … 56 56 super(message); 57 57 } 58 58 59 59 /** 60 60 * Builds a <code>MapdustActionUploaderException</code> object based on the 61 61 * given argument. 62 * 62 * 63 63 * @param cause The cause of the exception. 64 64 */ … … 66 66 super(cause); 67 67 } 68 68 69 69 /** 70 70 * Builds a <code>MapdustActionUploaderException</code> object based on the 71 71 * given arguments. 72 * 72 * 73 73 * @param message The message of the exception. 74 74 * @param cause The cause of the exception. -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/MapdustGUI.java
r25127 r25591 40 40 import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin; 41 41 import org.openstreetmap.josm.plugins.mapdust.gui.component.panel.MapdustActionPanel; 42 import org.openstreetmap.josm.plugins.mapdust.gui.component.panel.MapdustBugListPanel; 42 43 import org.openstreetmap.josm.plugins.mapdust.gui.component.panel.MapdustBugPropertiesPanel; 43 import org.openstreetmap.josm.plugins.mapdust.gui.component.panel.MapdustPanel; 44 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionListObserver; 44 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver; 45 45 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugDetailsObservable; 46 46 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugDetailsObserver; 47 import org.openstreetmap.josm.plugins.mapdust.gui.observer.Mapdust InitialUpdateObservable;48 import org.openstreetmap.josm.plugins.mapdust.gui.observer.Mapdust InitialUpdateObserver;47 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObservable; 48 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver; 49 49 import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustAction; 50 50 import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustPluginState; 51 import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustServiceCommand; 51 52 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug; 53 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter; 54 import org.openstreetmap.josm.plugins.mapdust.service.value.Status; 52 55 import org.openstreetmap.josm.tools.Shortcut; 53 56 … … 55 58 /** 56 59 * This class is the main graphical user interface class. 57 * 60 * 58 61 * @author Bea 59 62 */ 60 public class MapdustGUI extends ToggleDialog implements 61 MapdustActionListObserver, MapdustBugDetailsObservable, 62 MapdustInitialUpdateObservable { 63 63 public class MapdustGUI extends ToggleDialog implements MapdustActionObserver, 64 MapdustBugDetailsObservable, MapdustUpdateObservable { 65 64 66 /** The serial version UID */ 65 private static final long serialVersionUID = 1L;66 67 private static final long serialVersionUID = -1194197412364335190L; 68 67 69 /** The list of MapDust bug details observers */ 68 70 private final ArrayList<MapdustBugDetailsObserver> bugDetailsObservers = 69 71 new ArrayList<MapdustBugDetailsObserver>(); 70 72 71 73 /** The list of MapDust initial update observers */ 72 private final ArrayList<MapdustInitialUpdateObserver> initialUpdateObservers = 73 new ArrayList<MapdustInitialUpdateObserver>(); 74 75 /** The <code>MapdustPanel</code> object */ 76 private MapdustPanel panel; 77 74 private final ArrayList<MapdustUpdateObserver> initialUpdateObservers = 75 new ArrayList<MapdustUpdateObserver>(); 76 77 /** The <code>MapdustPlugin</code> plugin */ 78 private MapdustPlugin mapdustPlugin; 79 80 /** The <code>MapdustBugPropertiesPanel</code> */ 81 private MapdustBugPropertiesPanel detailsPanel; 82 83 /** The <code>MapdustBugListPanel</code> object */ 84 private MapdustBugListPanel panel; 85 78 86 /** The <code>MapdustActionPanel</code> object */ 79 private MapdustActionPanel queuePanel;80 87 private MapdustActionPanel actionPanel; 88 81 89 /** The <code>JTabbedPanel</code> object */ 82 90 private JTabbedPane tabbedPane; 83 84 /** The <code>MapdustPlugin</code> plugin */ 85 private MapdustPlugin mapdustPlugin; 86 87 /** The <code>MapdustBugPropertiesPanel</code> */ 88 private MapdustBugPropertiesPanel detailsPanel; 89 91 90 92 /** The <code>JPanel</code> */ 91 93 private JPanel mainPanel; 92 94 93 95 /** Specifies if the MapDust data was or not downloaded */ 94 96 private boolean downloaded = false; 95 97 96 98 /** 97 99 * Builds a <code>MapdustGUi</code> based on the given parameters. 98 * 100 * 99 101 * @param name The name of the GUI 100 102 * @param iconName The name of the icon … … 109 111 this.mapdustPlugin = mapdustPlugin; 110 112 } 111 113 114 /** 115 * Displays the <code>MapdustGUI</code> dialog window in the JOSM editor. If 116 * the MapDust data was not downloaded yet, it will donwload the data and 117 * also update the MapDust plugin with the data. If the MapDust data was 118 * already downloaded, then the <code>MapdustGUI</code> will be displayed. 119 */ 120 @Override 121 public void showDialog() { 122 if (!downloaded) { 123 notifyObservers(null, true); 124 downloaded = true; 125 } 126 super.showDialog(); 127 } 128 129 /** 130 * Adds the given <code>MapdustAction</code> object to the list of actions. 131 * 132 * @param action The <code>MapdustAction</code> object 133 */ 134 @Override 135 public synchronized void addAction(MapdustAction action) { 136 /* add the action */ 137 List<MapdustAction> actionList = actionPanel.getActionList(); 138 actionList.add(action); 139 List<MapdustBug> mapdustBugs = panel.getMapdustBugsList(); 140 boolean showBug = shouldDisplay(action.getMapdustBug(), 141 mapdustPlugin.getFilter()); 142 mapdustBugs = modifyBug(mapdustBugs, action.getMapdustBug(), showBug); 143 144 /* update panels */ 145 updateMapdustPanel(mapdustBugs); 146 updateMapdustActionPanel(actionList); 147 if (showBug && 148 !action.getCommand().equals(MapdustServiceCommand.ADD_BUG)) { 149 panel.resetSelectedBug(0); 150 } else { 151 mapdustPlugin.getMapdustLayer().setBugSelected(null); 152 } 153 revalidate(); 154 Main.map.mapView.revalidate(); 155 Main.map.repaint(); 156 } 157 158 /** 159 * Verifies if the given <code>MapdustBug</code> should be shown on the 160 * MapDust bug list/ map. Any <code>MapdustBug</code> should be shown on the 161 * MapDust bug list / map only if it is permitted by the selected filters. 162 * 163 * @param modifiedBug The <code>MapdustBug</code> object 164 * @param filter The <code>MapdustBugFilter</code> object 165 * @return true if the given MapDust bug should be shown in the list/map 166 * false otherwise 167 */ 168 private boolean shouldDisplay(MapdustBug modifiedBug, 169 MapdustBugFilter filter) { 170 boolean result = false; 171 if (filter != null && filter.getStatuses() != null 172 && !filter.getStatuses().isEmpty()) { 173 if (filter.getStatuses().contains(modifiedBug.getStatus().getKey())) { 174 result = true; 175 } 176 } else { 177 result = true; 178 } 179 return result; 180 } 181 112 182 /** 113 183 * Updates the MapDust GUI with the given list of <code>MapdustBug</code> 114 184 * objects. 115 * 185 * 116 186 * @param mapdustBugs The list of <code>MapdustBug</code> objects 117 187 * @param mapdustPlugin The <code>MapdustPlugin</code> object … … 119 189 public synchronized void update(List<MapdustBug> mapdustBugs, 120 190 MapdustPlugin mapdustPlugin) { 121 this.mapdustPlugin= mapdustPlugin;191 setMapdustPlugin(mapdustPlugin); 122 192 String pluginState = Main.pref.get("mapdust.pluginState"); 123 193 if (pluginState.equals(MapdustPluginState.ONLINE.getValue())) { 124 /* remove the panels */125 194 if (tabbedPane != null) { 126 /* offline to online */ 195 /* from offline to online */ 127 196 remove(mainPanel); 128 queuePanel = null; 129 } else { 130 /* online to online */ 131 if (mainPanel != null) { 132 remove(mainPanel); 133 } 134 } 135 /* add panels with updated data */ 136 panel = new MapdustPanel(mapdustBugs, "Bug reports", mapdustPlugin); 137 MapdustBug selectedBug = (mapdustBugs != null && mapdustBugs.size() 138 > 0) ? mapdustBugs.get(0) : null; 139 if (detailsPanel == null) { 140 detailsPanel = new MapdustBugPropertiesPanel(selectedBug); 141 panel.addObserver(detailsPanel); 142 addObserver(detailsPanel); 143 } 144 notifyObservers(selectedBug); 145 panel.addObserver(detailsPanel); 146 mainPanel = new JPanel(); 147 mainPanel.setAutoscrolls(true); 148 mainPanel.setLayout(new BorderLayout()); 149 if (mapdustBugs != null) { 150 mainPanel.add(detailsPanel, BorderLayout.NORTH); 151 } 152 mainPanel.add(panel, BorderLayout.CENTER); 153 add(mainPanel, BorderLayout.CENTER); 197 tabbedPane = null; 198 actionPanel = null; 199 mainPanel = null; 200 panel = null; 201 } 202 updateMapdustPanel(mapdustBugs); 203 if (mainPanel == null) { 204 createMainPanel(); 205 } 154 206 } else { 155 List<MapdustAction> list = new ArrayList<MapdustAction>(); 156 /* remove panels */ 157 if (queuePanel == null) { 207 if (tabbedPane == null) { 158 208 /* from online to offline */ 159 209 remove(mainPanel); 160 } else { 161 list = queuePanel.getActionList(); 162 remove(mainPanel); 163 } 164 /* add panels with updated data */ 165 tabbedPane = new JTabbedPane(); 166 queuePanel = new MapdustActionPanel(list, "Offline Contribution", 210 mainPanel = null; 211 panel = null; 212 } 213 List<MapdustAction> actionList = 214 actionPanel != null ? actionPanel.getActionList() 215 : new ArrayList<MapdustAction>(); 216 217 /* update panels */ 218 List<MapdustBug> bugs = 219 filterMapdustBugList(mapdustBugs, actionList, 220 mapdustPlugin.getFilter()); 221 updateMapdustPanel(bugs); 222 updateMapdustActionPanel(actionList); 223 if (mainPanel == null) { 224 createMainPanel(); 225 } 226 } 227 } 228 229 230 /** 231 * Updates the MapDust bugs panel with the new list of data. 232 * 233 * @param mapdustBugs The list of <code>MapdustBug</code> objects 234 */ 235 private void updateMapdustPanel(List<MapdustBug> mapdustBugs) { 236 MapdustBug selectedBug = 237 (mapdustBugs != null && mapdustBugs.size() > 0) ? mapdustBugs 238 .get(0) : null; 239 if (detailsPanel == null) { 240 detailsPanel = new MapdustBugPropertiesPanel(selectedBug); 241 addObserver(detailsPanel); 242 } 243 if (panel == null) { 244 panel = new MapdustBugListPanel(mapdustBugs, "Bug reports", 167 245 mapdustPlugin); 168 panel = new MapdustPanel(mapdustBugs, "Bug reports (offline)", 169 mapdustPlugin); 170 MapdustBug selectedBug = (mapdustBugs != null && mapdustBugs.size() 171 > 0) ? mapdustBugs.get(0) : null; 172 if (detailsPanel == null) { 173 detailsPanel = new MapdustBugPropertiesPanel(selectedBug); 174 panel.addObserver(detailsPanel); 175 addObserver(detailsPanel); 176 } 246 panel.addObserver(detailsPanel); 247 } else { 248 panel.updateComponents(mapdustBugs); 177 249 notifyObservers(selectedBug); 178 panel.addObserver(detailsPanel); 179 mainPanel = new JPanel(); 180 mainPanel.setAutoscrolls(true); 181 mainPanel.setLayout(new BorderLayout()); 182 if (mapdustBugs != null) { 183 mainPanel.add(detailsPanel, BorderLayout.NORTH); 184 } 185 tabbedPane.add(panel, 0); 186 tabbedPane.add(queuePanel); 187 mainPanel.add(tabbedPane, BorderLayout.CENTER); 188 add(mainPanel, BorderLayout.CENTER); 189 } 190 } 191 192 /** 193 * Adds the given <code>MapdustAction</code> object to the list of actions. 194 * 195 * @param action The <code>MapdustAction</code> object 196 */ 197 @Override 198 public synchronized void addAction(MapdustAction action) { 199 /* add the action */ 200 List<MapdustAction> list = queuePanel.getActionList(); 201 List<MapdustBug> mapdustBugs = panel.getMapdustBugsList(); 202 mapdustBugs = modifyBug(mapdustBugs, action.getMapdustBug()); 203 204 /* remove panels */ 205 if (mainPanel != null) { 206 remove(mainPanel); 207 } 208 /* create new tabbed pane */ 209 tabbedPane = new JTabbedPane(); 210 list.add(action); 211 queuePanel = new MapdustActionPanel(list, "Offline Contribution", 212 mapdustPlugin); 213 panel = new MapdustPanel(mapdustBugs, "Bug reports (offline)", 214 mapdustPlugin); 250 } 251 } 252 253 /** 254 * Updates the MapDust action panel with the new list of data. 255 * 256 * @param actionList The list of <code>MapdustAction</code> objects 257 */ 258 private void updateMapdustActionPanel(List<MapdustAction> actionList) { 259 if (actionPanel == null) { 260 actionPanel = new MapdustActionPanel(actionList, 261 "Offline Contribution", mapdustPlugin); 262 } else { 263 actionPanel.updateComponents(actionList); 264 } 265 } 266 267 /** 268 * Creates the main panel of the plugin and adds to the content pane. 269 */ 270 private void createMainPanel() { 215 271 mainPanel = new JPanel(); 216 272 mainPanel.setAutoscrolls(true); 217 273 mainPanel.setLayout(new BorderLayout()); 218 274 mainPanel.add(detailsPanel, BorderLayout.NORTH); 219 tabbedPane.add(panel, 0); 220 tabbedPane.add(queuePanel); 221 mainPanel.add(tabbedPane, BorderLayout.CENTER); 275 if (actionPanel == null) { 276 mainPanel.add(panel, BorderLayout.CENTER); 277 } else { 278 tabbedPane = new JTabbedPane(); 279 tabbedPane.add(panel, 0); 280 tabbedPane.add(actionPanel); 281 mainPanel.add(tabbedPane, BorderLayout.CENTER); 282 } 222 283 add(mainPanel, BorderLayout.CENTER); 223 revalidate(); 224 } 225 226 /** 227 * Disables the buttons from the <code>MapdustButtonPanel</code> buttons. 228 * 229 */ 230 public void disableBtnPanel() { 231 panel.getBtnPanel().getBtnWorkOffline().setEnabled(false); 232 panel.getBtnPanel().getBtnRefresh().setEnabled(false); 233 panel.getBtnPanel().getBtnAddComment().setEnabled(false); 234 panel.getBtnPanel().getBtnFixBugReport().setEnabled(false); 235 panel.getBtnPanel().getBtnInvalidateBugReport().setEnabled(false); 236 panel.getBtnPanel().getBtnReOpenBugReport().setEnabled(false); 237 } 238 239 284 } 285 286 287 /** 288 * Filters the given list of <code>MapdustBug</code>s based on the given 289 * list of <code>MapdustAction</code>s. The filtering is done in order to 290 * show the modified bugs ( but not already committed operations) if they 291 * also appears in the new list of bugs, according to the latest 292 * modifications. 293 * 294 * @param bugList The list of <code>MapdustBug</code> objects 295 * @param actionList The list of <code>MapdustAction</code> objects 296 * @param filter The <code>MapdustBugFilter</code> object 297 * @return A filtered list of <code>MapdustBug</code>s 298 */ 299 private List<MapdustBug> filterMapdustBugList(List<MapdustBug> bugList, 300 List<MapdustAction> actionList, MapdustBugFilter filter) { 301 if (bugList != null && actionList != null) { 302 for (MapdustAction action : actionList) { 303 int index = bugList.indexOf(action.getMapdustBug()); 304 if (index >= 0) { 305 if (action.getNewStatus() != null) { 306 Status newStatus = 307 Status.getStatus(action.getNewStatus()); 308 if (filter != null && filter.getStatuses() != null 309 && !filter.getStatuses().isEmpty()) { 310 if (filter.getStatuses().contains( 311 newStatus.getKey())) { 312 bugList.get(index).setStatus(newStatus); 313 } else { 314 bugList.remove(index); 315 } 316 } else { 317 bugList.get(index).setStatus(newStatus); 318 } 319 } 320 } 321 } 322 } 323 return bugList; 324 } 325 240 326 /** 241 327 * Modifies the given <code>MapdustBug</code> in the given list of 242 328 * <code>MapdustBug</code> objects. Returns the list of bugs containing the 243 329 * modified bug. 244 * 330 * 245 331 * @param mapdustBugs The list of <code>MapdustBug</code> objects 246 332 * @param modifiedBug The <code>MapdustBug</code> object 333 * @param showBug A flag indicating if the given modified bug should be 334 * displayed on the map and on the list of bugs 247 335 * @return the modified list 248 336 */ 249 337 private List<MapdustBug> modifyBug(List<MapdustBug> mapdustBugs, 250 MapdustBug modifiedBug) { 338 MapdustBug modifiedBug, boolean showBug) { 251 339 int index = -1; 252 340 for (int i = 0; i < mapdustBugs.size(); i++) { … … 260 348 /* remove, and add to the top of the list */ 261 349 mapdustBugs.remove(index); 262 mapdustBugs.add(0, modifiedBug); 350 if (showBug) { 351 mapdustBugs.add(0, modifiedBug); 352 } 263 353 } 264 354 return mapdustBugs; 265 355 } 266 267 /** 268 * Displays the <code>MapdustGUI</code> dialog window in the JOSM editor. If 269 * the MapDust data was not downloaded yet, it will donwload the data and 270 * also update the MapDust plugin with the data. If the MapDust data was 271 * already downloaded, then the <code>MapdustGUI</code> will be displayed. 272 */ 273 @Override 274 public void showDialog() { 275 if (!downloaded) { 276 notifyObservers(); 277 downloaded = true; 278 } 279 super.showDialog(); 280 } 281 356 357 /** 358 * Returns the selected bug from the list of bugs. If there is no bug 359 * selected then the returned result is null. 360 * 361 * @return The selected bug 362 */ 363 public MapdustBug getSelectedBug() { 364 MapdustBug selectedBug = null; 365 if (panel != null) { 366 selectedBug = panel.getSelectedBug(); 367 } 368 return selectedBug; 369 } 370 371 /** 372 * Sets the given <code>MapdustBug</code> to be selected from the list of 373 * bugs. 374 * 375 * @param mapdustBug The <code>MapdustBug</code> object 376 */ 377 public void setSelectedBug(MapdustBug mapdustBug) { 378 if (panel != null) { 379 panel.setSelectedBug(mapdustBug); 380 } 381 } 382 383 /** 384 * Disables the buttons from the <code>MapdustPanel</code>. 385 * 386 */ 387 public void disableBtnPanel() { 388 if (panel != null) { 389 panel.disableBtnPanel(); 390 } 391 } 392 393 /** 394 * Enables the basic components from the <code>MapdustButtonPanel</code>. 395 * Basic components are considered the following buttons: work offline, 396 * filter bug report, and refresh.If the onlyBasic flag is true then the 397 * other buttons will be disabled. 398 * 399 * @param onlyBasic If true then the not basic buttons will be disabled 400 */ 401 public void enableBtnPanel(boolean onlyBasic) { 402 if (panel != null) { 403 panel.enableBtnPanel(onlyBasic); 404 } 405 } 406 407 /** 408 * Returns the list of <code>MapdustAction</code> objects. 409 * 410 * @return list of <code>MapdustAction</code> 411 */ 412 public List<MapdustAction> getMapdustActionList() { 413 return getActionPanel().getActionList(); 414 } 415 282 416 /** 283 417 * Adds a new MapDust bug details observer to the list of observers. 284 * 418 * 285 419 * @param observer The <code>MapdustBugDetailsObserver</code> object 286 420 */ … … 291 425 } 292 426 } 293 294 /** 295 * Adds a new MapDust initialupdate observer to the list of observers.296 * 297 * @param observer The <code>Mapdust InitialUpdateObserver</code> object298 */ 299 @Override 300 public void addObserver(Mapdust InitialUpdateObserver observer) {427 428 /** 429 * Adds a new MapDust update observer to the list of observers. 430 * 431 * @param observer The <code>MapdustUpdateObserver</code> object 432 */ 433 @Override 434 public void addObserver(MapdustUpdateObserver observer) { 301 435 if (!this.initialUpdateObservers.contains(observer)) { 302 436 this.initialUpdateObservers.add(observer); 303 437 } 304 438 } 305 439 306 440 /** 307 441 * Removes the given MapDust bug details observer from the list of 308 442 * observers. 309 * 443 * 310 444 * @param observer The <code>MapdustBugDetailsObserver</code> object 311 445 */ … … 313 447 public void removeObserver(MapdustBugDetailsObserver observer) { 314 448 this.bugDetailsObservers.remove(observer); 315 316 } 317 449 450 } 451 318 452 /** 319 453 * Removes the given MapDust initial update observer from the list of 320 454 * observers. 321 * 455 * 322 456 * @param observer The <code>MapdustInitialUpdateObserver</code> object 323 457 */ 324 458 @Override 325 public void removeObserver(Mapdust InitialUpdateObserver observer) {459 public void removeObserver(MapdustUpdateObserver observer) { 326 460 this.initialUpdateObservers.remove(observer); 327 328 } 329 461 462 } 463 330 464 /** 331 465 * Notifies the <code>MapdustBugDetailsObserver</code> objects observing the … … 340 474 } 341 475 } 342 476 343 477 /** 344 478 * Notifies the <code>MapdustInitialUpdateObserver</code> objects waiting … … 346 480 */ 347 481 @Override 348 public void notifyObservers() { 349 Iterator<Mapdust InitialUpdateObserver> elements =482 public void notifyObservers(MapdustBugFilter filter, boolean first) { 483 Iterator<MapdustUpdateObserver> elements = 350 484 this.initialUpdateObservers.iterator(); 351 485 while (elements.hasNext()) { 352 (elements.next()). initialUpdate();353 } 354 } 355 486 (elements.next()).update(null, true); 487 } 488 } 489 356 490 /** 357 491 * Returns the <code>MapdustPanel</code> object 358 * 492 * 359 493 * @return the panel 360 494 */ 361 public MapdustPanel getPanel() { 495 public MapdustBugListPanel getPanel() { 362 496 return panel; 363 497 } 364 498 365 499 /** 366 500 * Returns the <code>MapdustActionPanel</code> object 367 * 501 * 368 502 * @return the queuePanel 369 503 */ 370 public MapdustActionPanel getQueuePanel() { 371 return queuePanel; 372 } 373 504 public MapdustActionPanel getActionPanel() { 505 return actionPanel; 506 } 507 508 /** 509 * @return the mapdustPlugin 510 */ 511 public MapdustPlugin getMapdustPlugin() { 512 return mapdustPlugin; 513 } 514 515 /** 516 * @param mapdustPlugin the mapdustPlugin to set 517 */ 518 public void setMapdustPlugin(MapdustPlugin mapdustPlugin) { 519 this.mapdustPlugin = mapdustPlugin; 520 } 521 374 522 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/adapter/DisplayMenu.java
r24514 r25591 92 92 private void showMenu(MouseEvent event) { 93 93 if (event.isPopupTrigger()) { 94 JList c = (JList) event.getComponent();95 94 int x = event.getX(); 96 95 int y = event.getY(); … … 99 98 if (!listBugs.isSelectionEmpty() 100 99 && locationToIndex == selectedIndex) { 101 int count = c.getModel().getSize(); 102 int cal = count * 18; 103 if (y <= cal) { 104 menu.show(listBugs, x, y); 105 } 100 menu.show(listBugs, x, y); 101 106 102 } 107 103 } 108 104 } 105 109 106 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/adapter/WindowClose.java
r25127 r25591 31 31 import java.awt.event.WindowAdapter; 32 32 import java.awt.event.WindowEvent; 33 import javax.swing.JToggleButton;34 33 import org.openstreetmap.josm.Main; 35 34 import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.AbstractDialog; … … 48 47 49 48 /** Serial version UID */ 50 private static final long serialVersionUID = 1L;51 49 52 50 /** A <code>AbstractDialog</code> object */ … … 55 53 /** The <code>MapdustButtonPanel</code> object */ 56 54 private MapdustButtonPanel btnPanel; 57 58 /** The <code>JToggleButton</code> which had fired the dialog */59 private JToggleButton btnFired;60 55 61 56 /** … … 69 64 * @param dialog The dialog which will be closed 70 65 * @param btnPanel The button panel 71 * @param btnFired The button which fired the display dialog action72 66 */ 73 public WindowClose(AbstractDialog dialog, MapdustButtonPanel btnPanel, 74 JToggleButton btnFired) { 67 public WindowClose(AbstractDialog dialog, MapdustButtonPanel btnPanel ) { 75 68 this.dialog = dialog; 76 69 this.btnPanel = btnPanel; 77 this.btnFired = btnFired;78 70 } 79 71 … … 86 78 btnPanel.getBtnWorkOffline().setEnabled(true); 87 79 btnPanel.getBtnWorkOffline().setSelected(false); 80 btnPanel.getBtnWorkOffline().setFocusable(false); 81 btnPanel.getBtnFilter().setEnabled(true); 82 btnPanel.getBtnFilter().setSelected(false); 83 btnPanel.getBtnFilter().setFocusable(false); 88 84 if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) { 89 85 btnPanel.getBtnRefresh().setEnabled(false); 90 86 } else { 91 87 btnPanel.getBtnRefresh().setEnabled(true); 88 btnPanel.getBtnRefresh().setSelected(false); 89 btnPanel.getBtnRefresh().setFocusable(false); 92 90 } 93 91 if (status.equals(Status.OPEN.getValue())) { 94 92 btnPanel.getBtnFixBugReport().setEnabled(true); 95 93 btnPanel.getBtnInvalidateBugReport().setEnabled(true); 96 btnPanel.getBtnReOpenBugReport().setEnabled(false);97 94 btnPanel.getBtnAddComment().setEnabled(true); 98 95 } else { 99 96 if (status.equals(Status.FIXED.getValue())) { 100 btnPanel.getBtnFixBugReport().setEnabled(false);101 btnPanel.getBtnInvalidateBugReport().setEnabled(false);102 97 btnPanel.getBtnReOpenBugReport().setEnabled(true); 103 98 btnPanel.getBtnAddComment().setEnabled(true); 104 99 } else { 105 100 if (status.equals(Status.INVALID.getValue())) { 106 btnPanel.getBtnFixBugReport().setEnabled(false);107 btnPanel.getBtnInvalidateBugReport().setEnabled(false);108 101 btnPanel.getBtnReOpenBugReport().setEnabled(true); 109 102 btnPanel.getBtnAddComment().setEnabled(true); 110 } else {111 btnPanel.getBtnFixBugReport().setEnabled(false);112 btnPanel.getBtnInvalidateBugReport().setEnabled(false);113 btnPanel.getBtnReOpenBugReport().setEnabled(false);114 btnPanel.getBtnAddComment().setEnabled(false);115 103 } 116 104 } 117 105 } 118 btnPanel.getBtnRefresh().setSelected(false);119 btnPanel.getBtnAddComment().setSelected(false);120 btnPanel.getBtnFixBugReport().setSelected(false);121 btnPanel.getBtnInvalidateBugReport().setSelected(false);122 btnPanel.getBtnReOpenBugReport().setSelected(false);123 106 } 124 /* enable fired button */ 125 if (btnFired != null) { 126 btnFired.setEnabled(true); 127 btnFired.setSelected(false); 128 } 107 108 btnPanel.getBtnAddComment().setSelected(false); 109 btnPanel.getBtnAddComment().setFocusable(false); 110 btnPanel.getBtnFixBugReport().setSelected(false); 111 btnPanel.getBtnFixBugReport().setFocusable(false); 112 btnPanel.getBtnInvalidateBugReport().setSelected(false); 113 btnPanel.getBtnInvalidateBugReport().setFocusable(false); 114 btnPanel.getBtnReOpenBugReport().setSelected(false); 115 btnPanel.getBtnReOpenBugReport().setFocusable(false); 116 129 117 /* dispose dialog */ 130 dialog.setVisible(false);131 118 dialog.dispose(); 132 119 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteActionList.java
r25127 r25591 39 39 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustActionUploaderException; 40 40 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI; 41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.Mapdust RefreshObservable;42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.Mapdust RefreshObserver;41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObservable; 42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver; 43 43 import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustPluginState; 44 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter; 44 45 45 46 … … 53 54 */ 54 55 public class ExecuteActionList extends MapdustExecuteAction implements 55 Mapdust RefreshObservable {56 MapdustUpdateObservable { 56 57 57 58 /** Serial version UID */ 58 private static final long serialVersionUID = 1L;59 private static final long serialVersionUID = -7487830542214611774L; 59 60 60 61 /** List of MapdustRefreshObserver objects */ 61 private final ArrayList<Mapdust RefreshObserver> observers =62 new ArrayList<Mapdust RefreshObserver>();62 private final ArrayList<MapdustUpdateObserver> observers = 63 new ArrayList<MapdustUpdateObserver>(); 63 64 64 65 /** … … 72 73 73 74 /** 74 * Uploads the content of the action list to the MapDust service. 75 * 75 * Uploads the content of the action list to the MapDust service. 76 * 76 77 * @param event The event which fires this action 77 78 */ … … 81 82 try { 82 83 MapdustActionUploader.getInstance().uploadData( 83 getMapdustGUI().get QueuePanel().getActionList());84 getMapdustGUI().getMapdustActionList()); 84 85 } catch (MapdustActionUploaderException e) { 85 86 String errorMessage = "There was an error uploading the "; … … 88 89 tr("Error"), JOptionPane.ERROR_MESSAGE); 89 90 } 90 Main.pref.put("mapdust.pluginState", MapdustPluginState.ONLINE.getValue());91 getMapdustGUI().getPanel().getBtnPanel().getBtnRefresh().setEnabled(true);92 notifyObservers(); 91 Main.pref.put("mapdust.pluginState", 92 MapdustPluginState.ONLINE.getValue()); 93 notifyObservers(null, false); 93 94 } 94 95 } … … 100 101 */ 101 102 @Override 102 public void addObserver(Mapdust RefreshObserver observer) {103 public void addObserver(MapdustUpdateObserver observer) { 103 104 if (!this.observers.contains(observer)) { 104 105 this.observers.add(observer); … … 112 113 */ 113 114 @Override 114 public void removeObserver(Mapdust RefreshObserver observer) {115 public void removeObserver(MapdustUpdateObserver observer) { 115 116 this.observers.remove(observer); 116 117 } … … 120 121 */ 121 122 @Override 122 public void notifyObservers() { 123 Iterator<Mapdust RefreshObserver> elements = this.observers.iterator();123 public void notifyObservers(MapdustBugFilter filter, boolean first) { 124 Iterator<MapdustUpdateObserver> elements = this.observers.iterator(); 124 125 while (elements.hasNext()) { 125 (elements.next()). refreshData();126 (elements.next()).update(filter, false); 126 127 } 127 128 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteAddBug.java
r25127 r25591 39 39 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI; 40 40 import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.CreateIssueDialog; 41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObservable;42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObserver;41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable; 42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver; 43 43 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable; 44 44 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver; … … 64 64 */ 65 65 public class ExecuteAddBug extends MapdustExecuteAction implements 66 MapdustBugObservable, MapdustAction ListObservable {66 MapdustBugObservable, MapdustActionObservable { 67 67 68 68 /** The serial version UID */ 69 private static final long serialVersionUID = 1L;70 71 /** The list of Map dust bug observers */69 private static final long serialVersionUID = 8023875766573474513L; 70 71 /** The list of MapDust bug observers */ 72 72 private final ArrayList<MapdustBugObserver> bugObservers = 73 73 new ArrayList<MapdustBugObserver>(); 74 74 75 /** The list of Map dust action observers */76 private final ArrayList<MapdustAction ListObserver> actionObservers =77 new ArrayList<MapdustAction ListObserver>();75 /** The list of MapDust action observers */ 76 private final ArrayList<MapdustActionObserver> actionObservers = 77 new ArrayList<MapdustActionObserver>(); 78 78 79 79 /** … … 97 97 * are valid. Otherwise a corresponding warning message will be shown to the 98 98 * user. 99 * 99 * 100 100 * @param event The action event which fires this action 101 101 */ … … 122 122 latlon = Main.map.mapView.getLatLon(p.x, p.y); 123 123 } 124 MapdustBug bug = new MapdustBug(latlon, type, commentText, nickname); 124 MapdustBug bug = new MapdustBug(latlon, type, commentText, 125 nickname); 125 126 String pluginState = Main.pref.get("mapdust.pluginState"); 126 127 if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) { 127 128 /* offline state */ 128 int index = getSelectedBugIndex();129 129 bug.setStatus(Status.OPEN); 130 130 String iconPath = getIconPath(bug); 131 131 MapdustAction mapdustAction = new MapdustAction( 132 132 MapdustServiceCommand.ADD_BUG, iconPath, bug); 133 if (getMapdustGUI().getQueuePanel() != null) { 133 /* destroy dialog */ 134 getDialog().dispose(); 135 mapdustGUI.enableBtnPanel(false); 136 if (getMapdustGUI().getActionPanel() != null) { 134 137 notifyObservers(mapdustAction); 135 138 } 136 resetSelectedBug(index);137 139 } else { 138 140 /* online state */ … … 143 145 } catch (MapdustServiceHandlerException e) { 144 146 errorMessage = "There was a Mapdust service error."; 145 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 147 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 146 148 tr("Error"), JOptionPane.ERROR_MESSAGE); 147 149 } … … 153 155 } catch (MapdustServiceHandlerException e) { 154 156 errorMessage = "There was a Mapdust service error."; 155 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 156 tr("Error"), JOptionPane.ERROR_MESSAGE); 157 JOptionPane.showMessageDialog(Main.parent, 158 tr(errorMessage), tr("Error"), 159 JOptionPane.ERROR_MESSAGE); 157 160 } 161 /* destroy dialog */ 162 getDialog().dispose(); 163 mapdustGUI.enableBtnPanel(false); 158 164 if (newMapdustBug != null) { 159 165 notifyObservers(newMapdustBug); 160 166 } 161 167 } 162 resetSelectedBug(0);163 168 } 164 /* destroy dialog */165 getDialog().dispose();166 return;167 169 } 168 170 } … … 209 211 */ 210 212 @Override 211 public void addObserver(MapdustAction ListObserver observer) {213 public void addObserver(MapdustActionObserver observer) { 212 214 if (!this.actionObservers.contains(observer)) { 213 215 this.actionObservers.add(observer); … … 222 224 */ 223 225 @Override 224 public void removeObserver(MapdustAction ListObserver observer) {226 public void removeObserver(MapdustActionObserver observer) { 225 227 this.actionObservers.remove(observer); 226 228 … … 234 236 @Override 235 237 public void notifyObservers(MapdustAction mapdustAction) { 236 Iterator<MapdustAction ListObserver> elements =238 Iterator<MapdustActionObserver> elements = 237 239 this.actionObservers.iterator(); 238 240 while (elements.hasNext()) { -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteCancel.java
r25127 r25591 47 47 48 48 /** The serial version UID */ 49 private static final long serialVersionUID = 1L;49 private static final long serialVersionUID = 5357125707042485489L; 50 50 51 51 /** … … 67 67 /** 68 68 * Cancels the executed action, and closes the visible dialog window. 69 * 69 * 70 70 * @param event The action event which fires this action 71 71 */ … … 76 76 String status = Main.pref.get("selectedBug.status"); 77 77 /* enable buttons */ 78 MapdustButtonPanel btnPanel = getMapdustGUI().getPanel().getBtnPanel(); 78 MapdustButtonPanel btnPanel = 79 getMapdustGUI().getPanel().getBtnPanel(); 79 80 if (btnPanel != null) { 80 81 btnPanel.getBtnWorkOffline().setEnabled(true); 82 btnPanel.getBtnWorkOffline().setFocusable(false); 81 83 btnPanel.getBtnWorkOffline().setSelected(false); 82 84 if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) { … … 102 104 false); 103 105 btnPanel.getBtnReOpenBugReport().setEnabled(true); 104 105 106 btnPanel.getBtnAddComment().setEnabled(true); 106 107 } else { 107 // created bug, then close dialog 108 btnPanel.getBtnFixBugReport().setEnabled(false); 109 btnPanel.getBtnInvalidateBugReport().setEnabled( 110 false); 111 btnPanel.getBtnReOpenBugReport().setEnabled(false); 112 btnPanel.getBtnAddComment().setEnabled(false); 108 if (!status.isEmpty()) { 109 btnPanel.getBtnFixBugReport().setEnabled(false); 110 btnPanel.getBtnInvalidateBugReport() 111 .setEnabled(false); 112 btnPanel.getBtnReOpenBugReport().setEnabled( 113 false); 114 btnPanel.getBtnAddComment().setEnabled(false); 115 } 113 116 } 114 117 } 115 118 } 116 btnPanel.getBtnRefresh().setSelected(false); 119 btnPanel.getBtnFilter().setEnabled(true); 120 btnPanel.getBtnFilter().setSelected(false); 121 btnPanel.getBtnFilter().setFocusable(false); 117 122 btnPanel.getBtnAddComment().setSelected(false); 123 btnPanel.getBtnAddComment().setFocusable(false); 118 124 btnPanel.getBtnFixBugReport().setSelected(false); 125 btnPanel.getBtnFixBugReport().setFocusable(false); 119 126 btnPanel.getBtnInvalidateBugReport().setSelected(false); 127 btnPanel.getBtnInvalidateBugReport().setFocusable(false); 120 128 btnPanel.getBtnReOpenBugReport().setSelected(false); 129 btnPanel.getBtnReOpenBugReport().setFocusable(false); 121 130 } 122 131 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteCloseBug.java
r25127 r25591 38 38 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI; 39 39 import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.ChangeIssueStatusDialog; 40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObservable;41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObserver;40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable; 41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver; 42 42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable; 43 43 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver; … … 63 63 */ 64 64 public class ExecuteCloseBug extends MapdustExecuteAction implements 65 MapdustBugObservable, MapdustAction ListObservable {65 MapdustBugObservable, MapdustActionObservable { 66 66 67 67 /** Serial version UID */ 68 private static final long serialVersionUID = 1L;68 private static final long serialVersionUID = 3468827127588061014L; 69 69 70 70 /** The list of Mapdust bug observers */ … … 73 73 74 74 /** The list of Mapdust action observers */ 75 private final ArrayList<MapdustAction ListObserver> actionObservers =76 new ArrayList<MapdustAction ListObserver>();75 private final ArrayList<MapdustActionObserver> actionObservers = 76 new ArrayList<MapdustActionObserver>(); 77 77 78 78 /** … … 95 95 * Closes the given MapDust bug. If the entered informations are invalid a 96 96 * corresponding warning message will be displayed. 97 * 97 * 98 98 * @param event The action event which fires this action 99 99 */ … … 118 118 /* valid input data */ 119 119 Main.pref.put("mapdust.nickname", nickname); 120 MapdustBug selectedBug = getSelectedBug(); 120 MapdustBug selectedBug = mapdustGUI.getSelectedBug(); 121 121 MapdustComment comment = new MapdustComment(selectedBug.getId(), 122 122 commentText, nickname); … … 129 129 MapdustServiceCommand.CHANGE_BUG_STATUS, iconPath, 130 130 selectedBug, comment, 2); 131 if (getMapdustGUI().getQueuePanel() != null) { 131 /* destroy dialog */ 132 enableFiredButton(issueDialog.getFiredButton()); 133 mapdustGUI.enableBtnPanel(false); 134 issueDialog.dispose(); 135 if (getMapdustGUI().getActionPanel()!= null) { 132 136 notifyObservers(mapdustAction); 133 137 } … … 140 144 } catch (MapdustServiceHandlerException e) { 141 145 errorMessage = "There was a Mapdust service error."; 142 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 143 tr("Error"), JOptionPane.ERROR_MESSAGE); 146 JOptionPane.showMessageDialog(Main.parent, 147 tr(errorMessage), tr("Error"), 148 JOptionPane.ERROR_MESSAGE); 144 149 } 145 150 if (id != null) { … … 147 152 MapdustBug newMapdustBug = null; 148 153 try { 149 newMapdustBug = handler.getBug(selectedBug.getId(), null); 154 newMapdustBug = handler.getBug(selectedBug.getId(), 155 null); 150 156 } catch (MapdustServiceHandlerException e) { 151 157 errorMessage = "There was a Mapdust service error."; 152 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 153 tr("Error"), JOptionPane.ERROR_MESSAGE); 158 JOptionPane.showMessageDialog(Main.parent, 159 tr(errorMessage), tr("Error"), 160 JOptionPane.ERROR_MESSAGE); 154 161 } 162 /* destroy dialog */ 163 enableFiredButton(issueDialog.getFiredButton()); 164 mapdustGUI.enableBtnPanel(false); 165 issueDialog.dispose(); 155 166 if (newMapdustBug != null) { 156 167 notifyObservers(newMapdustBug); … … 158 169 } 159 170 } 160 /* enable buttons */161 enableFiredButton(issueDialog.getFiredButton());162 resetSelectedBug(0);163 /* destroy dialog */164 issueDialog.dispose();165 171 } 166 172 } … … 185 191 */ 186 192 @Override 187 public void addObserver(MapdustAction ListObserver observer) {193 public void addObserver(MapdustActionObserver observer) { 188 194 if (!this.actionObservers.contains(observer)) { 189 195 this.actionObservers.add(observer); … … 201 207 202 208 } 203 /** 204 * Removes the MapDust action list observer object from the list of observers. 209 210 /** 211 * Removes the MapDust action list observer object from the list of 212 * observers. 205 213 * 206 214 * @param observer The <code>MapdustActionListObserver</code> object 207 215 */ 208 216 @Override 209 public void removeObserver(MapdustAction ListObserver observer) {217 public void removeObserver(MapdustActionObserver observer) { 210 218 this.actionObservers.remove(observer); 211 219 … … 228 236 @Override 229 237 public void notifyObservers(MapdustAction mapdustAction) { 230 Iterator<MapdustAction ListObserver> elements =238 Iterator<MapdustActionObserver> elements = 231 239 this.actionObservers.iterator(); 232 240 while (elements.hasNext()) { -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteCommentBug.java
r25127 r25591 38 38 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI; 39 39 import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.CommentIssueDialog; 40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObservable;41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObserver;40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable; 41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver; 42 42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable; 43 43 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver; … … 54 54 * Comments the given <code>MapdustBug</code> object. Validates the input data, 55 55 * and based on the plugin state executes the corresponding action. If the 56 * plugin is in the "ONLINE" state then executes the Map dust Service56 * plugin is in the "ONLINE" state then executes the MapDust Service 57 57 * 'commentBug' method with the given input parameters. If the plugin is in the 58 58 * "OFFLINE" state then the given action is added to the actions list. … … 62 62 */ 63 63 public class ExecuteCommentBug extends MapdustExecuteAction implements 64 MapdustBugObservable, MapdustAction ListObservable {64 MapdustBugObservable, MapdustActionObservable { 65 65 66 66 /** The serial version UID */ 67 private static final long serialVersionUID = 1L;68 69 /** The list of Map dust bug observers */67 private static final long serialVersionUID = 4391634740784919337L; 68 69 /** The list of MapDust bug observers */ 70 70 private final ArrayList<MapdustBugObserver> bugObservers = 71 71 new ArrayList<MapdustBugObserver>(); 72 72 73 73 /** The list of mapdust action observers */ 74 private final ArrayList<MapdustAction ListObserver> actionObservers =75 new ArrayList<MapdustAction ListObserver>();74 private final ArrayList<MapdustActionObserver> actionObservers = 75 new ArrayList<MapdustActionObserver>(); 76 76 77 77 /** … … 94 94 * Creates a comment for the given MapDust bug. If the entered informations 95 95 * are invalid a corresponding warning message will be displayed. 96 * 96 * 97 97 * @param event The action event which fires this action 98 98 */ … … 117 117 /* valid */ 118 118 Main.pref.put("mapdust.nickname", nickname); 119 MapdustBug selectedBug = getSelectedBug(); 119 MapdustBug selectedBug = mapdustGUI.getSelectedBug(); 120 120 MapdustComment comment = new MapdustComment(selectedBug.getId(), 121 121 commentText, nickname); … … 127 127 MapdustServiceCommand.COMMENT_BUG, iconPath, 128 128 selectedBug, comment); 129 if (getMapdustGUI().getQueuePanel() != null) { 129 if (getMapdustGUI().getActionPanel() != null) { 130 issueDialog.dispose(); 130 131 notifyObservers(mapdustAction); 131 132 } … … 138 139 } catch (MapdustServiceHandlerException e) { 139 140 errorMessage = "There was a Mapdust service error."; 140 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 141 tr("Error"), JOptionPane.ERROR_MESSAGE); 141 JOptionPane.showMessageDialog(Main.parent, 142 tr(errorMessage), tr("Error"), 143 JOptionPane.ERROR_MESSAGE); 142 144 } 143 145 if (id != null) { … … 145 147 MapdustBug newMapdustBug = null; 146 148 try { 147 newMapdustBug = handler.getBug(selectedBug.getId(), null); 149 newMapdustBug = handler.getBug(selectedBug.getId(), 150 null); 148 151 } catch (MapdustServiceHandlerException e) { 149 152 errorMessage = "There was a Mapdust service error."; … … 159 162 /* enable buttons */ 160 163 enableFiredButton(issueDialog.getFiredButton()); 161 resetSelectedBug(0); 164 mapdustGUI.enableBtnPanel(false); 165 mapdustGUI.getPanel().resetSelectedBug(0); 162 166 /* destroy dialog */ 163 167 issueDialog.dispose(); … … 184 188 */ 185 189 @Override 186 public void addObserver(MapdustAction ListObserver observer) {190 public void addObserver(MapdustActionObserver observer) { 187 191 if (!this.actionObservers.contains(observer)) { 188 192 this.actionObservers.add(observer); … … 202 206 203 207 /** 204 * Removes the MapDust action list observer object from the list of observers. 208 * Removes the MapDust action list observer object from the list of 209 * observers. 205 210 * 206 211 * @param observer The <code>MapdustActionListObserver</code> object 207 212 */ 208 213 @Override 209 public void removeObserver(MapdustAction ListObserver observer) {214 public void removeObserver(MapdustActionObserver observer) { 210 215 this.actionObservers.remove(observer); 211 216 } … … 227 232 @Override 228 233 public void notifyObservers(MapdustAction mapdustAction) { 229 Iterator<MapdustAction ListObserver> elements =234 Iterator<MapdustActionObserver> elements = 230 235 this.actionObservers.iterator(); 231 236 while (elements.hasNext()) { … … 233 238 } 234 239 } 235 240 236 241 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteInvalidateBug.java
r25127 r25591 38 38 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI; 39 39 import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.ChangeIssueStatusDialog; 40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObservable;41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObserver;40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable; 41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver; 42 42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable; 43 43 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver; … … 64 64 */ 65 65 public class ExecuteInvalidateBug extends MapdustExecuteAction implements 66 MapdustBugObservable, MapdustAction ListObservable {66 MapdustBugObservable, MapdustActionObservable { 67 67 68 68 /** The serial version UID */ 69 private static final long serialVersionUID = 1L;69 private static final long serialVersionUID = 542699469544481797L; 70 70 71 71 /** The list of mapdust bug observers */ … … 74 74 75 75 /** The list of mapdust action observers */ 76 private final ArrayList<MapdustAction ListObserver> actionObservers =77 new ArrayList<MapdustAction ListObserver>();76 private final ArrayList<MapdustActionObserver> actionObservers = 77 new ArrayList<MapdustActionObserver>(); 78 78 79 79 /** … … 98 98 * Invalidates the given MapDust bug. If the entered informations are 99 99 * invalid a corresponding warning message will be displayed. 100 * 100 * 101 101 * @param event The action event which fires this action 102 102 */ … … 115 115 if (errorMessage != null) { 116 116 /* invalid input */ 117 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 117 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 118 118 tr("Missing input data"), JOptionPane.WARNING_MESSAGE); 119 119 return; … … 121 121 /* valid input */ 122 122 Main.pref.put("mapdust.nickname", nickname); 123 MapdustBug selectedBug = getSelectedBug(); 124 MapdustComment comment = new MapdustComment(selectedBug.getId(), 123 MapdustBug selectedBug = mapdustGUI.getSelectedBug(); 124 MapdustComment comment = new MapdustComment(selectedBug.getId(), 125 125 commentText, nickname); 126 126 String pluginState = Main.pref.get("mapdust.pluginState"); … … 130 130 String iconPath = getIconPath(selectedBug); 131 131 MapdustAction mapdustAction = new MapdustAction( 132 MapdustServiceCommand.CHANGE_BUG_STATUS, iconPath, 132 MapdustServiceCommand.CHANGE_BUG_STATUS, iconPath, 133 133 selectedBug, comment, 3); 134 if (getMapdustGUI().getQueuePanel() != null) { 134 /* destroy dialog */ 135 136 /* enable buttons */ 137 mapdustGUI.enableBtnPanel(false); 138 enableFiredButton(issueDialog.getFiredButton()); 139 issueDialog.dispose(); 140 if (getMapdustGUI().getActionPanel() != null) { 135 141 notifyObservers(mapdustAction); 136 142 } … … 143 149 } catch (MapdustServiceHandlerException e) { 144 150 errorMessage = "There was a Mapdust service error."; 145 JOptionPane.showMessageDialog(Main.parent, 151 JOptionPane.showMessageDialog(Main.parent, 146 152 tr(errorMessage), tr("Error"), 147 153 JOptionPane.ERROR_MESSAGE); … … 151 157 MapdustBug newMapdustBug = null; 152 158 try { 153 newMapdustBug = handler.getBug(selectedBug.getId(), 159 newMapdustBug = handler.getBug(selectedBug.getId(), 154 160 null); 155 161 } catch (MapdustServiceHandlerException e) { 156 162 errorMessage = "There was a Mapdust service error."; 157 163 errorMessage += "Mapdust bug report."; 158 JOptionPane.showMessageDialog(Main.parent, 164 JOptionPane.showMessageDialog(Main.parent, 159 165 tr(errorMessage), tr("Error"), 160 166 JOptionPane.ERROR_MESSAGE); 161 167 } 168 /* destroy dialog */ 169 170 /* enable buttons */ 171 enableFiredButton(issueDialog.getFiredButton()); 172 mapdustGUI.enableBtnPanel(false); 173 issueDialog.dispose(); 174 162 175 if (newMapdustBug != null) { 163 176 notifyObservers(newMapdustBug); … … 165 178 } 166 179 } 167 /* enable buttons */ 168 enableFiredButton(issueDialog.getFiredButton()); 169 resetSelectedBug(0); 170 /* destroy dialog */ 171 issueDialog.dispose(); 180 172 181 } 173 182 } … … 192 201 */ 193 202 @Override 194 public void addObserver(MapdustAction ListObserver observer) {203 public void addObserver(MapdustActionObserver observer) { 195 204 if (!this.actionObservers.contains(observer)) { 196 205 this.actionObservers.add(observer); … … 215 224 */ 216 225 @Override 217 public void removeObserver(MapdustAction ListObserver observer) {226 public void removeObserver(MapdustActionObserver observer) { 218 227 this.actionObservers.remove(observer); 219 228 … … 236 245 @Override 237 246 public void notifyObservers(MapdustAction mapdustAction) { 238 Iterator<MapdustAction ListObserver> elements =247 Iterator<MapdustActionObserver> elements = 239 248 this.actionObservers.iterator(); 240 249 while (elements.hasNext()) { -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteReOpenBug.java
r25127 r25591 38 38 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI; 39 39 import org.openstreetmap.josm.plugins.mapdust.gui.component.dialog.ChangeIssueStatusDialog; 40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObservable;41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustAction ListObserver;40 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObservable; 41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustActionObserver; 42 42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObservable; 43 43 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustBugObserver; … … 64 64 */ 65 65 public class ExecuteReOpenBug extends MapdustExecuteAction implements 66 MapdustBugObservable, MapdustAction ListObservable {66 MapdustBugObservable, MapdustActionObservable { 67 67 68 68 /** The serial version UID */ 69 private static final long serialVersionUID = 1L; 70 71 /** The list of mapdust bug observers */69 private static final long serialVersionUID = 8275121997644127251L; 70 71 /** The list of MapDust bug observers */ 72 72 private final ArrayList<MapdustBugObserver> bugObservers = 73 73 new ArrayList<MapdustBugObserver>(); 74 74 75 /** The list of mapdust action observers */76 private final ArrayList<MapdustAction ListObserver> actionObservers =77 new ArrayList<MapdustAction ListObserver>();75 /** The list of MapDust action observers */ 76 private final ArrayList<MapdustActionObserver> actionObservers = 77 new ArrayList<MapdustActionObserver>(); 78 78 79 79 /** … … 95 95 96 96 /** 97 * 97 * 98 98 * @param event The event which fires this action 99 99 */ … … 112 112 if (errorMessage != null) { 113 113 /* invalid data */ 114 JOptionPane.showMessageDialog(Main.parent, 115 tr(errorMessage), tr("Missing input data"), 116 JOptionPane.WARNING_MESSAGE); 114 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 115 tr("Missing input data"), JOptionPane.WARNING_MESSAGE); 117 116 return; 118 117 } 119 118 /* valid */ 120 119 Main.pref.put("mapdust.nickname", nickname); 121 MapdustBug selectedBug = getSelectedBug(); 122 MapdustComment comment = 123 new MapdustComment(selectedBug.getId(), commentText, 124 nickname); 120 MapdustBug selectedBug = mapdustGUI.getSelectedBug(); 121 MapdustComment comment = new MapdustComment(selectedBug.getId(), 122 commentText, nickname); 125 123 String pluginState = Main.pref.get("mapdust.pluginState"); 126 124 if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) { … … 128 126 selectedBug.setStatus(Status.OPEN); 129 127 String iconPath = getIconPath(selectedBug); 130 MapdustAction mapdustAction = 131 new MapdustAction( 132 MapdustServiceCommand.CHANGE_BUG_STATUS, 133 iconPath, selectedBug, comment, 1); 134 if (getMapdustGUI().getQueuePanel() != null) { 128 MapdustAction mapdustAction = new MapdustAction( 129 MapdustServiceCommand.CHANGE_BUG_STATUS, iconPath, 130 selectedBug, comment, 1); 131 /* destroy dialog */ 132 mapdustGUI.enableBtnPanel(false); 133 enableFiredButton(issueDialog.getFiredButton()); 134 issueDialog.dispose(); 135 if (getMapdustGUI().getActionPanel() != null) { 135 136 notifyObservers(mapdustAction); 136 137 } 137 138 } else { 138 /* online, call Map dust service method */139 /* online, call MapDust service method */ 139 140 MapdustServiceHandler handler = new MapdustServiceHandler(); 140 141 Long id = null; … … 149 150 } 150 151 if (id != null) { 151 // success152 152 MapdustBug newMapdustBug = null; 153 153 try { 154 newMapdustBug = 155 handler.getBug(selectedBug.getId(),null);154 newMapdustBug = handler.getBug(selectedBug.getId(), 155 null); 156 156 } catch (MapdustServiceHandlerException e) { 157 157 errorMessage = "There was a Mapdust service error."; … … 161 161 JOptionPane.ERROR_MESSAGE); 162 162 } 163 mapdustGUI.enableBtnPanel(false); 164 enableFiredButton(issueDialog.getFiredButton()); 165 issueDialog.dispose(); 163 166 if (newMapdustBug != null) { 164 167 notifyObservers(newMapdustBug); … … 166 169 } 167 170 } 168 /* enable buttons */169 enableFiredButton(issueDialog.getFiredButton());170 resetSelectedBug(0);171 /* destroy dialog */172 issueDialog.dispose();173 171 } 174 172 } … … 193 191 */ 194 192 @Override 195 public void addObserver(MapdustAction ListObserver observer) {193 public void addObserver(MapdustActionObserver observer) { 196 194 if (!this.actionObservers.contains(observer)) { 197 195 this.actionObservers.add(observer); … … 211 209 212 210 /** 213 * Removes the MapDust action list observer object from the list of observers. 211 * Removes the MapDust action list observer object from the list of 212 * observers. 214 213 * 215 214 * @param observer The <code>MapdustActionListObserver</code> object 216 215 */ 217 216 @Override 218 public void removeObserver(MapdustAction ListObserver observer) {217 public void removeObserver(MapdustActionObserver observer) { 219 218 this.actionObservers.remove(observer); 220 219 … … 237 236 @Override 238 237 public void notifyObservers(MapdustAction mapdustAction) { 239 Iterator<MapdustAction ListObserver> elements =238 Iterator<MapdustActionObserver> elements = 240 239 this.actionObservers.iterator(); 241 240 while (elements.hasNext()) { … … 243 242 } 244 243 } 245 244 246 245 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteRefresh.java
r25127 r25591 35 35 import javax.swing.JToggleButton; 36 36 import org.openstreetmap.josm.Main; 37 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObservable; 38 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustRefreshObserver; 37 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObservable; 38 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver; 39 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter; 39 40 40 41 … … 47 48 */ 48 49 public class ExecuteRefresh extends AbstractAction implements 49 Mapdust RefreshObservable {50 MapdustUpdateObservable { 50 51 51 52 /** The serial version UID */ 52 private static final long serialVersionUID = 1L; 53 private static final long serialVersionUID = 1507634893685333278L; 53 54 54 55 /** The list of MapDust refresh observers */ 55 private final ArrayList<Mapdust RefreshObserver> observers =56 new ArrayList<Mapdust RefreshObserver>();56 private final ArrayList<MapdustUpdateObserver> observers = 57 new ArrayList<MapdustUpdateObserver>(); 57 58 58 59 /** … … 62 63 63 64 /** 64 * Updates the Map dust data.65 * 65 * Updates the MapDust data. 66 * 66 67 * @param event The event which fires this action 67 68 */ … … 72 73 /* update the bugs */ 73 74 Main.pref.put("mapdust.showError", true); 74 notifyObservers(); 75 notifyObservers(null, false); 75 76 btn.setSelected(false); 77 btn.setFocusable(false); 76 78 } 77 79 } … … 83 85 */ 84 86 @Override 85 public void addObserver(Mapdust RefreshObserver observer) {87 public void addObserver(MapdustUpdateObserver observer) { 86 88 if (!this.observers.contains(observer)) { 87 89 this.observers.add(observer); … … 95 97 */ 96 98 @Override 97 public void removeObserver(Mapdust RefreshObserver observer) {99 public void removeObserver(MapdustUpdateObserver observer) { 98 100 this.observers.remove(observer); 99 101 } … … 103 105 */ 104 106 @Override 105 public void notifyObservers() { 106 Iterator<Mapdust RefreshObserver> elements = this.observers.iterator();107 public void notifyObservers(MapdustBugFilter filter, boolean first) { 108 Iterator<MapdustUpdateObserver> elements = this.observers.iterator(); 107 109 while (elements.hasNext()) { 108 (elements.next()). refreshData();110 (elements.next()).update(filter, false); 109 111 } 110 112 } 111 113 112 114 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteWorkOffline.java
r25127 r25591 39 39 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustActionUploaderException; 40 40 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI; 41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.Mapdust RefreshObservable;42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.Mapdust RefreshObserver;41 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObservable; 42 import org.openstreetmap.josm.plugins.mapdust.gui.observer.MapdustUpdateObserver; 43 43 import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustPluginState; 44 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter; 44 45 45 46 46 47 /** 47 * Executes the work offline action. In the offline mode the user actions will 48 * Executes the "work offline" action. In the offline mode the user actions will 48 49 * not be uploaded immediately to the MapDust service. The user can perform the 49 50 * following actions in offline mode: add bug, comment bug and change bug … … 55 56 */ 56 57 public class ExecuteWorkOffline extends MapdustExecuteAction implements 57 Mapdust RefreshObservable {58 MapdustUpdateObservable { 58 59 59 60 /** The serial version UID */ 60 private static final long serialVersionUID = 1L;61 private static final long serialVersionUID = 8792828131813689548L; 61 62 62 /** The list of mapdust refresh observers */63 private final ArrayList<Mapdust RefreshObserver> observers =64 new ArrayList<Mapdust RefreshObserver>();63 /** The list of MapDust refresh observers */ 64 private final ArrayList<MapdustUpdateObserver> observers = 65 new ArrayList<MapdustUpdateObserver>(); 65 66 66 67 /** … … 81 82 /** 82 83 * Sets the 'offline' mode for the plugin. 83 * 84 * 84 85 * @param event The event which fires this action 85 86 */ … … 102 103 tr(message), tr(title), JOptionPane.YES_NO_OPTION); 103 104 if (result == JOptionPane.YES_OPTION) { 104 // process data105 105 try { 106 106 MapdustActionUploader.getInstance().uploadData( 107 getMapdustGUI().get QueuePanel().getActionList());107 getMapdustGUI().getMapdustActionList()); 108 108 } catch (MapdustActionUploaderException e) { 109 String errorMessage = "There was a Mapdust service error."; 109 String errorMessage = "There was a Mapdust service"; 110 errorMessage+=" error."; 110 111 JOptionPane.showMessageDialog(Main.parent, 111 112 tr(errorMessage), tr("Error"), … … 117 118 btn.setSelected(false); 118 119 } 119 notifyObservers(); 120 notifyObservers(null, false); 120 121 } 121 122 } … … 128 129 */ 129 130 @Override 130 public void addObserver(Mapdust RefreshObserver observer) {131 public void addObserver(MapdustUpdateObserver observer) { 131 132 if (!this.observers.contains(observer)) { 132 133 this.observers.add(observer); … … 140 141 */ 141 142 @Override 142 public void removeObserver(Mapdust RefreshObserver observer) {143 public void removeObserver(MapdustUpdateObserver observer) { 143 144 this.observers.remove(observer); 144 145 } … … 148 149 */ 149 150 @Override 150 public void notifyObservers() { 151 Iterator<Mapdust RefreshObserver> elements = this.observers.iterator();151 public void notifyObservers(MapdustBugFilter filter, boolean first) { 152 Iterator<MapdustUpdateObserver> elements = this.observers.iterator(); 152 153 while (elements.hasNext()) { 153 (elements.next()). refreshData();154 (elements.next()).update(filter, false); 154 155 } 155 156 } 156 157 157 158 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/MapdustExecuteAction.java
r24514 r25591 30 30 31 31 import javax.swing.AbstractAction; 32 import javax.swing.JList;33 32 import javax.swing.JToggleButton; 34 33 import org.openstreetmap.josm.plugins.mapdust.gui.MapdustGUI; … … 47 46 48 47 /** Serial version UID */ 49 private static final long serialVersionUID = 1L;48 private static final long serialVersionUID = 4318259806647818543L; 50 49 51 50 /** The abstract dialog object */ … … 113 112 114 113 /** 115 * Returns the selected MapDust bug from the MapDust bugs list.116 *117 * @return A <code>MapdustBug</code> object118 */119 protected MapdustBug getSelectedBug() {120 JList listBugs = this.mapdustGUI.getPanel().getListBugs();121 MapdustBug selectedBug = (MapdustBug) listBugs.getSelectedValue();122 return selectedBug;123 }124 125 /**126 * Returns the index of the MapDust bug selected from the MapDust bugs list.127 *128 * @return index129 */130 protected int getSelectedBugIndex() {131 JList listBugs = this.mapdustGUI.getPanel().getListBugs();132 int index = listBugs.getSelectedIndex();133 return index;134 }135 136 /**137 * Sets the given object from the given index to be selected.138 *139 * @param index The index of the element from the list of bugs140 */141 protected void resetSelectedBug(int index) {142 JList listBugs = this.mapdustGUI.getPanel().getListBugs();143 listBugs.setSelectedIndex(index);144 }145 146 /**147 114 * Enables the given button. This button had fired a corresponding action, 148 115 * and after the action finishes, the button need to become enabled. … … 152 119 protected void enableFiredButton(JToggleButton button) { 153 120 if (button != null) { 154 button.setEnabled(true);155 121 button.setSelected(false); 122 button.setFocusable(false); 156 123 } 157 124 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/package-info.java
r24514 r25591 1 1 /** 2 * Contains the Action classes which handles the user actions. 2 * Contains the action classes which handles the user actions. 3 * Each of these class extends the <code>MapdustExecuteAction</code> abstract 4 * class. 3 5 */ 4 6 package org.openstreetmap.josm.plugins.mapdust.gui.action.execute; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/package-info.java
r24514 r25591 1 1 /** 2 * Contains the GUI action classes. 2 * Contains the MapDust GUI action classes. The action classes are divided 3 * in three main categories: adapter, execute and show. 3 4 */ 4 5 package org.openstreetmap.josm.plugins.mapdust.gui.action; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/MapdustShowAction.java
r25127 r25591 44 44 45 45 /** The serial version UID */ 46 private static final long serialVersionUID = 1L;46 private static final long serialVersionUID = -4894445690647156702L; 47 47 48 48 /** The title of the dialog window */ -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/ShowCloseBugAction.java
r25127 r25591 30 30 31 31 import java.awt.event.ActionEvent; 32 import javax.swing.JMenuItem; 32 33 import javax.swing.JToggleButton; 33 34 import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin; … … 37 38 38 39 /** 39 * Displays the close bug action dialog window. 40 * Displays the <code>ChangeIssueStatusDialog</code> dialog window of type 41 * 'close'. This action is executed whenever the user clicks on the 42 * "Close bug report" button or selects the "Close bug" option from the pop-up 43 * menu. 40 44 * 41 45 * @author Bea … … 45 49 46 50 /** The serial version UID */ 47 private static final long serialVersionUID = 1L;51 private static final long serialVersionUID = 6459224244170352152L; 48 52 49 53 /** … … 53 57 54 58 /** 55 * Builds a <code>ShowCloseBugAction</code> object 59 * Builds a <code>ShowCloseBugAction</code> object based on the given 60 * argument. 56 61 * 57 62 * @param mapdustPlugin The <code>MapdustPlugin</code> object … … 66 71 } 67 72 73 /** 74 * Builds a <code>ChangeIssueStatusDialog</code> dialog window of type 75 * "close" and displays on the screen. 76 * 77 * @param event The <code>ActionEvent</code> object 78 */ 68 79 @Override 69 80 public void actionPerformed(ActionEvent event) { … … 72 83 if (event.getSource() instanceof JToggleButton) { 73 84 btn = (JToggleButton) event.getSource(); 74 btn.setEnabled(false); 85 } else { 86 if (event.getSource() instanceof JMenuItem) { 87 getButtonPanel().getBtnFixBugReport().setSelected(true); 88 } 75 89 } 76 90 disableButtons(getButtonPanel()); … … 85 99 } 86 100 101 /** 102 * Disables the buttons from the <code>MapdustButtonPanel</code> according 103 * to the executed action type. The only enabled button will be close bug 104 * report button. 105 * 106 * @param buttonPanel The <code>MapdustButtonPanel</code> object 107 */ 87 108 @Override 88 109 void disableButtons(MapdustButtonPanel buttonPanel) { 89 110 buttonPanel.getBtnWorkOffline().setEnabled(false); 111 buttonPanel.getBtnWorkOffline().setSelected(false); 112 buttonPanel.getBtnWorkOffline().setFocusable(false); 90 113 buttonPanel.getBtnRefresh().setEnabled(false); 114 buttonPanel.getBtnRefresh().setSelected(false); 115 buttonPanel.getBtnRefresh().setFocusable(false); 116 buttonPanel.getBtnFilter().setEnabled(false); 117 buttonPanel.getBtnFilter().setSelected(false); 118 buttonPanel.getBtnFilter().setFocusable(false); 91 119 buttonPanel.getBtnAddComment().setEnabled(false); 120 buttonPanel.getBtnAddComment().setSelected(false); 121 buttonPanel.getBtnAddComment().setFocusable(false); 92 122 buttonPanel.getBtnInvalidateBugReport().setEnabled(false); 123 buttonPanel.getBtnInvalidateBugReport().setSelected(false); 124 buttonPanel.getBtnInvalidateBugReport().setFocusable(false); 93 125 buttonPanel.getBtnReOpenBugReport().setEnabled(false); 94 126 buttonPanel.getBtnReOpenBugReport().setSelected(false); 127 buttonPanel.getBtnReOpenBugReport().setFocusable(false); 95 128 } 96 129 -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/ShowCommentBugAction.java
r25127 r25591 30 30 31 31 import java.awt.event.ActionEvent; 32 import javax.swing.JMenuItem; 32 33 import javax.swing.JToggleButton; 33 34 import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin; … … 37 38 38 39 /** 39 * Displays the comment bug dialog. 40 * Displays the <code>CommentIssueDialog</code> dialog window. This action is 41 * executed whenever the user clicks on the "Create bug report comment" button 42 * or selects the "Add comment" option from the pop-up menu. 40 43 * 41 44 * @author Bea … … 45 48 46 49 /** The serial version UID */ 47 private static final long serialVersionUID = 1L;50 private static final long serialVersionUID = -8174561825477499474L; 48 51 49 52 /** … … 67 70 } 68 71 72 /** 73 * Builds a <code>CommentIssueDialog</code> dialog window and displays 74 * on the screen. 75 * 76 * @param event The <code>ActionEvent</code> object 77 */ 69 78 @Override 70 79 public void actionPerformed(ActionEvent event) { … … 73 82 if (event.getSource() instanceof JToggleButton) { 74 83 btn = (JToggleButton) event.getSource(); 75 btn.setEnabled(false); 84 } else { 85 if (event.getSource() instanceof JMenuItem) { 86 getButtonPanel().getBtnAddComment().setSelected(true); 87 } 76 88 } 77 89 disableButtons(getButtonPanel()); … … 85 97 } 86 98 99 /** 100 * Disables the buttons from the <code>MapdustButtonPanel</code> according 101 * to the executed action type. The only enabled button will be the "Create 102 * bug report comment" button. 103 * 104 * @param buttonPanel The <code>MapdustButtonPanel</code> object 105 */ 87 106 @Override 88 107 void disableButtons(MapdustButtonPanel buttonPanel) { 89 108 buttonPanel.getBtnWorkOffline().setEnabled(false); 109 buttonPanel.getBtnWorkOffline().setSelected(false); 110 buttonPanel.getBtnWorkOffline().setFocusable(false); 90 111 buttonPanel.getBtnRefresh().setEnabled(false); 112 buttonPanel.getBtnRefresh().setSelected(false); 113 buttonPanel.getBtnRefresh().setFocusable(false); 114 buttonPanel.getBtnFilter().setEnabled(false); 115 buttonPanel.getBtnFilter().setSelected(false); 116 buttonPanel.getBtnFilter().setFocusable(false); 117 buttonPanel.getBtnInvalidateBugReport().setEnabled(false); 118 buttonPanel.getBtnInvalidateBugReport().setSelected(false); 119 buttonPanel.getBtnInvalidateBugReport().setFocusable(false); 120 buttonPanel.getBtnReOpenBugReport().setEnabled(false); 121 buttonPanel.getBtnReOpenBugReport().setSelected(false); 122 buttonPanel.getBtnReOpenBugReport().setFocusable(false); 91 123 buttonPanel.getBtnFixBugReport().setEnabled(false); 92 buttonPanel.getBtn InvalidateBugReport().setEnabled(false);93 buttonPanel.getBtn ReOpenBugReport().setEnabled(false);124 buttonPanel.getBtnFixBugReport().setSelected(false); 125 buttonPanel.getBtnFixBugReport().setFocusable(false); 94 126 } 95 127 -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/ShowInvalidateBugAction.java
r25127 r25591 30 30 31 31 import java.awt.event.ActionEvent; 32 import javax.swing.JMenuItem; 32 33 import javax.swing.JToggleButton; 33 34 import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin; … … 37 38 38 39 /** 39 * Displays the invalidate bug dialog. 40 * Displays the <code>ChangeIssueStatusDialog</code> dialog window of type 41 * 'invalidate'. This action is executed whenever the user clicks on the 42 * "Invalidate bug report" button or selects the "Invalidate bug" option from 43 * the pop-up menu. 40 44 * 41 45 * @author Bea … … 67 71 } 68 72 73 /** 74 * Builds a <code>ChangeIssueStatusDialog</code> dialog window of type 75 * "invalidate" and displays on the screen. 76 * 77 * @param event The <code>ActionEvent</code> object 78 */ 69 79 @Override 70 80 public void actionPerformed(ActionEvent event) { … … 73 83 if (event.getSource() instanceof JToggleButton) { 74 84 btn = (JToggleButton) event.getSource(); 75 btn.setEnabled(false); 85 } else { 86 if (event.getSource() instanceof JMenuItem) { 87 getButtonPanel().getBtnInvalidateBugReport().setSelected( 88 true); 89 } 76 90 } 77 91 disableButtons(getButtonPanel()); … … 86 100 } 87 101 102 /** 103 * Disables the buttons from the <code>MapdustButtonPanel</code> according 104 * to the executed action type. The only enabled button will be the 105 * "Invalidate bug report" button. 106 * 107 * @param buttonPanel The <code>MapdustButtonPanel</code> object 108 */ 88 109 @Override 89 110 void disableButtons(MapdustButtonPanel buttonPanel) { 90 111 buttonPanel.getBtnWorkOffline().setEnabled(false); 112 buttonPanel.getBtnWorkOffline().setSelected(false); 113 buttonPanel.getBtnWorkOffline().setFocusable(false); 91 114 buttonPanel.getBtnRefresh().setEnabled(false); 115 buttonPanel.getBtnRefresh().setSelected(false); 116 buttonPanel.getBtnRefresh().setFocusable(false); 117 buttonPanel.getBtnFilter().setEnabled(false); 118 buttonPanel.getBtnFilter().setSelected(false); 119 buttonPanel.getBtnFilter().setFocusable(false); 92 120 buttonPanel.getBtnAddComment().setEnabled(false); 121 buttonPanel.getBtnAddComment().setSelected(false); 122 buttonPanel.getBtnAddComment().setFocusable(false); 123 buttonPanel.getBtnReOpenBugReport().setEnabled(false); 124 buttonPanel.getBtnReOpenBugReport().setSelected(false); 125 buttonPanel.getBtnReOpenBugReport().setFocusable(false); 93 126 buttonPanel.getBtnFixBugReport().setEnabled(false); 94 buttonPanel.getBtnReOpenBugReport().setEnabled(false); 127 buttonPanel.getBtnFixBugReport().setSelected(false); 128 buttonPanel.getBtnFixBugReport().setFocusable(false); 95 129 } 96 130 -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/ShowReOpenBugAction.java
r25127 r25591 30 30 31 31 import java.awt.event.ActionEvent; 32 import javax.swing.JMenuItem; 32 33 import javax.swing.JToggleButton; 33 34 import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin; … … 37 38 38 39 /** 39 * Displays the re-open bug dialog window. 40 * Displays the <code>ChangeIssueStatusDialog</code> dialog window of type 41 * 'reopen'. This action is executed whenever the user clicks on the 42 * "Re-open bug report" button or selects the "Re-open bug" option from 43 * the pop-up menu. 40 44 * 41 45 * @author Bea … … 66 70 } 67 71 72 /** 73 * Builds a <code>ChangeIssueStatusDialog</code> dialog window of type 74 * "re-open" and displays on the screen. 75 * 76 * @param event The <code>ActionEvent</code> object 77 */ 68 78 @Override 69 79 public void actionPerformed(ActionEvent event) { … … 72 82 if (event.getSource() instanceof JToggleButton) { 73 83 btn = (JToggleButton) event.getSource(); 74 btn.setEnabled(false); 84 btn.setSelected(true); 85 } if (event.getSource() instanceof JMenuItem){ 86 getButtonPanel().getBtnReOpenBugReport().setSelected(true); 75 87 } 76 88 disableButtons(getButtonPanel()); … … 85 97 } 86 98 99 /** 100 * Disables the buttons from the <code>MapdustButtonPanel</code> according 101 * to the executed action type. The only enabled button will be the 102 * "Re-open bug report" button. 103 * 104 * @param buttonPanel The <code>MapdustButtonPanel</code> object 105 */ 87 106 @Override 88 107 void disableButtons(MapdustButtonPanel buttonPanel) { 89 108 if (buttonPanel != null) { 90 109 buttonPanel.getBtnWorkOffline().setEnabled(false); 110 buttonPanel.getBtnWorkOffline().setSelected(false); 111 buttonPanel.getBtnWorkOffline().setFocusable(false); 91 112 buttonPanel.getBtnRefresh().setEnabled(false); 113 buttonPanel.getBtnRefresh().setSelected(false); 114 buttonPanel.getBtnRefresh().setFocusable(false); 115 buttonPanel.getBtnFilter().setEnabled(false); 116 buttonPanel.getBtnFilter().setSelected(false); 117 buttonPanel.getBtnFilter().setFocusable(false); 92 118 buttonPanel.getBtnAddComment().setEnabled(false); 119 buttonPanel.getBtnAddComment().setSelected(false); 120 buttonPanel.getBtnAddComment().setFocusable(false); 121 buttonPanel.getBtnInvalidateBugReport().setEnabled(false); 122 buttonPanel.getBtnInvalidateBugReport().setSelected(false); 123 buttonPanel.getBtnInvalidateBugReport().setFocusable(false); 93 124 buttonPanel.getBtnFixBugReport().setEnabled(false); 94 buttonPanel.getBtnInvalidateBugReport().setEnabled(false); 125 buttonPanel.getBtnFixBugReport().setSelected(false); 126 buttonPanel.getBtnFixBugReport().setFocusable(false); 95 127 } 96 128 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/show/package-info.java
r24514 r25591 1 1 /** 2 * Contains the classes, which are used in order to display the dialogs of the plugin. 2 * Contains the classes, which are used in order to display the dialogs of the 3 * plugin. 4 * Each of these classes extends the <code>MapdustShowAction</code> abstract 5 * class. 3 6 */ 4 7 package org.openstreetmap.josm.plugins.mapdust.gui.action.show; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/AbstractDialog.java
r24514 r25591 42 42 43 43 /** The serial version UID */ 44 private static final long serialVersionUID = 1L;44 private static final long serialVersionUID = 7543537884312236858L; 45 45 46 46 /** The button which opened the dialog window */ … … 71 71 this.firedButton = firedButton; 72 72 } 73 73 74 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/ChangeIssueStatusDialog.java
r25312 r25591 58 58 * related actions: close bug report, invalidate bug report and re-open bug 59 59 * report. 60 * 60 * 61 61 * @author Bea 62 62 */ 63 63 public class ChangeIssueStatusDialog extends AbstractDialog { 64 64 65 65 /** The serial version UID */ 66 private static final long serialVersionUID = 1L;67 66 private static final long serialVersionUID = -4106150600118847229L; 67 68 68 /** The message test */ 69 69 private final String messageText; 70 70 71 71 /** Custom text */ 72 72 private JScrollPane cmpMessage; 73 73 74 74 /** Nickname label */ 75 75 private JLabel lblNickname; 76 76 77 77 /** Nickname text field */ 78 78 private JTextField txtNickname; 79 79 80 80 /** Comment label */ 81 81 private JLabel lblComment; 82 82 83 83 /** Description text area */ 84 84 private JScrollPane cmpDescription; 85 85 86 86 /** The description text */ 87 87 private JTextArea txtDescription; 88 88 89 89 /** Cancel button */ 90 90 private JButton btnCancel; 91 91 92 92 /** OK button */ 93 93 private JButton btnOk; 94 94 95 95 /** The type */ 96 96 private final String type; 97 97 98 98 /** 99 99 * Builds a new <code>ChangeStatusDialog</code> object with the given 100 100 * parameters. 101 * 101 * 102 102 * @param title The title of the dialog 103 103 * @param iconName The name of the icon … … 126 126 setLayout(null); 127 127 addComponents(mapdustPlugin); 128 MapdustButtonPanel btnPanel = mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel(); 129 addWindowListener(new WindowClose(this, btnPanel, getFiredButton())); 130 } 131 132 /** 133 * Adds the components to the panel. 134 * 128 MapdustButtonPanel btnPanel = 129 mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel(); 130 addWindowListener(new WindowClose(this, btnPanel)); 131 } 132 133 /** 134 * Adds the components to the dialog window. 135 * 135 136 * @param mapdustPlugin The <code>MapdustPlugin</code> object 136 137 */ … … 142 143 /* create the message cmp */ 143 144 if (cmpMessage == null) { 144 JTextPane txtPane = ComponentUtil.createJTextPane(messageText, 145 JTextPane txtPane = ComponentUtil.createJTextPane(messageText, 145 146 backgroundColor); 146 147 Rectangle bounds = new Rectangle(10, 10, 330, 50); … … 176 177 txtDescription.setLineWrap(true); 177 178 txtDescription.setFont(new Font("Times New Roman", Font.PLAIN, 12)); 178 cmpDescription = ComponentUtil.createJScrollPane(txtDescription, 179 cmpDescription = ComponentUtil.createJScrollPane(txtDescription, 179 180 bounds, backgroundColor, false, true); 180 181 } 181 182 /* creates the cancel action */ 182 ExecuteCancel cancelAction = new ExecuteCancel(this, 183 ExecuteCancel cancelAction = new ExecuteCancel(this, 183 184 mapdustPlugin.getMapdustGUI()); 184 185 AbstractAction okAction; … … 191 192 if (type.equals("invalidate")) { 192 193 /* create the invalidate bug action */ 193 okAction = new ExecuteInvalidateBug(this, mapdustPlugin.getMapdustGUI()); 194 okAction = new ExecuteInvalidateBug(this, 195 mapdustPlugin.getMapdustGUI()); 194 196 ((ExecuteInvalidateBug) okAction).addObserver(mapdustPlugin); 195 197 ((ExecuteInvalidateBug) okAction).addObserver(mapdustPlugin … … 197 199 } else { 198 200 /* executes the re-open bug action */ 199 okAction = new ExecuteReOpenBug(this, 201 okAction = new ExecuteReOpenBug(this,mapdustPlugin.getMapdustGUI()); 200 202 ((ExecuteReOpenBug) okAction).addObserver(mapdustPlugin); 201 ((ExecuteReOpenBug) okAction).addObserver(mapdustPlugin.getMapdustGUI()); 203 ((ExecuteReOpenBug) okAction).addObserver(mapdustPlugin 204 .getMapdustGUI()); 202 205 } 203 206 } … … 205 208 if (btnCancel == null) { 206 209 Rectangle bounds = new Rectangle(240, 170, 90, 25); 207 btnCancel = ComponentUtil.createJButton("Cancel", bounds, cancelAction); 210 btnCancel = ComponentUtil.createJButton("Cancel", bounds, 211 cancelAction); 208 212 } 209 213 /* creates the ok button */ … … 222 226 setSize(340, 210); 223 227 } 224 228 225 229 /** 226 230 * Returns the <code>JScrollPane</code> of the info message. 227 * 231 * 228 232 * @return the cmpMessage 229 233 */ … … 231 235 return this.cmpMessage; 232 236 } 233 237 234 238 /** 235 239 * Returns the <code>JLabel</code> of the nickname 236 * 240 * 237 241 * @return the lblNickname 238 242 */ … … 240 244 return this.lblNickname; 241 245 } 242 246 243 247 /** 244 248 * Returns the <code>JTextField</code> of the nickname 245 * 249 * 246 250 * @return the txtNickname 247 251 */ … … 249 253 return this.txtNickname; 250 254 } 251 255 252 256 /** 253 257 * Returns the <code>JLabel</code> of the comment 254 * 258 * 255 259 * @return the lblComment 256 260 */ … … 258 262 return this.lblComment; 259 263 } 260 264 261 265 /** 262 266 * Returns the <code>JScrollPane</code> of the description 263 * 267 * 264 268 * @return the cmpDescription 265 269 */ … … 267 271 return this.cmpDescription; 268 272 } 269 273 270 274 /** 271 275 * Returns the <code>JTextArea</code> of the description 272 * 276 * 273 277 * @return the txtDescription 274 278 */ … … 276 280 return this.txtDescription; 277 281 } 278 282 279 283 /** 280 284 * Returns the cancel button 281 * 285 * 282 286 * @return the btnCancel 283 287 */ … … 285 289 return this.btnCancel; 286 290 } 287 291 288 292 /** 289 293 * Returns the ok buttons 290 * 294 * 291 295 * @return the btnOk 292 296 */ … … 294 298 return this.btnOk; 295 299 } 296 300 297 301 /** 298 302 * Retruns the message text 299 * 303 * 300 304 * @return the messageText 301 305 */ … … 303 307 return this.messageText; 304 308 } 305 306 /** 307 * Returns the type 308 * 309 310 /** 311 * Returns the type of the dialog window 312 * 309 313 * @return the type 310 314 */ … … 312 316 return this.type; 313 317 } 314 318 315 319 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/CommentIssueDialog.java
r25312 r25591 61 61 62 62 /** The serial version UID */ 63 private static final long serialVersionUID = 1L;63 private static final long serialVersionUID = 7788698281871951326L; 64 64 65 65 /** The message text */ … … 118 118 setLayout(null); 119 119 addComponents(mapdustPlugin); 120 MapdustButtonPanel btnPanel = mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel(); 121 addWindowListener(new WindowClose(this, btnPanel, getFiredButton())); 122 } 123 124 /** 125 * Add the components to the panel 120 MapdustButtonPanel btnPanel = 121 mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel(); 122 addWindowListener(new WindowClose(this, btnPanel)); 123 } 124 125 /** 126 * Add the components to the dialog window. 127 * 128 * @param mapdustPlugin The <code>MapdustPlugin</code> object 126 129 */ 127 130 @Override 128 131 public void addComponents(MapdustPlugin mapdustPlugin) { 129 /* initialize components of the JDialog */130 132 Color backgroundColor = getContentPane().getBackground(); 131 133 Font font = new Font("Times New Roman", Font.BOLD, 14); 132 /* create themessagecmp*/134 /* message text */ 133 135 if (cmpMessage == null) { 134 136 JTextPane txtPane = ComponentUtil.createJTextPane(messageText, … … 138 140 backgroundColor, true, true); 139 141 } 140 /* create the nickname label and text field*/142 /* nickaname */ 141 143 if (lblNickname == null) { 142 144 Rectangle bounds = new Rectangle(10, 70, 91, 25); … … 156 158 } 157 159 } 158 /* c reates the comment label and text area*/160 /* comment */ 159 161 if (lblComment == null) { 160 162 Rectangle bounds = new Rectangle(10, 110, 79, 25); … … 169 171 backgroundColor, false, true); 170 172 } 171 /* c reates the cancel button */173 /* cancel button */ 172 174 if (btnCancel == null) { 173 175 Rectangle bounds = new Rectangle(240, 170, 90, 25); 174 176 ExecuteCancel cancelAction = new ExecuteCancel(this, 175 177 mapdustPlugin.getMapdustGUI()); 176 btnCancel = ComponentUtil.createJButton("Cancel", bounds, cancelAction); 177 } 178 /* creates the ok button */ 178 btnCancel = ComponentUtil.createJButton("Cancel", bounds, 179 cancelAction); 180 } 181 /* ok button */ 179 182 if (btnOk == null) { 180 183 Rectangle bounds = new Rectangle(170, 170, 60, 25); … … 185 188 btnOk = ComponentUtil.createJButton("OK", bounds, okAction); 186 189 } 187 /* add components to the frame*/190 /* add components */ 188 191 add(cmpMessage); 189 192 add(lblNickname); -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/CreateIssueDialog.java
r25312 r25591 54 54 55 55 /** 56 * This class is used for creating a dialog window for the new issue Map dust Bug56 * This class is used for creating a dialog window for the new issue MapDust Bug 57 57 * action. 58 58 * … … 63 63 64 64 /** The serial version UID */ 65 private static final long serialVersionUID = 1L; 65 private static final long serialVersionUID = 1912577313684808253L; 66 66 67 67 /** The create issue text */ … … 71 71 private JScrollPane cmpMessage; 72 72 73 /** Type */ 73 /** The label of the bug type */ 74 74 private JLabel lblType; 75 75 76 /** The typecombo box */76 /** The combo box for the bug types */ 77 77 private JComboBox cbbType; 78 78 79 /** Nickname*/79 /** The nickname label */ 80 80 private JLabel lblNickname; 81 81 82 /** The txtnickname */82 /** The nickname text field */ 83 83 private JTextField txtNickname; 84 84 85 /** Description */85 /** The description label */ 86 86 private JLabel lblDescription; 87 87 … … 105 105 * parameters. 106 106 * 107 * @param title The title of the dialog108 * @param iconName The name of the icon109 * @param messageText The text of the message component.110 107 * @param point The position where the bug was created 111 108 * @param mapdustPlugin The <code>MapdustPlugin</code> object … … 120 117 /* add components to the dialog */ 121 118 addComponents(mapdustPlugin); 122 /* add window listene t*/119 /* add window listener */ 123 120 MapdustButtonPanel btnPanel = 124 121 mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel(); 125 addWindowListener(new WindowClose(this, btnPanel , null));122 addWindowListener(new WindowClose(this, btnPanel)); 126 123 } 127 124 … … 144 141 145 142 /** 146 * Displays the dialog. 143 * Displays the dialog window on the screen. 147 144 */ 148 145 public void showDialog() { … … 153 150 } 154 151 152 /** 153 * Adds the components to the dialog window. 154 * 155 * @param mapdustPlugin The <code>MapdustPlugin</code> object 156 */ 155 157 @Override 156 158 public void addComponents(MapdustPlugin mapdustPlugin) { 157 159 Color backgroundColor = getContentPane().getBackground(); 158 160 Font font = new Font("Times New Roman", Font.BOLD, 14); 159 /* create themessagecmp*/161 /* text message */ 160 162 if (cmpMessage == null) { 161 163 JTextPane txtPane = ComponentUtil.createJTextPane(createIssueText, 162 164 backgroundColor); 163 cmpMessage = ComponentUtil.createJScrollPane(txtPane, 164 new Rectangle(10,10, 330, 50), backgroundColor, true, true); 165 } 166 /* the type label and combo box */ 165 Rectangle bounds = new Rectangle(10, 10, 330, 50); 166 cmpMessage = ComponentUtil.createJScrollPane(txtPane, bounds, 167 backgroundColor, true, true); 168 } 169 /* type */ 167 170 if (lblType == null) { 168 lblType = ComponentUtil.createJLabel("Type", font,169 new Rectangle(10, 70, 91, 25));171 Rectangle bounds = new Rectangle(10, 70, 91, 25); 172 lblType = ComponentUtil.createJLabel("Type", font, bounds); 170 173 } 171 174 if (cbbType == null) { 172 175 ComboBoxRenderer renderer = new ComboBoxRenderer(); 173 cbbType = ComponentUtil.createJComboBox(new Rectangle(110, 70, 230, 174 25), renderer, backgroundColor); 175 } 176 /* create the nickname label and text field */ 176 Rectangle bounds = new Rectangle(110, 70, 230, 25); 177 cbbType = ComponentUtil.createJComboBox(bounds, renderer, 178 backgroundColor); 179 } 180 /* nickname */ 177 181 if (lblNickname == null) { 178 lblNickname = ComponentUtil.createJLabel("Nickname", font,179 new Rectangle(10, 110, 79, 25));182 Rectangle bounds = new Rectangle(10, 110, 79, 25); 183 lblNickname = ComponentUtil.createJLabel("Nickname", font, bounds); 180 184 } 181 185 if (txtNickname == null) { 182 txtNickname = ComponentUtil.createJTextField(new Rectangle(110, 110,183 230,25));186 Rectangle bounds = new Rectangle(110, 110, 230,25); 187 txtNickname = ComponentUtil.createJTextField(bounds); 184 188 /* get the nickname */ 185 189 String nickname = Main.pref.get("mapdust.nickname"); … … 192 196 } 193 197 } 194 /* creates thedescriptionlabel and text area*/198 /* description */ 195 199 if (lblDescription == null) { 200 Rectangle bounds = new Rectangle(10, 150, 95, 25); 196 201 lblDescription = ComponentUtil.createJLabel("Description", font, 197 new Rectangle(10, 150, 95, 25));202 bounds); 198 203 } 199 204 if (cmpDescription == null) { 205 Rectangle bounds = new Rectangle(110, 150, 230, 50); 200 206 txtDescription = new JTextArea(); 201 207 txtDescription.setFont(new Font("Times New Roman", Font.PLAIN, 12)); 202 208 txtDescription.setLineWrap(true); 203 209 cmpDescription = ComponentUtil.createJScrollPane(txtDescription, 204 new Rectangle(110, 150, 230, 50), backgroundColor, false, 205 true); 206 } 207 /* creates the cancel button */ 210 bounds, backgroundColor, false, true); 211 } 212 /* cancel button */ 208 213 if (btnCancel == null) { 209 214 Rectangle bounds = new Rectangle(250, 210, 90, 25); … … 213 218 cancelAction); 214 219 } 215 /* creates theok button */220 /* ok button */ 216 221 if (btnOk == null) { 217 222 Rectangle bounds = new Rectangle(180, 210, 60, 25); 218 ExecuteAddBug okAction = new ExecuteAddBug(this,219 mapdustPlugin.getMapdustGUI()); 223 ExecuteAddBug okAction = 224 new ExecuteAddBug(this, mapdustPlugin.getMapdustGUI()); 220 225 okAction.addObserver(mapdustPlugin); 221 226 okAction.addObserver(mapdustPlugin.getMapdustGUI()); -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/package-info.java
r24514 r25591 1 1 /** 2 * Contains the dialog classes. 2 * Contains the MapDust GUI dialog classes. The dialog classes extends the 3 * <code>AbstractDialog</code> abstract class. 3 4 */ 4 5 package org.openstreetmap.josm.plugins.mapdust.gui.component.dialog; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/ActionListModel.java
r24514 r25591 43 43 44 44 /** The serial version UID */ 45 private static final long serialVersionUID = 1L;45 private static final long serialVersionUID = -4919264544683489112L; 46 46 47 47 /** … … 51 51 52 52 /** 53 * Builds a <code>MapdustAction</code> object 53 * Builds an empty <code>MapdustAction</code> object 54 54 */ 55 55 public ActionListModel() { … … 58 58 59 59 /** 60 * Builds a <code>MapdustAction</code> object 60 * Builds a <code>MapdustAction</code> object based on the given argument 61 * 61 62 * @param list A list of <code>MapdustAction</code> objects 62 63 */ … … 65 66 } 66 67 68 /** 69 * Returns the <code>MapdustAction</code> from the given position. 70 * 71 * @param index The position of the element 72 * @return <code>MapdustAction</code> from the given position 73 */ 67 74 @Override 68 75 public Object getElementAt(int index) { 69 return list.get(index); 76 if (index >= 0 && index < list.size()) { 77 return list.get(index); 78 } 79 return null; 70 80 } 71 81 82 /** 83 * Returns the size of the list of objects. 84 * 85 * @return size 86 */ 72 87 @Override 73 88 public int getSize() { 74 return list.size(); 89 return (list != null ? list.size() : 0); 75 90 } 76 91 -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/BugsListModel.java
r24514 r25591 30 30 31 31 import java.util.List; 32 import javax.swing.ListModel; 33 import javax.swing.event.ListDataListener; 32 import javax.swing.AbstractListModel; 34 33 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug; 35 34 … … 41 40 * 42 41 */ 43 public class BugsListModel implements ListModel { 42 public class BugsListModel extends AbstractListModel { 43 44 /** The serial version UID */ 45 private static final long serialVersionUID = 3451277352571392219L; 44 46 45 47 /** The list of <code>MapdustBug</code> objects */ … … 62 64 } 63 65 64 @Override 65 public void addListDataListener(ListDataListener l) {} 66 66 /** 67 * Returns the <code>MapdustBug</code> from the given position. 68 * 69 * @param index The position of the element 70 * @return <code>MapdustBug</code> from the given position 71 */ 67 72 @Override 68 73 public Object getElementAt(int index) { 69 return bugs.get(index); 74 if (index >= 0 && index < bugs.size()) { 75 return bugs.get(index); 76 } 77 return null; 70 78 } 71 79 80 /** 81 * Returns the size of the list of objects. 82 * 83 * @return size 84 */ 72 85 @Override 73 86 public int getSize() { … … 75 88 } 76 89 77 @Override 78 public void removeListDataListener(ListDataListener l) {} 90 /** 91 * Updates the bugs list model. 92 */ 93 public void update() { 94 this.fireContentsChanged(this, 0, bugs.size() - 1); 95 } 79 96 80 97 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/CommentListModel.java
r24514 r25591 35 35 36 36 /** 37 * List model for <code>MapdustComment</code> objects 37 * List model for <code>MapdustComment</code> objects. 38 38 * 39 39 * @author Bea … … 61 61 } 62 62 63 @Override 64 public void addListDataListener(ListDataListener l) {} 65 63 /** 64 * Returns the <code>MapdustComment</code> from the given position. 65 * 66 * @param index The position of the element 67 * @return <code>MapdustComment</code> from the given position 68 */ 66 69 @Override 67 70 public Object getElementAt(int index) { 68 return comments[index]; 71 if (index > 0 && index < comments.length) { 72 return comments[index]; 73 } 74 return null; 69 75 } 70 76 77 /** 78 * Returns the size of the list of objects. 79 * 80 * @return size 81 */ 71 82 @Override 72 83 public int getSize() { 73 return comments.length; 84 return (comments != null ? comments.length : 0); 74 85 } 75 86 … … 77 88 public void removeListDataListener(ListDataListener l) {} 78 89 90 @Override 91 public void addListDataListener(ListDataListener l) {} 92 79 93 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/TypesListModel.java
r24514 r25591 43 43 44 44 /** The serial version UID */ 45 private static final long serialVersionUID = 1L;45 private static final long serialVersionUID = 4005728061902494996L; 46 46 47 47 /** The array of types */ … … 58 58 } 59 59 60 /** 61 * Returns the <code>Type</code> from the given position. 62 * 63 * @param index The position of the element 64 * @return <code>Type</code> from the given position 65 */ 60 66 @Override 61 67 public Object getElementAt(int index) { … … 63 69 } 64 70 71 /** 72 * Returns the size of the list of objects. 73 * 74 * @return size 75 */ 65 76 @Override 66 77 public int getSize() { … … 68 79 } 69 80 81 /** 82 * Returns the selected <code>Type</code> object. 83 * 84 * @return selected item 85 */ 70 86 @Override 71 87 public Object getSelectedItem() { … … 73 89 } 74 90 91 /** 92 * Sets the selected <code>Type</code> object. 93 * 94 * @param anItem The selected item 95 */ 75 96 @Override 76 97 public void setSelectedItem(Object anItem) { -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/model/package-info.java
r24514 r25591 1 1 /** 2 * Contains the <code>ListModel</code> classes used for building customized 3 * list and combo box GUI elements for the MapDust plugin. 4 */ 2 5 package org.openstreetmap.josm.plugins.mapdust.gui.component.model; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustActionPanel.java
r24514 r25591 39 39 import org.openstreetmap.josm.plugins.mapdust.MapdustPlugin; 40 40 import org.openstreetmap.josm.plugins.mapdust.gui.action.execute.ExecuteActionList; 41 import org.openstreetmap.josm.plugins.mapdust.gui.component.model.ActionListModel; 41 42 import org.openstreetmap.josm.plugins.mapdust.gui.component.util.ComponentUtil; 42 43 import org.openstreetmap.josm.plugins.mapdust.gui.value.MapdustAction; … … 52 53 53 54 /** The serial version UID */ 54 private static final long serialVersionUID = 1L;55 private static final long serialVersionUID = -6648507056357610823L; 55 56 56 57 /** The scroll pane */ … … 58 59 59 60 /** The JList containing the MapDust action objects */ 60 private JList queueList;61 private JList actionJList; 61 62 62 63 /** The list of <code>MapdustAction</code> objects */ 63 private finalList<MapdustAction> actionList;64 private List<MapdustAction> actionList; 64 65 65 66 /** … … 88 89 MapdustPlugin mapdustPlugin) { 89 90 /* create components */ 90 AbstractAction action = new ExecuteActionList(mapdustPlugin.getMapdustGUI()); 91 AbstractAction action = new ExecuteActionList 92 (mapdustPlugin.getMapdustGUI()); 91 93 JToggleButton btnUpload = ComponentUtil.createJButton("Upload list data", 92 94 null, null, action); 93 95 ((ExecuteActionList) action).addObserver(mapdustPlugin); 94 96 if (cmpActionList == null) { 95 queueList = ComponentUtil.createJList(list);96 cmpActionList = ComponentUtil.createJScrollPane( queueList);97 actionJList = ComponentUtil.createJList(list); 98 cmpActionList = ComponentUtil.createJScrollPane(actionJList); 97 99 } 98 100 add(cmpActionList, BorderLayout.CENTER); … … 101 103 102 104 /** 103 * Returns the list of <code>MapdustAction</code> object 105 * Updates the <code>MapdustActionPanel</code> with the given list of 106 * <code>MapdustAction</code>s. 107 * 108 * @param actionList The list of <code>MapdustAction</code> objects 109 */ 110 public void updateComponents(List<MapdustAction> actionList) { 111 setActionList(actionList); 112 actionJList.setModel(new ActionListModel(actionList)); 113 cmpActionList.getViewport().setView(actionJList); 114 cmpActionList.invalidate(); 115 116 } 117 118 /** 119 * Returns the list of <code>MapdustAction</code>s 104 120 * 105 121 * @return the actionList … … 110 126 111 127 /** 112 * Returns the action list<code>JScrollPane</code>object128 * Sets the list of <code>MapdustAction</code>s 113 129 * 114 * @ return the cmpActionList130 * @param actionList the actionList to set 115 131 */ 116 public JScrollPane getCmpActionList() { 117 return cmpActionList; 118 } 119 120 /** 121 * Returns the action list <code>JList</code> object 122 * 123 * @return the queueList 124 */ 125 public JList getQueueList() { 126 return queueList; 132 public void setActionList(List<MapdustAction> actionList) { 133 this.actionList = actionList; 127 134 } 128 135 -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustAddressPanel.java
r24514 r25591 48 48 49 49 /** The serial version UID */ 50 private static final long serialVersionUID = 1L;50 private static final long serialVersionUID = 8388870946800544374L; 51 51 52 52 /** … … 63 63 64 64 /** 65 * Updates the components of the <code>MapdustAddressPanel</code> based 66 * on the given parameters. 67 * 68 * @param address The <code>Address</code> of a MapDust bug 69 * @param coordinates The <code>LatLon</code> of a MapDust bug 70 */ 71 public void updateComponents(Address address,LatLon coordinates){ 72 removeAll(); 73 addComponents(address, coordinates); 74 } 75 76 /** 65 77 * Creates the components of the panel, and adds to the parent panel. 66 78 * … … 73 85 Font fontLabelVal = new Font("Times New Roman", Font.PLAIN, 12); 74 86 75 /* addcountry */87 /* country */ 76 88 add(ComponentUtil.createJLabel("Country: ", fontLabel, null)); 77 89 String country = address != null ? address.getCountryCode() : ""; 78 90 add(ComponentUtil.createJLabel(country, fontLabelVal, null)); 79 91 80 /* addlabel */92 /* label */ 81 93 add(ComponentUtil.createJLabel("City: ", fontLabel, null)); 82 94 String city = address != null ? address.getCity() : ""; 83 95 add(ComponentUtil.createJLabel(city, fontLabelVal, null)); 84 96 85 /* addstatecode */97 /* statecode */ 86 98 add(ComponentUtil.createJLabel("State code: ", fontLabel, null)); 87 99 String state = address != null ? address.getStateCode() : ""; 88 100 add(ComponentUtil.createJLabel(state, fontLabelVal, null)); 89 101 90 /* addlabel */102 /* label */ 91 103 add(ComponentUtil.createJLabel("Zip code: ", fontLabel, null)); 92 104 String zip = address != null ? address.getZipCode() : ""; 93 105 add(ComponentUtil.createJLabel(zip, fontLabelVal, null)); 94 106 95 /* addstreet name */107 /* street name */ 96 108 add(ComponentUtil.createJLabel("Street: ", fontLabel, null)); 97 109 String street = address != null ? address.getStreetName() : ""; 98 110 add(ComponentUtil.createJLabel(street, fontLabelVal, null)); 99 111 100 /* addhouse number */112 /* house number */ 101 113 add(ComponentUtil.createJLabel("House number: ", fontLabel, null)); 102 114 String houseNr = address != null ? address.getHouseNumber() : ""; 103 115 add(ComponentUtil.createJLabel(houseNr, fontLabelVal, null)); 104 116 105 /* addlat */117 /* lat */ 106 118 add(ComponentUtil.createJLabel("Latitude: ", fontLabel, null)); 107 119 String lat = coordinates != null ? ("" + coordinates.lat()) : ""; 108 120 add(ComponentUtil.createJLabel(lat, fontLabelVal, null)); 109 121 110 /* addlon */122 /* lon */ 111 123 add(ComponentUtil.createJLabel("Longitude: ", fontLabel, null)); 112 124 String lon = coordinates != null ? ("" + coordinates.lon()) : ""; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustBugDetailsPanel.java
r24733 r25591 58 58 59 59 /** The serial version UID */ 60 private static final long serialVersionUID = 1L;60 private static final long serialVersionUID = 65974543949362926L; 61 61 62 62 /** The <code>MapdustBug</code> object */ 63 private finalMapdustBug bug;63 private MapdustBug bug; 64 64 65 65 /** … … 76 76 77 77 /** 78 * Updates the components of the <code>MapdustBugDetailsPanel</code> based 79 * on the given parameter. 80 * 81 * @param bug The <code>MapdustBug</code> 82 */ 83 public void updateComponents(MapdustBug bug) { 84 this.bug = bug; 85 removeAll(); 86 addComponents(); 87 } 88 89 /** 78 90 * Add the components to the panel. 79 91 */ … … 81 93 /* the font of the label and label value */ 82 94 Font fontLabel = new Font("Times New Roman", Font.BOLD, 12); 83 Font fontLabelVal = new Font("Times New Roman", Font.PLAIN,12); 95 Font fontLabelVal = new Font("Times New Roman", Font.PLAIN, 12); 84 96 /* date formatter */ 85 DateFormat df = DateFormat.getDateInstance( 97 DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, 86 98 Locale.getDefault()); 87 99 88 /* addthe id */100 /* the id */ 89 101 add(ComponentUtil.createJLabel("Id: ", fontLabel, null)); 90 102 String idStr = bug != null ? bug.getId().toString() : ""; … … 101 113 add(txtId); 102 114 103 /* addthe type */115 /* the type */ 104 116 add(ComponentUtil.createJLabel("Type: ", fontLabel, null)); 105 117 String typeStr = bug != null ? bug.getType().getValue() : ""; 106 118 add(ComponentUtil.createJLabel(typeStr, fontLabelVal, null)); 107 119 108 /* addthe status */120 /* the status */ 109 121 add(ComponentUtil.createJLabel("Status: ", fontLabel, null)); 110 122 String statusStr = bug != null ? bug.getStatus().getValue() : ""; 111 123 add(ComponentUtil.createJLabel(statusStr, fontLabelVal, null)); 112 124 113 /* addthe source */125 /* the source */ 114 126 add(ComponentUtil.createJLabel("Source: ", fontLabel, null)); 115 127 String sourceStr = bug != null ? bug.getSource() : ""; 116 128 add(ComponentUtil.createJLabel(sourceStr, fontLabelVal, null)); 117 129 118 /* addthe nickname */130 /* the nickname */ 119 131 add(ComponentUtil.createJLabel("Created by: ", fontLabel, null)); 120 132 String nicknameStr = bug != null ? bug.getNickname() : ""; 121 133 add(ComponentUtil.createJLabel(nicknameStr, fontLabelVal, null)); 122 134 123 /* addthe date created */135 /* the date created */ 124 136 add(ComponentUtil.createJLabel("Date created: ", fontLabel, null)); 125 137 String dateCreatedStr = … … 127 139 add(ComponentUtil.createJLabel(dateCreatedStr, fontLabelVal, null)); 128 140 129 /* addthe date updated */141 /* the date updated */ 130 142 add(ComponentUtil.createJLabel("Date updated: ", fontLabel, null)); 131 143 String dateUpdatedStr = 132 144 bug != null ? df.format(bug.getDateUpdated()) : ""; 133 145 add(ComponentUtil.createJLabel(dateUpdatedStr, fontLabelVal, null)); 134 135 146 } 136 147 … … 141 152 if (bug != null) { 142 153 String mapdustSite = 143 154 Configuration.getInstance().getMapdustBugDetailsUrl(); 144 155 bugDetailsUrl = mapdustSite + bug.getId().toString(); 145 156 } … … 150 161 String errorMessage = "Error opening the MapDust bug "; 151 162 errorMessage += "details page"; 152 JOptionPane.showMessageDialog(Main.parent, 153 tr(errorMessage), tr("Error"), 154 JOptionPane.ERROR_MESSAGE); 163 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 164 tr("Error"), JOptionPane.ERROR_MESSAGE); 155 165 } 156 166 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustBugPropertiesPanel.java
r25127 r25591 49 49 /** 50 50 * Defines the JPanel for the <code>MapdustBug</code> object properties. 51 * The MapDust bug properties panel displays detailed information about a 52 * given <code>MapdustBug</code> and it is composed by the following panels: 53 * <code>MapdustBugDetailsPanel</code>, <code>MapdustAddressPanel</code>, 54 * <code>MapdustDescriptionPanel</code>, <code>MapdustCommentsPanel</code> and 55 * <code>MapdustHelpPanel</code>. 51 56 * 52 57 * @author Bea … … 56 61 57 62 /** The serial version UID */ 58 private static final long serialVersionUID = 1L; 63 private static final long serialVersionUID = 5320232823004570279L; 64 65 /** The <code>MapdustBugDetailsPanel</code> object */ 66 private MapdustBugDetailsPanel detailsPanel; 67 68 /** The <code>MapdustAddressPanel</code> object */ 69 private MapdustAddressPanel addressPanel; 70 71 /** The <code>MapdustDescriptionPanel</code> object */ 72 private MapdustDescriptionPanel descriptionPanel; 59 73 60 74 /** The <code>MapdustCommentsPanel</code> object */ 61 75 private MapdustCommentsPanel commentsPanel; 62 76 63 /** The <code>MapdustBugDetailsPanel</code> object */64 private MapdustBugDetailsPanel detailsPanel;65 66 /** The <code>MapdustAddressPanel</code> object */67 private MapdustAddressPanel addressPanel;68 69 /** The <code>MapdustDescriptionPanel</code> object */70 private MapdustDescriptionPanel descriptionPanel;71 72 77 /** The <code>MapdustHelpPanel</code> object */ 73 78 private MapdustHelpPanel helpPanel; … … 83 88 84 89 /** 85 * Builds a <code>MapdustBugPropertiesPanel</code> object. 90 * Builds a <code>MapdustBugPropertiesPanel</code> object based on the given 91 * argument. 86 92 * 87 93 * @param mapdustBug The <code>MapdustBug</code> object … … 96 102 /** 97 103 * Displays the details of the given MapDust bug. 98 * 104 * 99 105 * @param mapdustBug The <code>MapdustBug</code> object 100 106 */ … … 112 118 if (mainPanel != null) { 113 119 index = mainPanel.getSelectedIndex(); 114 if (mainPanel.getComponentCount() > 0) { 115 mainPanel.remove(cmpDetails); 116 mainPanel.remove(cmpAddress); 117 mainPanel.remove(descriptionPanel); 118 mainPanel.remove(commentsPanel); 119 mainPanel.remove(helpPanel); 120 } 121 remove(mainPanel); 122 } 120 } 121 123 122 /* create the panels */ 124 123 createPanels(selectedBug); … … 134 133 */ 135 134 private void addComponents(MapdustBug mapdustBug) { 136 MapdustBug selectedBug =mapdustBug;135 MapdustBug selectedBug = mapdustBug; 137 136 if (mapdustBug != null) { 138 137 if (mapdustBug.getNumberOfComments() > 0) { … … 140 139 selectedBug = getBug(id); 141 140 } 142 createPanels(selectedBug);143 }141 } 142 createPanels(selectedBug); 144 143 } 145 144 … … 150 149 */ 151 150 private void createPanels(MapdustBug mapdustBug) { 152 /* create details panel */ 153 detailsPanel = new MapdustBugDetailsPanel(mapdustBug); 154 cmpDetails = ComponentUtil.createJScrollPane(detailsPanel, getBounds(), 155 getBackground(), true, true); 156 cmpDetails.setPreferredSize(new Dimension(100, 100)); 157 cmpDetails.setName("Bug Details"); 158 159 /* create address panel */ 151 /* details panel */ 152 if (cmpDetails == null) { 153 detailsPanel = new MapdustBugDetailsPanel(mapdustBug); 154 cmpDetails = ComponentUtil.createJScrollPane(detailsPanel, 155 getBounds(), getBackground(), true, true); 156 cmpDetails.setPreferredSize(new Dimension(100, 100)); 157 cmpDetails.setName("Bug Details"); 158 } else { 159 detailsPanel.updateComponents(mapdustBug); 160 } 161 162 /* address panel */ 160 163 Address address = mapdustBug != null ? mapdustBug.getAddress() : null; 161 164 LatLon coordinates = mapdustBug != null ? mapdustBug.getLatLon() : null; 162 addressPanel = new MapdustAddressPanel(address, coordinates); 163 cmpAddress = ComponentUtil.createJScrollPane(addressPanel, getBounds(), 164 getBackground(), true, true); 165 cmpAddress.setName("Address"); 166 cmpAddress.setPreferredSize(new Dimension(100, 100)); 167 168 /* create description panel */ 165 if (cmpAddress == null) { 166 addressPanel = new MapdustAddressPanel(address, coordinates); 167 cmpAddress = ComponentUtil.createJScrollPane(addressPanel, 168 getBounds(), getBackground(), true, true); 169 cmpAddress.setName("Address"); 170 cmpAddress.setPreferredSize(new Dimension(100, 100)); 171 } else { 172 addressPanel.updateComponents(address, coordinates); 173 } 174 175 /* description panel */ 169 176 String description = mapdustBug != null ? mapdustBug.getDescription() : ""; 170 descriptionPanel = new MapdustDescriptionPanel(description); 171 172 /* create comments panel */ 177 if (descriptionPanel == null) { 178 descriptionPanel = new MapdustDescriptionPanel(description); 179 } else { 180 descriptionPanel.updateComponents(description); 181 } 182 183 /* comments panel */ 173 184 MapdustComment[] comments = mapdustBug != null ? mapdustBug.getComments() 174 185 : new MapdustComment[0]; 175 commentsPanel = new MapdustCommentsPanel(comments); 176 177 /* create the help panel */ 178 helpPanel = new MapdustHelpPanel(); 186 if (commentsPanel == null) { 187 commentsPanel = new MapdustCommentsPanel(comments); 188 } else { 189 commentsPanel.updateComponents(comments); 190 mainPanel.setTitleAt(3, commentsPanel.getName()); 191 } 192 193 /* the help panel */ 194 if (helpPanel == null) { 195 helpPanel = new MapdustHelpPanel(); 196 } 179 197 180 198 /* creates the main panel */ 181 mainPanel = new JTabbedPane(); 182 mainPanel.setIgnoreRepaint(true); 183 mainPanel.add(cmpDetails, 0); 184 mainPanel.add(cmpAddress, 1); 185 mainPanel.add(descriptionPanel, 2); 186 mainPanel.add(commentsPanel, 3); 187 mainPanel.add(helpPanel); 188 add(mainPanel, BorderLayout.CENTER); 199 if (mainPanel == null) { 200 mainPanel = new JTabbedPane(); 201 mainPanel.setIgnoreRepaint(true); 202 mainPanel.add(cmpDetails, 0); 203 mainPanel.add(cmpAddress, 1); 204 mainPanel.add(descriptionPanel, 2); 205 mainPanel.add(commentsPanel, 3); 206 mainPanel.add(helpPanel); 207 add(mainPanel, BorderLayout.CENTER); 208 } else { 209 mainPanel.revalidate(); 210 } 189 211 } 190 212 … … 201 223 } catch (MapdustServiceHandlerException e) { 202 224 String errorMessage = "There was a MapDust service error durring "; 203 errorMessage +=" the MapDust bug retrieve process.";225 errorMessage += " the MapDust bug retrieve process."; 204 226 JOptionPane.showMessageDialog(Main.parent, tr(errorMessage), 205 227 tr("Error"), JOptionPane.ERROR_MESSAGE); -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustButtonPanel.java
r24514 r25591 39 39 import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowCloseBugAction; 40 40 import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowCommentBugAction; 41 import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowFilterBugAction; 41 42 import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowInvalidateBugAction; 42 43 import org.openstreetmap.josm.plugins.mapdust.gui.action.show.ShowReOpenBugAction; … … 46 47 47 48 /** 48 * Defines the panel of the Map dust buglist action buttons.49 * Defines the panel of buttons for the MapDust bugs list. 49 50 * 50 51 * @author Bea … … 54 55 55 56 /** The serial version UID */ 56 private static final long serialVersionUID = 1L;57 private static final long serialVersionUID = -4234650664854226973L; 57 58 58 59 /** The work offline button */ 59 60 private JToggleButton btnWorkOffline; 60 61 62 /** The filter button */ 63 private JToggleButton btnFilter; 64 65 /** The add comment button */ 66 private JToggleButton btnAddComment; 67 68 /** The fix bug report button */ 69 private JToggleButton btnFixBugReport; 70 71 /** The invalidate bug report button */ 72 private JToggleButton btnInvalidateBugReport; 73 74 /** The re-open bug report button */ 75 private JToggleButton btnReOpenBugReport; 76 61 77 /** The refresh button */ 62 78 private JToggleButton btnRefresh; 63 64 /** The add comment button */65 private JToggleButton btnAddComment;66 67 /** The fix bug report button */68 private JToggleButton btnFixBugReport;69 70 /** The invalidate bug report button */71 private JToggleButton btnInvalidateBugReport;72 73 /** The re-open bug report button */74 private JToggleButton btnReOpenBugReport;75 79 76 80 /** … … 91 95 92 96 /** 93 * Add the components to the button panel 97 * Add the components to the button panel. 94 98 * 95 99 * @param mapdustPlugin The <code>MapdustPlugin</code> object 96 100 */ 97 101 private void addComponents(MapdustPlugin mapdustPlugin) { 98 /* create components */99 102 /* 'Work offline' button */ 100 103 if (btnWorkOffline == null) { … … 109 112 imagePath = "dialogs/online.png"; 110 113 } 111 AbstractAction action = new ExecuteWorkOffline(mapdustPlugin.getMapdustGUI()); 114 AbstractAction action = 115 new ExecuteWorkOffline(mapdustPlugin.getMapdustGUI()); 112 116 ((ExecuteWorkOffline) action).addObserver(mapdustPlugin); 113 btnWorkOffline = ComponentUtil.createJButton("Work offline", 114 tooltipText, imagePath, action); 117 btnWorkOffline = 118 ComponentUtil.createJButton("Work offline", tooltipText, 119 imagePath, action); 120 btnWorkOffline.setSelected(false); 121 btnWorkOffline.setFocusTraversalKeysEnabled(false); 122 } 123 /* 'Filter' button */ 124 if (btnFilter == null) { 125 AbstractAction action = new ShowFilterBugAction(mapdustPlugin); 126 btnFilter = 127 ComponentUtil.createJButton("Filter bug reports", 128 "Filter bug reports", 129 "dialogs/mapdust_bug_filter.png", action); 130 btnFilter.setEnabled(true); 131 btnFilter.setFocusTraversalKeysEnabled(false); 132 } 133 /* 'Add Comment' button */ 134 if (btnAddComment == null) { 135 AbstractAction action = new ShowCommentBugAction(mapdustPlugin); 136 btnAddComment = 137 ComponentUtil 138 .createJButton("Comment bug report", 139 "Comment bug report", 140 "dialogs/comment.png", action); 141 btnAddComment.setEnabled(false); 142 btnAddComment.setFocusTraversalKeysEnabled(false); 143 } 144 /* 'Fix bug report' button */ 145 if (btnFixBugReport == null) { 146 AbstractAction action = new ShowCloseBugAction(mapdustPlugin); 147 btnFixBugReport = 148 ComponentUtil.createJButton("Close bug report", 149 "Close bug report", "dialogs/fixed.png", action); 150 btnFixBugReport.setEnabled(false); 151 btnFixBugReport.setFocusTraversalKeysEnabled(false); 152 } 153 /* 'Invalidate bug report' button */ 154 if (btnInvalidateBugReport == null) { 155 AbstractAction action = new ShowInvalidateBugAction(mapdustPlugin); 156 btnInvalidateBugReport = 157 ComponentUtil.createJButton("Invalidate bug report", 158 "Invalidate bug report", "dialogs/invalid.png", 159 action); 160 btnInvalidateBugReport.setEnabled(false); 161 btnInvalidateBugReport.setFocusTraversalKeysEnabled(false); 162 } 163 /* 'Re-open bug report' button */ 164 if (btnReOpenBugReport == null) { 165 AbstractAction action = new ShowReOpenBugAction(mapdustPlugin); 166 btnReOpenBugReport = 167 ComponentUtil.createJButton("Re-open bug report", 168 "Re-open bug report", "dialogs/reopen.png", action); 169 btnReOpenBugReport.setEnabled(false); 170 btnReOpenBugReport.setFocusTraversalKeysEnabled(false); 115 171 } 116 172 /* 'Refresh' button */ … … 119 175 AbstractAction action = new ExecuteRefresh(); 120 176 ((ExecuteRefresh) action).addObserver(mapdustPlugin); 121 btnRefresh = ComponentUtil.createJButton("Refresh", "Refresh", 122 "dialogs/refresh.png", action); 177 btnRefresh = 178 ComponentUtil.createJButton("Refresh", "Refresh", 179 "dialogs/mapdust_refresh.png", action); 123 180 if (pluginState.equals(MapdustPluginState.OFFLINE.getValue())) { 124 181 btnRefresh.setEnabled(false); 125 182 } 126 } 127 /* 'Add Comment' button */ 128 if (btnAddComment == null) { 129 AbstractAction action = new ShowCommentBugAction(mapdustPlugin); 130 btnAddComment = ComponentUtil.createJButton("Comment bug report", 131 "Comment bug report", "dialogs/comment.png", action); 132 btnAddComment.setEnabled(false); 133 } 134 /* 'Fix bug report' button */ 135 if (btnFixBugReport == null) { 136 AbstractAction action = new ShowCloseBugAction(mapdustPlugin); 137 btnFixBugReport = ComponentUtil.createJButton("Close bug report", 138 "Close bug report", "dialogs/fixed.png", action); 139 btnFixBugReport.setEnabled(false); 140 } 141 /* 'Invalidate bug report' button */ 142 if (btnInvalidateBugReport == null) { 143 AbstractAction action = new ShowInvalidateBugAction(mapdustPlugin); 144 btnInvalidateBugReport = ComponentUtil.createJButton("Invalidate bug report", 145 "Invalidate bug report", "dialogs/invalid.png", action); 146 btnInvalidateBugReport.setEnabled(false); 147 } 148 /* 'Re-open bug report' button */ 149 if (btnReOpenBugReport == null) { 150 AbstractAction action = new ShowReOpenBugAction(mapdustPlugin); 151 btnReOpenBugReport = ComponentUtil.createJButton("Re-open bug report", 152 "Re-open bug report", "dialogs/reopen.png", action); 153 btnReOpenBugReport.setEnabled(false); 183 btnRefresh.setFocusTraversalKeysEnabled(false); 154 184 } 155 185 156 186 /* add components */ 157 187 add(btnWorkOffline); 158 add(btn Refresh);188 add(btnFilter); 159 189 add(btnAddComment); 160 190 add(btnFixBugReport); 161 191 add(btnInvalidateBugReport); 162 192 add(btnReOpenBugReport); 193 add(btnRefresh); 194 } 195 196 /** 197 * Disables the buttons from the <code>MapdustButtonPanel</code>. 198 */ 199 public void disableComponents() { 200 if (btnWorkOffline != null) { 201 btnWorkOffline.setEnabled(false); 202 btnWorkOffline.setSelected(false); 203 btnWorkOffline.setFocusable(false); 204 } 205 if (btnFilter != null) { 206 btnFilter.setEnabled(false); 207 btnFilter.setEnabled(false); 208 btnFilter.setEnabled(false); 209 } 210 if (btnRefresh != null) { 211 btnRefresh.setEnabled(false); 212 btnRefresh.setSelected(false); 213 btnRefresh.setFocusable(false); 214 } 215 if (btnAddComment != null) { 216 btnAddComment.setEnabled(false); 217 btnAddComment.setSelected(false); 218 btnAddComment.setFocusable(false); 219 } 220 if (btnFixBugReport != null) { 221 btnFixBugReport.setEnabled(false); 222 btnFixBugReport.setSelected(false); 223 btnFixBugReport.setFocusable(false); 224 } 225 if (btnInvalidateBugReport != null) { 226 btnInvalidateBugReport.setEnabled(false); 227 btnInvalidateBugReport.setEnabled(false); 228 btnInvalidateBugReport.setEnabled(false); 229 } 230 if (btnReOpenBugReport != null) { 231 btnReOpenBugReport.setEnabled(false); 232 btnReOpenBugReport.setEnabled(false); 233 btnReOpenBugReport.setEnabled(false); 234 } 235 } 236 237 /** 238 * Enables the basic components from the <code>MapdustButtonPanel</code>. 239 * Basic components are considered the following buttons: work offline, 240 * filter bug report, and refresh.If the onlyBasic flag is true then the 241 * other buttons will be disabled. 242 * 243 * @param onlyBasic If true then the not basic buttons will be disabled 244 */ 245 public void enableBasicComponents(boolean onlyBasic) { 246 btnWorkOffline.setEnabled(true); 247 btnFilter.setEnabled(true); 248 btnRefresh.setEnabled(true); 249 if (onlyBasic) { 250 btnAddComment.setEnabled(false); 251 btnAddComment.setSelected(false); 252 btnAddComment.setFocusable(false); 253 btnFixBugReport.setEnabled(false); 254 btnFixBugReport.setSelected(false); 255 btnFixBugReport.setFocusable(false); 256 btnInvalidateBugReport.setEnabled(false); 257 btnInvalidateBugReport.setEnabled(false); 258 btnInvalidateBugReport.setEnabled(false); 259 btnReOpenBugReport.setEnabled(false); 260 btnReOpenBugReport.setEnabled(false); 261 btnReOpenBugReport.setEnabled(false); 262 263 } 163 264 } 164 265 … … 182 283 183 284 /** 285 * @return the btnFilter 286 */ 287 public JToggleButton getBtnFilter() { 288 return btnFilter; 289 } 290 291 /** 184 292 * Returns the add comment button 185 293 * -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustCommentsPanel.java
r25127 r25591 52 52 53 53 /** The serial version UID */ 54 private static final long serialVersionUID = 1L;54 private static final long serialVersionUID = 5730420562553912697L; 55 55 56 56 /** … … 62 62 public MapdustCommentsPanel(MapdustComment[] comments) { 63 63 setLayout(new BorderLayout()); 64 String name = "Bug Comments ("; 65 name += comments.length + " )"; 66 setName(name); 64 addComponents(comments); 65 } 66 67 /** 68 * Updates the components of the <code>MapdustCommentsPanel</code> based on 69 * the given parameter. 70 * 71 * @param comments The array of <code>MapdustComment</code>s 72 */ 73 public void updateComponents(MapdustComment[] comments) { 74 removeAll(); 67 75 addComponents(comments); 68 76 } … … 74 82 */ 75 83 private void addComponents(MapdustComment[] comments) { 84 String name = "Bug Comments ("; 85 name += comments.length + " )"; 86 setName(name); 76 87 JTextArea txt = new JTextArea(); 77 88 txt.setAutoscrolls(true); -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustDescriptionPanel.java
r24514 r25591 49 49 50 50 /** The serial version UID */ 51 private static final long serialVersionUID = 1L;51 private static final long serialVersionUID = -4246874841836269643L; 52 52 53 53 /** … … 60 60 String name = "Description "; 61 61 setName(name); 62 addComponents(description); 63 } 64 65 /** 66 * Updates the components of the <code>MapdustDescriptionPanel</code> based 67 * on the given parameter 68 * 69 * @param description The description 70 */ 71 public void updateComponents(String description) { 72 removeAll(); 73 addComponents(description); 74 } 75 76 /** 77 * Adds the components to the <code>MapdustDescriptionPanel</code>. 78 * 79 * @param description the description 80 */ 81 private void addComponents(String description) { 62 82 if (description != null && !description.isEmpty()) { 63 83 JTextArea txtDescription = new JTextArea(description); … … 65 85 txtDescription.setFont(new Font("Times New Roman", Font.BOLD, 12)); 66 86 txtDescription.setEditable(false); 67 JScrollPane cmpDescription = ComponentUtil.createJScrollPane( txtDescription,68 null, Color.white, true, true); 87 JScrollPane cmpDescription = ComponentUtil.createJScrollPane( 88 txtDescription, null, Color.white, true, true); 69 89 cmpDescription.setPreferredSize(new Dimension(100, 100)); 70 90 add(cmpDescription, BorderLayout.CENTER); -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustHelpPanel.java
r25312 r25591 55 55 56 56 /** The serial version UID */ 57 private static final long serialVersionUID = 1L;57 private static final long serialVersionUID = 8366853437915060878L; 58 58 59 59 /** … … 94 94 * related to the MapDust plugin. 95 95 * 96 * @return 96 * @return a string containing the text which will be displayed on the Help 97 * tab 97 98 */ 98 99 private String buildText() { -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/package-info.java
r24514 r25591 1 1 /** 2 * constains the panel classes 2 * Contains the customized <code>JPanel</code> classes used for building 3 * the MapDust plugin GUI. 3 4 */ 4 5 package org.openstreetmap.josm.plugins.mapdust.gui.component.panel; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/renderer/ActionListCellRenderer.java
r24514 r25591 49 49 50 50 /** The serial version UID */ 51 private static final long serialVersionUID = 1L;51 private static final long serialVersionUID = 7552949107018269769L; 52 52 53 53 /** -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/renderer/BugListCellRenderer.java
r25127 r25591 49 49 50 50 /** The serial version UID */ 51 private static final long serialVersionUID = 1L;51 private static final long serialVersionUID = -5888587819204364046L; 52 52 53 53 /** … … 78 78 text += mapdustBug.getType().getValue(); 79 79 if (mapdustBug.getAddress() != null) { 80 text += " (" + mapdustBug.getAddress().toString() + " )"; 80 String addressStr=mapdustBug.getAddress().toString(); 81 if (!addressStr.trim().isEmpty()) { 82 text += " (" + mapdustBug.getAddress().toString() + " )"; 83 } 81 84 } 82 85 DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, … … 86 89 label.setText(text); 87 90 label.setFont(new Font("Times New Roman", Font.BOLD, 12)); 91 label.setSize(200, 20); 88 92 } 89 93 if (value instanceof String){ -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/util/ComponentUtil.java
r24514 r25591 38 38 import javax.swing.Action; 39 39 import javax.swing.JButton; 40 import javax.swing.JCheckBox; 40 41 import javax.swing.JComboBox; 41 42 import javax.swing.JLabel; … … 49 50 import javax.swing.ListCellRenderer; 50 51 import javax.swing.ListSelectionModel; 52 import javax.swing.SwingConstants; 51 53 import javax.swing.border.LineBorder; 52 54 import org.openstreetmap.josm.plugins.mapdust.gui.component.model.ActionListModel; … … 74 76 * @param font The font of the label 75 77 * @param bounds The bounds of the element 76 * @return A <code>JLabel</code> label78 * @return A <code>JLabel</code> object 77 79 */ 78 80 public static JLabel createJLabel(String text, Font font, Rectangle bounds) { … … 83 85 jLabel.setText(text); 84 86 jLabel.setFont(font); 87 return jLabel; 88 } 89 90 /** 91 * Creates a <code>JLabel</code> object with the given properties. 92 * 93 * @param text The text of the label 94 * @param iconName The name of the label icon 95 * @param bounds The dimension of the label 96 * @return A <code>JLabel</code> object 97 */ 98 public static JLabel createJLabel(String text, String iconName, 99 Rectangle bounds) { 100 JLabel jLabel = new JLabel(text, ImageProvider.get(iconName), 101 SwingConstants.LEFT); 102 jLabel.setBounds(bounds); 103 jLabel.setFont(new Font("Times New Roman", Font.BOLD, 12)); 85 104 return jLabel; 86 105 } … … 286 305 } 287 306 307 /** 308 * Creates a new <code>JCheckBox</code> object with the given properties. 309 * 310 * @param bounds The dimension of the check box 311 * @return A <code>JCheckBox</code> object 312 */ 313 public static JCheckBox createJCheckBox(Rectangle bounds) { 314 JCheckBox jCheckBox = new JCheckBox(); 315 jCheckBox.setBounds(bounds); 316 return jCheckBox; 317 } 318 288 319 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/util/package-info.java
r24514 r25591 1 1 /** 2 * Contains helper classes used for building the GUI. 3 */ 2 4 package org.openstreetmap.josm.plugins.mapdust.gui.component.util; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/MapdustBugDetailsObservable.java
r24514 r25591 55 55 56 56 /** 57 * Notifies all the observers observing the given <code>MapdustAction</code>58 * object. 57 * Notifies all the observers observing the details of the given 58 * <code>MapdustBug</code> object. 59 59 * 60 60 * @param mapdustBug The <code>MapdustBug</code> object 61 61 */ 62 62 public void notifyObservers(MapdustBug mapdustBug); 63 63 64 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/MapdustBugDetailsObserver.java
r24514 r25591 47 47 */ 48 48 public void showDetails(MapdustBug mapdustBug); 49 49 50 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/MapdustBugObservable.java
r24514 r25591 44 44 * Adds a new observer to the list of observers. 45 45 * 46 * @param observer The <code>MapdustBugObserv able</code> object46 * @param observer The <code>MapdustBugObserver</code> object 47 47 */ 48 48 public void addObserver(MapdustBugObserver observer); … … 51 51 * Removes the given observer from the list of observers. 52 52 * 53 * @param observer The <code>MapdustBugObserv able</code> object53 * @param observer The <code>MapdustBugObserver</code> object 54 54 */ 55 55 public void removeObserver(MapdustBugObserver observer); … … 62 62 */ 63 63 public void notifyObservers(MapdustBug mapdustBug); 64 64 65 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/MapdustBugObserver.java
r24514 r25591 46 46 */ 47 47 public void changedData(MapdustBug mapdustBug); 48 48 49 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/observer/package-info.java
r24514 r25591 1 1 /** 2 * Contains the observer and observable interfaces. 3 */ 2 4 package org.openstreetmap.josm.plugins.mapdust.gui.observer; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/package-info.java
r24514 r25591 1 1 /** 2 * Contains the graphical user interface related part of the Mapdust plugin. 2 * Contains the graphical user interface related classes of the MapDust plugin. 3 * These classes are divided based on their type in the following four packages: 4 * action, component, observer and value. 3 5 */ 4 6 package org.openstreetmap.josm.plugins.mapdust.gui; 5 7 8 -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/value/MapdustPluginState.java
r24514 r25591 30 30 31 31 /** 32 * Enum representing the MapDust plugin state. The plugin can be in the 32 * Enumeration representing the MapDust plugin state. The plugin can be in the 33 33 * following 2 states: online and offline. 34 34 * -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/value/MapdustServiceCommand.java
r24514 r25591 30 30 31 31 /** 32 * Enum representing the MapDust service "commands". 32 * Enumeration representing the MapDust service "commands". 33 33 * 34 34 * @author Bea -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/value/package-info.java
r24514 r25591 1 1 /** 2 * Contains helper classes used by GUI. 3 */ 2 4 package org.openstreetmap.josm.plugins.mapdust.gui.value; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/package-info.java
r24514 r25591 1 1 /** 2 * The Mapdust OSMBug reported JOSMplugin classes.3 * 2 * Contains the JOSM MapDust Bug reporter plugin classes. 3 * 4 4 */ 5 5 package org.openstreetmap.josm.plugins.mapdust; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/MapdustServiceHandler.java
r24514 r25591 36 36 import org.openstreetmap.josm.plugins.mapdust.service.connector.response.MapdustPostResponse; 37 37 import org.openstreetmap.josm.plugins.mapdust.service.converter.MapdustConverter; 38 import org.openstreetmap.josm.plugins.mapdust.service.value.BoundingBox; 38 39 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug; 40 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter; 39 41 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustComment; 40 42 import org.openstreetmap.josm.plugins.mapdust.service.value.Paging; … … 78 80 * a corresponding exception will be thrown. 79 81 * 80 * @param minLon The minimum longitude. This parameter is required. 81 * @param minLat The minimum latitude.This parameter is required. 82 * @param maxLon The maximum longitude.This parameter is required. 83 * @param maxLat The maximum latitude.This parameter is required. 82 * @param bBox The bounding box where the bugs are searched. 83 * @param filter The MapDust bug filter. The bugs can be filtered based on 84 * the status, type and description. This parameter is not required. 84 85 * @return A list of <code>MapdustBug</code> objects. 85 *86 86 * @throws MapdustServiceHandlerException In the case of an error 87 87 */ 88 public List<MapdustBug> getBugs( Double minLon, Double minLat,89 Double maxLon, Double maxLat)throws MapdustServiceHandlerException {88 public List<MapdustBug> getBugs(BoundingBox bBox, MapdustBugFilter filter) 89 throws MapdustServiceHandlerException { 90 90 MapdustGetBugsResponse getBugsResponse = null; 91 91 /* validates the coordinates */ 92 if ( minLon== null ||minLat == null || maxLon== null93 || maxLat== null) {92 if (bBox.getMinLon() == null || bBox.getMinLat() == null 93 || bBox.getMaxLon() == null || bBox.getMaxLat() == null) { 94 94 throw new MapdustServiceHandlerException("Invalid coordinates!"); 95 95 } 96 96 /* executes the getBug MapDust method */ 97 97 try { 98 getBugsResponse = connector.getBugs( minLon, minLat, maxLon, maxLat);98 getBugsResponse = connector.getBugs(bBox, filter); 99 99 } catch (MapdustConnectorException e) { 100 100 throw new MapdustServiceHandlerException(e.getMessage(), e); … … 152 152 throw new MapdustServiceHandlerException(errorMessage); 153 153 } 154 /* executes the add bug MapDust method */154 /* executes the addBug MapDust method */ 155 155 try { 156 156 postResponse = connector.addBug(bug); … … 181 181 /* validates comment */ 182 182 if (comment == null) { 183 String errorMessage ="Invalid comment. The comment cannot be null!";183 String errorMessage = "Invalid comment. The comment cannot be null!"; 184 184 throw new MapdustServiceHandlerException(errorMessage); 185 185 } … … 219 219 /* validates comment */ 220 220 if (comment == null) { 221 String errorMessage="Invalid comment. The comment cannot be null!"; 221 String errorMessage = 222 "Invalid comment. The comment cannot be null!"; 222 223 throw new MapdustServiceHandlerException(errorMessage); 223 224 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/MapdustServiceHandlerException.java
r24514 r25591 31 31 /** 32 32 * Defines the exception type for <code>MapdustServiceHandler</code> object. 33 * 33 * 34 34 * @author Bea 35 35 */ 36 36 public class MapdustServiceHandlerException extends Exception { 37 37 38 38 /** The serial version UID */ 39 private static final long serialVersionUID = 1L;40 39 private static final long serialVersionUID = -2860059748215555626L; 40 41 41 /** 42 42 * Builds an empty <code>MapdustServiceHandlerException</code> object. … … 45 45 super(); 46 46 } 47 47 48 48 /** 49 49 * Builds a <code>MapdustServiceHandlerException</code> object based on the 50 50 * given argument. 51 * 51 * 52 52 * @param message The message of the exception. 53 53 */ … … 55 55 super(message); 56 56 } 57 57 58 58 /** 59 59 * Builds a <code>MapdustServiceHandlerException</code> object based on the 60 60 * given argument. 61 * 61 * 62 62 * @param cause The cause of the exception. 63 63 */ … … 65 65 super(cause); 66 66 } 67 67 68 68 /** 69 69 * Builds a <code>MapdustServiceHandlerException</code> object based on the 70 70 * given arguments. 71 * 71 * 72 72 * @param message The message of the exception. 73 73 * @param cause The cause of the exception. -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/MapdustConnector.java
r24514 r25591 33 33 import java.net.URL; 34 34 import java.util.HashMap; 35 import java.util.List; 35 36 import java.util.Map; 37 import org.openstreetmap.josm.plugins.mapdust.service.connector.parser.MapdustParser; 38 import org.openstreetmap.josm.plugins.mapdust.service.connector.parser.MapdustParserException; 36 39 import org.openstreetmap.josm.plugins.mapdust.service.connector.response.MapdustGetBugResponse; 37 40 import org.openstreetmap.josm.plugins.mapdust.service.connector.response.MapdustGetBugsResponse; 38 41 import org.openstreetmap.josm.plugins.mapdust.service.connector.response.MapdustPostResponse; 39 import org.openstreetmap.josm.plugins.mapdust.service.parser.MapdustParser; 40 import org.openstreetmap.josm.plugins.mapdust.service.parser.MapdustParserException; 42 import org.openstreetmap.josm.plugins.mapdust.service.value.BoundingBox; 41 43 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBug; 44 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustBugFilter; 42 45 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustComment; 43 46 import org.openstreetmap.josm.plugins.mapdust.service.value.MapdustResponseStatusCode; … … 85 88 86 89 /** 87 * Searches for the OSM Map dust bugs in the given bounding box. The method88 * executes the 'getBugs' Map dust service method, parses the obtained90 * Searches for the OSM MapDust bugs in the given bounding box. The method 91 * executes the 'getBugs' MapDust service method, parses the obtained 89 92 * response object and return a <code>MapdustGetBugsResponse</code> object 90 93 * containing the pagination information and the array of bugs. In the case … … 92 95 * will be thrown. 93 96 * 94 * @param minLon The minimum longitude. This parameter is required. 95 * @param minLat The minimum latitude.This parameter is required. 96 * @param maxLon The maximum longitude.This parameter is required. 97 * @param maxLat The maximum latitude.This parameter is required. 97 * @param bBox The bounding box where the bugs are searched. 98 * @param filter The MapDust bug filter. The bugs can be filtered based on 99 * the status, type and description. This parameter is not required. 98 100 * @return A <code>MapdustGetBugsResponse</code> object, containing the 99 101 * pagination information and an array of <code>MapdustBugContent</code> … … 101 103 * @throws MapdustConnectorException In the case of an error. 102 104 */ 103 public MapdustGetBugsResponse getBugs( Double minLon, Double minLat,104 Double maxLon, Double maxLat) throws MapdustConnectorException {105 public MapdustGetBugsResponse getBugs(BoundingBox bBox, 106 MapdustBugFilter filter) throws MapdustConnectorException { 105 107 /* execute GET method and get the response */ 106 108 HttpResponse httpResponse = null; 107 109 try { 108 httpResponse = executeGetBugs( minLon, minLat, maxLon, maxLat);110 httpResponse = executeGetBugs(bBox, filter); 109 111 } catch (MalformedURLException e) { 110 112 throw new MapdustConnectorException(e.getMessage(), e); … … 114 116 throw new MapdustConnectorException(e.getMessage(), e); 115 117 } 116 117 118 /* parse HttpResponse */ 118 119 MapdustGetBugsResponse result = null; … … 120 121 /* verify status codes */ 121 122 handleStatusCode(httpResponse); 122 result =(MapdustGetBugsResponse) getParser().parseResponse( 123 result = (MapdustGetBugsResponse) getParser().parseResponse( 123 124 httpResponse.getContent(), 124 125 MapdustGetBugsResponse.class); … … 131 132 } 132 133 134 133 135 /** 134 136 * Returns the OSM bug with the given id. If the <code>Paging</code> object 135 137 * is set, then the comments of the bug will be paginated. The method 136 * executes the 'getBug' Map dust service method, parses the obtained138 * executes the 'getBug' MapDust service method, parses the obtained 137 139 * response object and return a <code>MapdustGetBugResponse</code> object. 138 140 * In the case if the response code is not 2 … … 156 158 throw new MapdustConnectorException(e.getMessage(), e); 157 159 } 158 159 160 /* parse result */ 160 161 MapdustGetBugResponse result = null; 161 162 try { 162 163 handleStatusCode(httpResponse); 163 result =(MapdustGetBugResponse) parser.parseResponse( 164 httpResponse.getContent(), 165 MapdustGetBugResponse.class); 164 result = (MapdustGetBugResponse) getParser().parseResponse( 165 httpResponse.getContent(), MapdustGetBugResponse.class); 166 166 } catch (MapdustConnectorException e) { 167 167 throw new MapdustConnectorException(e.getMessage(), e); … … 174 174 /** 175 175 * Creates a new OSM bug with the specified arguments. The method executes 176 * the 'addBug' Map dust service method, parses the obtained response object176 * the 'addBug' MapDust service method, parses the obtained response object 177 177 * and return a <code>MapdustPostResponse</code> object containing the id of 178 178 * the created comment. In the case if the response code is not 200,201 or … … 202 202 try { 203 203 handleStatusCode(httpResponse); 204 result =(MapdustPostResponse) parser.parseResponse( 205 httpResponse.getContent(), 206 MapdustPostResponse.class); 204 result = (MapdustPostResponse) getParser().parseResponse( 205 httpResponse.getContent(), MapdustPostResponse.class); 207 206 } catch (MapdustConnectorException e) { 208 207 throw new MapdustConnectorException(e.getMessage(), e); … … 215 214 /** 216 215 * Creates a new comment for the given bug. The method executes the 217 * 'commentBug' Map dust service method, parses the obtained response object216 * 'commentBug' MapDust service method, parses the obtained response object 218 217 * and return a <code>MapdustPostResponse</code> object containing the id of 219 218 * the created comment. In the case if the response code is not 200,201 or … … 237 236 throw new MapdustConnectorException(e.getMessage(), e); 238 237 } 239 240 238 /* parse result */ 241 239 MapdustPostResponse result = null; 242 240 try { 243 241 handleStatusCode(httpResponse); 244 result = (MapdustPostResponse) parser.parseResponse( 245 httpResponse.getContent(), 246 MapdustPostResponse.class); 242 result = (MapdustPostResponse) getParser().parseResponse( 243 httpResponse.getContent(), MapdustPostResponse.class); 247 244 } catch (MapdustConnectorException e) { 248 245 throw new MapdustConnectorException(e.getMessage(), e); … … 255 252 /** 256 253 * Changes the status of a given bug. The method executes the 257 * 'changeBugStatus' Map dust service method, parses the obtained response254 * 'changeBugStatus' MapDust service method, parses the obtained response 258 255 * object and return a <code>MapdustPostResponse</code> object containing 259 256 * the id of the created comment. In the case if the response code is not … … 283 280 try { 284 281 handleStatusCode(httpResponse); 285 result = (MapdustPostResponse) parser.parseResponse(282 result = (MapdustPostResponse) getParser().parseResponse( 286 283 httpResponse.getContent(), MapdustPostResponse.class); 287 284 } catch (MapdustConnectorException e) { … … 294 291 295 292 /** 296 * Executes the 'getBugs' Mapdust service method. 297 * 298 * @param minLon The minimum longitude. This parameter is required. 299 * @param minLat The minimum latitude.This parameter is required. 300 * @param maxLon The maximum longitude.This parameter is required. 301 * @param maxLat The maximum latitude.This parameter is required. 302 * 293 * Executes the 'getBugs' MapDust service method. 294 * 295 * @param bBox The bounding box where the bugs are searched. This parameter 296 * it is a required parameter. 297 * @param filter The MapDust bug filter. The bugs can be filtered based on 298 * the status, type and description. This parameter is not required. 303 299 * @return A <code>HttpResponse</code> object containing the JSON response. 304 300 * @throws MalformedURLException In the case if the format of the URL is … … 306 302 * @throws IOException In the case of an IO error 307 303 */ 308 private HttpResponse executeGetBugs(Double minLon, Double minLat, 309 Double maxLon, Double maxLat) throws MalformedURLException, 310 IOException { 304 private HttpResponse executeGetBugs(BoundingBox bBox, 305 MapdustBugFilter filter) throws MalformedURLException, IOException { 311 306 HttpResponse httpResponse = null; 312 307 String mapdustUri = Configuration.getInstance().getMapdustUrl(); … … 317 312 urlString += "/getBugs?"; 318 313 urlString += "key=" + mapdustApiKey; 319 urlString += "&bbox=" + minLon + "," + minLat + ","; 320 urlString += maxLon + "," + maxLat; 314 urlString += "&bbox=" + bBox.getMinLon(); 315 urlString += "," + bBox.getMinLat(); 316 urlString += "," + bBox.getMaxLon(); 317 urlString += "," + bBox.getMaxLat(); 318 if (filter != null) { 319 if (filter.getStatuses() != null 320 && filter.getStatuses().size() > 0) { 321 String paramStatus = buildParameter(filter.getStatuses()); 322 if (!paramStatus.isEmpty()) { 323 urlString += "&fs=" + paramStatus; 324 } 325 } 326 if (filter.getTypes() != null && filter.getTypes().size() > 0) { 327 String paramTypes = buildParameter(filter.getTypes()); 328 if (!paramTypes.isEmpty()) { 329 urlString += "&ft=" + paramTypes; 330 } 331 } 332 if (filter.getDescr() != null && filter.getDescr()) { 333 urlString += "&idd=" + "0"; 334 } 335 } 321 336 } 322 337 URL url = null; 323 338 if (urlString != null) { 324 339 url = new URL(urlString); 325 httpResponse = httpConnector.executeGET(url); 326 340 httpResponse = getHttpConnector().executeGET(url); 327 341 } 328 342 return httpResponse; … … 330 344 331 345 /** 332 * Executes the 'getBug' Map dust service method.346 * Executes the 'getBug' MapDust service method. 333 347 * 334 348 * @param id The id of the object … … 363 377 if (urlString != null) { 364 378 url = new URL(urlString); 365 httpResponse = httpConnector.executeGET(url); 366 379 httpResponse = getHttpConnector().executeGET(url); 367 380 } 368 381 return httpResponse; … … 370 383 371 384 /** 372 * Executes the 'addBug' Map dust service method.385 * Executes the 'addBug' MapDust service method. 373 386 * 374 387 * @param bug A <code>MapdustBug</code> object 375 388 * @return A <code>HttpResponse</code> containing the JSON response of the 376 * Map dust method.389 * MapDust method. 377 390 * 378 391 * @throws MalformedURLException In the case if the format of the URL is … … 391 404 urlString += "/addBug"; 392 405 requestParameters.put("key", mapdustApiKey); 393 String coordinatesStr = 394 bug.getLatLon().getX() +"," + bug.getLatLon().getY();406 String coordinatesStr = "" + bug.getLatLon().getX(); 407 coordinatesStr += "," + bug.getLatLon().getY(); 395 408 requestParameters.put("coordinates", coordinatesStr); 396 409 requestParameters.put("type", bug.getType().getKey()); … … 401 414 if (urlString != null) { 402 415 url = new URL(urlString); 403 httpResponse = httpConnector.executePOST(url, null,416 httpResponse = getHttpConnector().executePOST(url, null, 404 417 requestParameters); 405 406 418 } 407 419 return httpResponse; … … 409 421 410 422 /** 411 * Executes the 'commentBug' Map dust service method.423 * Executes the 'commentBug' MapDust service method. 412 424 * 413 425 * @param comment The <code>MapdustComment</code> object 414 426 * @return A <code>HttpResponse</code> containing the JSON response of the 415 * Map dust method.427 * MapDust method. 416 428 * @throws MalformedURLException In the case if the format of the URL is 417 429 * invalid … … 436 448 if (urlString != null) { 437 449 url = new URL(urlString); 438 httpResponse = httpConnector.executePOST(url, null,450 httpResponse = getHttpConnector().executePOST(url, null, 439 451 requestParameters); 440 441 452 } 442 453 return httpResponse; … … 444 455 445 456 /** 446 * Executes the 'changeBugStatus' Map dust service method.457 * Executes the 'changeBugStatus' MapDust service method. 447 458 * 448 459 * @param statusId The id of the status. 449 460 * @param comment A <code>MapdustComment</code> object. 450 461 * @return A <code>HttpResponse</code> containing the JSON response of the 451 * Map dust method.462 * MapDust method. 452 463 * 453 464 * @throws MalformedURLException In the case if the format of the URL is … … 474 485 if (urlString != null) { 475 486 url = new URL(urlString); 476 httpResponse = httpConnector.executePOST(url, null,487 httpResponse = getHttpConnector().executePOST(url, null, 477 488 requestParameters); 478 479 489 } 480 490 return httpResponse; 491 } 492 493 /** 494 * Builds a string containing the elements of the given list. The elements 495 * will be separated by a comma. If the list does not contains any element 496 * the returned result will be an empty string. 497 * 498 * @param list The list of objects. 499 * @return a string 500 */ 501 private String buildParameter(List<? extends Object> list) { 502 StringBuffer sb = new StringBuffer(); 503 for (Object obj : list) { 504 if (obj != null) { 505 sb.append(obj).append(","); 506 } 507 } 508 return sb.substring(0, sb.length() - 1); 481 509 } 482 510 … … 508 536 case 400: 509 537 errorMessage = statusMessage + " "; 510 errorMessage+= MapdustResponseStatusCode.Status400.getDescription(); 538 errorMessage += MapdustResponseStatusCode.Status400.getDescription(); 511 539 throw new MapdustConnectorException(errorMessage); 512 540 case 401: 513 errorMessage = statusMessage+ " "; 514 errorMessage+= MapdustResponseStatusCode.Status401.getDescription(); 541 errorMessage = statusMessage + " "; 542 errorMessage += MapdustResponseStatusCode.Status401.getDescription(); 515 543 throw new MapdustConnectorException(errorMessage); 516 544 case 403: 517 errorMessage = statusMessage + " "; 518 errorMessage+= MapdustResponseStatusCode.Status403 519 .getDescription(); 545 errorMessage = statusMessage + " "; 546 errorMessage += MapdustResponseStatusCode.Status403.getDescription(); 520 547 throw new MapdustConnectorException(errorMessage); 521 548 case 404: 522 errorMessage = statusMessage+ " "; 523 errorMessage+=MapdustResponseStatusCode.Status404 524 .getDescription(); 549 errorMessage = statusMessage + " "; 550 errorMessage += MapdustResponseStatusCode.Status404.getDescription(); 525 551 throw new MapdustConnectorException(errorMessage); 526 552 case 405: 527 errorMessage = statusMessage+ " "; 528 errorMessage+= MapdustResponseStatusCode.Status405 529 .getDescription(); 553 errorMessage = statusMessage + " "; 554 errorMessage += MapdustResponseStatusCode.Status405.getDescription(); 530 555 throw new MapdustConnectorException(errorMessage); 531 556 case 500: 532 errorMessage = statusMessage + " "; 533 errorMessage+=MapdustResponseStatusCode.Status500 534 .getDescription(); 557 errorMessage = statusMessage + " "; 558 errorMessage += MapdustResponseStatusCode.Status500.getDescription(); 535 559 throw new MapdustConnectorException(errorMessage); 536 560 case 601: 537 errorMessage = statusMessage + " "; 538 errorMessage+=MapdustResponseStatusCode.Status601 539 .getDescription(); 561 errorMessage = statusMessage + " "; 562 errorMessage += MapdustResponseStatusCode.Status601.getDescription(); 540 563 throw new MapdustConnectorException(errorMessage); 541 564 case 602: 542 errorMessage = statusMessage+ " "; 543 errorMessage+= MapdustResponseStatusCode.Status602 544 .getDescription(); 565 errorMessage = statusMessage + " "; 566 errorMessage += MapdustResponseStatusCode.Status602.getDescription(); 545 567 throw new MapdustConnectorException(errorMessage); 546 568 default: … … 551 573 552 574 /** 575 * Returns the <code>HttpConnector</code> 576 * 553 577 * @return the httpConnector 554 578 */ … … 558 582 559 583 /** 584 * Sets the <code>MapdustParser</code> 585 * 560 586 * @return the parser 561 587 */ -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/MapdustConnectorException.java
r24514 r25591 31 31 /** 32 32 * Defines the exception type for the <code>MapdustConnector</code> object. 33 * 33 * 34 34 * @author Bea 35 * 35 * 36 36 */ 37 37 public class MapdustConnectorException extends Exception { 38 38 39 39 /** The serial version UID */ 40 private static final long serialVersionUID = 1L;41 40 private static final long serialVersionUID = 6222042834700541233L; 41 42 42 /** 43 43 * Builds a <code>MapdustConnectorException</code> object. … … 46 46 super(); 47 47 } 48 48 49 49 /** 50 50 * Builds a <code>MapdustConnectorException</code> object based on the given 51 51 * argument. 52 * 52 * 53 53 * @param message The message of the exception 54 54 */ … … 56 56 super(message); 57 57 } 58 58 59 59 /** 60 60 * Builds a <code>MapdustConnectorException</code> object based on the given 61 61 * argument. 62 * 62 * 63 63 * @param cause The cause of the exception 64 64 */ … … 66 66 super(cause); 67 67 } 68 68 69 69 /** 70 70 * Builds a <code>MapdustConnectorException</code> object based on the given 71 71 * arguments. 72 * 72 * 73 73 * @param message The message of the exception 74 74 * @param cause The cause of the exception … … 77 77 super(message, cause); 78 78 } 79 79 80 80 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/package-info.java
r24514 r25591 1 1 /** 2 * contains thehttpconnector2 * Contains the MapDust service connector classes. 3 3 */ 4 4 package org.openstreetmap.josm.plugins.mapdust.service.connector; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustBugProperties.java
r24514 r25591 56 56 private String description; 57 57 58 /** Flag indicating if the description is default or not */ 59 private boolean isDefaultDescription; 60 58 61 /** The nickname of the bug */ 59 62 private String nickname; … … 93 96 * @param type The type of the bug 94 97 * @param description The description of the bug 98 * @param isDefaultDescription Flag indicating if the description is default 99 * or not 95 100 * @param nickname The nickname 96 101 * @param skoUid The skobbler user id … … 103 108 */ 104 109 public MapdustBugProperties(Date dateCreated, Date dateUpdated, 105 Integer status, String type, String description, String nickname,106 String skoUid , String extUid, String source, String kmlUrl,107 Address addres s, Integer numberOfComments,108 MapdustCommentProperties[] comments) { 110 Integer status, String type, String description, 111 boolean isDefaultDescription, String nickname, String skoUid, 112 String extUid, String source, String kmlUrl, Address address, 113 Integer numberOfComments, MapdustCommentProperties[] comments) { 109 114 this.dateCreated = dateCreated; 110 115 this.dateUpdated = dateUpdated; … … 112 117 this.type = type; 113 118 this.description = description; 119 this.isDefaultDescription = isDefaultDescription; 114 120 this.nickname = nickname; 115 121 this.skoUid = skoUid; … … 213 219 214 220 /** 221 * Returns the isDefaultDescription flag 222 * 223 * @return the isDefaultDescription 224 */ 225 public boolean getIsDefaultDescription() { 226 return isDefaultDescription; 227 } 228 229 /** 230 * Sets the isDefaultDescription flag 231 * 232 * @param isDefaultDescription the isDefaultDescription to set 233 */ 234 public void setIsDefaultDescription(boolean isDefaultDescription) { 235 this.isDefaultDescription = isDefaultDescription; 236 } 237 238 /** 215 239 * Returns the nickname 216 240 * … … 355 379 this.comments = comments; 356 380 } 381 357 382 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustCommentProperties.java
r24514 r25591 27 27 */ 28 28 package org.openstreetmap.josm.plugins.mapdust.service.connector.response; 29 29 30 30 31 import java.util.Date; … … 189 190 this.source = source; 190 191 } 192 191 193 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustGetBugsResponse.java
r24514 r25591 36 36 * 37 37 */ 38 public class MapdustGetBugsResponse 38 public class MapdustGetBugsResponse { 39 39 40 40 /** The array of <code>MapdustBugContent</code> object */ … … 73 73 } 74 74 75 76 75 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustGetResponse.java
r24514 r25591 38 38 * 39 39 */ 40 public class MapdustGetResponse 40 public class MapdustGetResponse { 41 41 42 42 /** … … 60 60 61 61 /** 62 * Returns the <code>Paging</code> object 63 * 62 64 * @return the paging 63 65 */ … … 67 69 68 70 /** 71 * Sets the <code>Paging</code> object 72 * 69 73 * @param paging the paging to set 70 74 */ -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/MapdustPostResponse.java
r24514 r25591 73 73 this.id = id; 74 74 } 75 75 76 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/connector/response/package-info.java
r24514 r25591 1 1 /** 2 * containsthe response objects2 * Contains the MapDust service the response objects. 3 3 */ 4 4 package org.openstreetmap.josm.plugins.mapdust.service.connector.response; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/converter/MapdustConverter.java
r24514 r25591 65 65 /* sets the id */ 66 66 bug.setId(bugResponse.getId()); 67 68 67 /* sets the coordinates */ 69 68 Geometry geometry = bugResponse.getGeometry(); … … 76 75 } 77 76 bug.setLatLon(latLon); 78 79 77 /* sets the properties of the bug */ 80 78 MapdustBugProperties bugProperties = bugResponse.getProperties(); … … 94 92 /* sets the description */ 95 93 bug.setDescription(bugProperties.getDescription()); 94 /* sets the isDefaultDescription */ 95 bug.setIsDefaultDescription(bugProperties 96 .getIsDefaultDescription()); 96 97 /* sets the skobbler user id */ 97 98 bug.setSkoUid(bugProperties.getSkoUid()); -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/converter/package-info.java
r24514 r25591 1 1 /** 2 * contains the converterobject2 * Contains the converter class. 3 3 */ 4 4 package org.openstreetmap.josm.plugins.mapdust.service.converter; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/package-info.java
r24514 r25591 1 1 /** 2 * retrieves and sends data from/to the Mapdust api 3 * 2 * Contains the MapDust API connection classes. These classes are used for 3 * downloading/uploading MapDust bug data from/to the MapDust service. 4 * The MapDust service connection classes are divided based on their type 5 * in the following four packages: connector, converter, parser and value. 6 * 4 7 */ 5 8 package org.openstreetmap.josm.plugins.mapdust.service; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/value/MapdustBug.java
r24514 r25591 65 65 private String description; 66 66 67 /** Flag indicating if the description is default or not */ 68 private boolean isDefaultDescription; 69 67 70 /** The nickname of the user who created the bug */ 68 71 private String nickname; … … 120 123 * @param type The type of the bug 121 124 * @param description The description of the bug 125 * @param isDefaultDescription Flag indicating if the description is default 126 * or not 122 127 * @param nickname The nickname 123 128 * @param skoUid The skobbler user id … … 130 135 public MapdustBug(Long id, LatLon latLon, Address address, 131 136 Date dateCreated, Date dateUpdated, Status status, Type type, 132 String description, String nickname , String skoUid, String extUid,133 String source, String kmlUrl , Integer numberOfComments,134 MapdustComment[] comments) { 137 String description, boolean isDefaultDescription, String nickname, 138 String skoUid, String extUid, String source, String kmlUrl, 139 Integer numberOfComments, MapdustComment[] comments) { 135 140 this.id = id; 136 141 this.latLon = latLon; … … 141 146 this.type = type; 142 147 this.description = description; 148 this.isDefaultDescription = isDefaultDescription; 143 149 this.nickname = nickname; 144 150 this.skoUid = skoUid; … … 277 283 278 284 /** 285 * Returns the isDefaultDescription flag 286 * 287 * @return the isDefaultDescription 288 */ 289 public boolean getIsDefaultDescription() { 290 return isDefaultDescription; 291 } 292 293 /** 294 * Sets the isDefaultDescription flag 295 * 296 * @param isDefaultDescription the isDefaultDescription to set 297 */ 298 public void setIsDefaultDescription(boolean isDefaultDescription) { 299 this.isDefaultDescription = isDefaultDescription; 300 } 301 302 /** 279 303 * Returns the address 280 304 * … … 419 443 } 420 444 445 /* (non-Javadoc) 446 * @see java.lang.Object#hashCode() 447 */ 448 @Override 449 public int hashCode() { 450 final int prime = 31; 451 int result = 1; 452 result = prime * result + ((id == null) ? 0 : id.hashCode()); 453 return result; 454 } 455 456 /* (non-Javadoc) 457 * @see java.lang.Object#equals(java.lang.Object) 458 */ 459 @Override 460 public boolean equals(Object obj) { 461 if (this == obj) 462 return true; 463 if (obj == null) 464 return false; 465 if (getClass() != obj.getClass()) 466 return false; 467 MapdustBug other = (MapdustBug) obj; 468 if (id == null) { 469 if (other.id != null) 470 return false; 471 } else if (!id.equals(other.id)) 472 return false; 473 return true; 474 } 475 476 421 477 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/value/Status.java
r24514 r25591 41 41 42 42 /** The serial version UID */ 43 private static final long serialVersionUID = 1L;43 private static final long serialVersionUID = 5534551701260061940L; 44 44 45 45 /** The key of the <code>Status</code> */ -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/value/Type.java
r24514 r25591 43 43 44 44 /** The serial version UID */ 45 private static final long serialVersionUID = 1L;45 private static final long serialVersionUID = 4022464908172242274L; 46 46 47 47 /** The key of the <code>Type</code> */ -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/service/value/package-info.java
r24514 r25591 1 1 /** 2 * Contains the objects used byrepresenting the Mapdust data.2 * Contains the objects used for representing the MapDust data. 3 3 */ 4 4 package org.openstreetmap.josm.plugins.mapdust.service.value; -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/util/http/HttpConnector.java
r24514 r25591 51 51 52 52 /** The timeout */ 53 private final int timeout = 10000;53 private final int timeout = 20000; 54 54 55 55 /** The <code>RetrySetup</code> */
Note:
See TracChangeset
for help on using the changeset viewer.