Merge branch 'develop' into features/JAL-2446NCList
[jalview.git] / src / jalview / io / cache / JvCacheableInputBox.java
index 444670b..3d0daed 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.io.cache;
 
 import jalview.bin.Cache;
@@ -55,7 +75,8 @@ public class JvCacheableInputBox<E> extends JComboBox<String>
     super();
     this.cacheKey = newCacheKey;
     setEditable(true);
-    setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+    setPrototypeDisplayValue(
+            "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
     appCache = AppCache.getInstance();
     initCachePopupMenu();
     initCache(newCacheKey);
@@ -77,8 +98,8 @@ public class JvCacheableInputBox<E> extends JComboBox<String>
       return;
     }
     // convert delimited cache items to a list of strings
-    List<String> persistedCacheItems = Arrays.asList(delimitedCacheStr
-            .split(AppCache.CACHE_DELIMITER));
+    List<String> persistedCacheItems = Arrays
+            .asList(delimitedCacheStr.split(AppCache.CACHE_DELIMITER));
 
     LinkedHashSet<String> foundCacheItems = appCache
             .getAllCachedItemsFor(cacheKey);
@@ -101,12 +122,12 @@ public class JvCacheableInputBox<E> extends JComboBox<String>
   {
     pnlDefaultCache.setBackground(Color.WHITE);
     // pad panel so as to align with other menu items
-    pnlDefaultCache.setBorder(BorderFactory.createEmptyBorder(0,
-            LEFT_BOARDER_WIDTH, 0, 0));
+    pnlDefaultCache.setBorder(
+            BorderFactory.createEmptyBorder(0, LEFT_BOARDER_WIDTH, 0, 0));
     txtDefaultCacheSize.setPreferredSize(new Dimension(45, 20));
     txtDefaultCacheSize.setFont(new java.awt.Font("Verdana", 0, 12));
-    lblDefaultCacheSize.setText(MessageManager
-            .getString("label.default_cache_size"));
+    lblDefaultCacheSize
+            .setText(MessageManager.getString("label.default_cache_size"));
     lblDefaultCacheSize.setFont(new java.awt.Font("Verdana", 0, 12));
     // Force input to accept only Integer entries up to length - INPUT_LIMIT
     txtDefaultCacheSize.setDocument(new PlainDocument()
@@ -141,8 +162,8 @@ public class JvCacheableInputBox<E> extends JComboBox<String>
     pnlDefaultCache.add(lblDefaultCacheSize);
     menuItemClearCache.setFont(new java.awt.Font("Verdana", 0, 12));
     pnlDefaultCache.add(txtDefaultCacheSize);
-    menuItemClearCache.setText(MessageManager
-            .getString("action.clear_cached_items"));
+    menuItemClearCache
+            .setText(MessageManager.getString("action.clear_cached_items"));
     menuItemClearCache.addActionListener(new ActionListener()
     {
       @Override
@@ -195,9 +216,9 @@ public class JvCacheableInputBox<E> extends JComboBox<String>
       @Override
       public void run()
       {
-        int userLimit = txtDefaultCacheSize.getText().trim().isEmpty() ? Integer
-                .valueOf(AppCache.DEFAULT_LIMIT) : Integer
-                .valueOf(txtDefaultCacheSize.getText());
+        int userLimit = txtDefaultCacheSize.getText().trim().isEmpty()
+                ? Integer.valueOf(AppCache.DEFAULT_LIMIT)
+                : Integer.valueOf(txtDefaultCacheSize.getText());
         int cacheLimit = appCache.updateCacheLimit(cacheKey, userLimit);
         String userInput = getUserInput();
         if (userInput != null && !userInput.isEmpty())
@@ -259,7 +280,6 @@ public class JvCacheableInputBox<E> extends JComboBox<String>
     });
   }
 
-
   /**
    * This method should be called to persist the in-memory cache when this
    * components parent frame is closed / exited
@@ -267,9 +287,9 @@ public class JvCacheableInputBox<E> extends JComboBox<String>
   public void persistCache()
   {
     appCache.persistCache(cacheKey);
-    int userLimit = txtDefaultCacheSize.getText().trim().isEmpty() ? Integer
-            .valueOf(AppCache.DEFAULT_LIMIT) : Integer
-            .valueOf(txtDefaultCacheSize.getText());
+    int userLimit = txtDefaultCacheSize.getText().trim().isEmpty()
+            ? Integer.valueOf(AppCache.DEFAULT_LIMIT)
+            : Integer.valueOf(txtDefaultCacheSize.getText());
     appCache.updateCacheLimit(cacheKey, userLimit);
   }
 
@@ -280,8 +300,8 @@ public class JvCacheableInputBox<E> extends JComboBox<String>
    */
   public String getUserInput()
   {
-    return getEditor().getItem() == null ? "" : getEditor().getItem()
-            .toString().trim();
+    return getEditor().getItem() == null ? ""
+            : getEditor().getItem().toString().trim();
   }
 
 }