IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/ConfigKey.java b/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/ConfigKey.java
new file mode 100644
|
-
|
+
|
|
| | 1 | package org.openstreetmap.josm.plugins.buildings_tools; |
| | 2 | |
| | 3 | enum ConfigKey { |
| | 4 | TAGS("buildings_tools.tags"), |
| | 5 | SHAPE("buildings_tools.shape"), |
| | 6 | BBMODE("buildings_tools.bbmode"), |
| | 7 | SOFTCURSOR("buildings_tools.softcursor"), |
| | 8 | NOCLICKDRAG("buildings_tools.noclickdrag"), |
| | 9 | ADDRNODE("buildings_tools.addrNode"); |
| | 10 | |
| | 11 | private final String key; |
| | 12 | |
| | 13 | ConfigKey(String key) { |
| | 14 | this.key = key; |
| | 15 | } |
| | 16 | |
| | 17 | public String getKey() { |
| | 18 | return key; |
| | 19 | } |
| | 20 | } |
| | 21 | No newline at end of file |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/DrawBuildingAction.java b/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/DrawBuildingAction.java
|
a
|
b
|
|
| 39 | 39 | import org.openstreetmap.josm.gui.layer.OsmDataLayer; |
| 40 | 40 | import org.openstreetmap.josm.gui.util.KeyPressReleaseListener; |
| 41 | 41 | import org.openstreetmap.josm.gui.util.ModifierExListener; |
| | 42 | import org.openstreetmap.josm.spi.preferences.Config; |
| | 43 | import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener; |
| 42 | 44 | import org.openstreetmap.josm.tools.Geometry; |
| 43 | 45 | import org.openstreetmap.josm.tools.ImageProvider; |
| 44 | 46 | import org.openstreetmap.josm.tools.Logging; |
| … |
… |
|
| 50 | 52 | None, Drawing, DrawingWidth, DrawingAngFix |
| 51 | 53 | } |
| 52 | 54 | |
| 53 | | private final Cursor cursorCrosshair; |
| 54 | 55 | private final Cursor cursorJoinNode; |
| 55 | 56 | private final Cursor cursorJoinWay; |
| 56 | 57 | private Cursor currCursor; |
| … |
… |
|
| 65 | 66 | |
| 66 | 67 | final transient Building building = new Building(); |
| 67 | 68 | |
| | 69 | private final PreferenceChangedListener shapeChangeListener = event -> updCursor(); |
| | 70 | |
| 68 | 71 | public DrawBuildingAction() { |
| 69 | 72 | super(tr("Draw buildings"), "building", tr("Draw buildings"), |
| 70 | 73 | Shortcut.registerShortcut("mapmode:buildings", |
| 71 | 74 | tr("Mode: {0}", tr("Draw buildings")), |
| 72 | 75 | KeyEvent.VK_B, Shortcut.DIRECT), |
| 73 | | getCursor()); |
| | 76 | // Set super.cursor to crosshair without overlay because super.cursor is final, |
| | 77 | // but we use two different cursors with overlays for rectangular and circular buildings |
| | 78 | // the actual cursor is drawn in enterMode() |
| | 79 | ImageProvider.getCursor("crosshair", null)); |
| 74 | 80 | |
| 75 | | cursorCrosshair = getCursor(); |
| | 81 | currCursor = getCursor(); |
| 76 | 82 | cursorJoinNode = ImageProvider.getCursor("crosshair", "joinnode"); |
| 77 | 83 | cursorJoinWay = ImageProvider.getCursor("crosshair", "joinway"); |
| 78 | | currCursor = cursorCrosshair; |
| 79 | 84 | } |
| 80 | 85 | |
| 81 | 86 | private static Cursor getCursor() { |
| … |
… |
|
| 133 | 138 | @Override |
| 134 | 139 | public void enterMode() { |
| 135 | 140 | super.enterMode(); |
| | 141 | |
| 136 | 142 | MapFrame map = MainApplication.getMap(); |
| 137 | 143 | if (getLayerManager().getEditDataSet() == null) { |
| 138 | 144 | map.selectSelectTool(false); |
| 139 | 145 | return; |
| 140 | 146 | } |
| 141 | 147 | selectedColor = new NamedColorProperty(marktr("selected"), selectedColor).get(); |
| 142 | | currCursor = cursorCrosshair; |
| 143 | 148 | map.mapView.addMouseListener(this); |
| 144 | 149 | map.mapView.addMouseMotionListener(this); |
| 145 | 150 | map.mapView.addTemporaryLayer(this); |
| 146 | 151 | map.keyDetector.addKeyListener(this); |
| 147 | 152 | map.keyDetector.addModifierExListener(this); |
| 148 | 153 | SelectionEventManager.getInstance().addSelectionListener(this); |
| | 154 | Config.getPref().addKeyPreferenceChangeListener(ConfigKey.SHAPE.getKey(), shapeChangeListener); |
| | 155 | |
| 149 | 156 | updateSnap(getLayerManager().getEditDataSet().getSelected()); |
| | 157 | // super.enterMode() draws the basic cursor. Overwrite it with the cursor for the current building mode. |
| | 158 | updCursor(); |
| 150 | 159 | } |
| 151 | 160 | |
| 152 | 161 | @Override |
| … |
… |
|
| 159 | 168 | map.keyDetector.removeKeyListener(this); |
| 160 | 169 | map.keyDetector.removeModifierExListener(this); |
| 161 | 170 | SelectionEventManager.getInstance().removeSelectionListener(this); |
| | 171 | Config.getPref().removeKeyPreferenceChangeListener(ConfigKey.SHAPE.getKey(), shapeChangeListener); |
| | 172 | |
| 162 | 173 | if (mode != Mode.None) |
| 163 | 174 | map.mapView.repaint(); |
| 164 | 175 | mode = Mode.None; |
| … |
… |
|
| 385 | 396 | } |
| 386 | 397 | |
| 387 | 398 | private void updCursor() { |
| 388 | | if (mousePos == null) |
| 389 | | return; |
| 390 | 399 | if (!MainApplication.isDisplayingMapView()) |
| 391 | 400 | return; |
| 392 | | Node n = null; |
| 393 | | if (!ctrl) { |
| 394 | | n = MainApplication.getMap().mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable); |
| | 401 | |
| | 402 | if (!ctrl && (mousePos != null)) { |
| | 403 | Node n = MainApplication.getMap().mapView.getNearestNode(mousePos, OsmPrimitive::isSelectable); |
| 395 | 404 | if (n != null) { |
| 396 | 405 | setCursor(cursorJoinNode); |
| 397 | 406 | return; |
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/ToolSettings.java b/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/ToolSettings.java
|
a
|
b
|
|
| 19 | 19 | // Hide default constructor for utils classes |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | | public static final BooleanProperty PROP_USE_ADDR_NODE = new BooleanProperty("buildings_tools.addrNode", false); |
| | 22 | static final BooleanProperty PROP_USE_ADDR_NODE = new BooleanProperty(ConfigKey.ADDRNODE.getKey(), false); |
| 23 | 23 | |
| 24 | 24 | public enum Shape { |
| 25 | 25 | CIRCLE, RECTANGLE |
| … |
… |
|
| 71 | 71 | values.add(entry.getKey()); |
| 72 | 72 | values.add(entry.getValue()); |
| 73 | 73 | } |
| 74 | | Config.getPref().putList("buildings_tools.tags", values); |
| | 74 | Config.getPref().putList(ConfigKey.TAGS.getKey(), values); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | private static void loadTags() { |
| 78 | 78 | TAGS.clear(); |
| 79 | | Collection<String> values = Config.getPref().getList("buildings_tools.tags", |
| | 79 | Collection<String> values = Config.getPref().getList(ConfigKey.TAGS.getKey(), |
| 80 | 80 | Arrays.asList("building", "yes")); |
| 81 | 81 | try { |
| 82 | 82 | for (Iterator<String> iterator = values.iterator(); iterator.hasNext();) { |
| … |
… |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | public static void saveShape(Shape shape) { |
| 91 | | Config.getPref().put("buildings_tool.shape", shape.name()); |
| | 91 | Config.getPref().put(ConfigKey.SHAPE.getKey(), shape.name()); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | private static Shape loadShape() { |
| 95 | | String shape = Config.getPref().get("buildings_tool.shape"); |
| | 95 | String shape = Config.getPref().get(ConfigKey.SHAPE.getKey()); |
| 96 | 96 | if (ToolSettings.Shape.CIRCLE.name().equals(shape)) { |
| 97 | 97 | ToolSettings.shape = Shape.CIRCLE; |
| 98 | 98 | return Shape.CIRCLE; |
| … |
… |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public static void setBBMode(boolean bbmode) { |
| 106 | | Config.getPref().putBoolean("buildings_tools.bbmode", bbmode); |
| | 106 | Config.getPref().putBoolean(ConfigKey.BBMODE.getKey(), bbmode); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | public static boolean isBBMode() { |
| 110 | | return Config.getPref().getBoolean("buildings_tools.bbmode", false); |
| | 110 | return Config.getPref().getBoolean(ConfigKey.BBMODE.getKey(), false); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public static void setSoftCursor(boolean softCursor) { |
| 114 | | Config.getPref().putBoolean("buildings_tools.softcursor", softCursor); |
| | 114 | Config.getPref().putBoolean(ConfigKey.SOFTCURSOR.getKey(), softCursor); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public static boolean isSoftCursor() { |
| 118 | | return Config.getPref().getBoolean("buildings_tools.softcursor", false); |
| | 118 | return Config.getPref().getBoolean(ConfigKey.SOFTCURSOR.getKey(), false); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public static boolean isAutoSelect() { |
| … |
… |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public static boolean isNoClickAndDrag() { |
| 130 | | return Config.getPref().getBoolean("buildings_tools.noclickdrag", false); |
| | 130 | return Config.getPref().getBoolean(ConfigKey.NOCLICKDRAG.getKey(), false); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public static void setNoClickAndDrag(boolean noClickDrag) { |
| 134 | | Config.getPref().putBoolean("buildings_tools.noclickdrag", noClickDrag); |
| | 134 | Config.getPref().putBoolean(ConfigKey.NOCLICKDRAG.getKey(), noClickDrag); |
| 135 | 135 | } |
| 136 | 136 | } |