From: tcofoegbu Date: Thu, 4 May 2017 18:22:16 +0000 (+0100) Subject: JAL-1648 improvements: enter key closes the popup and updates cache immidately, unifo... X-Git-Tag: Release_2_10_2~3^2~45^2~5 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=911f6d89255dfb01f864a65760057a4cbb4b6564;p=jalview.git JAL-1648 improvements: enter key closes the popup and updates cache immidately, uniform font applied to all popup's component --- diff --git a/src/jalview/io/cache/JvCacheableInputBox.java b/src/jalview/io/cache/JvCacheableInputBox.java index 06302c3..499654c 100644 --- a/src/jalview/io/cache/JvCacheableInputBox.java +++ b/src/jalview/io/cache/JvCacheableInputBox.java @@ -7,6 +7,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -33,7 +34,7 @@ public class JvCacheableInputBox extends JComboBox private static final int INPUT_LIMIT = 2; - private static final int LEFT_BOARDER_WIDTH = 2; + private static final int LEFT_BOARDER_WIDTH = 18; private String cacheKey; @@ -80,7 +81,7 @@ public class JvCacheableInputBox extends JComboBox .split(AppCache.CACHE_DELIMITER)); LinkedHashSet foundCacheItems = appCache - .getAllCachedItemsFor(cacheKey);// cacheItems.get(cacheKey); + .getAllCachedItemsFor(cacheKey); if (foundCacheItems == null) { foundCacheItems = new LinkedHashSet(); @@ -103,8 +104,10 @@ public class JvCacheableInputBox extends JComboBox 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.setFont(new java.awt.Font("Verdana", 0, 12)); // Force input to accept only Integer entries up to length - INPUT_LIMIT txtDefaultCacheSize.setDocument(new PlainDocument() { @@ -120,8 +123,23 @@ public class JvCacheableInputBox extends JComboBox } } }); + txtDefaultCacheSize.addKeyListener(new java.awt.event.KeyAdapter() + { + @Override + public void keyPressed(KeyEvent e) + { + if (e.getKeyCode() == KeyEvent.VK_ENTER) + { + e.consume(); + updateCache(); + closePopup(); + } + } + }); + txtDefaultCacheSize.setText(appCache.getCacheLimit(cacheKey)); pnlDefaultCache.add(lblDefaultCacheSize); + menuItemClearCache.setFont(new java.awt.Font("Verdana", 0, 12)); pnlDefaultCache.add(txtDefaultCacheSize); menuItemClearCache.setText(MessageManager .getString("action.clear_cached_items")); @@ -143,6 +161,12 @@ public class JvCacheableInputBox extends JComboBox add(popup); } + private void closePopup() + { + popup.setVisible(false); + popup.transferFocus(); + } + /** * Answers true if input text is an integer *