/hg/icedtea-web: Added three keys to DeploymentConfiguration. Ma...

jkang at icedtea.classpath.org jkang at icedtea.classpath.org
Fri Sep 19 19:48:01 UTC 2014


changeset 6e689ab02eb0 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=6e689ab02eb0
author: Jie Kang <jkang at redhat.com>
date: Fri Sep 19 15:47:00 2014 -0400

	Added three keys to DeploymentConfiguration. Max cache size, cache enable,
	and cache compression enable.

	2014-09-19  Jie Kang  <jkang at redhat.com>

	    Added three keys to DeploymentConfiguration. Max cache size, cache enable,
	    and cache compression enable.
	    * netx/net/sourceforge/jnlp/CacheUtil.java: now uses keys
	    * netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java:
	    now uses keys
	    * netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java:


diffstat:

 ChangeLog                                                               |   9 +
 netx/net/sourceforge/jnlp/cache/CacheUtil.java                          |   2 +-
 netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java           |  18 ++-
 netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java |  54 +++------
 4 files changed, 44 insertions(+), 39 deletions(-)

diffs (205 lines):

diff -r 85ede1a5ab91 -r 6e689ab02eb0 ChangeLog
--- a/ChangeLog	Fri Sep 19 14:06:23 2014 +0200
+++ b/ChangeLog	Fri Sep 19 15:47:00 2014 -0400
@@ -1,3 +1,12 @@
+2014-09-19  Jie Kang  <jkang at redhat.com>
+
+    Added three keys to DeploymentConfiguration. Max cache size, cache enable,
+    and cache compression enable.
+    * netx/net/sourceforge/jnlp/CacheUtil.java: now uses keys
+    * netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java:
+    now uses keys
+    * netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java:
+
 2014-09-19  Jiri Vanek  <jvanek at redhat.com>
 
 	Translator made immutable
diff -r 85ede1a5ab91 -r 6e689ab02eb0 netx/net/sourceforge/jnlp/cache/CacheUtil.java
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java	Fri Sep 19 14:06:23 2014 +0200
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java	Fri Sep 19 15:47:00 2014 -0400
@@ -545,7 +545,7 @@
 
                 long maxSize = -1; // Default
                 try {
-                    maxSize = Long.parseLong(JNLPRuntime.getConfiguration().getProperty("deployment.cache.max.size"));
+                    maxSize = Long.parseLong(JNLPRuntime.getConfiguration().getProperty(DeploymentConfiguration.KEY_CACHE_MAX_SIZE));
                 } catch (NumberFormatException nfe) {
                 }
 
diff -r 85ede1a5ab91 -r 6e689ab02eb0 netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java
--- a/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java	Fri Sep 19 14:06:23 2014 +0200
+++ b/netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java	Fri Sep 19 15:47:00 2014 -0400
@@ -16,6 +16,13 @@
 
 package net.sourceforge.jnlp.config;
 
+import static net.sourceforge.jnlp.config.PathsAndFiles.JAVA_DEPLOYMENT_PROP_FILE;
+import static net.sourceforge.jnlp.config.PathsAndFiles.USER_CACHE_HOME;
+import static net.sourceforge.jnlp.config.PathsAndFiles.USER_CONFIG_HOME;
+import static net.sourceforge.jnlp.config.PathsAndFiles.USER_DEPLOYMENT_FILE;
+import static net.sourceforge.jnlp.config.PathsAndFiles.USER_SECURITY;
+import static net.sourceforge.jnlp.runtime.Translator.R;
+
 import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
 import java.io.File;
@@ -32,13 +39,12 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+
 import javax.naming.ConfigurationException;
 import javax.swing.JOptionPane;
+
 import net.sourceforge.jnlp.cache.CacheLRUWrapper;
-import static net.sourceforge.jnlp.config.PathsAndFiles.*;
 import net.sourceforge.jnlp.runtime.JNLPRuntime;
