diff --git a/src/main/java/osm/jp/gpx/matchtime/gui/SimpleCardListener.java b/src/main/java/osm/jp/gpx/matchtime/gui/SimpleCardListener.java index 4ff55b8..dd890dd 100644 --- a/src/main/java/osm/jp/gpx/matchtime/gui/SimpleCardListener.java +++ b/src/main/java/osm/jp/gpx/matchtime/gui/SimpleCardListener.java @@ -37,6 +37,9 @@ else if (propertyName.equals(AppParameters.GPX_BASETIME)) { toEnable(cardNo, checkBasetime(param.argField.getText())); } + else if (propertyName.equals(AppParameters.GPX_SOURCE_FOLDER)) { + toEnable(cardNo, checkGpxFolder(param.argField.getText())); + } } /** @@ -68,6 +71,35 @@ return false; } + /** + * "GPX_SOURCE_FOLDER"の設定内容が有効かどうかを判別する + * @param str + * @return + */ + boolean checkGpxFolder(String str) { + if (str != null) { + Path p = Paths.get(str); + if (p != null) { + if (Files.exists(p)) { + if (Files.isDirectory(p)) { + List entries; + try { + entries = Files.list(p).collect(Collectors.toList()); + for (Path file : entries) { + if (file.toString().toLowerCase().endsWith(".gpx")) { + return true; + } + } + } catch (IOException e) { + return false; + } + } + } + } + } + return false; + } + /** * "GPX_BASETIME"の設定内容が有効かどうかを判別する