From b10d999b1ddcbadc606d512668483cb90e3b29ee Mon Sep 17 00:00:00 2001 From: tenzap Date: Sun, 30 Jul 2023 18:22:21 +0200 Subject: [PATCH] in dataTable, when both gtfs/osm values are empty, set new value as empty too --- .../gui/object/BooleanMouseListener.java | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/object/BooleanMouseListener.java b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/object/BooleanMouseListener.java index cae47620..68dfe0a9 100644 --- a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/object/BooleanMouseListener.java +++ b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/gui/object/BooleanMouseListener.java @@ -51,27 +51,33 @@ private void checkBoxEvent(MouseEvent e) { // add appropriate data to New Values String dataValue = (String)dataTable.getValueAt(row, column-1); - if((dataValue!=null) && !(dataValue.equals(""))){ - Boolean otherCheckBox; - String otherData, insertData=dataValue; - int otherCheckColumn; - int dataColumn = column - 1; - int otherDataColumn; + Boolean otherCheckBox; + String otherData, insertData = dataValue; + int otherCheckColumn; + int otherDataColumn; + + // look at data, checkBox info for other columns + // FIXME: needs some cleaning up for better readability + if (column == StopTableInfo.GTFS_CHECK_COL) { + otherCheckColumn = StopTableInfo.OSM_CHECK_COL; + otherDataColumn = otherCheckColumn - 1; + otherCheckBox = (Boolean) dataTable.getValueAt(row, otherCheckColumn); + otherData = (String) dataTable.getValueAt(row, otherDataColumn); + } else { // column == StopTableInfo.OSM_CHECK_COL + otherCheckColumn = StopTableInfo.GTFS_CHECK_COL; + otherDataColumn = otherCheckColumn - 1; + otherCheckBox = (Boolean) dataTable.getValueAt(row, otherCheckColumn); + otherData = (String) dataTable.getValueAt(row, otherDataColumn); + } + + if((dataValue!=null) && !(dataValue.equals(""))){ // look at data, checkBox info for other columns // FIXME: needs some cleaning up for better readability if(column==StopTableInfo.GTFS_CHECK_COL) { - otherCheckColumn = StopTableInfo.OSM_CHECK_COL; - otherDataColumn = otherCheckColumn - 1; - otherCheckBox = (Boolean)dataTable.getValueAt(row, otherCheckColumn); - otherData = (String)dataTable.getValueAt(row, otherDataColumn); if(otherData!=null && !(otherData.equals(""))) insertData = addToOSMMultiValue(dataValue, otherData); } else { // column == StopTableInfo.OSM_CHECK_COL - otherCheckColumn = StopTableInfo.GTFS_CHECK_COL; - otherDataColumn = otherCheckColumn - 1; - otherCheckBox = (Boolean)dataTable.getValueAt(row, otherCheckColumn); - otherData = (String)dataTable.getValueAt(row, otherDataColumn); if(otherCheckBox) { if (otherData!=null && !(otherData.equals(""))) insertData = addToOSMMultiValue(dataValue, otherData); @@ -118,6 +124,11 @@ private void checkBoxEvent(MouseEvent e) { } } + if ((dataValue == null || dataValue.isBlank()) && (otherData == null || otherData.isBlank())) { + insertData = null; + dataTable.setValueAt(insertData, row, StopTableInfo.NEW_VALUE_DATA_COL); + } + String tagName = (String)dataTable.getValueAt(row, 0); if (tagName.equals("public_transport:version")) { reportViewer.PTVersionChanged();