use of cbit.gui.TextFieldAutoCompletion in project vcell by virtualcell.
the class EventPanel method getDelayTextField.
// private InputVerifier delayInputVerifier = new InputVerifier() {
// @Override
// public boolean verify(JComponent input) {
// boolean bValid = true;
// Exception delayException = null;
// boolean bTextNotEmpty = getDelayTextField().getText() != null && getDelayTextField().getText().trim().length() > 0;
// try{
// if (bTextNotEmpty) {
// //Use createDelay to check validity
// createDelay(getBioEvent(),getDelayTextField().getText(),getSimulationContext(),getRdbtnTrigTime().isSelected());
// }
// }catch(Exception e){
// bValid = false;
// delayException = e;
// // e.printStackTrace();
// }
// if (bValid) {
// getDelayTextField().setBorder(UIManager.getBorder("TextField.border"));
// getDelayTextField().setToolTipText(null);
// enableTriggerRadioButtons(bTextNotEmpty);
// } else {
// getDelayTextField().setBorder(GuiConstants.ProblematicTextFieldBorder);
// getDelayTextField().setToolTipText("Error parse 'delay': "+delayException.getMessage());
// enableTriggerRadioButtons(false);
// // SwingUtilities.invokeLater(new Runnable() {
// // public void run() {
// // getDelayTextField().requestFocus();
// // }
// // });
// }
// return bValid;
// }
// };
// ActionListener editTimerActionListener = new ActionListener() {
// private String lastEdit = null;
// @Override
// public void actionPerformed(ActionEvent e) {
// if(!delayTextField.isPopupVisible()){
//
// }
// }
// };
// Timer editTimer;
private TextFieldAutoCompletion getDelayTextField() {
if (delayTextField == null) {
try {
delayTextField = new TextFieldAutoCompletion();
delayTextField.setName("DelayTextField");
KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
// System.out.println(evt);
if (evt.getPropertyName().equals("focusOwner") && evt.getNewValue() == delayTextField) {
// System.out.println("-----I got Focus "+delayTextField.hashCode()+" "+(getBioEvent()==null?null:getBioEvent().hashCode()));
} else if (evt.getPropertyName().equals("focusOwner") && evt.getOldValue() == delayTextField && evt.getNewValue() != delayTextField) {
// System.out.println("-----I lost Focus "+bErrorDialog+" "+delayTextField.hashCode()+" autolist visible="+delayTextField.isPopupVisible()+" "+(getBioEvent()==null?null:getBioEvent().hashCode()));
if (!delayTextField.isPopupVisible()) {
try {
setNewDelay(getBioEvent(), getDelayTextField().getText(), getSimulationContext(), getRdbtnTrigTime().isSelected());
} catch (Exception e) {
e.printStackTrace();
}
// System.out.println("set new delay="+(getBioEvent()==null?null:getBioEvent().getDelay()));
}
}
// System.out.println(EventPanel.this.hashCode()+" "+evt);
}
});
delayTextField.getDocument().addUndoableEditListener(new UndoableEditListener() {
@Override
public void undoableEditHappened(UndoableEditEvent e) {
if (delayTextField.getText() != null && delayTextField.getText().length() > 0) {
enableTriggerRadioButtons(true);
} else {
enableTriggerRadioButtons(false);
}
// delayInputVerifier.verify(delayTextField);
}
});
// delayTextField.addMouseListener(new MouseAdapter() {
// @Override
// public void mouseExited(MouseEvent e) {
// super.mouseExited(e);
// if(!delayTextField.isPopupVisible()){
// delayInputVerifier.verify(delayTextField);
// }else{
// System.out.println("-----MouseExit");
// }
// }
// });
delayTextField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
updateDelay();
}
});
//
// delayTextField.setInputVerifier(delayInputVerifier);
} catch (java.lang.Throwable e) {
e.printStackTrace(System.out);
}
}
return delayTextField;
}
Aggregations