import jalview.util.MessageManager;
import jalview.util.Platform;
+import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusListener;
volatile boolean enterWasPressed = false;
+private String prototypeDisplayValue;
+
+private boolean isJS;
+
/**
* @return flag indicating if the most recent keypress was enter
*/
public JvCacheableInputBox(String newCacheKey)
{
super();
- if (Platform.isJS())
+ isJS = true;//Platform.isJS();
+ this.prototypeDisplayValue =
+ "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
+ if (isJS)
{
- textField = new JTextField();
+ textField = new JTextField() {
+ public Dimension getPreferredSize() {
+ return super.getPreferredSize();
+// FontMetrics fm = getFontMetrics(getFont());
+// return new Dimension(fm.stringWidth(prototypeDisplayValue), fm.getHeight());
+ }
+ };
return;
}
// let event bubble up
}
});
- comboBox.setPrototypeDisplayValue(
- "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
+ comboBox.setPrototypeDisplayValue(prototypeDisplayValue);
appCache = AppCache.getInstance();
initCachePopupMenu();
initCache(newCacheKey);
*/
public void updateCache()
{
- if (Platform.isJS())
+ if (isJS)
{
return;
}
*/
public void persistCache()
{
- if (!Platform.isJS())
+ if (!isJS)
{
appCache.persistCache(cacheKey);
}
*/
public String getUserInput()
{
- if (Platform.isJS())
+ if (isJS)
{
return textField.getText().trim();
}
public JComponent getComponent()
{
- return Platform.isJS() ? textField : comboBox;
+ return isJS ? textField : comboBox;
}
public void addActionListener(ActionListener actionListener)
{
- if (Platform.isJS())
+ if (isJS)
{
textField.addActionListener(actionListener);
}
public void addDocumentListener(DocumentListener listener)
{
- if (!Platform.isJS())
+ if (!isJS)
{
((JTextComponent) comboBox.getEditor().getEditorComponent())
.getDocument().addDocumentListener(listener);
public void addFocusListener(FocusListener focusListener)
{
- if (Platform.isJS())
+ if (isJS)
{
textField.addFocusListener(focusListener);
}
public void addKeyListener(KeyListener kl)
{
- if (!Platform.isJS())
+ if (!isJS)
{
comboBox.getEditor().getEditorComponent().addKeyListener(kl);
}
public void setEditable(boolean b)
{
- if (!Platform.isJS())
+ if (!isJS)
{
comboBox.setEditable(b);
}
public void setPrototypeDisplayValue(String string)
{
- if (!Platform.isJS())
+ this.prototypeDisplayValue = string;
+ if (!isJS)
{
comboBox.setPrototypeDisplayValue(string);
- }
+ }
}
public void setSelectedItem(String userInput)
{
- if (!Platform.isJS())
+ if (!isJS)
{
comboBox.setSelectedItem(userInput);
}
public boolean isPopupVisible()
{
- if (!Platform.isJS())
+ if (!isJS)
{
return comboBox.isPopupVisible();
}
public void addCaretListener(CaretListener caretListener)
{
- if (!Platform.isJS())
+ if (!isJS)
{
((JTextComponent) comboBox.getEditor().getEditorComponent())
.addCaretListener(caretListener);
public void addItem(String item)
{
- if (!Platform.isJS())
+ if (!isJS)
{
comboBox.addItem(item);
}