1 package org.simantics.district.maps.server.prefs;
3 import java.io.IOException;
4 import java.net.URISyntaxException;
6 import org.eclipse.core.runtime.preferences.InstanceScope;
7 import org.osgi.service.prefs.Preferences;
8 import org.simantics.district.maps.server.Activator;
10 public class MapsServerPreferences {
12 public static final String P_NODE = Activator.PLUGIN_ID;
14 public static final String P_START_AUTOMATICALLY = "org.simantics.maps.server.startAutomatically";
16 public static final String P_DEFAULT_PORT = "org.simantics.maps.server.defaultPort";
18 public static final String P_CURRENT_MBTILES = "org.simantics.maps.server.currentMbTiles";
20 public static final String P_CURRENT_TM2STYLE = "org.simantics.maps.server.currentTM2Style";
22 public static final String P_SERVER_FOLDER = "org.simantics.maps.server.serverFolder";
24 public static Preferences getPreferences() {
25 return InstanceScope.INSTANCE.getNode(MapsServerPreferences.P_NODE);
28 public static boolean startAutomatically() {
29 return getPreferences().getBoolean(P_START_AUTOMATICALLY, true);
32 public static int defaultPort() {
33 return getPreferences().getInt(P_DEFAULT_PORT, 8585);
36 public static String currentMBTiles() {
37 return getPreferences().get(P_CURRENT_MBTILES, "helsinki_finland.mbtiles");
40 public static String currentTM2Style() {
41 return getPreferences().get(P_CURRENT_TM2STYLE, "mapbox-studio-osm-bright.tm2");
44 public static String serverFolder() throws IOException, URISyntaxException {
45 return getPreferences().get(P_SERVER_FOLDER, Activator.getTileserverMapnikRoot().toAbsolutePath().toString());