public void removeRelatedTableRow(DomainGlazedListTable relatedTable, DomainObject model)
     throws ObjectNotRemovedException {
   int selectedRow = relatedTable.getSelectedRow();
   if (selectedRow == -1) {
     JOptionPane.showMessageDialog(
         this, "You must select a row to remove.", "warning", JOptionPane.WARNING_MESSAGE);
   } else {
     int response =
         JOptionPane.showConfirmDialog(
             this,
             "Are you sure you want to delete "
                 + relatedTable.getSelectedRows().length
                 + " record(s)",
             "Delete records",
             JOptionPane.YES_NO_OPTION);
     if (response == JOptionPane.OK_OPTION) {
       ArrayList<DomainObject> relatedObjects = relatedTable.removeSelectedRows();
       for (DomainObject relatedObject : relatedObjects) {
         model.removeRelatedObject(relatedObject);
       }
       int rowCount = relatedTable.getRowCount();
       if (rowCount == 0) {
         // do nothing
       } else if (selectedRow >= rowCount) {
         relatedTable.setRowSelectionInterval(rowCount - 1, rowCount - 1);
       } else {
         relatedTable.setRowSelectionInterval(selectedRow, selectedRow);
       }
       // set record to dirty
       ApplicationFrame.getInstance().setRecordDirty();
     }
   }
 }
 protected int editRelatedRecord(
     DomainGlazedListTable table, Class clazz, Boolean buffered, DomainEditor domainEditor) {
   int selectedRow = table.getSelectedRow();
   if (selectedRow != -1) {
     DomainObject domainObject = table.getSortedList().get(selectedRow);
     if (domainEditor == null) {
       try {
         domainEditor =
             DomainEditorFactory.getInstance()
                 .createDomainEditorWithParent(clazz, editorField.getParentEditor(), false);
         domainEditor.setCallingTable(table);
       } catch (UnsupportedTableModelException e1) {
         new ErrorDialog(
                 editorField.getParentEditor(),
                 "Error creating editor for " + clazz.getSimpleName(),
                 e1)
             .showDialog();
       } catch (DomainEditorCreationException e) {
         new ErrorDialog(
                 editorField.getParentEditor(),
                 "Error creating editor for " + clazz.getSimpleName(),
                 e)
             .showDialog();
       }
     }
     domainEditor.setBuffered(buffered);
     domainEditor.setSelectedRow(selectedRow);
     domainEditor.setNavigationButtons();
     domainEditor.setModel(domainObject, null);
     int returnValue = domainEditor.showDialog();
     if (domainEditor.getBuffered()) {
       if (returnValue == JOptionPane.CANCEL_OPTION) {
         domainEditor.editorFields.cancelEdit();
       } else {
         domainEditor.editorFields.acceptEdit();
         ApplicationFrame.getInstance()
             .setRecordDirty(); // ok an edit was made, so set the record dirty
       }
     }
     return returnValue;
   } else {
     return JOptionPane.CANCEL_OPTION;
   }
 }