-import static net.sourceforge.jnlp.runtime.Translator.R;
-
 import net.sourceforge.jnlp.util.FileUtils;
 import net.sourceforge.jnlp.util.logging.OutputController;
 
@@ -90,6 +96,12 @@
     public static final String KEY_USER_CACHE_DIR = "deployment.user.cachedir";
     public static final String KEY_USER_PERSISTENCE_CACHE_DIR = "deployment.user.pcachedir";
     public static final String KEY_SYSTEM_CACHE_DIR = "deployment.system.cachedir";
+
+    public static final String  KEY_CACHE_MAX_SIZE = "deployment.cache.max.size";
+
+    public static final String KEY_CACHE_ENABLED = "deployment.javapi.cache.enabled";
+    public static final String KEY_CACHE_COMPRESSION_ENABLED = "deployment.cache.jarcompression";
+
     public static final String KEY_USER_LOG_DIR = "deployment.user.logdir";
     public static final String KEY_USER_TMP_DIR = "deployment.user.tmp";
     /** the directory containing locks for single instance applications */
diff -r 85ede1a5ab91 -r 6e689ab02eb0 netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java
--- a/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java	Fri Sep 19 14:06:23 2014 +0200
+++ b/netx/net/sourceforge/jnlp/controlpanel/TemporaryInternetFilesPanel.java	Fri Sep 19 15:47:00 2014 -0400
@@ -18,13 +18,12 @@
 
 package net.sourceforge.jnlp.controlpanel;
 
-import java.awt.*;
+import static java.lang.Integer.parseInt;
+import static java.lang.Long.parseLong;
 
-import net.sourceforge.jnlp.config.DeploymentConfiguration;
-import net.sourceforge.jnlp.runtime.Translator;
-
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ComponentAdapter;
@@ -45,9 +44,11 @@
 import javax.swing.JSpinner;
 import javax.swing.JTextField;
 import javax.swing.SpinnerNumberModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
 
