/* ******** **
* Constant **
* ******** */
private void createConstantRow() {
final Term term = new Term();
term.setConstant( true );
/*
* Elements
*/
// PrefixCombo
final JComboBox constCombo = new JComboBox();
constCombo.setFont(this.parent.getFONT());
constCombo.addFocusListener(this.comboBoxFocusListener);
constCombo.addItemListener( new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent evt) {
if (evt.getStateChange() == ItemEvent.SELECTED) {
final JComboBox selectedChoice = (JComboBox)evt.getSource();
term.setSelectedPrefix(selectedChoice.getSelectedItem().toString());
term.setPrefix(true);
}
else if (evt.getStateChange() == ItemEvent.DESELECTED) {}
}
} );
term.setConstantCombo(constCombo);
// PrefixCombo
final JComboBox namedConstCombo = new JComboBox();
namedConstCombo.addFocusListener(this.comboBoxFocusListener);
namedConstCombo.addItemListener( new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent evt) {
if (evt.getStateChange() == ItemEvent.SELECTED) {
final JComboBox selectedChoice = (JComboBox)evt.getSource();
term.setPrefixForName(selectedChoice.getSelectedItem().toString());
}
else if (evt.getStateChange() == ItemEvent.DESELECTED) {}
}
} );
term.setNameComboBox(namedConstCombo);
// TextField Name
final JTextFieldResizing tfName = new HintTextFieldResizing("Name", "Name", this.parent.getFONT(), this);
tfName.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(final FocusEvent fe) {
term.setTfName(tfName);
}});
// TextField Value
final JTextFieldResizing tfValue = new HintTextFieldResizing("Value", "Value", this.parent.getFONT(), this);
tfValue.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(final FocusEvent fe) {
term.setValue(tfValue.getText());
}});
// Label
final JLabel label = new JLabel("Constant:");
label.setFont(this.parent.getFONT());
// Buttons
final Dimension buttonDimension = new Dimension();
buttonDimension.setSize(30d, 24d);
final JIconButton upButton = new JIconButton("icons/001_24.png");
upButton.setPreferredSize(buttonDimension);
upButton.setMaximumSize(buttonDimension);
upButton.setMinimumSize(buttonDimension);
upButton.addActionListener(new ActionListener(){
@Override
public void actionPerformed(final ActionEvent e) {
ListOperatorPanel.this.listOperator.swapTerms(term,true);
ListOperatorPanel.this.repaintAllTerms();
}});
final JIconButton downButton = new JIconButton("icons/001_22.png");
downButton.setPreferredSize(buttonDimension);
downButton.setMaximumSize(buttonDimension);
downButton.setMinimumSize(buttonDimension);
downButton.addActionListener(new ActionListener(){
@Override
public void actionPerformed(final ActionEvent e) {
ListOperatorPanel.this.listOperator.swapTerms(term,false);
ListOperatorPanel.this.repaintAllTerms();
}});
final JIconButton deleteButton = new JIconButton("icons/001_02.png");
deleteButton.setPreferredSize(buttonDimension);
deleteButton.setMaximumSize(buttonDimension);
deleteButton.setMinimumSize(buttonDimension);
deleteButton.addActionListener(new ActionListener(){
@Override
public void actionPerformed(final ActionEvent e) {
ListOperatorPanel.this.removeRow(term);
ListOperatorPanel.this.listOperator.getTerms().remove(term);
}});
/*
* Calibration
*/
this.gbc.gridy++;
this.gbc.gridx = 0;
this.termRowsPanel.add(upButton,this.gbc);
this.gbc.gridx++;
this.termRowsPanel.add(downButton,this.gbc);
this.gbc.gridx++;
this.termRowsPanel.add(label,this.gbc);
this.gbc.gridx++;
this.termRowsPanel.add(constCombo,this.gbc);
this.gbc.gridx++;
this.termRowsPanel.add(tfValue, this.gbc);
this.gbc.gridx++;
this.termRowsPanel.add(deleteButton,this.gbc);
this.termRowsPanel.remove(this.listOperator.getNextTermCombo());
this.createNextTermCombo();
term.setDeleteButton(deleteButton);
term.setUpButton(upButton);
term.setDownButton(downButton);
term.setLabel(label);
term.setTextFieldResizing(tfValue);
term.setTfName(tfName);
term.setInit(true);
this.listOperator.getTerms().add( term );
this.updateSize();
}