/
rgd045
/
crypt-file
Обзор
Документация
Войти
/
rgd045
/
crypt-file
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/main/java/org/cryptomator/common/settings/Settings.java
208 строк
8 KB
Sebastian Stenzel
volume settings → change tcp port
07 ноя 2022, 18:16
Не верифицирован
07 ноя 2022, 18:16
1b4117d
Код
Авторство
О чём код?
/******************************************************************************* * Copyright (c) 2014, 2017 Sebastian Stenzel * All rights reserved. * This program and the accompanying materials are made available under the terms of the accompanying LICENSE file. * * Contributors: * Sebastian Stenzel - initial API and implementation ******************************************************************************/ package org.cryptomator.common.settings; import org.apache.commons.lang3.SystemUtils; import org.cryptomator.common.Environment; import javafx.beans.Observable; import javafx.beans.property.BooleanProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.NodeOrientation; import java.util.function.Consumer; public class Settings { public static final int MIN_PORT = 1024; public static final int MAX_PORT = 65535; public static final boolean DEFAULT_ASKED_FOR_UPDATE_CHECK = false; public static final boolean DEFAULT_CHECK_FOR_UPDATES = false; public static final boolean DEFAULT_START_HIDDEN = false; public static final boolean DEFAULT_AUTO_CLOSE_VAULTS = false; public static final boolean DEFAULT_USE_KEYCHAIN = true; public static final int DEFAULT_PORT = 42427; public static final int DEFAULT_NUM_TRAY_NOTIFICATIONS = 3; public static final boolean DEFAULT_DEBUG_MODE = false; public static final UiTheme DEFAULT_THEME = UiTheme.LIGHT; @Deprecated // to be changed to "whatever is available" eventually public static final String DEFAULT_KEYCHAIN_PROVIDER = SystemUtils.IS_OS_WINDOWS ? "org.cryptomator.windows.keychain.WindowsProtectedKeychainAccess" : SystemUtils.IS_OS_MAC ? "org.cryptomator.macos.keychain.MacSystemKeychainAccess" : "org.cryptomator.linux.keychain.SecretServiceKeychainAccess"; public static final NodeOrientation DEFAULT_USER_INTERFACE_ORIENTATION = NodeOrientation.LEFT_TO_RIGHT; public static final String DEFAULT_LICENSE_KEY = ""; public static final boolean DEFAULT_SHOW_MINIMIZE_BUTTON = false; public static final String DEFAULT_DISPLAY_CONFIGURATION = ""; public static final String DEFAULT_LANGUAGE = null; private final ObservableList<VaultSettings> directories = FXCollections.observableArrayList(VaultSettings::observables); private final BooleanProperty askedForUpdateCheck = new SimpleBooleanProperty(DEFAULT_ASKED_FOR_UPDATE_CHECK); private final BooleanProperty checkForUpdates = new SimpleBooleanProperty(DEFAULT_CHECK_FOR_UPDATES); private final BooleanProperty startHidden = new SimpleBooleanProperty(DEFAULT_START_HIDDEN); private final BooleanProperty autoCloseVaults = new SimpleBooleanProperty(DEFAULT_AUTO_CLOSE_VAULTS); private final BooleanProperty useKeychain = new SimpleBooleanProperty(DEFAULT_USE_KEYCHAIN); private final IntegerProperty port = new SimpleIntegerProperty(DEFAULT_PORT); private final IntegerProperty numTrayNotifications = new SimpleIntegerProperty(DEFAULT_NUM_TRAY_NOTIFICATIONS); private final BooleanProperty debugMode = new SimpleBooleanProperty(DEFAULT_DEBUG_MODE); private final ObjectProperty<UiTheme> theme = new SimpleObjectProperty<>(DEFAULT_THEME); private final ObjectProperty<String> keychainProvider = new SimpleObjectProperty<>(DEFAULT_KEYCHAIN_PROVIDER); private final ObjectProperty<NodeOrientation> userInterfaceOrientation = new SimpleObjectProperty<>(DEFAULT_USER_INTERFACE_ORIENTATION); private final StringProperty licenseKey = new SimpleStringProperty(DEFAULT_LICENSE_KEY); private final BooleanProperty showMinimizeButton = new SimpleBooleanProperty(DEFAULT_SHOW_MINIMIZE_BUTTON); private final BooleanProperty showTrayIcon; private final IntegerProperty windowXPosition = new SimpleIntegerProperty(); private final IntegerProperty windowYPosition = new SimpleIntegerProperty(); private final IntegerProperty windowWidth = new SimpleIntegerProperty(); private final IntegerProperty windowHeight = new SimpleIntegerProperty(); private final ObjectProperty<String> displayConfiguration = new SimpleObjectProperty<>(DEFAULT_DISPLAY_CONFIGURATION); private final StringProperty language = new SimpleStringProperty(DEFAULT_LANGUAGE); private final StringProperty mountService = new SimpleStringProperty(); private Consumer<Settings> saveCmd; /** * Package-private constructor; use {@link SettingsProvider}. */ Settings(Environment env) { this.showTrayIcon = new SimpleBooleanProperty(env.showTrayIcon()); directories.addListener(this::somethingChanged); askedForUpdateCheck.addListener(this::somethingChanged); checkForUpdates.addListener(this::somethingChanged); startHidden.addListener(this::somethingChanged); autoCloseVaults.addListener(this::somethingChanged); useKeychain.addListener(this::somethingChanged); port.addListener(this::somethingChanged); numTrayNotifications.addListener(this::somethingChanged); debugMode.addListener(this::somethingChanged); theme.addListener(this::somethingChanged); keychainProvider.addListener(this::somethingChanged); userInterfaceOrientation.addListener(this::somethingChanged); licenseKey.addListener(this::somethingChanged); showMinimizeButton.addListener(this::somethingChanged); showTrayIcon.addListener(this::somethingChanged); windowXPosition.addListener(this::somethingChanged); windowYPosition.addListener(this::somethingChanged); windowWidth.addListener(this::somethingChanged); windowHeight.addListener(this::somethingChanged); displayConfiguration.addListener(this::somethingChanged); language.addListener(this::somethingChanged); mountService.addListener(this::somethingChanged); } void setSaveCmd(Consumer<Settings> saveCmd) { this.saveCmd = saveCmd; } private void somethingChanged(@SuppressWarnings("unused") Observable observable) { this.save(); } void save() { if (saveCmd != null) { saveCmd.accept(this); } } /* Getter/Setter */ public ObservableList<VaultSettings> getDirectories() { return directories; } public BooleanProperty askedForUpdateCheck() { return askedForUpdateCheck; } public BooleanProperty checkForUpdates() { return checkForUpdates; } public BooleanProperty startHidden() { return startHidden; } public BooleanProperty autoCloseVaults() { return autoCloseVaults; } public BooleanProperty useKeychain() { return useKeychain; } public IntegerProperty port() { return port; } public IntegerProperty numTrayNotifications() { return numTrayNotifications; } public BooleanProperty debugMode() { return debugMode; } public StringProperty mountService() { return mountService; } public ObjectProperty<UiTheme> theme() { return theme; } public ObjectProperty<String> keychainProvider() {return keychainProvider;} public ObjectProperty<NodeOrientation> userInterfaceOrientation() { return userInterfaceOrientation; } public StringProperty licenseKey() { return licenseKey; } public BooleanProperty showMinimizeButton() { return showMinimizeButton; } public BooleanProperty showTrayIcon() { return showTrayIcon; } public IntegerProperty windowXPositionProperty() { return windowXPosition; } public IntegerProperty windowYPositionProperty() { return windowYPosition; } public IntegerProperty windowWidthProperty() { return windowWidth; } public IntegerProperty windowHeightProperty() { return windowHeight; } public ObjectProperty<String> displayConfigurationProperty() { return displayConfiguration; } public StringProperty languageProperty() { return language; } }