/*
* Uniterm
*/
private void createUnitermRow(){
final Term term = new Term();
term.setUniterm(true);
/*
* Elements
*/
// 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);
}});
// Label
final JLabel label = new JLabel("Uniterm:");
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) {
UnitermOperatorPanel.this.unitermOperator.swapTerms(term,true);
UnitermOperatorPanel.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) {
UnitermOperatorPanel.this.unitermOperator.swapTerms(term,false);
UnitermOperatorPanel.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) {
UnitermOperatorPanel.this.removeRow(term);
UnitermOperatorPanel.this.unitermOperator.getTerms().remove(term);
}});
final JButton connectionButton = new JButton("Connection");
connectionButton.addActionListener(new ActionListener(){
@Override
public void actionPerformed(final ActionEvent e) {
final RuleGraph ruleGraph = (RuleGraph) UnitermOperatorPanel.this.parent;
ruleGraph.getVisualEditor().connectionMode = new TermConnection(ruleGraph,UnitermOperatorPanel.this.unitermOperator,term);
connectionButton.setEnabled(false);
}});
/*
* 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++;
if ( this.unitermOperator.isNamed() ) {
this.termRowsPanel.add(namedConstCombo,this.gbc);
this.gbc.gridx++;
this.termRowsPanel.add(tfName,this.gbc);
this.gbc.gridx++;
}
this.gbc.gridx++;
this.termRowsPanel.add(connectionButton,this.gbc);
this.gbc.gridx++;
this.termRowsPanel.add(deleteButton,this.gbc);
this.termRowsPanel.remove(this.unitermOperator.getNextTermCombo());
this.createNextTermCombo();
term.setDeleteButton(deleteButton);
term.setUpButton(upButton);
term.setDownButton(downButton);
term.setLabel(label);
term.setConnectionButton(connectionButton);
term.setTfName(tfName);
term.setInit(true);
this.unitermOperator.getTerms().add( term );
this.updateSize();
}