public class VerantwortlicherModul extends AbstractModul {
/** Creates new form TestPanel */
public VerantwortlicherModul() {
initComponents();
init();
setName("Verantwortlicher");
verantwortlicherTable.holeDaten();
zaehleraktualisieren();
}
void init() {
verantwortlicherTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
verantwortlicherTable.setAutoCreateRowSorter(true);
int anzahlSpalten = verantwortlicherTable.getRowCount() - 1;
jLabel2.setText((new Integer(anzahlSpalten)).toString());
verantwortlicherTable.getModel().addTableModelListener(
new TableModelListener() {
public void tableChanged(TableModelEvent e) {
jtabletablechanged(e);
}
});
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
verantwortlicherTable = new VerantwortlicherTable();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jComboBox1 = new javax.swing.JComboBox();
_tfxMandant = new javax.swing.JLabel();
setLayout(new java.awt.GridBagLayout());
jLabel1.setText("Anzahl Datensätze: ");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 7;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 4, 4, 0);
add(jLabel1, gridBagConstraints);
jLabel2.setText("0");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 7;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 4, 0);
add(jLabel2, gridBagConstraints);
jScrollPane2.setViewportView(verantwortlicherTable);
jButton1.setText("Einfügen");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("Löschen");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(
jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout
.setHorizontalGroup(jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout
.createSequentialGroup()
.addComponent(
jScrollPane2,
javax.swing.GroupLayout.DEFAULT_SIZE,
639, Short.MAX_VALUE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(
jButton1,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(
jButton2,
javax.swing.GroupLayout.DEFAULT_SIZE,
92,
Short.MAX_VALUE))
.addContainerGap()));
jPanel1Layout
.setVerticalGroup(jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addContainerGap()
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jScrollPane2,
javax.swing.GroupLayout.PREFERRED_SIZE,
362,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addComponent(
jButton1)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jButton2)))
.addContainerGap(
javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 22;
gridBagConstraints.gridheight = 6;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 500.0;
gridBagConstraints.weighty = 500.0;
add(jPanel1, gridBagConstraints);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(
new String[] { "Walbusch" }));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.insets = new java.awt.Insets(3, 0, 3, 0);
add(jComboBox1, gridBagConstraints);
_tfxMandant.setText("Mandant");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(7, 11, 8, 10);
add(_tfxMandant, gridBagConstraints);
}// </editor-fold>
private void jtabletablechanged(TableModelEvent e) {
}
public void zaehleraktualisieren() {
int i = verantwortlicherTable.zaehlenAnzahl();
Integer meinInteger = new Integer(i);
String s = meinInteger.toString();
jLabel2.setText(s);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int position = verantwortlicherTable.getSelectedRow();
if (verantwortlicherTable.getSelectedRow() == -1) {
verantwortlicherTable.anlegenDatensatz(0);
} else if (verantwortlicherTable.getSelectedRow() != -1) {
verantwortlicherTable.anlegenDatensatz(position);
}
zaehleraktualisieren();
}
public void setzeDaten() {
verantwortlicherTable.holeDaten();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
int position;
position = verantwortlicherTable.getSelectedRow();
int i = FrameUtilities.showYesNoCancelDialog(null, null,
"Wollen Sie wirklich den Verantwortlichen löschen");
switch (i) {
case FrameUtilities.JA_OPTION:
verantwortlicherTable.deleteRow(position);
break;
case FrameUtilities.NEIN_OPTION:
break;
case FrameUtilities.ABBRECHEN_OPTION:
break;
default:
FrameUtilities.showMessageDialog(null, "Fehler", "Fehler!");
}
zaehleraktualisieren();
}
// Variables declaration - do not modify
private javax.swing.JLabel _tfxMandant;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane2;
private VerantwortlicherTable verantwortlicherTable;
// End of variables declaration
// *******************************************************************
// Implementiert Modul
// *******************************************************************
public void open() {
}
public void aktualisieren() {
verantwortlicherTable.aktualisieren();
}
public void speichern() {
verantwortlicherTable.speicherDaten();
}
public void deactivate() {
super.deactivate();
}
public void setModus() {
}