extract legal settings to static variable
This commit is contained in:
parent
ed0e3bd871
commit
697d2b59a8
@ -18,11 +18,16 @@ import app.model.Model;
|
|||||||
public class SettingsProvider implements SettingsProviderI {
|
public class SettingsProvider implements SettingsProviderI {
|
||||||
|
|
||||||
private static EventBus eventBus;
|
private static EventBus eventBus;
|
||||||
|
|
||||||
private static final String SETTINGS_PATH =
|
private static final String SETTINGS_PATH =
|
||||||
(System.getProperty("os.name").startsWith("Windows"))
|
(System.getProperty("os.name").startsWith("Windows"))
|
||||||
? System.getProperty("user.home") + "\\AppData\\Roaming\\/BNNsettings.dat"
|
? System.getProperty("user.home") + "\\AppData\\Roaming\\/BNNsettings.dat"
|
||||||
: System.getProperty("user.home") + System.getProperty("file.separator") + ".BNNsettings.dat";
|
: System.getProperty("user.home") + System.getProperty("file.separator") + ".BNNsettings.dat";
|
||||||
|
|
||||||
|
private static List<String> legalSettings =
|
||||||
|
Arrays.asList("Java", "Markdown", "Monokai", "Solarized Light");
|
||||||
|
|
||||||
|
|
||||||
public SettingsProvider(EventBus eB) {
|
public SettingsProvider(EventBus eB) {
|
||||||
setEventBus(eB);
|
setEventBus(eB);
|
||||||
Model.setSettingsProvider(this);
|
Model.setSettingsProvider(this);
|
||||||
@ -36,7 +41,6 @@ public class SettingsProvider implements SettingsProviderI {
|
|||||||
@Override
|
@Override
|
||||||
public void loadSettings() {
|
public void loadSettings() {
|
||||||
List<String> settings = new ArrayList<>();
|
List<String> settings = new ArrayList<>();
|
||||||
List<String> legalSettings = Arrays.asList("Java", "Markdown", "Monokai", "Solarized Light");
|
|
||||||
try (Scanner sc = new Scanner(new File(SETTINGS_PATH))) {
|
try (Scanner sc = new Scanner(new File(SETTINGS_PATH))) {
|
||||||
|
|
||||||
while (sc.hasNextLine()) {
|
while (sc.hasNextLine()) {
|
||||||
@ -56,7 +60,7 @@ public class SettingsProvider implements SettingsProviderI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("[WARNING] Couldn't read settings file. Using defaults");
|
System.err.println("[WARNING] Couldn't find settings file. Using defaults");
|
||||||
eventBus.post(new LanguageChangedEvent("Java"));
|
eventBus.post(new LanguageChangedEvent("Java"));
|
||||||
eventBus.post(new ThemeChangedEvent("Monokai"));
|
eventBus.post(new ThemeChangedEvent("Monokai"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user