Changeset 14542 in josm
- Timestamp:
- 2018-12-09T23:58:32+01:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r14397 r14542 130 130 if (!isEnabled()) 131 131 return; 132 133 DataSet ds = getLayerManager().getEditDataSet(); 132 runOn(getLayerManager().getEditDataSet()); 133 } 134 135 /** 136 * Run the action on the given dataset. 137 * @param ds dataset 138 * @since 14542 139 */ 140 public static void runOn(DataSet ds) { 134 141 Collection<OsmPrimitive> sel = ds.getSelected(); 135 142 List<Node> nodes = OsmPrimitive.getFilteredList(sel, Node.class); -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r14397 r14542 26 26 import org.openstreetmap.josm.command.SplitWayCommand; 27 27 import org.openstreetmap.josm.data.UndoRedoHandler; 28 import org.openstreetmap.josm.data.osm.DataSet; 28 29 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 29 30 import org.openstreetmap.josm.data.osm.Node; … … 66 67 @Override 67 68 public void actionPerformed(ActionEvent e) { 69 runOn(getLayerManager().getEditDataSet()); 70 } 71 72 /** 73 * Run the action on the given dataset. 74 * @param ds dataset 75 * @since 14542 76 */ 77 public static void runOn(DataSet ds) { 68 78 69 79 if (SegmentToKeepSelectionDialog.DISPLAY_COUNT.get() > 0) { … … 73 83 } 74 84 75 Collection<OsmPrimitive> selection = getLayerManager().getEditDataSet().getSelected();85 Collection<OsmPrimitive> selection = ds.getSelected(); 76 86 77 87 List<Node> selectedNodes = OsmPrimitive.getFilteredList(selection, Node.class); … … 284 294 List<? extends PrimitiveId> newSel = result.getNewSelection(); 285 295 if (newSel != null && !newSel.isEmpty()) { 286 MainApplication.getLayerManager().getEditDataSet().setSelected(newSel);296 way.getDataSet().setSelected(newSel); 287 297 } 288 298 } -
trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java
r14138 r14542 17 17 import org.openstreetmap.josm.data.osm.Node; 18 18 import org.openstreetmap.josm.data.osm.Way; 19 import org.openstreetmap.josm.gui.MainApplication;20 import org.openstreetmap.josm.gui.layer.OsmDataLayer;21 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 22 20 import org.openstreetmap.josm.tools.GeoProperty; … … 38 36 @Rule 39 37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 40 public JOSMTestRules test = new JOSMTestRules().projection() .main();38 public JOSMTestRules test = new JOSMTestRules().projection(); 41 39 42 40 /** … … 49 47 public void testTicket7421case0() throws ReflectiveOperationException { 50 48 DataSet dataSet = new DataSet(); 51 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);52 49 53 50 Node n1 = new Node(new EastNorth(0, 0)); … … 64 61 dataSet.addSelected(w); 65 62 66 CreateCircleAction action = new CreateCircleAction(); 67 action.setEnabled(true); 68 try { 69 MainApplication.getLayerManager().addLayer(layer); 70 action.actionPerformed(null); 71 } finally { 72 // Ensure we clean the place before leaving, even if test fails. 73 MainApplication.getLayerManager().removeLayer(layer); 74 } 63 CreateCircleAction.runOn(dataSet); 75 64 76 65 // Expected result: Dataset contain one closed way, clockwise … … 115 104 public void testTicket7421case1() throws ReflectiveOperationException { 116 105 DataSet dataSet = new DataSet(); 117 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);118 106 119 107 Node n1 = new Node(new EastNorth(0, 0)); … … 135 123 136 124 try { 137 CreateCircleAction action = new CreateCircleAction(); 138 action.setEnabled(true); 139 try { 140 MainApplication.getLayerManager().addLayer(layer); 141 action.actionPerformed(null); 142 } finally { 143 // Ensure we clean the place before leaving, even if test fails. 144 MainApplication.getLayerManager().removeLayer(layer); 145 } 125 CreateCircleAction.runOn(dataSet); 146 126 147 127 // Expected result: Dataset contain one closed way, clockwise -
trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
r12828 r14542 7 7 import java.util.Arrays; 8 8 9 import org.junit.Before;10 9 import org.junit.Rule; 11 10 import org.junit.Test; … … 14 13 import org.openstreetmap.josm.data.osm.Node; 15 14 import org.openstreetmap.josm.data.osm.Way; 16 import org.openstreetmap.josm.gui.MainApplication;17 import org.openstreetmap.josm.gui.layer.OsmDataLayer;18 15 import org.openstreetmap.josm.testutils.JOSMTestRules; 19 16 … … 25 22 public final class SplitWayActionTest { 26 23 27 /** Class under test. */28 private static SplitWayAction action;29 30 24 /** 31 25 * Setup test. … … 33 27 @Rule 34 28 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 35 public JOSMTestRules test = new JOSMTestRules().main().projection(); 36 37 /** 38 * Setup test. 39 */ 40 @Before 41 public void setUp() { 42 if (action == null) { 43 action = MainApplication.getMenu().splitWay; 44 action.setEnabled(true); 45 } 46 } 29 public JOSMTestRules test = new JOSMTestRules().projection(); 47 30 48 31 /** … … 53 36 public void testTicket11184() { 54 37 DataSet dataSet = new DataSet(); 55 OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);56 38 57 39 Node n1 = new Node(new EastNorth(0, 0)); … … 81 63 dataSet.addSelected(w2); 82 64 83 try { 84 MainApplication.getLayerManager().addLayer(layer); 85 action.actionPerformed(null); 86 } finally { 87 // Ensure we clean the place before leaving, even if test fails. 88 MainApplication.getLayerManager().removeLayer(layer); 89 } 65 SplitWayAction.runOn(dataSet); 90 66 91 67 // Ensures 3 ways.
Note:
See TracChangeset
for help on using the changeset viewer.