Changeset 34816 in osm for applications/editors/josm/plugins
- Timestamp:
- 2019-01-12T11:52:51+01:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitObjectAction.java
r34812 r34816 58 58 @Override 59 59 public void actionPerformed(ActionEvent e) { 60 60 DataSet ds = getLayerManager().getEditDataSet(); 61 61 if (!checkSelection(ds.getSelected())) { 62 62 showWarningNotification(tr("The current selection cannot be used for splitting.")); -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/SplitOnIntersectionsAction.java
r34812 r34816 37 37 private static final String TOOL_DESC = tr("Split adjacent ways on T-intersections"); 38 38 public SplitOnIntersectionsAction() { 39 40 41 42 39 super(TITLE, "dumbutils/splitonintersections", TOOL_DESC, 40 Shortcut.registerShortcut("tools:splitonintersections", tr("Tool: {0}", tr("Split adjacent ways")), 41 KeyEvent.VK_P, Shortcut.ALT_CTRL_SHIFT), 42 true); 43 43 } 44 44 … … 95 95 SplitWayCommand split = SplitWayCommand.split(entry.getKey(), entry.getValue(), selectedWays); 96 96 if (split != null) { 97 98 99 100 97 // execute, we need the result, see also #16006 98 UndoRedoHandler.getInstance().add(split); 99 selectedWays.remove(split.getOriginalWay()); 100 selectedWays.addAll(split.getNewWays()); 101 101 list.add(split); 102 102 } … … 104 104 105 105 if (!list.isEmpty()) { 106 107 108 109 110 111 112 106 if (list.size() > 1) { 107 // create a single command for the previously executed commands 108 SequenceCommand seq = new SequenceCommand(TITLE, list); 109 for (int i = 0; i < list.size(); i++) { 110 UndoRedoHandler.getInstance().undo(); 111 } 112 UndoRedoHandler.getInstance().add(seq); 113 113 } 114 114 getLayerManager().getEditDataSet().clearSelection(); -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/TagSourceAction.java
r34792 r34816 44 44 UndoRedoHandler.getInstance().add(new ChangePropertyCommand(selection, "source", source)); 45 45 } 46 46 47 @Override 47 48 protected void updateEnabledState() { … … 53 54 } 54 55 55 56 56 @Override 57 57 protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) { 58 58 if (!selectionBuf.isEmpty()) { 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 59 String newSource = null; 60 for (OsmPrimitive p : selectionBuf) { 61 String s = p.get("source"); 62 if (s != null) { 63 if (newSource == null) 64 newSource = s; 65 else { 66 if (!newSource.equals(s)) { 67 newSource = null; 68 break; 69 } 70 } 71 } 72 } 73 if (newSource != null && !newSource.isEmpty()) { 74 74 source = newSource; 75 75 Config.getPref().put("sourcetag.value", source); 76 76 } 77 77 } 78 78 selectionBuf = new ArrayList<>(selection); -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/replacegeometry/ReplaceGeometryUtils.java
r34812 r34816 132 132 */ 133 133 public static ReplaceGeometryCommand buildUpgradeNodeCommand(Node subjectNode, OsmPrimitive referenceObject) { 134 134 if (!subjectNode.getParentWays().isEmpty()) { 135 135 throw new ReplaceGeometryException(tr("Node belongs to way(s), cannot replace.")); 136 136 } -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/NodeWayUtils.java
r34814 r34816 48 48 static void addNeighbours(Way w, Node n, Collection<Node> nodes) { 49 49 if (!n.getParentWays().contains(w)) 50 50 return; 51 51 52 52 List<Node> nodeList = w.getNodes(); … … 469 469 // select nodes and ways inside selected ways and multipolygons 470 470 for (OsmPrimitive p: selected) { 471 472 addAllInsideWay(dataset, (Way)p, newWays, newNodes);473 471 if (p instanceof Way) { 472 addAllInsideWay(dataset, (Way) p, newWays, newNodes); 473 } 474 474 } 475 475 for (OsmPrimitive p: selected) { 476 if (!(p instanceof Relation) || !p.isMultipolygon())477 continue;478 addAllInsideMultipolygon(dataset, (Relation) p, newWays, newNodes);476 if ((p instanceof Relation) && p.isMultipolygon()) { 477 addAllInsideMultipolygon(dataset, (Relation) p, newWays, newNodes); 478 } 479 479 } 480 480 if (ignoreNodesOfFoundWays) { -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModNodesAction.java
r34812 r34816 45 45 if (num == 0) return; 46 46 int k = 0, idx; 47 // check if executed again, we cycle through all available commands48 if (lastCmd != null && !selection.isEmpty() 47 // check if executed again, we cycle through all available commands 48 if (lastCmd != null && !selection.isEmpty()) { 49 49 idx = UndoRedoHandler.getInstance().commands.lastIndexOf(lastCmd); 50 50 } else { … … 57 57 cmd = UndoRedoHandler.getInstance().commands.get(idx); 58 58 if (cmd.getAffectedDataSet() == ds) { 59 60 61 62 63 64 65 66 67 68 59 Collection<? extends OsmPrimitive> pp = cmd.getParticipatingPrimitives(); 60 nodes.clear(); 61 for (OsmPrimitive p : pp) { // find all affected ways 62 if (p instanceof Node && !p.isDeleted()) nodes.add((Node) p); 63 } 64 if (!nodes.isEmpty() && !ds.getSelectedNodes().containsAll(nodes)) { 65 ds.setSelected(nodes); 66 lastCmd = cmd; // remember last used command and last selection 67 return; 68 } 69 69 } 70 70 k++; -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/SelectModWaysAction.java
r34812 r34816 45 45 int k = 0, idx; 46 46 // check if executed again, we cycle through all available commands 47 if (lastCmd != null && !ds.getSelectedWays().isEmpty() 47 if (lastCmd != null && !ds.getSelectedWays().isEmpty()) { 48 48 idx = UndoRedoHandler.getInstance().commands.lastIndexOf(lastCmd); 49 49 } else { … … 56 56 cmd = UndoRedoHandler.getInstance().commands.get(idx); 57 57 if (cmd.getAffectedDataSet() == ds) { 58 59 60 61 62 63 64 65 66 67 68 58 Collection<? extends OsmPrimitive> pp = cmd.getParticipatingPrimitives(); 59 ways.clear(); 60 for (OsmPrimitive p : pp) { 61 // find all affected ways 62 if (p instanceof Way && !p.isDeleted()) ways.add((Way) p); 63 } 64 if (!ways.isEmpty() && !ds.getSelectedWays().containsAll(ways)) { 65 ds.setSelected(ways); 66 lastCmd = cmd; // remember last used command and last selection 67 return; 68 } 69 69 } 70 70 k++; -
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/selection/UndoSelectionAction.java
r34812 r34816 40 40 if (history == null || history.isEmpty()) return; // empty history 41 41 if (lastSel != null) { 42 43 44 45 46 47 42 Collection<OsmPrimitive> selection = ds.getSelected(); 43 if (lastSel.size() == selection.size() && selection.containsAll(lastSel)) { 44 // repeated action 45 } else { 46 index = -1; 47 } 48 48 } 49 49 … … 61 61 k++; 62 62 if (!newSel.isEmpty()) { 63 64 65 66 67 68 63 Collection<OsmPrimitive> oldSel = ds.getSelected(); 64 if (oldSel.size() == newSel.size() && newSel.containsAll(oldSel)) { 65 // ignore no-change selection 66 continue; 67 } 68 break; 69 69 } 70 70 } … … 78 78 @Override 79 79 protected void updateEnabledState() { 80 81 82 83 80 DataSet ds = getLayerManager().getEditDataSet(); 81 lastSel = null; 82 index = -1; 83 setEnabled(ds != null && ds.getSelectionHistory().isEmpty()); 84 84 } 85 85 }
Note:
See TracChangeset
for help on using the changeset viewer.