From e540683b0692c9a7807a4093a955f68b4cae916e Mon Sep 17 00:00:00 2001 From: Tim Bernhard Date: Wed, 27 Jan 2021 16:06:43 +0100 Subject: [PATCH] Fix part of #33: update specimen parts table on attribute change --- .../entity/SpecimenPartAttribute.java | 2 +- .../mcz/imagecapture/ui/ButtonEditor.java | 8 +- .../dialog/SpecimenPartAttributeDialog.java | 571 +++++++++--------- .../ui/frame/SpecimenDetailsViewPane.java | 4 + 4 files changed, 291 insertions(+), 294 deletions(-) diff --git a/src/main/java/edu/harvard/mcz/imagecapture/entity/SpecimenPartAttribute.java b/src/main/java/edu/harvard/mcz/imagecapture/entity/SpecimenPartAttribute.java index 3870d19..6cbc476 100644 --- a/src/main/java/edu/harvard/mcz/imagecapture/entity/SpecimenPartAttribute.java +++ b/src/main/java/edu/harvard/mcz/imagecapture/entity/SpecimenPartAttribute.java @@ -179,7 +179,7 @@ public Object clone() { SpecimenPartAttribute newAttr = new SpecimenPartAttribute( null, attributeType, attributeValue, attributeUnits, attributeRemark, attributeDeterminer, - (Date)attributeDate.clone()); + attributeDate == null ? null : (Date)attributeDate.clone()); return newAttr; } } diff --git a/src/main/java/edu/harvard/mcz/imagecapture/ui/ButtonEditor.java b/src/main/java/edu/harvard/mcz/imagecapture/ui/ButtonEditor.java index 34ff392..1ede761 100644 --- a/src/main/java/edu/harvard/mcz/imagecapture/ui/ButtonEditor.java +++ b/src/main/java/edu/harvard/mcz/imagecapture/ui/ButtonEditor.java @@ -275,11 +275,7 @@ public void actionPerformed(ActionEvent e) { ((PositionTemplateEditor)parentComponent) .setTemplate((String)targetId); } catch (NoSuchTemplateException e1) { - log.error("No such template on button press on a template in list."); - log.error("Error", e1); - ; - log.trace("Trace", e1); - ; + log.error("No such template on button press on a template in list.", e1); } break; @@ -332,7 +328,7 @@ public void actionPerformed(ActionEvent e) { break; case OPEN_SPECIMENPARTATTRIBUTES: SpecimenPartAttributeDialog attrDialog = - new SpecimenPartAttributeDialog((SpecimenPart)targetId); + new SpecimenPartAttributeDialog((SpecimenPart)targetId, parentComponent); attrDialog.setVisible(true); break; } diff --git a/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/SpecimenPartAttributeDialog.java b/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/SpecimenPartAttributeDialog.java index d96f01a..0914cec 100644 --- a/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/SpecimenPartAttributeDialog.java +++ b/src/main/java/edu/harvard/mcz/imagecapture/ui/dialog/SpecimenPartAttributeDialog.java @@ -32,319 +32,316 @@ import edu.harvard.mcz.imagecapture.exceptions.SaveFailedException; import edu.harvard.mcz.imagecapture.lifecycle.SpecimenPartAttributeLifeCycle; import edu.harvard.mcz.imagecapture.lifecycle.SpecimenPartLifeCycle; +import edu.harvard.mcz.imagecapture.ui.frame.SpecimenDetailsViewPane; import edu.harvard.mcz.imagecapture.ui.tablemodel.SpecimenPartsAttrTableModel; -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.border.EmptyBorder; -import javax.swing.table.AbstractTableModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.table.AbstractTableModel; +import java.awt.*; +import java.awt.event.*; + /** * Dialog providing a list of specimen part attributes for a specimen part, * with the ability to add more attributes. */ public class SpecimenPartAttributeDialog extends JDialog { - private static final long serialVersionUID = 1870811168027430021L; - - private static final Logger log = - LoggerFactory.getLogger(SpecimenPartAttributeDialog.class); - private final JPanel contentPanel = new JPanel(); - private SpecimenPartAttributeDialog thisDialog; - private JTable table; - private JPopupMenu popupMenu; // on table - private int clickedOnRow; // on table - - private JButton okButton; + private static final long serialVersionUID = 1870811168027430021L; - private final SpecimenPart parentPart; - private JComboBox comboBoxType; - private JComboBox comboBoxValue; - private JTextField textFieldUnits; - private JTextField textFieldRemarks; + private static final Logger log = + LoggerFactory.getLogger(SpecimenPartAttributeDialog.class); + private final JPanel contentPanel = new JPanel(); + private final SpecimenPart parentPart; + private Component parentComponent; + private SpecimenPartAttributeDialog thisDialog; + private JTable table; + private JPopupMenu popupMenu; // on table + private int clickedOnRow; // on table + private JButton okButton; + private JComboBox comboBoxType; + private JComboBox comboBoxValue; + private JTextField textFieldUnits; + private JTextField textFieldRemarks; - /** - * Create the dialog. - */ - public SpecimenPartAttributeDialog(SpecimenPart parentPart) { - this.parentPart = parentPart; - SpecimenPartLifeCycle spls = new SpecimenPartLifeCycle(); - spls.merge(parentPart); - // SpecimenPartAttributeLifeCycle spals = new - // SpecimenPartAttributeLifeCycle(); Iterator i - // = parentPart.getAttributeCollection().iterator(); while - // (i.hasNext()) { try { - //SpecimenPartAttribute attrib = i.next(); spals.persist(attrib); - //} catch (SaveFailedException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - // } - init(); - } - - public SpecimenPartAttributeDialog() { - this.parentPart = new SpecimenPart(); - init(); - } - - private void init() { - thisDialog = this; - setBounds(100, 100, 820, 335); - getContentPane().setLayout(new BorderLayout()); - contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); - getContentPane().add(contentPanel, BorderLayout.CENTER); - JPanel panel = new JPanel(); - panel.setLayout(new FormLayout( - new ColumnSpec[] { - FormSpecs.RELATED_GAP_COLSPEC, - FormSpecs.DEFAULT_COLSPEC, - FormSpecs.RELATED_GAP_COLSPEC, - ColumnSpec.decode("default:grow"), - }, - new RowSpec[] { - FormSpecs.RELATED_GAP_ROWSPEC, - FormSpecs.DEFAULT_ROWSPEC, - FormSpecs.RELATED_GAP_ROWSPEC, - FormSpecs.DEFAULT_ROWSPEC, - FormSpecs.RELATED_GAP_ROWSPEC, - FormSpecs.DEFAULT_ROWSPEC, - FormSpecs.RELATED_GAP_ROWSPEC, - FormSpecs.DEFAULT_ROWSPEC, - FormSpecs.RELATED_GAP_ROWSPEC, - FormSpecs.DEFAULT_ROWSPEC, - })); - { - JLabel lblAttributeType = new JLabel("Attribute Type"); - panel.add(lblAttributeType, "2, 2, right, default"); + /** + * Create the dialog. + */ + public SpecimenPartAttributeDialog(SpecimenPart parentPart) { + this.parentPart = parentPart; + SpecimenPartLifeCycle spls = new SpecimenPartLifeCycle(); + spls.merge(parentPart); + // SpecimenPartAttributeLifeCycle spals = new + // SpecimenPartAttributeLifeCycle(); Iterator i + // = parentPart.getAttributeCollection().iterator(); while + // (i.hasNext()) { try { + //SpecimenPartAttribute attrib = i.next(); spals.persist(attrib); + //} catch (SaveFailedException e) { + // // TODO Auto-generated catch block + // e.printStackTrace(); + // } + // } + init(); } - { - comboBoxType = new JComboBox(); - comboBoxType.setModel(new DefaultComboBoxModel( - new String[] {"caste", "scientific name", "sex", "life stage", - "part association"})); - comboBoxType.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String item = comboBoxType.getSelectedItem().toString(); - if (item != null) { - comboBoxValue.setEditable(false); - if (item.equals("scientific name")) { - comboBoxValue.setEditable(true); - } - if (item.equals("sex")) { - comboBoxValue.setModel( - new DefaultComboBoxModel(Sex.getSexValues())); - } - if (item.equals("life stage")) { - comboBoxValue.setModel( - new DefaultComboBoxModel(LifeStage.getLifeStageValues())); - } - if (item.equals("caste")) { - comboBoxValue.setModel( - new DefaultComboBoxModel(Caste.getCasteValues())); - } - if (item.equals("part association")) { - comboBoxValue.setModel(new DefaultComboBoxModel( - PartAssociation.getPartAssociationValues())); - } - } - } - }); - panel.add(comboBoxType, "4, 2, fill, default"); - } - { - JLabel lblValue = new JLabel("Value"); - panel.add(lblValue, "2, 4, right, default"); - } - { - comboBoxValue = new JComboBox(); - comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); - panel.add(comboBoxValue, "4, 4, fill, default"); - } - { - JLabel lblUnits = new JLabel("Units"); - panel.add(lblUnits, "2, 6, right, default"); - } - { - textFieldUnits = new JTextField(); - panel.add(textFieldUnits, "4, 6, fill, default"); - textFieldUnits.setColumns(10); - } - { - JLabel lblRemarks = new JLabel("Remarks"); - panel.add(lblRemarks, "2, 8, right, default"); - } - contentPanel.setLayout(new BorderLayout(0, 0)); - contentPanel.add(panel, BorderLayout.WEST); - { - textFieldRemarks = new JTextField(); - panel.add(textFieldRemarks, "4, 8, fill, default"); - textFieldRemarks.setColumns(10); + public SpecimenPartAttributeDialog() { + this.parentPart = new SpecimenPart(); + init(); } - { - JButton btnAdd = new JButton("Add"); - btnAdd.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - SpecimenPartAttribute newAttribs = new SpecimenPartAttribute(); - newAttribs.setAttributeType( - comboBoxType.getSelectedItem().toString()); - newAttribs.setAttributeValue( - comboBoxValue.getSelectedItem().toString()); - newAttribs.setAttributeUnits(textFieldUnits.getText()); - newAttribs.setAttributeRemark(textFieldRemarks.getText()); - newAttribs.setSpecimenPart(parentPart); - newAttribs.setAttributeDeterminer( - Singleton.getSingletonInstance().getUserFullName()); - parentPart.getAttributeCollection().add(newAttribs); - SpecimenPartAttributeLifeCycle sls = - new SpecimenPartAttributeLifeCycle(); - try { - sls.attachDirty(newAttribs); - } catch (SaveFailedException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - ((AbstractTableModel)table.getModel()).fireTableDataChanged(); - } - }); - panel.add(btnAdd, "4, 10"); - } - try { - JLabel lblNewLabel = new JLabel( - parentPart.getSpecimen().getBarcode() + ":" + - parentPart.getPartName() + " " + parentPart.getPreserveMethod() + - " (" + parentPart.getLotCount() + - ") Right click on table to edit attributes."); - contentPanel.add(lblNewLabel, BorderLayout.NORTH); - } catch (Exception e) { - JLabel lblNewLabel = new JLabel("No Specimen"); - contentPanel.add(lblNewLabel, BorderLayout.NORTH); - } - JComboBox comboBox = new JComboBox(); - comboBox.addItem("caste"); - JComboBox comboBox1 = new JComboBox(); - for (int i = 0; i < Caste.getCasteValues().length; i++) { - comboBox1.addItem(Caste.getCasteValues()[i]); - } - JScrollPane scrollPane = new JScrollPane(); - - table = new JTable( - new SpecimenPartsAttrTableModel(parentPart.getAttributeCollection())); - // table.getColumnModel().getColumn(0).setCellEditor(new - // DefaultCellEditor(comboBox)); + public SpecimenPartAttributeDialog(SpecimenPart targetId, Component parentComponent) { + this(targetId); + this.parentComponent = parentComponent; + } - table.addMouseListener(new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - if (e.isPopupTrigger()) { - clickedOnRow = ((JTable)e.getComponent()).getSelectedRow(); - popupMenu.show(e.getComponent(), e.getX(), e.getY()); + private void init() { + thisDialog = this; + setBounds(100, 100, 820, 335); + getContentPane().setLayout(new BorderLayout()); + contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + getContentPane().add(contentPanel, BorderLayout.CENTER); + JPanel panel = new JPanel(); + panel.setLayout(new FormLayout( + new ColumnSpec[]{ + FormSpecs.RELATED_GAP_COLSPEC, + FormSpecs.DEFAULT_COLSPEC, + FormSpecs.RELATED_GAP_COLSPEC, + ColumnSpec.decode("default:grow"), + }, + new RowSpec[]{ + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + FormSpecs.RELATED_GAP_ROWSPEC, + FormSpecs.DEFAULT_ROWSPEC, + })); + { + JLabel lblAttributeType = new JLabel("Attribute Type"); + panel.add(lblAttributeType, "2, 2, right, default"); } - } - - @Override - public void mouseReleased(MouseEvent e) { - if (e.isPopupTrigger()) { - clickedOnRow = ((JTable)e.getComponent()).getSelectedRow(); - popupMenu.show(e.getComponent(), e.getX(), e.getY()); + { + comboBoxType = new JComboBox(); + comboBoxType.setModel(new DefaultComboBoxModel( + new String[]{"caste", "scientific name", "sex", "life stage", + "part association"})); + comboBoxType.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String item = comboBoxType.getSelectedItem().toString(); + if (item != null) { + comboBoxValue.setEditable(false); + if (item.equals("scientific name")) { + comboBoxValue.setEditable(true); + } + if (item.equals("sex")) { + comboBoxValue.setModel( + new DefaultComboBoxModel(Sex.getSexValues())); + } + if (item.equals("life stage")) { + comboBoxValue.setModel( + new DefaultComboBoxModel(LifeStage.getLifeStageValues())); + } + if (item.equals("caste")) { + comboBoxValue.setModel( + new DefaultComboBoxModel(Caste.getCasteValues())); + } + if (item.equals("part association")) { + comboBoxValue.setModel(new DefaultComboBoxModel( + PartAssociation.getPartAssociationValues())); + } + } + } + }); + panel.add(comboBoxType, "4, 2, fill, default"); } - } - }); - - popupMenu = new JPopupMenu(); - - JMenuItem mntmCloneRow = new JMenuItem("Edit Row"); - mntmCloneRow.setMnemonic(KeyEvent.VK_E); - mntmCloneRow.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - try { - // Launch a dialog to edit the selected row. - SpecimenPartAttribEditDialog popup = new SpecimenPartAttribEditDialog( - ((SpecimenPartsAttrTableModel)table.getModel()) - .getRowObject(clickedOnRow)); - popup.setVisible(true); - } catch (Exception ex) { - log.error(ex.getMessage()); - JOptionPane.showMessageDialog( - thisDialog, - "Failed to edit a part attribute row. " + ex.getMessage()); + { + JLabel lblValue = new JLabel("Value"); + panel.add(lblValue, "2, 4, right, default"); } - } - }); - popupMenu.add(mntmCloneRow); + { + comboBoxValue = new JComboBox(); + comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues())); - JMenuItem mntmDeleteRow = new JMenuItem("Delete Row"); - mntmDeleteRow.setMnemonic(KeyEvent.VK_D); - mntmDeleteRow.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + panel.add(comboBoxValue, "4, 4, fill, default"); + } + { + JLabel lblUnits = new JLabel("Units"); + panel.add(lblUnits, "2, 6, right, default"); + } + { + textFieldUnits = new JTextField(); + panel.add(textFieldUnits, "4, 6, fill, default"); + textFieldUnits.setColumns(10); + } + { + JLabel lblRemarks = new JLabel("Remarks"); + panel.add(lblRemarks, "2, 8, right, default"); + } + contentPanel.setLayout(new BorderLayout(0, 0)); + contentPanel.add(panel, BorderLayout.WEST); + { + textFieldRemarks = new JTextField(); + panel.add(textFieldRemarks, "4, 8, fill, default"); + textFieldRemarks.setColumns(10); + } + { + JButton btnAdd = new JButton("Add"); + btnAdd.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + SpecimenPartAttribute newAttribs = new SpecimenPartAttribute(); + newAttribs.setAttributeType( + comboBoxType.getSelectedItem().toString()); + newAttribs.setAttributeValue( + comboBoxValue.getSelectedItem().toString()); + newAttribs.setAttributeUnits(textFieldUnits.getText()); + newAttribs.setAttributeRemark(textFieldRemarks.getText()); + newAttribs.setSpecimenPart(parentPart); + newAttribs.setAttributeDeterminer( + Singleton.getSingletonInstance().getUserFullName()); + parentPart.getAttributeCollection().add(newAttribs); + SpecimenPartAttributeLifeCycle sls = + new SpecimenPartAttributeLifeCycle(); + try { + sls.attachDirty(newAttribs); + } catch (SaveFailedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + ((AbstractTableModel) table.getModel()).fireTableDataChanged(); + if (parentComponent != null) { + try { + ((SpecimenDetailsViewPane) parentComponent).fireSpecimenPartsTableUpdate(); + } catch (Exception ex) { + log.error("Failed to fire table change on parent of specimen attribute dialog", ex); + } + } + } + }); + panel.add(btnAdd, "4, 10"); + } try { - if (clickedOnRow >= 0) { - ((SpecimenPartsAttrTableModel)table.getModel()) - .deleteRow(clickedOnRow); - } - } catch (Exception ex) { - log.error(ex.getMessage()); - JOptionPane.showMessageDialog( - thisDialog, - "Failed to delete a part attribute row. " + ex.getMessage()); + JLabel lblNewLabel = new JLabel( + parentPart.getSpecimen().getBarcode() + ":" + + parentPart.getPartName() + " " + parentPart.getPreserveMethod() + + " (" + parentPart.getLotCount() + + ") Right click on table to edit attributes."); + contentPanel.add(lblNewLabel, BorderLayout.NORTH); + } catch (Exception e) { + JLabel lblNewLabel = new JLabel("No Specimen"); + contentPanel.add(lblNewLabel, BorderLayout.NORTH); } - } - }); - popupMenu.add(mntmDeleteRow); + JComboBox comboBox = new JComboBox(); + comboBox.addItem("caste"); + JComboBox comboBox1 = new JComboBox(); + for (int i = 0; i < Caste.getCasteValues().length; i++) { + comboBox1.addItem(Caste.getCasteValues()[i]); + } + JScrollPane scrollPane = new JScrollPane(); + + table = new JTable( + new SpecimenPartsAttrTableModel(parentPart.getAttributeCollection())); + + // table.getColumnModel().getColumn(0).setCellEditor(new + // DefaultCellEditor(comboBox)); - // TODO: Enable controlled value editing of selected row. + table.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (e.isPopupTrigger()) { + clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); + popupMenu.show(e.getComponent(), e.getX(), e.getY()); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (e.isPopupTrigger()) { + clickedOnRow = ((JTable) e.getComponent()).getSelectedRow(); + popupMenu.show(e.getComponent(), e.getX(), e.getY()); + } + } + }); - // table.getColumnModel().getColumn(1).setCellEditor(new - // DefaultCellEditor(comboBox1)); + popupMenu = new JPopupMenu(); - scrollPane.setViewportView(table); - contentPanel.add(scrollPane, BorderLayout.EAST); - { - JPanel buttonPane = new JPanel(); - buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); - getContentPane().add(buttonPane, BorderLayout.SOUTH); - { - okButton = new JButton("OK"); - okButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - okButton.grabFocus(); - thisDialog.setVisible(false); - } + JMenuItem mntmCloneRow = new JMenuItem("Edit Row"); + mntmCloneRow.setMnemonic(KeyEvent.VK_E); + mntmCloneRow.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + // Launch a dialog to edit the selected row. + SpecimenPartAttribEditDialog popup = new SpecimenPartAttribEditDialog( + ((SpecimenPartsAttrTableModel) table.getModel()) + .getRowObject(clickedOnRow)); + popup.setVisible(true); + } catch (Exception ex) { + log.error(ex.getMessage()); + JOptionPane.showMessageDialog( + thisDialog, + "Failed to edit a part attribute row. " + ex.getMessage()); + } + } }); - okButton.setActionCommand("OK"); - buttonPane.add(okButton); - getRootPane().setDefaultButton(okButton); - } - { - JButton cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - thisDialog.setVisible(false); - } + popupMenu.add(mntmCloneRow); + + JMenuItem mntmDeleteRow = new JMenuItem("Delete Row"); + mntmDeleteRow.setMnemonic(KeyEvent.VK_D); + mntmDeleteRow.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + if (clickedOnRow >= 0) { + ((SpecimenPartsAttrTableModel) table.getModel()) + .deleteRow(clickedOnRow); + } + } catch (Exception ex) { + log.error(ex.getMessage()); + JOptionPane.showMessageDialog( + thisDialog, + "Failed to delete a part attribute row. " + ex.getMessage()); + } + } }); - cancelButton.setActionCommand("Cancel"); - buttonPane.add(cancelButton); - } + popupMenu.add(mntmDeleteRow); + + // TODO: Enable controlled value editing of selected row. + + // table.getColumnModel().getColumn(1).setCellEditor(new + // DefaultCellEditor(comboBox1)); + + scrollPane.setViewportView(table); + contentPanel.add(scrollPane, BorderLayout.EAST); + { + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); + getContentPane().add(buttonPane, BorderLayout.SOUTH); + { + okButton = new JButton("OK"); + okButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + okButton.grabFocus(); + thisDialog.setVisible(false); + } + }); + okButton.setActionCommand("OK"); + buttonPane.add(okButton); + getRootPane().setDefaultButton(okButton); + } + { + JButton cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + thisDialog.setVisible(false); + } + }); + cancelButton.setActionCommand("Cancel"); + buttonPane.add(cancelButton); + } + } } - } } diff --git a/src/main/java/edu/harvard/mcz/imagecapture/ui/frame/SpecimenDetailsViewPane.java b/src/main/java/edu/harvard/mcz/imagecapture/ui/frame/SpecimenDetailsViewPane.java index c3c45fb..734fed4 100644 --- a/src/main/java/edu/harvard/mcz/imagecapture/ui/frame/SpecimenDetailsViewPane.java +++ b/src/main/java/edu/harvard/mcz/imagecapture/ui/frame/SpecimenDetailsViewPane.java @@ -1411,6 +1411,10 @@ public void keyTyped(java.awt.event.KeyEvent e) { return jScrollPaneSpecimenParts; } + public void fireSpecimenPartsTableUpdate() { + ((AbstractTableModel)this.getJTableSpecimenParts().getModel()).fireTableDataChanged(); + } + private JTable getJTableSpecimenParts() { if (jTableSpecimenParts == null) { try {