private void ruleDeleteButtonActionPerformed( java.awt.event.ActionEvent evt) // GEN-FIRST:event_ruleDeleteButtonActionPerformed { // GEN-HEADEREND:event_ruleDeleteButtonActionPerformed commitTableEdits(); SegmentationRulesModel model = (SegmentationRulesModel) ruleTable.getModel(); model.removeRow(ruleTable.getSelectedRow()); } // GEN-LAST:event_ruleDeleteButtonActionPerformed
@Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (e.getSource() == mapTable.getSelectionModel()) { mapErrorsLabel.setText(""); if (lsm.isSelectionEmpty()) { mapDeleteButton.setEnabled(false); mapUpButton.setEnabled(false); mapDownButton.setEnabled(false); ruleTable.setModel(new DefaultTableModel()); ruleInsertButton.setEnabled(false); } else { mapDeleteButton.setEnabled(true); int selrow = mapTable.getSelectedRow(); int rows = mapTable.getRowCount(); if (selrow > 0) mapUpButton.setEnabled(true); else mapUpButton.setEnabled(false); if (selrow < (rows - 1)) mapDownButton.setEnabled(true); else mapDownButton.setEnabled(false); MapRule maprule = this.editableSRX.getMappingRules().get(selrow); SegmentationRulesModel model = new SegmentationRulesModel(maprule.getRules()); ruleTable.setModel(model); model.addExceptionListener( new ExceptionListener() { @Override public void exceptionThrown(Exception e) { ruleErrorsLabel.setText(e.getLocalizedMessage()); } }); ruleInsertButton.setEnabled(true); } } else if (e.getSource() == ruleTable.getSelectionModel()) { ruleErrorsLabel.setText(""); if (lsm.isSelectionEmpty()) { ruleDeleteButton.setEnabled(false); ruleUpButton.setEnabled(false); ruleDownButton.setEnabled(false); } else { ruleDeleteButton.setEnabled(true); int rules = ruleTable.getRowCount(); int rulerow = ruleTable.getSelectedRow(); if (rulerow > 0) ruleUpButton.setEnabled(true); else ruleUpButton.setEnabled(false); if (rulerow < (rules - 1)) ruleDownButton.setEnabled(true); else ruleDownButton.setEnabled(false); } } }
private void ruleInsertButtonActionPerformed( java.awt.event.ActionEvent evt) // GEN-FIRST:event_ruleInsertButtonActionPerformed { // GEN-HEADEREND:event_ruleInsertButtonActionPerformed commitTableEdits(); SegmentationRulesModel model = (SegmentationRulesModel) ruleTable.getModel(); model.addRow(); ruleTable.changeSelection(ruleTable.getRowCount() - 1, 0, false, false); ruleTable.changeSelection( ruleTable.getRowCount() - 1, ruleTable.getColumnCount() - 1, false, true); } // GEN-LAST:event_ruleInsertButtonActionPerformed
private void ruleUpButtonActionPerformed( java.awt.event.ActionEvent evt) // GEN-FIRST:event_ruleUpButtonActionPerformed { // GEN-HEADEREND:event_ruleUpButtonActionPerformed commitTableEdits(); SegmentationRulesModel model = (SegmentationRulesModel) ruleTable.getModel(); int selrow = ruleTable.getSelectedRow(); model.moveRowUp(selrow); ruleTable.getSelectionModel().clearSelection(); ruleTable.getSelectionModel().addSelectionInterval(selrow - 1, selrow - 1); } // GEN-LAST:event_ruleUpButtonActionPerformed