petCount++;
}
nodesToDelete.add(node);
}
ConfirmationDialog dialog = new ConfirmationDialog() {
protected void onConfirm() {
for (Iterator i = nodesToDelete.iterator(); i.hasNext();) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)i.next();
ownersTreeModel.removeNodeFromParent(node);
if (node.getUserObject() instanceof Owner) {
// clinic.deleteOwner((Owner) node.getUserObject());
}
else {
// clinic.deletePet((Pet) node.getUserObject());
}
}
}
};
// TODO check default closeAction on ConfirmationDialog
// setting closeAction explicitly to dispose, if confirmationDialog has this default,
// this line may be removed.
dialog.setCloseAction(CloseAction.DISPOSE);
if (ownerCount > 0 && petCount > 0) {
dialog.setTitle(getMessage("confirmDeleteOwnerAndPetDialog.title"));
dialog.setConfirmationMessage(getMessage("confirmDeleteOwnerAndPetDialog.label"));
}
else if (ownerCount > 0) {
dialog.setTitle(getMessage("confirmDeleteOwnerDialog.title"));
dialog.setConfirmationMessage(getMessage("confirmDeleteOwnerDialog.label"));
}
else {
dialog.setTitle(getMessage("confirmDeletePetDialog.title"));
dialog.setConfirmationMessage(getMessage("confirmDeletePetDialog.label"));
}
dialog.showDialog();
}