-import static java.lang.Integer.parseInt;
-import static java.lang.Long.parseLong;
+import net.sourceforge.jnlp.config.DeploymentConfiguration;
+import net.sourceforge.jnlp.runtime.Translator;
 
 /**
  * The actual panel that contains the fields that the user can edit accordingly.
@@ -61,23 +62,6 @@
 @SuppressWarnings("serial")
 public class TemporaryInternetFilesPanel extends NamedBorderPanel {
 
-    private static enum Properties {
-        CACHE_ENABLED("deployment.javapi.cache.enabled"),
-        USER_CACHEDIR("deployment.user.cachedir"),
-        CACHE_MAX_SIZE("deployment.cache.max.size"),
-        COMPRESSION_ENABLED("deployment.cache.jarcompression");
-
-        private final String prop;
-        Properties(final String prop) {
-            this.prop = prop;
-        }
-
-        @Override
-        public String toString() {
-            return prop;
-        }
-    }
-
     private static final Long CACHE_UNLIMITED_SIZE = Long.valueOf(-1l);
     private static final Long CACHE_MIN_SIZE = Long.valueOf(0l);
     private static final Long CACHE_MAX_SIZE = (long) Integer.MAX_VALUE;
@@ -123,14 +107,14 @@
         lCompression = new JLabel(Translator.R("TIFPCompressionLevel") + ":"); // Sets compression level for jar files.
 
         bLocation = new JButton(Translator.R("TIFPChange") + "...");
-        location = new JTextField(this.config.getProperty(Properties.USER_CACHEDIR.toString()));
+        location = new JTextField(this.config.getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR));
         locationDescription = new JLabel(Translator.R("TIFPLocationLabel") + ":");
         bViewFiles = new JButton(Translator.R("TIFPViewFiles"));
 
         diskSpacePanel = new JPanel();
         diskSpacePanel.setLayout(new GridBagLayout());
 
-        cacheDir = new File(config.getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR));
+        cacheDir = new File(this.config.getProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR));
         usableDiskSpace = cacheDir.getUsableSpace() / BYTES_TO_MEGABYTES; // getUsableSpace returns bytes
 
         addComponents();
@@ -159,16 +143,16 @@
         JLabel description = new JLabel(Translator.R("CPTempInternetFilesDescription"));
 
         // This section deals with how to use the disk space.
-        cbCompression.setSelectedIndex(parseInt(this.config.getProperty(Properties.COMPRESSION_ENABLED.toString())));
+        cbCompression.setSelectedIndex(parseInt(this.config.getProperty(DeploymentConfiguration.KEY_CACHE_COMPRESSION_ENABLED)));
         cbCompression.addItemListener(new ItemListener() {
             @Override
             public void itemStateChanged(ItemEvent e) {
-                config.setProperty(Properties.COMPRESSION_ENABLED.toString(), ((ComboItem) e.getItem()).getValue());
+                config.setProperty(DeploymentConfiguration.KEY_CACHE_COMPRESSION_ENABLED, ((ComboItem) e.getItem()).getValue());
             }
         });
 
         //Override getNextValue and getPreviousValue to make it jump to the closest increment/decrement of step size
-        final Long configCacheSize = parseLong(this.config.getProperty(Properties.CACHE_MAX_SIZE.toString()));
+        final Long configCacheSize = parseLong(this.config.getProperty(DeploymentConfiguration.KEY_CACHE_MAX_SIZE));
         final Long initialCacheSize = configCacheSize < CACHE_MIN_SIZE ? CACHE_MIN_SIZE : configCacheSize;
         final SpinnerNumberModel snmCacheSize = new PowerOfSpinnerNumberModel(initialCacheSize, TemporaryInternetFilesPanel.CACHE_MIN_SIZE, TemporaryInternetFilesPanel.CACHE_MAX_SIZE, TemporaryInternetFilesPanel.SPINNER_STEP_SIZE);
         cacheSizeSpinner.setModel(snmCacheSize);
@@ -232,7 +216,7 @@
 
                     if (canWrite) {
                         location.setText(result);
-                        config.setProperty(Properties.USER_CACHEDIR.toString(), result);
+                        config.setProperty(DeploymentConfiguration.KEY_USER_CACHE_DIR, result);
                     }
                 }
             }
@@ -356,7 +340,7 @@
                     cacheSizeWarningLabel.setText(Translator.R("TIFPCacheSizeSpinnerLargeValueWarning", usableDiskSpace));
                 }
 
-                config.setProperty(Properties.CACHE_MAX_SIZE.toString(), Long.valueOf(cacheSizeSpinnerValue).toString());
+                config.setProperty(DeploymentConfiguration.KEY_CACHE_MAX_SIZE, Long.valueOf(cacheSizeSpinnerValue).toString());
             } else {
                 showCacheSizeSpinnerGUIElements(false);
                 showCompressionAndLocationGUIElements(true);
@@ -377,12 +361,12 @@
             }
 
             if (selected) {
-                config.setProperty(Properties.CACHE_MAX_SIZE.toString(), cacheSizeSpinner.getValue().toString());
+                config.setProperty(DeploymentConfiguration.KEY_CACHE_MAX_SIZE, cacheSizeSpinner.getValue().toString());
             } else {
-                config.setProperty(Properties.CACHE_MAX_SIZE.toString(), Long.toString(CACHE_UNLIMITED_SIZE));
+                config.setProperty(DeploymentConfiguration.KEY_CACHE_MAX_SIZE, Long.toString(CACHE_UNLIMITED_SIZE));
             }
 
-            config.setProperty(Properties.CACHE_ENABLED.toString(), String.valueOf(!selected));
+            config.setProperty(DeploymentConfiguration.KEY_CACHE_ENABLED, String.valueOf(!selected));
         }
     }
 


More information about the distro-pkg-dev mailing list