Changeset 28630 in osm for applications/editors/josm/plugins/mapdust/src
- Timestamp:
- 2012-08-26T02:47:21+02:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/MapdustPlugin.java
r27852 r28630 27 27 */ 28 28 package org.openstreetmap.josm.plugins.mapdust; 29 30 29 31 30 import static org.openstreetmap.josm.tools.I18n.tr; … … 64 63 import org.openstreetmap.josm.tools.Shortcut; 65 64 66 67 65 /** 68 66 * This is the main class of the MapDust plug-in. Defines the MapDust plug-in … … 84 82 private CreateBugDialog dialog; 85 83 86 /** The JOSM user identity manager, it is used for obtaining the user name */87 private final JosmUserIdentityManager userIdentityManager;88 89 84 /** The list of <code>MapdustBug</code> objects */ 90 85 private List<MapdustBug> mapdustBugList; … … 92 87 /** The bounding box from where the MapDust bugs are down-loaded */ 93 88 private BoundingBox bBox; 89 90 /** The shortcut to access MapDust GUI */ 91 private Shortcut shortcut; 94 92 95 93 /** … … 110 108 public MapdustPlugin(PluginInformation info) { 111 109 super(info); 112 this.userIdentityManager = JosmUserIdentityManager.getInstance();113 110 this.filter = null; 114 111 this.bBox = null; … … 123 120 */ 124 121 private void initializePlugin() { 125 /* create MapDust GUI*/126 Shortcutshortcut = Shortcut.registerShortcut("MapDust", tr("Toggle: {0}", tr("Open MapDust")),122 /* create MapDust Shortcut */ 123 this.shortcut = Shortcut.registerShortcut("MapDust", tr("Toggle: {0}", tr("Open MapDust")), 127 124 KeyEvent.VK_0, Shortcut.ALT_SHIFT); 128 String name = "MapDust bug reports";129 String tooltip = "Activates the MapDust bug reporter plugin";130 mapdustGUI = new MapdustGUI(tr(name), "mapdust_icon.png", tr(tooltip),131 shortcut, 150, this);132 125 /* add default values for static variables */ 133 126 Main.pref.put("mapdust.pluginState", MapdustPluginState.ONLINE.getValue()); … … 136 129 Main.pref.put("mapdust.version", getPluginInformation().version); 137 130 Main.pref.put("mapdust.localVersion",getPluginInformation().localversion); 131 Main.pref.addPreferenceChangeListener(this); 138 132 } 139 133 … … 148 142 @Override 149 143 public void mapFrameInitialized(MapFrame oldMapFrame, MapFrame newMapFrame) { 150 if (newMapFrame == null) { 144 if (newMapFrame != null) { 145 /* add MapDust dialog window */ 146 mapdustGUI = new MapdustGUI(tr("MapDust bug reports"), "mapdust_icon.png", 147 tr("Activates the MapDust bug reporter plugin"), shortcut, 150, this); 148 /* add MapdustGUI */ 149 mapdustGUI.setBounds(newMapFrame.getBounds()); 150 mapdustGUI.addObserver(this); 151 newMapFrame.addToggleDialog(mapdustGUI); 152 /* add Listeners */ 153 NavigatableComponent.addZoomChangeListener(this); 154 MapView.addLayerChangeListener(this); 155 newMapFrame.mapView.addMouseListener(this); 156 /* put username to preferences */ 157 Main.pref.put("mapdust.josmUserName", JosmUserIdentityManager.getInstance().getUserName()); 158 } else { 151 159 /* if new MapFrame is null, remove listener */ 160 oldMapFrame.mapView.removeMouseListener(this); 152 161 MapView.removeLayerChangeListener(this); 153 162 NavigatableComponent.removeZoomChangeListener(this); 154 } else { 155 /* add MapDust dialog window */ 156 if (Main.map != null && Main.map.mapView != null) { 157 /* add MapdustGUI */ 158 mapdustGUI.setBounds(newMapFrame.getBounds()); 159 mapdustGUI.addObserver(this); 160 newMapFrame.addToggleDialog(mapdustGUI); 161 /* add Listeners */ 162 NavigatableComponent.addZoomChangeListener(this); 163 MapView.addLayerChangeListener(this); 164 Main.map.mapView.addMouseListener(this); 165 Main.pref.addPreferenceChangeListener(this); 166 /* put username to preferences */ 167 Main.pref.put("mapdust.josmUserName", 168 userIdentityManager.getUserName()); 169 } 163 mapdustGUI.removeObserver(this); 164 mapdustGUI = null; 170 165 } 171 166 } … … 183 178 @Override 184 179 public void preferenceChanged(PreferenceChangeEvent event) { 185 if (mapdustGUI .isShowing() && !wasError && mapdustLayer != null180 if (mapdustGUI != null && mapdustGUI.isShowing() && !wasError && mapdustLayer != null 186 181 && mapdustLayer.isVisible()) { 187 182 if (event.getKey().equals("osm-server.username")) { 188 String newUserName = userIdentityManager.getUserName();183 String newUserName = JosmUserIdentityManager.getInstance().getUserName(); 189 184 String oldUserName = Main.pref.get("mapdust.josmUserName"); 190 185 String nickname = Main.pref.get("mapdust.nickname"); … … 458 453 NavigatableComponent.removeZoomChangeListener(this); 459 454 Main.map.mapView.removeLayer(layer); 460 Main.map.remove(mapdustGUI);461 455 if (mapdustGUI != null) { 456 Main.map.remove(mapdustGUI); 462 457 mapdustGUI.destroy(); 463 458 } … … 476 471 @Override 477 472 public void zoomChanged() { 478 if (mapdustGUI .isShowing() && !wasError) {473 if (mapdustGUI != null && mapdustGUI.isShowing() && !wasError) { 479 474 boolean download = true; 480 475 BoundingBox curentBBox = getBBox(); … … 510 505 this.filter = filter; 511 506 } 512 if (mapdustGUI .isShowing() && !wasError) {507 if (mapdustGUI != null && mapdustGUI.isShowing() && !wasError) { 513 508 updatePluginData(); 514 509 } -
applications/editors/josm/plugins/mapdust/src/org/openstreetmap/josm/plugins/mapdust/gui/component/panel/MapdustHelpPanel.java
r25591 r28630 98 98 */ 99 99 private String buildText() { 100 String version = Main.pref.get("mapdust.version");101 String localVersion = Main.pref.get("mapdust.localVersion");100 Integer version = Integer.decode(Main.pref.get("mapdust.version")); 101 Integer localVersion = Integer.decode(Main.pref.get("mapdust.localVersion")); 102 102 String txt = "<html>"; 103 103 txt += "<font style='font-size:10px' face='Times New Roman'>"; 104 104 txt += "<b>You are using MapDust version "; 105 105 txt += "<i style='color:red;font-size:10px'>"; 106 if (version .equals(localVersion)) {106 if (version <= localVersion) { 107 107 txt += version + "</i>.</b><br>"; 108 108 } else {
Note:
See TracChangeset
for help on using the changeset viewer.