/**
* Create the dialog with {@link CloseAction#HIDE}. This will keep the dialog hidden in order
* to reuse the component. This avoids the time-consuming building of the dialog gui each time.
*/
private void createDialog() {
petForm = new PetForm(FormModelHelper.createFormModel(new Pet()), true);
dialogPage = new FormBackedDialogPage(petForm);
dialog = new TitledPageApplicationDialog(dialogPage, getWindowControl(), CloseAction.HIDE) {
protected void onAboutToShow() {
petForm.requestFocusInWindow();
setEnabled(dialogPage.isPageComplete());
}
protected boolean onFinish() {
petForm.commit();
Pet newPet = (Pet)petForm.getFormObject();
getSelectedOwner().addPet(newPet);
clinic.storePet(newPet);
DefaultMutableTreeNode ownerNode = getSelectedOwnerNode();
ownerNode.add(new DefaultMutableTreeNode(newPet));
ownersTreeModel.nodeStructureChanged(ownerNode);