Changeset 24821 in osm for applications/editors
- Timestamp:
- 2010-12-20T15:36:53+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java
r24733 r24821 79 79 private List<MapdustBug> mapdustBugList; 80 80 81 /** Flag indicating if the list of bugs was empty or not */ 82 private boolean wasEmpty; 83 81 84 /** 82 85 * Builds a new <code>MapDustPlugin</code> object based on the given … … 106 109 } else { 107 110 /* add MapDust dialog window */ 108 Shortcut shortcut = Shortcut.registerShortcut("mapdust", 109 tr("Toggle: {0}", tr("Open MapDust")), KeyEvent.VK_0, 111 Shortcut shortcut = Shortcut.registerShortcut("mapdust", 112 tr("Toggle: {0}", tr("Open MapDust")), KeyEvent.VK_0, 110 113 Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT); 111 114 String name = "MapDust bug reports"; … … 116 119 mapdustGUI.addObserver(this); 117 120 newMapFrame.addToggleDialog(mapdustGUI); 121 MapView.addZoomChangeListener(this); 118 122 MapView.addLayerChangeListener(this); 119 MapView.addZoomChangeListener(this);120 123 Main.map.mapView.addMouseListener(this); 121 124 } … … 135 138 if (getMapdustGUI().isDialogShowing()) { 136 139 /* updates the views */ 137 updateView(); 138 /* show message if there is not bug in the given area */ 139 if (this.mapdustBugList == null 140 || this.mapdustBugList.size() == 0) { 141 String waringMessage = "There is no MapDust bug "; 142 waringMessage += "in your visible area."; 140 if ((this.mapdustBugList == null || this.mapdustBugList 141 .size() == 0) && !wasEmpty) { 142 updateView(); 143 String waringMessage = "There is no MapDust bug in "; 144 waringMessage += "your visible area."; 143 145 JOptionPane.showMessageDialog(Main.parent, 144 146 tr(waringMessage), tr("Warning"), 145 147 JOptionPane.WARNING_MESSAGE); 148 wasEmpty = true; 149 } else { 150 updateView(); 151 wasEmpty = false; 146 152 } 147 153 } … … 215 221 } 216 222 mapdustLayer = null; 223 wasEmpty = false; 217 224 } 218 225 } … … 223 230 && Main.map.mapView.getActiveLayer() == getMapdustLayer()) { 224 231 /* show add bug dialog */ 225 if (event.getClickCount() == 2) { 226 mapdustGUI.getPanel().getBtnPanel().getBtnWorkOffline() 227 .setEnabled(false); 228 mapdustGUI.getPanel().getBtnPanel().getBtnRefresh() 229 .setEnabled(false); 230 mapdustGUI.getPanel().getBtnPanel().getBtnAddComment() 231 .setEnabled(false); 232 mapdustGUI.getPanel().getBtnPanel().getBtnFixBugReport() 233 .setEnabled(false); 234 mapdustGUI.getPanel().getBtnPanel().getBtnInvalidateBugReport() 235 .setEnabled(false); 236 mapdustGUI.getPanel().getBtnPanel().getBtnReOpenBugReport() 237 .setEnabled(false); 238 Main.pref.put("mapdust.modify", true); 239 MapdustBug selectedBug = mapdustGUI.getPanel().getSelectedBug(); 240 if (selectedBug != null) { 241 Main.pref.put("selectedBug.status", selectedBug.getStatus() 242 .getValue()); 232 if (event.getButton() == MouseEvent.BUTTON3 233 && event.getClickCount() == 2) { 234 String mapdustAddBug = Main.pref.get("mapdust.addBug"); 235 boolean addBug = Boolean.parseBoolean(mapdustAddBug); 236 if (!addBug) { 237 mapdustGUI.getPanel().getBtnPanel().getBtnWorkOffline() 238 .setEnabled(false); 239 mapdustGUI.getPanel().getBtnPanel().getBtnRefresh() 240 .setEnabled(false); 241 mapdustGUI.getPanel().getBtnPanel().getBtnAddComment() 242 .setEnabled(false); 243 mapdustGUI.getPanel().getBtnPanel().getBtnFixBugReport() 244 .setEnabled(false); 245 mapdustGUI.getPanel().getBtnPanel() 246 .getBtnInvalidateBugReport().setEnabled(false); 247 mapdustGUI.getPanel().getBtnPanel().getBtnReOpenBugReport() 248 .setEnabled(false); 249 Main.pref.put("mapdust.modify", true); 250 MapdustBug selectedBug = 251 mapdustGUI.getPanel().getSelectedBug(); 252 if (selectedBug != null) { 253 Main.pref.put("selectedBug.status", selectedBug 254 .getStatus().getValue()); 255 } else { 256 Main.pref.put("selectedBug.status", "create"); 257 } 258 String title = "Create bug report"; 259 String iconName = "dialogs/open.png"; 260 String messageText = 261 "In order to create a new bug report you"; 262 messageText += " need to provide your nickname and a brief"; 263 messageText += " description for the bug."; 264 Point point = event.getPoint(); 265 CreateIssueDialog dialog = 266 new CreateIssueDialog(tr(title), iconName, 267 tr(messageText), point, this); 268 dialog.setLocationRelativeTo(null); 269 dialog.getContentPane().setPreferredSize(dialog.getSize()); 270 dialog.pack(); 271 dialog.setVisible(true); 243 272 } else { 244 Main.pref.put(" selectedBug.status", "create");273 Main.pref.put("mapdust.addBug", false); 245 274 } 246 String title = "Create bug report";247 String iconName = "dialogs/open.png";248 String messageText = "In order to create a new bug report you";249 messageText += " need to provide your nickname and a brief";250 messageText += " description for the bug.";251 Point point = event.getPoint();252 CreateIssueDialog dialog =253 new CreateIssueDialog(tr(title), iconName,254 tr(messageText), point, this);255 dialog.setLocationRelativeTo(null);256 dialog.getContentPane().setPreferredSize(dialog.getSize());257 dialog.pack();258 dialog.setVisible(true);259 return;260 275 } 261 276 if (event.getButton() == MouseEvent.BUTTON1) { … … 280 295 /* update the dialog with the new data */ 281 296 mapdustGUI.update(mapdustBugList, this); 297 mapdustGUI.revalidate(); 282 298 if (mapdustLayer == null) { 283 299 /* create and add the layer */ 284 mapdustLayer = new MapdustLayer("MapDust", mapdustGUI, mapdustBugList); 300 mapdustLayer = 301 new MapdustLayer("MapDust", mapdustGUI, mapdustBugList); 285 302 Main.main.addLayer(mapdustLayer); 286 303 Main.map.mapView.moveLayer(mapdustLayer, 0); 304 ; 305 Main.map.mapView.addMouseListener(this); 287 306 MapView.addLayerChangeListener(this); 288 307 MapView.addZoomChangeListener(this); … … 295 314 } 296 315 /* repaint */ 297 Main.map.mapView. invalidate();316 Main.map.mapView.revalidate(); 298 317 Main.map.repaint(); 299 Main.map.mapView.repaint();300 }301 302 /**303 * Returns the bounds of the current map view.304 *305 * @return A <code>Bounds</code> object306 */307 private Bounds getBounds() {308 MapView mapView = Main.map.mapView;309 Bounds bounds =310 new Bounds(mapView.getLatLon(0, mapView.getHeight()),311 mapView.getLatLon(mapView.getWidth(), 0));312 return bounds;313 318 } 314 319 … … 320 325 public void initialUpdate() { 321 326 if (containsOsmDataLayer()) { 322 Main.worker.execute(new Runnable() { 323 324 @Override 325 public void run() { 326 updateData(); 327 328 } 329 }); 330 } 331 } 332 327 updateData(); 328 } 329 } 330 331 /** 332 * If the zoom was changed, download the bugs from the current map view. 333 */ 333 334 @Override 334 335 public void zoomChanged() { … … 388 389 throws MapdustServiceHandlerException { 389 390 /* get the bounding box */ 390 Bounds bounds = getBounds(); 391 MapView mapView = Main.map.mapView; 392 Bounds bounds = 393 new Bounds(mapView.getLatLon(0, mapView.getHeight()), 394 mapView.getLatLon(mapView.getWidth(), 0)); 391 395 Double minLon = bounds.getMin().lon(); 392 396 Double minLat = bounds.getMin().lat(); … … 425 429 426 430 @Override 427 public void mouseEntered(MouseEvent arg0) {} 431 public void mouseEntered(MouseEvent event) { 432 433 } 428 434 429 435 @Override … … 431 437 432 438 @Override 433 public void mousePressed(MouseEvent arg0) {} 439 public void mousePressed(MouseEvent event) { 440 441 } 434 442 435 443 @Override … … 473 481 474 482 /** 483 * Returns the list of <code>MapdustBug</code> objects 484 * 475 485 * @return the mapdustBugList 476 486 */ … … 480 490 481 491 /** 492 * Sets the list of <code>MapdustBug</code> objects 493 * 482 494 * @param mapdustBugList the mapdustBugList to set 483 495 */ -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/MapdustGUI.java
r24733 r24821 56 56 /** 57 57 * This class is the main graphical user interface class. 58 * 58 * 59 59 * @author Bea 60 60 */ … … 62 62 MapdustActionListObserver, MapdustBugDetailsObservable, 63 63 MapdustInitialUpdateObservable { 64 64 65 65 /** The serial version UID */ 66 66 private static final long serialVersionUID = 1L; 67 67 68 68 /** The list of MapDust bug details observers */ 69 69 private final ArrayList<MapdustBugDetailsObserver> bugDetailsObservers = 70 70 new ArrayList<MapdustBugDetailsObserver>(); 71 71 72 72 /** The list of MapDust initial update observers */ 73 73 private final ArrayList<MapdustInitialUpdateObserver> initialUpdateObservers = 74 74 new ArrayList<MapdustInitialUpdateObserver>(); 75 75 76 76 /** The <code>MapdustPanel</code> object */ 77 77 private MapdustPanel panel; 78 78 79 79 /** The <code>MapdustActionPanel</code> object */ 80 80 private MapdustActionPanel queuePanel; 81 81 82 82 /** The <code>JTabbedPanel</code> object */ 83 83 private JTabbedPane tabbedPane; 84 84 85 85 /** The <code>MapdustPlugin</code> plugin */ 86 86 private MapdustPlugin mapdustPlugin; 87 87 88 88 /** The <code>MapdustBugPropertiesPanel</code> */ 89 89 private final MapdustBugPropertiesPanel detailsPanel; 90 90 91 91 /** The <code>JPanel</code> */ 92 92 private JPanel mainPanel; 93 93 94 94 /** 95 95 * Flag indicating if the MapDust data was downloaded and the view was … … 97 97 */ 98 98 private boolean initialUpdate = false; 99 99 100 100 /** 101 101 * Builds a <code>MapdustGUi</code> based on the given parameters. 102 * 102 * 103 103 * @param name The name of the GUI 104 104 * @param iconName The name of the icon … … 149 149 } 150 150 } 151 151 152 152 /** 153 153 * Updates the MapDust GUI with the given list of <code>MapdustBug</code> 154 154 * objects. 155 * 155 * 156 156 * @param mapdustBugs The list of <code>MapdustBug</code> objects 157 157 * @param mapdustPlugin The <code>MapdustPlugin</code> object … … 178 178 /* add panels with updated data */ 179 179 panel = new MapdustPanel(mapdustBugs, "Bug reports", mapdustPlugin); 180 panel.addObserver(detailsPanel);181 180 MapdustBug selectedBug = 182 181 (mapdustBugs != null && mapdustBugs.size() > 0) ? mapdustBugs 183 182 .get(0) : null; 184 183 notifyObservers(selectedBug); 184 panel.addObserver(detailsPanel); 185 185 mainPanel = new JPanel(); 186 186 mainPanel.setAutoscrolls(true); … … 210 210 tabbedPane = new JTabbedPane(); 211 211 queuePanel = new MapdustActionPanel(list, "Offline Contribution", 212 212 mapdustPlugin); 213 213 panel = new MapdustPanel(mapdustBugs, "Bug reports (offline)", 214 mapdustPlugin); 215 panel.addObserver(detailsPanel); 214 mapdustPlugin); 216 215 mainPanel = new JPanel(); 217 216 mainPanel.setAutoscrolls(true); … … 226 225 } 227 226 } 228 227 229 228 /** 230 229 * Adds the given <code>MapdustAction</code> object to the list of actions. 231 * 230 * 232 231 * @param action The <code>MapdustAction</code> object 233 232 */ … … 238 237 List<MapdustBug> mapdustBugs = panel.getMapdustBugsList(); 239 238 mapdustBugs = modifyBug(mapdustBugs, action.getMapdustBug()); 240 239 241 240 /* remove panels */ 242 241 mainPanel.remove(detailsPanel); … … 260 259 mainPanel.add(tabbedPane, BorderLayout.CENTER); 261 260 add(mainPanel, BorderLayout.CENTER); 262 /* invalidate and repaint */ 263 invalidate(); 264 repaint(); 265 } 266 261 revalidate(); 262 } 263 267 264 /** 268 265 * Shows the MapDust main dialog. In the case if the plugin was not updated … … 270 267 * download the MapDust data from the current view, and update the plugin 271 268 * with the new data. 272 * 269 * 273 270 */ 274 271 @Override … … 281 278 } 282 279 } 283 280 284 281 /** 285 282 * Modifies the given <code>MapdustBug</code> in the given list of 286 283 * <code>MapdustBug</code> objects. Returns the list of bugs containing the 287 284 * modified bug. 288 * 285 * 289 286 * @param mapdustBugs The list of <code>MapdustBug</code> objects 290 287 * @param modifiedBug The <code>MapdustBug</code> object … … 308 305 return mapdustBugs; 309 306 } 310 307 311 308 /** 312 309 * Adds a new MapDust bug details observer to the list of observers. 313 * 310 * 314 311 * @param observer The <code>MapdustBugDetailsObserver</code> object 315 312 */ … … 320 317 } 321 318 } 322 319 323 320 /** 324 321 * Adds a new MapDust initial update observer to the list of observers. 325 * 322 * 326 323 * @param observer The <code>MapdustInitialUpdateObserver</code> object 327 324 */ … … 332 329 } 333 330 } 334 331 335 332 /** 336 333 * Removes the given MapDust bug details observer from the list of 337 334 * observers. 338 * 335 * 339 336 * @param observer The <code>MapdustBugDetailsObserver</code> object 340 337 */ … … 342 339 public void removeObserver(MapdustBugDetailsObserver observer) { 343 340 this.bugDetailsObservers.remove(observer); 344 345 } 346 341 342 } 343 347 344 /** 348 345 * Removes the given MapDust initial update observer from the list of 349 346 * observers. 350 * 347 * 351 348 * @param observer The <code>MapdustInitialUpdateObserver</code> object 352 349 */ … … 354 351 public void removeObserver(MapdustInitialUpdateObserver observer) { 355 352 this.initialUpdateObservers.remove(observer); 356 357 } 358 353 354 } 355 359 356 /** 360 357 * Notifies the <code>MapdustBugDetailsObserver</code> objects observing the … … 369 366 } 370 367 } 371 368 372 369 /** 373 370 * Notifies the <code>MapdustInitialUpdateObserver</code> objects waiting … … 382 379 } 383 380 } 384 381 385 382 /** 386 383 * Returns the <code>MapdustPanel</code> object 387 * 384 * 388 385 * @return the panel 389 386 */ … … 391 388 return panel; 392 389 } 393 390 394 391 /** 395 392 * Returns the <code>MapdustActionPanel</code> object 396 * 393 * 397 394 * @return the queuePanel 398 395 */ … … 400 397 return queuePanel; 401 398 } 402 399 403 400 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/adapter/WindowClose.java
r24514 r24821 41 41 /** 42 42 * Closes the given dialog window. 43 * 43 * 44 44 * @author Bea 45 45 * @version $Revision$ 46 46 */ 47 47 public class WindowClose extends WindowAdapter { 48 48 49 49 /** Serial version UID */ 50 50 private static final long serialVersionUID = 1L; 51 51 52 52 /** A <code>AbstractDialog</code> object */ 53 53 private AbstractDialog dialog; 54 54 55 55 /** The <code>MapdustButtonPanel</code> object */ 56 56 private MapdustButtonPanel btnPanel; 57 57 58 58 /** The <code>JToggleButton</code> which had fired the dialog */ 59 59 private JToggleButton btnFired; 60 60 61 61 /** 62 62 * Builds a <code>WindowClose</code> object 63 63 */ 64 64 public WindowClose() {} 65 65 66 66 /** 67 67 * Builds a <code>WindowClose</code> object based on the given arguments 68 * 68 * 69 69 * @param dialog The dialog which will be closed 70 70 * @param btnPanel The button panel … … 77 77 this.btnFired = btnFired; 78 78 } 79 79 80 80 @Override 81 81 public void windowClosing(WindowEvent event) { … … 128 128 } 129 129 /* dispose dialog */ 130 Main.pref.put("mapdust.addBug", true); 130 131 Main.pref.put("mapdust.modify", false); 132 dialog.setVisible(false); 131 133 dialog.dispose(); 134 return; 132 135 } 133 134 136 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/action/execute/ExecuteCancel.java
r24514 r24821 65 65 } 66 66 67 67 68 @Override 68 69 public void actionPerformed(ActionEvent event) { … … 116 117 btnPanel.getBtnReOpenBugReport().setSelected(false); 117 118 } 118 /* dispose dialog */119 Main.pref.put("mapdust.modify", false);120 getDialog().dispose();121 119 } 120 121 Main.pref.put("mapdust.addBug", true); 122 Main.pref.put("mapdust.modify", false); 123 /* dispose dialog */ 124 getDialog().setVisible(false); 125 getDialog().dispose(); 122 126 } 123 127 124 128 }
Note:
See TracChangeset
for help on using the changeset viewer.