summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2015-09-02 17:37:50 +0200
committerJonathan Bauer2015-09-02 17:37:50 +0200
commitf8677fb2ec42041448d47e2491dffa1e140a9124 (patch)
treec7b27921a4e1f5a3afadc0313d3c39041dbbcd70
parent[client] new "View"(Ansicht) menu in MainWindow with "Home page", "ImageList"... (diff)
downloadtutor-module-f8677fb2ec42041448d47e2491dffa1e140a9124.tar.gz
tutor-module-f8677fb2ec42041448d47e2491dffa1e140a9124.tar.xz
tutor-module-f8677fb2ec42041448d47e2491dffa1e140a9124.zip
[client] defined font scaling min, max, step in Config and use these to validate the saved font scaling value
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/Config.java80
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java2
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java5
3 files changed, 62 insertions, 25 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java b/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java
index 7636cf85..78124376 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/Config.java
@@ -9,6 +9,7 @@ import java.io.InputStream;
import java.util.Properties;
import org.apache.log4j.Logger;
+import org.openslx.dozmod.gui.window.DisclaimerWindow;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
import org.openslx.util.Util;
@@ -33,6 +34,13 @@ public class Config {
}
/**
+ * Constants for font scaling boundaries
+ */
+ public static final int FONT_SCALING_MIN = 75;
+ public static final int FONT_SCALING_MAX = 175;
+ public static final int FONT_SCALING_STEP = 5;
+
+ /**
* Out property holder with all the setting keys
*/
private static final Properties prop = new Properties();
@@ -179,16 +187,23 @@ public class Config {
*/
/**
- * Query the value of 'DisclaimerAgreement' from the configuration file.
+ * Returns the value of 'disclaimer.accepted_version'
*
* @return version of the disclaimer the user accepted, 0 otherwise.
*/
public static int getDisclaimerAgreement() {
- return getInteger("disclaimer.accepted_version", 0);
+ int savedVersion = getInteger("disclaimer.accepted_version", 0);
+ // check if we have a saved version and if it is larger than
+ // the current version. If it is, reset it to 0.
+ if (savedVersion != 0 && Math.abs(savedVersion - DisclaimerWindow.DISCLAIMER_VERSION) != 0) {
+ setDisclaimerAgreement(0);
+ return 0;
+ }
+ return savedVersion;
}
/**
- * Sets the value of 'DisclaimerAgreement' in the configuration file to 'value'
+ * Sets the value of 'disclaimer.accepted_version' to the given value
*
* @return true if it succeeded, false otherwise
*/
@@ -196,18 +211,28 @@ public class Config {
setInteger("disclaimer.accepted_version", value);
}
+ /**
+ * Returns the value of 'notice.virtualizer'
+ *
+ * @return value of 'notice.virtualizer' if set, false otherwise
+ */
public static boolean getVirtualizerRead() {
return getBoolean("notice.virtualizer", false);
}
+ /**
+ * Sets 'notice.virtualizer' to the given selection
+ *
+ * @param selection boolean to set the value to
+ */
public static void setVirtualizerRead(boolean selection) {
setBoolean("notice.virtualizer", selection);
}
/**
- * Get the remembered user, if set.
+ * Gets the remembered user saved as 'login.name', if set
*
- * @return user name if saved, an empty string otherwise.
+ * @return user name if saved, an empty string otherwise
*/
public static String getUsername() {
return getString("login.name", "");
@@ -223,17 +248,17 @@ public class Config {
}
/**
- * Query the value of 'Letzter Downloadpfad' from the configuration file.
+ * Query the value of 'download.path' from the configuration file.
*
* @return last download path if saved, the path to the user's home
- * otherwise.
+ * otherwise
*/
public static String getDownloadPath() {
return getString("download.path", System.getProperty("user.home"));
}
/**
- * Sets the value of 'Letzter Downloadpfad' in the configuration file to
+ * Sets the value of 'download.path' in the configuration file to
* 'value'
*
* @return true if it succeeded, false otherwise
@@ -243,17 +268,16 @@ public class Config {
}
/**
- * Query the value of 'Letzter Uploadpfad' from the configuration file.
+ * Gets the value of 'upload.path'
*
- * @return last upload path if saved, the path to the user's home otherwise.
+ * @return last upload path if saved, the path to the user's home otherwise
*/
public static String getUploadPath() {
return getString("upload.path", System.getProperty("user.home"));
}
/**
- * Sets the value of "Letzter Uploadpfad" in the configuration file to
- * 'value'
+ * Sets the value of "upload.path" the given value
*
* @return true if it succeeded, false otherwise
*/
@@ -312,7 +336,7 @@ public class Config {
}
/**
- * Load a saved session.
+ * Load a saved session
*
* @return Saved session, or <code>null</code> if no session was saved
*/
@@ -325,9 +349,9 @@ public class Config {
}
/**
- * Save the scaling for font rendering (in percent, 100% = no scaling)
+ * Sets the scaling for font rendering (in percent, 100% = no scaling)
*
- * @param percent
+ * @param percent to set the font scaling to
*/
public static void setFontScaling(int percent) {
setInteger("gui.fontscaling", percent);
@@ -335,9 +359,18 @@ public class Config {
/**
* Get scaling for font rendering (in percent, 100% = no scaling)
+ * If the saved value is not within the declared boundary, it will be
+ * reseted to 100.
+ *
+ * @return the saved value of 'gui.fontscaling' if within boundaries, 100 otherwise
*/
public static int getFontScaling() {
- return getInteger("gui.fontscaling", 100);
+ int savedFontScaling = getInteger("gui.fontscaling", 100);
+ if (savedFontScaling < FONT_SCALING_MIN || savedFontScaling > FONT_SCALING_MAX) {
+ setFontScaling(100);
+ return 100;
+ }
+ return savedFontScaling;
}
/**
@@ -350,9 +383,9 @@ public class Config {
}
/**
- * Get the mode in which the proxy server is configured.
+ * Get the mode in which the proxy server is configured
*
- * @return
+ * @return the saved proxy mode, ProxyMode.AUTO otherwise
*/
public static ProxyMode getProxyMode() {
try {
@@ -362,10 +395,6 @@ public class Config {
}
}
- /*
- * Generic helpers for different data types
- */
-
/**
* Gets the boolean from the given key.
* If nothing is found, return the given default value
@@ -436,6 +465,10 @@ public class Config {
queueSave();
}
+ /**
+ * Helper class to represent a saved session composed of the satellite adress,
+ * the satellite and master tokens
+ */
public static class SavedSession {
public final String address;
public final String token;
@@ -448,6 +481,9 @@ public class Config {
}
}
+ /**
+ * Enum representing the proxy mode
+ */
public enum ProxyMode {
NONE,
AUTO,
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java
index ae1c743f..b787275e 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/DisclaimerWindow.java
@@ -24,7 +24,7 @@ public class DisclaimerWindow extends DisclaimerWindowLayout implements UiFeedba
/**
* Use a version number for the disclaimer. Whenever we add/change something, this will be increased
*/
- private static final int DISCLAIMER_VERSION = 1;
+ public static final int DISCLAIMER_VERSION = 1;
final DisclaimerWindow me = this;
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java
index 5afa7bc9..a92b62ec 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ConfigWindowLayout.java
@@ -16,6 +16,7 @@ import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSlider;
+import org.openslx.dozmod.Config;
import org.openslx.dozmod.gui.helper.GridManager;
@SuppressWarnings("serial")
@@ -79,8 +80,8 @@ public class ConfigWindowLayout extends JDialog {
fontPanel.setBorder(BorderFactory.createTitledBorder("Schriftgröße"));
GridManager fontGrid = new GridManager(fontPanel, 1);
btnFontSize = new JSlider(JSlider.HORIZONTAL);
- btnFontSize.setModel(new DefaultBoundedRangeModel(100, 5, 75, 175));
- btnFontSize.setMinorTickSpacing(5);
+ btnFontSize.setModel(new DefaultBoundedRangeModel(100, Config.FONT_SCALING_STEP, Config.FONT_SCALING_MIN, Config.FONT_SCALING_MAX));
+ btnFontSize.setMinorTickSpacing(Config.FONT_SCALING_STEP);
btnFontSize.setMajorTickSpacing(25);
btnFontSize.setSnapToTicks(true);
btnFontSize.setPaintTicks(true);