Changeset 25312 in osm for applications
- Timestamp:
- 2011-02-15T09:42:40+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java
r25127 r25312 39 39 import org.openstreetmap.josm.Main; 40 40 import org.openstreetmap.josm.data.Bounds; 41 import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent; 42 import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener; 43 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 41 44 import org.openstreetmap.josm.gui.MapFrame; 42 45 import org.openstreetmap.josm.gui.MapView; … … 68 71 */ 69 72 public class MapdustPlugin extends Plugin implements LayerChangeListener, 70 ZoomChangeListener, MouseListener, MapdustRefreshObserver, 71 MapdustBugObserver, MapdustInitialUpdateObserver { 72 73 ZoomChangeListener, PreferenceChangedListener, MouseListener, 74 MapdustRefreshObserver, MapdustBugObserver, 75 MapdustInitialUpdateObserver { 76 73 77 /** The graphical user interface of the plug-in */ 74 78 private MapdustGUI mapdustGUI; 75 79 76 80 /** The layer of the MapDust plug-in */ 77 81 private MapdustLayer mapdustLayer; 78 82 79 83 /** The list of <code>MapdustBug</code> objects */ 80 84 private List<MapdustBug> mapdustBugList; 81 85 82 86 /** The <code>CreateIssueDialog</code> object */ 83 87 private CreateIssueDialog dialog; 84 88 85 89 /** Specifies if there was or not an error downloading the data */ 86 90 private boolean wasError = false; 87 91 92 /** The JOSM user identity manager, it is used for obtaining the username */ 93 private final JosmUserIdentityManager userIdentityManager; 94 88 95 /** 89 96 * Builds a new <code>MapDustPlugin</code> object based on the given 90 97 * arguments. 91 * 98 * 92 99 * @param info The <code>MapDustPlugin</code> object 93 100 */ 94 101 public MapdustPlugin(PluginInformation info) { 95 102 super(info); 103 /* create instance for JOSM user identity manager */ 104 userIdentityManager = JosmUserIdentityManager.getInstance(); 105 /* initialize the plugin */ 96 106 initializePlugin(); 97 107 } 98 108 99 109 /** 100 110 * Initialize the <code>MapdustPlugin</code> object. Creates the … … 105 115 private void initializePlugin() { 106 116 /* create MapDust GUI */ 107 Shortcut shortcut = Shortcut.registerShortcut("mapdust", 108 tr(" Toggle: {0}", tr("Open MapDust")), KeyEvent.VK_0,109 Shortcut. GROUP_MENU, Shortcut.SHIFT_DEFAULT);117 Shortcut shortcut = Shortcut.registerShortcut("mapdust", tr("Toggle: {0}", 118 tr("Open MapDust")), KeyEvent.VK_0, Shortcut.GROUP_MENU, 119 Shortcut.SHIFT_DEFAULT); 110 120 String name = "MapDust bug reports"; 111 121 String tooltip = "Activates the MapDust bug reporter plugin"; … … 113 123 shortcut, 150, this); 114 124 /* add default values for static variables */ 115 Main.pref.put("mapdust.pluginState", MapdustPluginState.ONLINE.getValue()); 116 Main.pref.put("mapdust.nickname", null); 125 Main.pref.put("mapdust.pluginState", 126 MapdustPluginState.ONLINE.getValue()); 127 Main.pref.put("mapdust.nickname", ""); 117 128 Main.pref.put("mapdust.showError", true); 118 } 119 129 Main.pref.put("mapdust.version", getPluginInformation().version); 130 Main.pref.put("mapdust.localVersion", 131 getPluginInformation().localversion); 132 } 133 120 134 /** 121 135 * Initializes the new <code>MapFrame</code>. Adds the 122 136 * <code>MapdustGUI</code> to the new <code>MapFrame</code> and sets the 123 137 * observers/listeners. 124 * 138 * 125 139 * @param oldMapFrame The old <code>MapFrame</code> object 126 140 * @param newMapFrame The new <code>MapFrame</code> object … … 147 161 /* add MouseListener */ 148 162 Main.map.mapView.addMouseListener(this); 149 } 150 } 151 } 152 163 Main.pref.addPreferenceChangeListener(this); 164 /* put username to preferences */ 165 Main.pref.put("mapdust.josmUserName", 166 userIdentityManager.getUserName()); 167 } 168 } 169 } 170 153 171 /** 154 172 * Refreshes the MapDust data. Downloads the data from the given area and … … 162 180 } 163 181 } 164 182 165 183 /** 166 184 * Downloads the MapDust bugs from the current map view, and updates the … … 174 192 } 175 193 } 176 194 177 195 /** 178 196 * Updates the given <code>MapdustBug</code> object from the map and from 179 197 * the MapDust bugs list. 180 * 198 * 181 199 * @param mapdustBug The <code>MapdustBug</code> object 182 200 */ … … 207 225 } 208 226 } 209 227 210 228 /** 211 229 * If the zoom was changed, download the bugs from the current map view. … … 218 236 } 219 237 } 220 238 221 239 /** 222 240 * No need to implement this. … … 224 242 @Override 225 243 public void activeLayerChange(Layer arg0, Layer arg1) {} 226 244 227 245 /** 228 246 * Adds the <code>MapdustLayer</code> to the JOSM editor. If the list of … … 242 260 } 243 261 } 244 262 245 263 /** 246 264 * Removes the <code>MapdustLayer</code> from the JOSM editor. Also closes … … 265 283 } 266 284 } 267 285 268 286 /** 269 287 * No need to implement this. … … 271 289 @Override 272 290 public void mouseEntered(MouseEvent event) {} 273 291 274 292 /** 275 293 * No need to implement this. … … 277 295 @Override 278 296 public void mouseExited(MouseEvent arg0) {} 279 297 280 298 /** 281 299 * No need to implement this. … … 283 301 @Override 284 302 public void mousePressed(MouseEvent event) {} 285 303 286 304 /** 287 305 * No need to implement this. … … 289 307 @Override 290 308 public void mouseReleased(MouseEvent arg0) {} 291 309 292 310 /** 293 311 * At mouse click the following two actions can be done: adding a new bug, … … 336 354 } 337 355 } 338 339 356 357 /** 358 * Listens for the events of type <code>PreferenceChangeEvent</code> . If 359 * the event key is 'osm-server.username' then if the username was changed 360 * in Preferences and it was used as 'nickname'( the user did not changed 361 * this completed nickname to someting else ) for submitting changes to 362 * MapDust , re-set the 'mapdust.josmUserName' and 'mapdust.nickname' 363 * properties. 364 * 365 * @param event The <code>PreferenceChangeEvent</code> obejct 366 */ 367 @Override 368 public void preferenceChanged(PreferenceChangeEvent event) { 369 if (this.mapdustGUI.isShowing() && !wasError && mapdustLayer != null 370 && mapdustLayer.isVisible()) { 371 if (event.getKey().equals("osm-server.username")) { 372 String newUserName = userIdentityManager.getUserName(); 373 String oldUserName = Main.pref.get("mapdust.josmUserName"); 374 String nickname = Main.pref.get("mapdust.nickname"); 375 if (nickname.isEmpty()) { 376 /* nickname was not completed */ 377 Main.pref.put("mapdust.josmUserName", newUserName); 378 Main.pref.put("mapdust.nickname", newUserName); 379 } else { 380 if (nickname.equals(oldUserName)) { 381 /* username was used for nickname, and was not changed */ 382 Main.pref.put("mapdust.josmUserName", newUserName); 383 Main.pref.put("mapdust.nickname", newUserName); 384 } else { 385 /* username was used for nickname, and was changed */ 386 Main.pref.put("mapdust.josmUserName", newUserName); 387 } 388 } 389 } 390 } 391 } 392 340 393 /** 341 394 * Updates the <code>MapdustPlugin</code> data. Downloads the … … 351 404 }); 352 405 } 353 406 354 407 /** 355 408 * Returns the bounds of the current <code>MapView</code>. 356 * 409 * 357 410 * @return bounds 358 411 */ 359 412 private Bounds getBounds() { 360 413 MapView mapView = Main.map.mapView; 361 Bounds bounds = new Bounds(mapView.getLatLon(0, mapView.getHeight()), 414 Bounds bounds = new Bounds(mapView.getLatLon(0, mapView.getHeight()), 362 415 mapView.getLatLon(mapView.getWidth(), 0)); 363 416 return bounds; 364 417 } 365 418 366 419 /** 367 420 * Updates the MapDust plugin data. Downloads the list of … … 375 428 Bounds bounds = getBounds(); 376 429 MapdustServiceHandler handler = new MapdustServiceHandler(); 377 mapdustBugList = handler.getBugs(bounds.getMin().lon(), 378 bounds.getMin().lat(), bounds.getMax().lon(), 430 mapdustBugList = handler.getBugs(bounds.getMin().lon(), 431 bounds.getMin().lat(), bounds.getMax().lon(), 379 432 bounds.getMax().lat()); 380 433 wasError = false; … … 391 444 } 392 445 } 393 446 394 447 /** 395 448 * Updates the current view ( map and MapDust bug list), with the given list … … 421 474 Main.map.repaint(); 422 475 } 423 476 424 477 /** 425 478 * Updates the MapDust bugs list with the given <code>MapdustBug</code> 426 479 * object. 427 * 480 * 428 481 * @param mapdustBug The <code>MapdustBug</code> object 429 482 */ … … 444 497 } 445 498 } 446 499 447 500 /** 448 501 * Returns the nearest <code>MapdustBug</code> object to the given point on 449 502 * the map. 450 * 503 * 451 504 * @param p A <code>Point</code> object 452 505 * @return A <code>MapdustBug</code> object … … 468 521 return nearestBug; 469 522 } 470 523 471 524 /** 472 525 * Verifies if the <code>OsmDataLayer</code> layer has been added to the 473 526 * list of layers. 474 * 527 * 475 528 * @return true if the <code>OsmDataLayer</code> layer has been added false 476 529 * otherwise … … 486 539 return contains; 487 540 } 488 541 489 542 /** 490 543 * Handles the <code>MapdustServiceHandlerException</code> error. 491 * 544 * 492 545 */ 493 546 private void handleError() { … … 502 555 } 503 556 } 504 557 505 558 /** 506 559 * Returns the <code>MapdustGUI</code> object 507 * 560 * 508 561 * @return the mapdustGUI 509 562 */ … … 511 564 return mapdustGUI; 512 565 } 513 566 514 567 /** 515 568 * Sets the <code>MapdustGUI</code> object. 516 * 569 * 517 570 * @param mapdustGUI the mapdustGUI to set 518 571 */ … … 520 573 this.mapdustGUI = mapdustGUI; 521 574 } 522 575 523 576 /** 524 577 * Returns the <code>MapdustLayer</code> object. 525 * 578 * 526 579 * @return the mapdustLayer 527 580 */ … … 529 582 return mapdustLayer; 530 583 } 531 584 532 585 /** 533 586 * Sets the <code>MapdustLayer</code> object. 534 * 587 * 535 588 * @param mapdustLayer the mapdustLayer to set 536 589 */ … … 538 591 this.mapdustLayer = mapdustLayer; 539 592 } 540 593 541 594 /** 542 595 * Returns the list of <code>MapdustBug</code> objects 543 * 596 * 544 597 * @return the mapdustBugList 545 598 */ … … 547 600 return mapdustBugList; 548 601 } 549 602 550 603 /** 551 604 * Sets the list of <code>MapdustBug</code> objects 552 * 605 * 553 606 * @param mapdustBugList the mapdustBugList to set 554 607 */ … … 556 609 this.mapdustBugList = mapdustBugList; 557 610 } 558 611 559 612 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/ChangeIssueStatusDialog.java
r25127 r25312 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 66 private static final long serialVersionUID = 1L; 67 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 … … 129 129 addWindowListener(new WindowClose(this, btnPanel, getFiredButton())); 130 130 } 131 131 132 132 /** 133 133 * Adds the components to the panel. 134 * 134 * 135 135 * @param mapdustPlugin The <code>MapdustPlugin</code> object 136 136 */ … … 142 142 /* create the message cmp */ 143 143 if (cmpMessage == null) { 144 JTextPane txtPane = ComponentUtil.createJTextPane(messageText, 144 JTextPane txtPane = ComponentUtil.createJTextPane(messageText, 145 145 backgroundColor); 146 146 Rectangle bounds = new Rectangle(10, 10, 330, 50); … … 153 153 lblNickname = ComponentUtil.createJLabel("Nickname", font, bounds); 154 154 } 155 String nickname = Main.pref.get("mapdust.nickname");156 155 if (txtNickname == null) { 157 156 Rectangle bounds = new Rectangle(100, 70, 230, 25); 158 157 txtNickname = ComponentUtil.createJTextField(bounds); 158 /* get the nickname */ 159 String nickname = Main.pref.get("mapdust.nickname"); 160 if (nickname.isEmpty()) { 161 /* if nickname is empty, then get JOSM username */ 162 nickname = Main.pref.get("mapdust.josmUserName"); 163 } 159 164 if (nickname != null && !nickname.isEmpty()) { 160 165 txtNickname.setText(nickname); … … 171 176 txtDescription.setLineWrap(true); 172 177 txtDescription.setFont(new Font("Times New Roman", Font.PLAIN, 12)); 173 cmpDescription = ComponentUtil.createJScrollPane(txtDescription, 178 cmpDescription = ComponentUtil.createJScrollPane(txtDescription, 174 179 bounds, backgroundColor, false, true); 175 180 } 176 181 /* creates the cancel action */ 177 ExecuteCancel cancelAction = new ExecuteCancel(this, mapdustPlugin.getMapdustGUI()); 182 ExecuteCancel cancelAction = new ExecuteCancel(this, 183 mapdustPlugin.getMapdustGUI()); 178 184 AbstractAction okAction; 179 185 if (type.equals("close")) { … … 181 187 okAction = new ExecuteCloseBug(this, mapdustPlugin.getMapdustGUI()); 182 188 ((ExecuteCloseBug) okAction).addObserver(mapdustPlugin); 183 ((ExecuteCloseBug) okAction).addObserver(mapdustPlugin 184 .getMapdustGUI()); 189 ((ExecuteCloseBug) okAction).addObserver(mapdustPlugin.getMapdustGUI()); 185 190 } else { 186 191 if (type.equals("invalidate")) { … … 194 199 okAction = new ExecuteReOpenBug(this, mapdustPlugin.getMapdustGUI()); 195 200 ((ExecuteReOpenBug) okAction).addObserver(mapdustPlugin); 196 ((ExecuteReOpenBug) okAction).addObserver(mapdustPlugin 197 .getMapdustGUI()); 201 ((ExecuteReOpenBug) okAction).addObserver(mapdustPlugin.getMapdustGUI()); 198 202 } 199 203 } … … 218 222 setSize(340, 210); 219 223 } 220 224 221 225 /** 222 226 * Returns the <code>JScrollPane</code> of the info message. 223 * 227 * 224 228 * @return the cmpMessage 225 229 */ … … 227 231 return this.cmpMessage; 228 232 } 229 233 230 234 /** 231 235 * Returns the <code>JLabel</code> of the nickname 232 * 236 * 233 237 * @return the lblNickname 234 238 */ … … 236 240 return this.lblNickname; 237 241 } 238 242 239 243 /** 240 244 * Returns the <code>JTextField</code> of the nickname 241 * 245 * 242 246 * @return the txtNickname 243 247 */ … … 245 249 return this.txtNickname; 246 250 } 247 251 248 252 /** 249 253 * Returns the <code>JLabel</code> of the comment 250 * 254 * 251 255 * @return the lblComment 252 256 */ … … 254 258 return this.lblComment; 255 259 } 256 260 257 261 /** 258 262 * Returns the <code>JScrollPane</code> of the description 259 * 263 * 260 264 * @return the cmpDescription 261 265 */ … … 263 267 return this.cmpDescription; 264 268 } 265 269 266 270 /** 267 271 * Returns the <code>JTextArea</code> of the description 268 * 272 * 269 273 * @return the txtDescription 270 274 */ … … 272 276 return this.txtDescription; 273 277 } 274 278 275 279 /** 276 280 * Returns the cancel button 277 * 281 * 278 282 * @return the btnCancel 279 283 */ … … 281 285 return this.btnCancel; 282 286 } 283 287 284 288 /** 285 289 * Returns the ok buttons 286 * 290 * 287 291 * @return the btnOk 288 292 */ … … 290 294 return this.btnOk; 291 295 } 292 296 293 297 /** 294 298 * Retruns the message text 295 * 299 * 296 300 * @return the messageText 297 301 */ … … 299 303 return this.messageText; 300 304 } 301 305 302 306 /** 303 307 * Returns the type 304 * 308 * 305 309 * @return the type 306 310 */ … … 308 312 return this.type; 309 313 } 310 314 311 315 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/CommentIssueDialog.java
r25127 r25312 143 143 lblNickname = ComponentUtil.createJLabel("Nickname", font, bounds); 144 144 } 145 String nickname = Main.pref.get("mapdust.nickname");146 145 if (txtNickname == null) { 147 146 Rectangle bounds = new Rectangle(100, 70, 230, 25); 148 147 txtNickname = ComponentUtil.createJTextField(bounds); 148 /* get the nickname */ 149 String nickname = Main.pref.get("mapdust.nickname"); 150 if (nickname.isEmpty()) { 151 /* if nickname is empty, get JOSM username */ 152 nickname = Main.pref.get("mapdust.josmUserName"); 153 } 149 154 if (nickname != null && !nickname.isEmpty()) { 150 155 txtNickname.setText(nickname); … … 169 174 ExecuteCancel cancelAction = new ExecuteCancel(this, 170 175 mapdustPlugin.getMapdustGUI()); 171 btnCancel = ComponentUtil.createJButton("Cancel", bounds, 172 cancelAction); 176 btnCancel = ComponentUtil.createJButton("Cancel", bounds, cancelAction); 173 177 } 174 178 /* creates the ok button */ 175 179 if (btnOk == null) { 176 180 Rectangle bounds = new Rectangle(170, 170, 60, 25); 177 ExecuteCommentBug okAction = 178 new ExecuteCommentBug(this,mapdustPlugin.getMapdustGUI());181 ExecuteCommentBug okAction = new ExecuteCommentBug(this, 182 mapdustPlugin.getMapdustGUI()); 179 183 okAction.addObserver(mapdustPlugin); 180 184 okAction.addObserver(mapdustPlugin.getMapdustGUI()); … … 272 276 return messageText; 273 277 } 274 278 275 279 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/dialog/CreateIssueDialog.java
r25127 r25312 112 112 */ 113 113 public CreateIssueDialog(Point point, MapdustPlugin mapdustPlugin) { 114 this.createIssueText = "In order to create a new bug report you";114 this.createIssueText = "In order to create a new bug report you"; 115 115 this.createIssueText += " need to provide your nickname and a brief"; 116 this.createIssueText += " description for the bug.";116 this.createIssueText += " description for the bug."; 117 117 this.point = point; 118 118 /* set JDialog settings */ … … 121 121 addComponents(mapdustPlugin); 122 122 /* add window listenet */ 123 MapdustButtonPanel btnPanel = mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel(); 123 MapdustButtonPanel btnPanel = 124 mapdustPlugin.getMapdustGUI().getPanel().getBtnPanel(); 124 125 addWindowListener(new WindowClose(this, btnPanel, null)); 125 126 } … … 128 129 * Initializes the dialog default fields. 129 130 */ 130 private void initializeDialog() {131 private void initializeDialog() { 131 132 /* set JDialog settings */ 132 133 setTitle("Create bug report"); … … 145 146 * Displays the dialog. 146 147 */ 147 public void showDialog() {148 setLocationRelativeTo(null);149 getContentPane().setPreferredSize(getSize());150 pack();151 setVisible(true);148 public void showDialog() { 149 setLocationRelativeTo(null); 150 getContentPane().setPreferredSize(getSize()); 151 pack(); 152 setVisible(true); 152 153 } 153 154 … … 161 162 backgroundColor); 162 163 cmpMessage = ComponentUtil.createJScrollPane(txtPane, 163 new Rectangle(10, 164 new Rectangle(10,10, 330, 50), backgroundColor, true, true); 164 165 } 165 166 /* the type label and combo box */ … … 170 171 if (cbbType == null) { 171 172 ComboBoxRenderer renderer = new ComboBoxRenderer(); 172 cbbType = ComponentUtil.createJComboBox(new Rectangle(110, 70, 230, 25),173 renderer, backgroundColor);173 cbbType = ComponentUtil.createJComboBox(new Rectangle(110, 70, 230, 174 25), renderer, backgroundColor); 174 175 } 175 176 /* create the nickname label and text field */ … … 179 180 } 180 181 if (txtNickname == null) { 181 txtNickname = ComponentUtil.createJTextField(new Rectangle(110, 110, 230, 25)); 182 /* nickname was set before */ 182 txtNickname = ComponentUtil.createJTextField(new Rectangle(110, 110, 183 230,25)); 184 /* get the nickname */ 183 185 String nickname = Main.pref.get("mapdust.nickname"); 186 if (nickname.isEmpty()) { 187 /* if nickname is empty, get the JOSM username */ 188 nickname = Main.pref.get("mapdust.josmUserName"); 189 } 184 190 if (nickname != null && !nickname.isEmpty()) { 185 191 txtNickname.setText(nickname); … … 196 202 txtDescription.setLineWrap(true); 197 203 cmpDescription = ComponentUtil.createJScrollPane(txtDescription, 198 new Rectangle(110, 150, 230, 50), backgroundColor, false, true); 204 new Rectangle(110, 150, 230, 50), backgroundColor, false, 205 true); 199 206 } 200 207 /* creates the cancel button */ -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustHelpPanel.java
r25142 r25312 43 43 import org.openstreetmap.josm.Main; 44 44 import org.openstreetmap.josm.plugins.mapdust.gui.component.util.ComponentUtil; 45 import org.openstreetmap.josm.plugins.mapdust.util.Configuration; 45 46 import org.openstreetmap.josm.tools.OpenBrowser; 46 import org.openstreetmap.josm.plugins.mapdust.util.Configuration;47 47 48 48 49 49 /** 50 50 * Defines the JPanel which displays the Help. 51 * 51 * 52 52 * @author Bea 53 53 */ 54 54 public class MapdustHelpPanel extends JPanel implements HyperlinkListener { 55 55 56 56 /** The serial version UID */ 57 57 private static final long serialVersionUID = 1L; 58 58 59 59 /** 60 60 * Builds a <code>MapdustDescriptionPanel</code> object … … 64 64 String name = "Help"; 65 65 setName(name); 66 String txt = "<html>"; 67 txt += "<font style='font-size:10px' face='Times New Roman'>"; 68 txt += "<b>To add bugs on the map you need to activate "; 69 txt += "the MapDust layer in the Layer List Dialog. "; 70 txt += "Click <a href='' target='_blank'>here</a> for more help."; 71 txt += "</b></font></html>"; 66 String txt = buildText(); 72 67 JEditorPane txtHelp = new JEditorPane("text/html", ""); 73 68 txtHelp.setEditorKit(new HTMLEditorKit()); … … 75 70 txtHelp.setText(txt); 76 71 txtHelp.addHyperlinkListener(this); 77 JScrollPane cmpDescription = 78 ComponentUtil.createJScrollPane(txtHelp, null, Color.white, 79 true, true); 72 JScrollPane cmpDescription = ComponentUtil.createJScrollPane(txtHelp, 73 null, Color.white, true, true); 80 74 cmpDescription.setPreferredSize(new Dimension(100, 100)); 81 75 add(cmpDescription, BorderLayout.CENTER); 82 76 } 83 77 84 78 @Override 85 79 public void hyperlinkUpdate(HyperlinkEvent event) { … … 95 89 } 96 90 } 97 91 92 /** 93 * Builds the text of the Help panel. This text contains general information 94 * related to the MapDust plugin. 95 * 96 * @return 97 */ 98 private String buildText() { 99 String version = Main.pref.get("mapdust.version"); 100 String localVersion = Main.pref.get("mapdust.localVersion"); 101 String txt = "<html>"; 102 txt += "<font style='font-size:10px' face='Times New Roman'>"; 103 txt += "<b>You are using MapDust version "; 104 txt += "<i style='color:red;font-size:10px'>"; 105 if (version.equals(localVersion)) { 106 txt += version + "</i>.</b><br>"; 107 } else { 108 txt += localVersion + "</i>. There is an update available. "; 109 txt += "Please update to version "; 110 txt += "<i style='color:red;font-size:10px'>" + version; 111 txt += "</i> to benefit from the latest improvements.</b><br>"; 112 } 113 txt += "<b>To add bugs on the map you need to activate "; 114 txt += "the MapDust layer in the Layer List Dialog."; 115 txt += "Click <a href='' target='_blank'>here</a> for more help."; 116 txt += "</b></font></html>"; 117 return txt; 118 } 119 98 120 }
Note:
See TracChangeset
for help on using the changeset viewer.