Changeset 9661 in josm
- Timestamp:
- 2016-01-28T09:29:14+01:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/RefreshAction.java
r9659 r9661 14 14 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 15 15 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 16 import org.openstreetmap.josm.gui.dialogs.relation. GenericRelationEditor;16 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor; 17 17 import org.openstreetmap.josm.gui.dialogs.relation.MemberTable; 18 18 import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel; 19 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;20 19 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 21 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; … … 47 46 putValue(SMALL_ICON, ImageProvider.get("dialogs/refresh")); 48 47 putValue(NAME, tr("Refresh")); 49 getEditor().getRootPane().getActionMap().put("refresh", this); 50 getEditor().getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), "refresh"); 48 if (editor instanceof JComponent) { 49 ((JComponent) editor).getRootPane().getActionMap().put("refresh", this); 50 ((JComponent) editor).getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), "refresh"); 51 } 51 52 Main.main.undoRedo.addCommandQueueListener(this); 52 53 updateEnabledState(); 53 }54 55 private GenericRelationEditor getEditor() {56 return (GenericRelationEditor) editor;57 54 } 58 55 … … 70 67 if (isEditorDirty() && confirmDiscardDirtyData() != 0) 71 68 return; 72 getEditor().reloadDataFromRelation();69 editor.reloadDataFromRelation(); 73 70 } 74 71 -
trunk/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java
r8857 r9661 67 67 } finally { 68 68 // Ensure we clean the place before leaving, even if test fails. 69 Main.ma p.mapView.removeLayer(layer);69 Main.main.removeLayer(layer); 70 70 } 71 71 … … 106 106 } finally { 107 107 // Ensure we clean the place before leaving, even if test fails. 108 Main.ma p.mapView.removeLayer(layer);108 Main.main.removeLayer(layer); 109 109 } 110 110 … … 149 149 } finally { 150 150 // Ensure we clean the place before leaving, even if test fails. 151 Main.ma p.mapView.removeLayer(layer);151 Main.main.removeLayer(layer); 152 152 } 153 153 -
trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java
r8876 r9661 97 97 } finally { 98 98 // Ensure we clean the place before leaving, even if test fails. 99 Main.ma p.mapView.removeLayer(layer);99 Main.main.removeLayer(layer); 100 100 } 101 101 … … 175 175 } finally { 176 176 // Ensure we clean the place before leaving, even if test fails. 177 Main.ma p.mapView.removeLayer(layer);177 Main.main.removeLayer(layer); 178 178 } 179 179 -
trunk/test/unit/org/openstreetmap/josm/actions/SelectByInternalPointActionTest.java
r9594 r9661 79 79 public void testGetSurroundingObjects() { 80 80 Layer layer = initDataSet(); 81 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(null).size()); 82 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(0, 0)).size()); 83 assertEquals(1, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(1.5, 1.5)).size()); 84 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(3, 3)).size()); 85 Main.main.removeLayer(layer); 81 try { 82 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(null).size()); 83 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(0, 0)).size()); 84 assertEquals(1, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(1.5, 1.5)).size()); 85 assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(new EastNorth(3, 3)).size()); 86 } finally { 87 // Ensure we clean the place before leaving, even if test fails. 88 Main.main.removeLayer(layer); 89 } 86 90 } 87 91 … … 92 96 public void testGetSmallestSurroundingObject() { 93 97 Layer layer = initDataSet(); 94 assertNull(SelectByInternalPointAction.getSmallestSurroundingObject(null)); 95 assertNotNull(SelectByInternalPointAction.getSmallestSurroundingObject(new EastNorth(1.5, 1.5))); 96 Main.main.removeLayer(layer); 98 try { 99 assertNull(SelectByInternalPointAction.getSmallestSurroundingObject(null)); 100 assertNotNull(SelectByInternalPointAction.getSmallestSurroundingObject(new EastNorth(1.5, 1.5))); 101 } finally { 102 // Ensure we clean the place before leaving, even if test fails. 103 Main.main.removeLayer(layer); 104 } 97 105 } 98 106 … … 103 111 public void testPerformSelection() { 104 112 Layer layer = initDataSet(); 105 DataSet ds = JosmAction.getCurrentDataSet(); 113 try { 114 DataSet ds = JosmAction.getCurrentDataSet(); 106 115 107 assertEquals(0, ds.getSelected().size()); 108 SelectByInternalPointAction.performSelection(null, false, false); 109 assertEquals(0, ds.getSelected().size()); 110 SelectByInternalPointAction.performSelection(new EastNorth(0, 0), false, false); 111 assertEquals(0, ds.getSelected().size()); 112 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), false, false); 113 assertEquals(1, ds.getSelected().size()); 114 ds.clearSelection(); 115 ds.addSelected(ds.getNodes()); 116 assertEquals(4, ds.getSelected().size()); 117 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), true, false); 118 assertEquals(5, ds.getSelected().size()); 119 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), false, true); 120 assertEquals(4, ds.getSelected().size()); 121 122 Main.main.removeLayer(layer); 116 assertEquals(0, ds.getSelected().size()); 117 SelectByInternalPointAction.performSelection(null, false, false); 118 assertEquals(0, ds.getSelected().size()); 119 SelectByInternalPointAction.performSelection(new EastNorth(0, 0), false, false); 120 assertEquals(0, ds.getSelected().size()); 121 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), false, false); 122 assertEquals(1, ds.getSelected().size()); 123 ds.clearSelection(); 124 ds.addSelected(ds.getNodes()); 125 assertEquals(4, ds.getSelected().size()); 126 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), true, false); 127 assertEquals(5, ds.getSelected().size()); 128 SelectByInternalPointAction.performSelection(new EastNorth(1.5, 1.5), false, true); 129 assertEquals(4, ds.getSelected().size()); 130 } finally { 131 // Ensure we clean the place before leaving, even if test fails. 132 Main.main.removeLayer(layer); 133 } 123 134 } 124 135 } -
trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
r8965 r9661 84 84 } finally { 85 85 // Ensure we clean the place before leaving, even if test fails. 86 Main.ma p.mapView.removeLayer(layer);86 Main.main.removeLayer(layer); 87 87 } 88 88 -
trunk/test/unit/org/openstreetmap/josm/actions/UnJoinNodeWayActionTest.java
r8857 r9661 78 78 } finally { 79 79 // Ensure we clean the place before leaving, even if test fails. 80 Main.ma p.mapView.removeLayer(layer);80 Main.main.removeLayer(layer); 81 81 } 82 82 -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/DrawActionTest.java
r8949 r9661 68 68 69 69 Main.main.addLayer(layer); 70 assertTrue(Main.map.selectDrawTool(false)); 70 try { 71 assertTrue(Main.map.selectDrawTool(false)); 71 72 72 Main.map.mapModeDraw.mouseReleased(new MouseEvent(73 Main.map,74 MouseEvent.MOUSE_RELEASED,75 2000,76 InputEvent.BUTTON1_MASK,77 50, 0,78 2, false));73 Main.map.mapModeDraw.mouseReleased(new MouseEvent( 74 Main.map, 75 MouseEvent.MOUSE_RELEASED, 76 2000, 77 InputEvent.BUTTON1_MASK, 78 50, 0, 79 2, false)); 79 80 80 JList<OsmPrimitive> lstPrimitives = new JList<>();81 OsmPrimitivRenderer renderer = new OsmPrimitivRenderer();81 JList<OsmPrimitive> lstPrimitives = new JList<>(); 82 OsmPrimitivRenderer renderer = new OsmPrimitivRenderer(); 82 83 83 assertEquals(3, w.getNodesCount());84 Collection<Node> sel = dataSet.getSelectedNodes();85 assertEquals(1, sel.size());84 assertEquals(3, w.getNodesCount()); 85 Collection<Node> sel = dataSet.getSelectedNodes(); 86 assertEquals(1, sel.size()); 86 87 87 Node n3 = sel.iterator().next();88 Node n3 = sel.iterator().next(); 88 89 89 assertNotNull(renderer.getListCellRendererComponent(lstPrimitives, n3, 0, false, false));90 assertNotNull(renderer.getListCellRendererComponent(lstPrimitives, n3, 0, false, false)); 90 91 91 Main.main.undoRedo.undo();92 Main.main.undoRedo.undo(); 92 93 93 assertEquals(2, w.getNodesCount());94 assertTrue(dataSet.getSelectedNodes().isEmpty());94 assertEquals(2, w.getNodesCount()); 95 assertTrue(dataSet.getSelectedNodes().isEmpty()); 95 96 96 assertNotNull(renderer.getListCellRendererComponent(lstPrimitives, n3, 0, false, false)); 97 assertNotNull(renderer.getListCellRendererComponent(lstPrimitives, n3, 0, false, false)); 98 } finally { 99 // Ensure we clean the place before leaving, even if test fails. 100 Main.main.removeLayer(layer); 101 } 97 102 } 98 103 } -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
r9205 r9661 102 102 Main.pref = new PreferencesMock(); 103 103 Main.main.addLayer(layer); 104 SelectAction action = new SelectActionMock(Main.map, dataSet, layer); 105 nodesMerged = false; 104 try { 105 SelectAction action = new SelectActionMock(Main.map, dataSet, layer); 106 nodesMerged = false; 106 107 107 action.setEnabled(true);108 action.putValue("active", true);108 action.setEnabled(true); 109 action.putValue("active", true); 109 110 110 MouseEvent event;111 event = new MouseEvent(Main.map,112 MouseEvent.MOUSE_PRESSED,113 0,114 InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK,115 100, 0,116 1,117 false);118 action.mousePressed(event);119 event = new MouseEvent(Main.map,120 MouseEvent.MOUSE_DRAGGED,121 1000,122 InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK,123 50, 0,124 1,125 false);126 action.mouseDragged(event);127 event = new MouseEvent(Main.map,128 MouseEvent.MOUSE_RELEASED,129 2000,130 InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK,131 5, 0,132 1,133 false);134 action.mouseReleased(event);111 MouseEvent event; 112 event = new MouseEvent(Main.map, 113 MouseEvent.MOUSE_PRESSED, 114 0, 115 InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK, 116 100, 0, 117 1, 118 false); 119 action.mousePressed(event); 120 event = new MouseEvent(Main.map, 121 MouseEvent.MOUSE_DRAGGED, 122 1000, 123 InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK, 124 50, 0, 125 1, 126 false); 127 action.mouseDragged(event); 128 event = new MouseEvent(Main.map, 129 MouseEvent.MOUSE_RELEASED, 130 2000, 131 InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK, 132 5, 0, 133 1, 134 false); 135 action.mouseReleased(event); 135 136 136 // As result of test, we must find a 2 nodes way, from EN(0, 0) to EN(100, 0) 137 assertTrue("Nodes are not merged", nodesMerged); 138 assertSame(String.format("Expect exactly one way, found %d\n", dataSet.getWays().size()), 139 dataSet.getWays().size(), 1); 140 Way rw = dataSet.getWays().iterator().next(); 141 assertFalse("Way shouldn't be deleted\n", rw.isDeleted()); 142 assertSame(String.format("Way shouldn't have 2 nodes, %d found\n", w.getNodesCount()), 143 rw.getNodesCount(), 2); 144 Node r1 = rw.firstNode(); 145 Node r2 = rw.lastNode(); 146 if (r1.getEastNorth().east() > r2.getEastNorth().east()) { 147 Node tmp = r1; 148 r1 = r2; 149 r2 = tmp; 137 // As result of test, we must find a 2 nodes way, from EN(0, 0) to EN(100, 0) 138 assertTrue("Nodes are not merged", nodesMerged); 139 assertSame(String.format("Expect exactly one way, found %d\n", dataSet.getWays().size()), 140 dataSet.getWays().size(), 1); 141 Way rw = dataSet.getWays().iterator().next(); 142 assertFalse("Way shouldn't be deleted\n", rw.isDeleted()); 143 assertSame(String.format("Way shouldn't have 2 nodes, %d found\n", w.getNodesCount()), 144 rw.getNodesCount(), 2); 145 Node r1 = rw.firstNode(); 146 Node r2 = rw.lastNode(); 147 if (r1.getEastNorth().east() > r2.getEastNorth().east()) { 148 Node tmp = r1; 149 r1 = r2; 150 r2 = tmp; 151 } 152 assertSame(String.format("East should be 0, found %f\n", r1.getEastNorth().east()), 153 Double.compare(r1.getEastNorth().east(), 0), 0); 154 assertSame(String.format("East should be 100, found %f\n", r2.getEastNorth().east()), 155 Double.compare(r2.getEastNorth().east(), 100), 0); 156 } finally { 157 // Ensure we clean the place before leaving, even if test fails. 158 Main.main.removeLayer(layer); 150 159 } 151 assertSame(String.format("East should be 0, found %f\n", r1.getEastNorth().east()),152 Double.compare(r1.getEastNorth().east(), 0), 0);153 assertSame(String.format("East should be 100, found %f\n", r2.getEastNorth().east()),154 Double.compare(r2.getEastNorth().east(), 100), 0);155 160 } 156 161 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/TMSLayerTest.java
r9436 r9661 50 50 private static void test(ImageryType expected, TMSLayer layer) { 51 51 Main.main.addLayer(layer); 52 assertEquals(expected, layer.getInfo().getImageryType()); 52 try { 53 assertEquals(expected, layer.getInfo().getImageryType()); 54 } finally { 55 // Ensure we clean the place before leaving, even if test fails. 56 Main.main.removeLayer(layer); 57 } 53 58 } 54 59 -
trunk/test/unit/org/openstreetmap/josm/gui/layer/WMSLayerTest.java
r9436 r9661 31 31 WMSLayer wms = new WMSLayer(new ImageryInfo("test wms", "http://localhost")); 32 32 Main.main.addLayer(wms); 33 assertEquals(ImageryType.WMS, wms.getInfo().getImageryType()); 33 try { 34 assertEquals(ImageryType.WMS, wms.getInfo().getImageryType()); 35 } finally { 36 // Ensure we clean the place before leaving, even if test fails. 37 Main.main.removeLayer(wms); 38 } 34 39 } 35 40 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayerTest.java
r9660 r9661 42 42 assertTrue(reader.parse(true)); 43 43 GpxLayer gpxLayer = new GpxLayer(reader.getGpxData()); 44 Main.main.addLayer(gpxLayer); 45 assertEquals(1, Main.map.mapView.getNumLayers()); 46 new Loader( 47 Collections.singleton(new File(TestUtils.getRegressionDataFile(12255, "G0016941.JPG"))), 48 gpxLayer).run(); 49 assertEquals(2, Main.map.mapView.getNumLayers()); 50 GeoImageLayer layer = Main.map.mapView.getLayersOfType(GeoImageLayer.class).iterator().next(); 51 assertEquals(gpxLayer, layer.getGpxLayer()); 52 List<ImageEntry> images = layer.getImages(); 53 assertEquals(1, images.size()); 54 assertEquals("<html>1 image loaded. 0 were found to be GPS tagged.</html>", layer.getInfoComponent()); 55 assertEquals("<html>1 image loaded. 0 were found to be GPS tagged.</html>", layer.getToolTipText()); 44 try { 45 Main.main.addLayer(gpxLayer); 46 assertEquals(1, Main.map.mapView.getNumLayers()); 47 new Loader( 48 Collections.singleton(new File(TestUtils.getRegressionDataFile(12255, "G0016941.JPG"))), 49 gpxLayer).run(); 50 assertEquals(2, Main.map.mapView.getNumLayers()); 51 GeoImageLayer layer = Main.map.mapView.getLayersOfType(GeoImageLayer.class).iterator().next(); 52 try { 53 assertEquals(gpxLayer, layer.getGpxLayer()); 54 List<ImageEntry> images = layer.getImages(); 55 assertEquals(1, images.size()); 56 assertEquals("<html>1 image loaded. 0 were found to be GPS tagged.</html>", layer.getInfoComponent()); 57 assertEquals("<html>1 image loaded. 0 were found to be GPS tagged.</html>", layer.getToolTipText()); 58 } finally { 59 // Ensure we clean the place before leaving, even if test fails. 60 Main.map.mapView.removeLayer(layer); 61 } 62 } finally { 63 // Ensure we clean the place before leaving, even if test fails. 64 Main.main.removeLayer(gpxLayer); 65 } 56 66 } 57 67 }
Note:
See TracChangeset
for help on using the changeset viewer.