X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fcache%2FJvCacheableInputBox.java;h=a837512c9d76d14dd905cfb4023b10c1a93dbba7;hb=d5702bf3268c2688e90d645ec635ad5bb5d3a76e;hp=1949ef02b1269f8f4877cf23ee809ee6c91c189c;hpb=3d0101179759ef157b088ea135423cd909512d9f;p=jalview.git diff --git a/src/jalview/io/cache/JvCacheableInputBox.java b/src/jalview/io/cache/JvCacheableInputBox.java index 1949ef0..a837512 100644 --- a/src/jalview/io/cache/JvCacheableInputBox.java +++ b/src/jalview/io/cache/JvCacheableInputBox.java @@ -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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.io.cache; import jalview.bin.Cache; @@ -8,6 +28,7 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -50,11 +71,49 @@ public class JvCacheableInputBox extends JComboBox private JMenuItem menuItemClearCache = new JMenuItem(); + volatile boolean enterWasPressed = false; + + /** + * @return flag indicating if the most recent keypress was enter + */ + public boolean wasEnterPressed() + { + return enterWasPressed; + } + public JvCacheableInputBox(String newCacheKey) { super(); this.cacheKey = newCacheKey; setEditable(true); + addKeyListener(new KeyListener() + { + + @Override + public void keyTyped(KeyEvent e) + { + enterWasPressed = false; + if (e.getKeyCode() == KeyEvent.VK_ENTER) + { + enterWasPressed = true; + } + // let event bubble up + } + + @Override + public void keyReleased(KeyEvent e) + { + // TODO Auto-generated method stub + + } + + @Override + public void keyPressed(KeyEvent e) + { + // TODO Auto-generated method stub + + } + }); setPrototypeDisplayValue( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); appCache = AppCache.getInstance();