diff --git a/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/GeoreferenceDialog.java b/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/GeoreferenceDialog.java index 40c4a46..c1d9db9 100644 --- a/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/GeoreferenceDialog.java +++ b/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/GeoreferenceDialog.java @@ -368,6 +368,9 @@ private boolean saveData() { * Update the marker on the map */ private void updateMap() { + if (textFieldDecimalLat.getText().isEmpty() || textFieldDecimalLong.getText().isEmpty()) { + return; + } try { GeoPosition address = new GeoPosition(Double.parseDouble(textFieldDecimalLat.getText()), @@ -377,7 +380,7 @@ private void updateMap() { WaypointPainter waypointPainter = new WaypointPainter(); waypointPainter.setWaypoints( - new HashSet(Arrays.asList(new DefaultWaypoint(address)))); + new HashSet(List.of(new DefaultWaypoint(address)))); // Create a compound painter that uses both the route-painter and the // waypoint-painter diff --git a/src/main/java/edu/harvard/mcz/imagecapture/ui/frame/SpecimenDetailsViewPane.java b/src/main/java/edu/harvard/mcz/imagecapture/ui/frame/SpecimenDetailsViewPane.java index d7f048e..244d217 100644 --- a/src/main/java/edu/harvard/mcz/imagecapture/ui/frame/SpecimenDetailsViewPane.java +++ b/src/main/java/edu/harvard/mcz/imagecapture/ui/frame/SpecimenDetailsViewPane.java @@ -466,7 +466,7 @@ private boolean save() { // Elevations Long min_elev; - if (jTextFieldMinElevation.getText().trim().length() == 0) { + if (jTextFieldMinElevation.getText().trim().isEmpty()) { min_elev = null; } else { try { @@ -477,7 +477,7 @@ private boolean save() { } specimen.setMinimum_elevation(min_elev); Long max_elev; - if (jTextFieldMaxElevation.getText().trim().length() == 0) { + if (jTextFieldMaxElevation.getText().trim().isEmpty()) { max_elev = null; } else { try { @@ -547,11 +547,8 @@ private boolean save() { specimen.setQuestions(jTextFieldQuestions.getText()); try { - // make sure specimen controller does not throw null pointer exception – - // whyever - if (specimenController.getSpecimen() == null) { - specimenController.setSpecimen(specimen); - } + // make sure specimen controller knows about the latest changes + specimenController.setSpecimen(specimen); specimenController.save(); // save the record setStateToClean(); // enable the navigation buttons this.setStatus("Saved"); // inform the user @@ -1774,7 +1771,7 @@ private JTable getNumberJTable() { // jTableNumbers.transferFocus(); // } // }; - if (specimen.getNumbers().size() > 0) { + if (!specimen.getNumbers().isEmpty()) { JTableCellTabbing.setTabMapping( jTableNumbers, 0, specimen.getNumbers().size(), 0, 2 );