+ private String[][] computeNamesAndValues() throws IOException {
+ List<String> tiles = server.availableMBTiles();
+ String[][] namesAndValues = new String[tiles.size()][];
+ for (int i = 0; i < tiles.size(); i++) {
+ String style = tiles.get(i);
+ String[] nameAndValue = new String[2];
+ nameAndValue[0] = style;
+ nameAndValue[1] = style;
+ namesAndValues[i] = nameAndValue;
+ }
+ return namesAndValues;
+ }
+
+ @Override
+ protected void performApply() {
+ // Upload new mbtiles file
+ String fileLocation = addNew.getStringValue();
+ if (fileLocation != null && !fileLocation.isEmpty()) {
+ Path p = Paths.get(fileLocation);
+ Path target = server.getDataDirectory().resolve(p.getFileName());
+ try {
+ Files.copy(p, target);
+ addNew.setStringValue("");
+ } catch (IOException e) {
+ String message = "Could not upload " + fileLocation + " to " + target.toAbsolutePath();
+ LOGGER.error(message, e);
+ setErrorMessage(message);
+ }
+ }
+ try {
+ currentTilesSelector.updateCombo(computeNamesAndValues());
+ currentTilesSelector.load();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ super.performApply();
+ }
+
+ @Override
+ public boolean performOk() {
+ boolean success = super.performOk();
+
+ try {
+ server.stop();
+ new TileserverMapnikStartJob(status -> {}).schedule();
+ } catch (Exception e) {
+ LOGGER.error("Could not restart tileserver-mapnik", e);
+ }
+
+ return success;
+ }