From 7ef98b98b3346feae4c535ffb26498e62a8aedaf Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 18 Oct 2014 23:20:21 +0200 Subject: [PATCH] remove rueckgabedatum from table model fix wrong data shown in upper panel --- src/de/mpg/molgen/buczek/portifix/Gui.form | 8 +- src/de/mpg/molgen/buczek/portifix/Gui.java | 10 +-- .../molgen/buczek/portifix/TableModel.java | 80 ++++++------------- 3 files changed, 35 insertions(+), 63 deletions(-) diff --git a/src/de/mpg/molgen/buczek/portifix/Gui.form b/src/de/mpg/molgen/buczek/portifix/Gui.form index 61ab4f8..ec20260 100644 --- a/src/de/mpg/molgen/buczek/portifix/Gui.form +++ b/src/de/mpg/molgen/buczek/portifix/Gui.form @@ -24,7 +24,7 @@ - + @@ -105,10 +105,10 @@ - - + + - + diff --git a/src/de/mpg/molgen/buczek/portifix/Gui.java b/src/de/mpg/molgen/buczek/portifix/Gui.java index dcadc37..3e54c0f 100644 --- a/src/de/mpg/molgen/buczek/portifix/Gui.java +++ b/src/de/mpg/molgen/buczek/portifix/Gui.java @@ -142,8 +142,8 @@ private void updateForm() { String[] name = new String[selected.length]; String[] exemplar = new String[selected.length]; for (int i = 0; i < name.length; i++) { - name[i] = join(" ", (String) tableModel.getValueAt(i, TableModel.COLUMN_VORNAME), (String) tableModel.getValueAt(i, TableModel.COLUMN_NACHNAME)); - exemplar[i] = join(" # ", (String) tableModel.getValueAt(i, TableModel.COLUMN_SCHLUESSELNUMMER), (String) tableModel.getValueAt(i, TableModel.COLUMN_EXEMPLARNUMMER)); + name[i] = join(" ", (String) tableModel.getValueAt(selected[i], TableModel.COLUMN_VORNAME), (String) tableModel.getValueAt(selected[i], TableModel.COLUMN_NACHNAME)); + exemplar[i] = join(" # ", (String) tableModel.getValueAt(selected[i], TableModel.COLUMN_SCHLUESSELNUMMER), (String) tableModel.getValueAt(selected[i], TableModel.COLUMN_EXEMPLARNUMMER)); } label_name.setText(singleColumnValueOfArray(name)); @@ -334,9 +334,9 @@ private void initComponents() { .addComponent(jLabel3)) .addGap(19, 19, 19) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(label_name, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(label_name, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE) .addComponent(label_abteilung, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap(66, Short.MAX_VALUE)) + .addContainerGap(22, Short.MAX_VALUE)) ); jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel3}); @@ -444,7 +444,7 @@ private void initComponents() { getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE) + .addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) diff --git a/src/de/mpg/molgen/buczek/portifix/TableModel.java b/src/de/mpg/molgen/buczek/portifix/TableModel.java index 79af27a..6b2330f 100644 --- a/src/de/mpg/molgen/buczek/portifix/TableModel.java +++ b/src/de/mpg/molgen/buczek/portifix/TableModel.java @@ -24,28 +24,25 @@ public class TableModel extends AbstractTableModel { Connection con; - public final static int COLUMN_NACHNAME=0; - public final static int COLUMN_VORNAME=1; - public final static int COLUMN_ABTEILUNG=2; - public final static int COLUMN_ENDEDATUM=3; - public final static int COLUMN_SCHLUESSELNUMMER=4; - public final static int COLUMN_EXEMPLARNUMMER=5; - public final static int COLUMN_RUECKGABEDATUM=6; - - public final static int COLUMN_VISIBLE_COUNT=7; - - public final static int COLUMN_AUSAGBE_ID=7; - public final static int COLUMN_EXEMPLAR_ID=8; - public final static int COLUMN_PERSONAL_ID=9; - - public final static int COLUMN_COUNT=10; - - + public final static int COLUMN_NACHNAME = 0; + public final static int COLUMN_VORNAME = 1; + public final static int COLUMN_ABTEILUNG = 2; + public final static int COLUMN_SCHLUESSELNUMMER = 3; + public final static int COLUMN_EXEMPLARNUMMER = 4; + public final static int COLUMN_RUECKGABEDATUM = 5; + + public final static int COLUMN_VISIBLE_COUNT = 6; + + public final static int COLUMN_AUSAGBE_ID = 6; + public final static int COLUMN_EXEMPLAR_ID = 7; + public final static int COLUMN_PERSONAL_ID = 8; + + public final static int COLUMN_COUNT = 10; + private final String COLUMN_NAMES[] = { "Nachname", "Vorname", "Abteilung", - "Ende Datum", "Schlüsselnummer", "Exemplarnummer", "Rückgabedatum", @@ -58,20 +55,15 @@ public class TableModel extends AbstractTableModel { String.class, String.class, String.class, - MyDate.class, String.class, String.class, MyDate.class, String.class, String.class, - String.class, - }; - - - - + String.class,}; + final private String SQL - = "select NAME_1,NAME_2,ABTEILUNG,ENDEDATUM,RUECKGABETERMINDATUM,AUSGABE.SCHLUESSELNUMMER," + = "select NAME_1,NAME_2,ABTEILUNG,RUECKGABETERMINDATUM,AUSGABE.SCHLUESSELNUMMER," + "EXEMPLARNUMMER,AUSGABE_ID,AUSGABE.EXEMPLAR_ID,AUSGABE.PERSONAL_ID" + " from AUSGABE,PERSONAL,EXEMPLAR" + " where AUSGABE.PERSONAL_ID=PERSONAL.PERSONAL_ID" @@ -80,7 +72,7 @@ public class TableModel extends AbstractTableModel { + " order by rueckgabetermindatum"; final private String SQL_ALL - = "select NAME_1,NAME_2,ABTEILUNG,ENDEDATUM,RUECKGABETERMINDATUM,AUSGABE.SCHLUESSELNUMMER," + = "select NAME_1,NAME_2,ABTEILUNG,RUECKGABETERMINDATUM,AUSGABE.SCHLUESSELNUMMER," + "EXEMPLARNUMMER,AUSGABE_ID,AUSGABE.EXEMPLAR_ID,AUSGABE.PERSONAL_ID" + " from AUSGABE,PERSONAL,EXEMPLAR" + " where AUSGABE.PERSONAL_ID=PERSONAL.PERSONAL_ID" @@ -131,20 +123,19 @@ void populate() throws SQLException { row[COLUMN_NACHNAME] = resultSet.getString(1); // name_1 vorname row[COLUMN_VORNAME] = resultSet.getString(2); // name_2 nachname row[COLUMN_ABTEILUNG] = resultSet.getString(3); // abteilung - row[COLUMN_ENDEDATUM] = upgradeOptionalDate(resultSet.getDate(4)); // endedatum (person) - row[COLUMN_RUECKGABEDATUM] = upgradeOptionalDate(resultSet.getDate(5)); // rueckgabetermin (ausgabe) - row[COLUMN_SCHLUESSELNUMMER] = resultSet.getString(6); // schluesselnummer - row[COLUMN_EXEMPLARNUMMER] = resultSet.getString(7); // exemplarnummer - row[COLUMN_AUSAGBE_ID] = resultSet.getString(8); // ausgabeid - row[COLUMN_EXEMPLAR_ID] = resultSet.getString(9); // exemplarid - row[COLUMN_PERSONAL_ID] = resultSet.getString(10); // personalid + row[COLUMN_RUECKGABEDATUM] = upgradeOptionalDate(resultSet.getDate(4)); // rueckgabetermin (ausgabe) + row[COLUMN_SCHLUESSELNUMMER] = resultSet.getString(5); // schluesselnummer + row[COLUMN_EXEMPLARNUMMER] = resultSet.getString(6); // exemplarnummer + row[COLUMN_AUSAGBE_ID] = resultSet.getString(7); // ausgabeid + row[COLUMN_EXEMPLAR_ID] = resultSet.getString(8); // exemplarid + row[COLUMN_PERSONAL_ID] = resultSet.getString(9); // personalid this.row.add(row); } this.fireTableDataChanged(); } public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; + return false; } private static final String UPDATE_STATEMENT @@ -168,26 +159,7 @@ void setNewDateThis(int rowIndex, Date newDate) { } } - private static final String UPDATE_STATEMENT_PERSON - = "update PERSONAL " - + " set ENDEDATUM=?" - + " where PERSONAL_ID=?"; - void setNewDatePerson(int rowIndex, Date newDate) { - PreparedStatement statement; - try { - statement = con.prepareStatement(UPDATE_STATEMENT_PERSON); - statement.setDate(1, new java.sql.Date(newDate.getTime())); - statement.setString(2, (String) getValueAt(rowIndex, COLUMN_PERSONAL_ID)); - int i = statement.executeUpdate(); - System.out.printf("%d rows updated\n", i); - populate(); - } catch (SQLException ex) { - Logger.getLogger(TableModel.class.getName()).log(Level.SEVERE, null, ex); - } - } - public void setConnection(Connection c) { this.con = c; } - }