Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
donald committed Oct 18, 2014
1 parent 7ef98b9 commit 8866dcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
27 changes: 9 additions & 18 deletions src/de/mpg/molgen/buczek/portifix/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ private void updateForm() {
private final int EDIT_MODE_PERSON = 1;
private final int EDIT_MODE_EXEMPLAR = 2;

private int edit_mode;

private void startEdit(int edit_mode) {
this.edit_mode = edit_mode;
private void startEdit() {
jTable1.setEnabled(false);
// setTreeEnabled(jTable1, false);
button_refresh.setEnabled(false);
Expand All @@ -180,22 +177,16 @@ private void stopEdit() {
}

private void saveThis() {
System.out.printf("Edit mode : %d\n", edit_mode);
int selected[] = jTable1.getSelectedRows();

if (edit_mode == EDIT_MODE_EXEMPLAR) {
try {
String s = textField_datum.getText();
Date d = MyDateFormat.parse(s);
System.out.printf(" %s --> %s\n", s, d);
for (int i = 0; i < selected.length; i++) {
tableModel.setNewDateThis(jTable1.convertRowIndexToModel(selected[i]), d);
}
} catch (ParseException exception) {
// invalid date string. keep old values
try {
String s = textField_datum.getText();
Date d = MyDateFormat.parse(s);
for (int i = 0; i < selected.length; i++) {
tableModel.setNewDateThis(jTable1.convertRowIndexToModel(selected[i]), d);
}
} else {
throw new Error("internal error");
} catch (ParseException exception) {
// invalid date string. keep old values
}
}

Expand Down Expand Up @@ -240,7 +231,7 @@ public void focusGained(FocusEvent e) {
if (textField_datum.getText().equals("...")) {
textField_datum.setText("");
}
startEdit(EDIT_MODE_EXEMPLAR);
startEdit();
}

@Override
Expand Down
4 changes: 1 addition & 3 deletions src/de/mpg/molgen/buczek/portifix/TableModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,13 @@ public Class getColumnClass(int column) {
return COLUMN_CLASS[column];
}

private static boolean SHOW_ALL = true;
private static final boolean SHOW_ALL = true;

private MyDate upgradeOptionalDate(Date d) {
return d == null ? null : new MyDate(d);
}

void populate() throws SQLException {
System.out.println("populate\n");
row.clear();
Statement statement = con.createStatement();
ResultSet resultSet = statement.executeQuery(SHOW_ALL ? SQL_ALL : SQL);
Expand Down Expand Up @@ -152,7 +151,6 @@ void setNewDateThis(int rowIndex, Date newDate) {
statement.setString(2, (String) getValueAt(rowIndex, COLUMN_EXEMPLAR_ID));
statement.setString(3, (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);
Expand Down

0 comments on commit 8866dcd

Please sign in to comment.