[josm-dev] patch for wmsplugin to keep menu items enabled when changing prefs
Bodo Meissner
bodo at bodo-m.de
Wed Jul 2 09:47:13 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello developers,
I found that the WMS menu items are disabled after pressing OK in the
preferences dialog. I have to restart JOSM or delete and re-open all layers
to get them enabled again.
When the WMSPlugin is initialized or I change preferences, refreshMenu()
is called to re-create menu entries. It calls setEnabledAll(false) to
disable them.
The only way to enable the menu entries is a call to mapFrameInitialized()
with oldFrame==null and newFrame!=null.
I think after changing the preferences the enabled state of the menu items
should be the same as before.
I created a small patch for WMSPlugin.java that stores the state in
setEnabledAll() and uses the stored state instead of false in refreshMenu().
With this change the WMS menu items will stay enabled when changing prefs
with a map layer loaded and stay disabled when changing prefs without a
map frame.
Bodo
Index: /home/mei/ews/osm/osm/applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java
===================================================================
- --- /home/mei/ews/osm/osm/applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java (revision 8630)
+++ /home/mei/ews/osm/osm/applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java (working copy)
@@ -33,6 +33,9 @@
static JMenu wmsJMenu;
static ArrayList<WMSInfo> wmsList = new ArrayList<WMSInfo>();
+
+ // remember state of menu item to restore on changed preferences
+ static private boolean menuEnabled = false;
public WMSPlugin() {
refreshMenu();
@@ -117,7 +120,7 @@
}));
wmsJMenu.addSeparator();
wmsJMenu.add(new JMenuItem(new Help_WMSmenuAction()));
- - setEnabledAll(false);
+ setEnabledAll(menuEnabled);
}
public static Grabber getGrabber(String wmsurl) {
@@ -134,6 +137,7 @@
if(item != null) item.setEnabled(isEnabled);
}
+ menuEnabled = isEnabled;
}
public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIa0COnMz9fgzDSqcRAhAgAJ47TbvJTGJIwiptBAQTcF//6bOiewCggMgE
SH/LLu2apeso9zdGQqJKZys=
=ag77
-----END PGP SIGNATURE-----
More information about the josm-dev
mailing list