}//GEN-LAST:event_btDeleteVidalActionPerformed
private void btAddFarmNodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAddFarmNodeActionPerformed
try {
Object value = treeVidalFarm.getLastSelectedPathComponent();
DirectoryVidalFarmItem newItem = null;
if (value instanceof DirectoryVidalFarmItem) {
DirectoryVidalFarmItem selected = (DirectoryVidalFarmItem) value;
tfName.setText("");
int res = JOptionPane.showConfirmDialog(null, pnlNewNode, "Заполните поля", JOptionPane.OK_CANCEL_OPTION, -1);
if (res == JOptionPane.OK_OPTION) {
if (tfName.getText().isEmpty()) {
MessageBox.showWarning(MessageBox.W_INCORRECT_DATA);
return;
} else {
ClassificationFarmDetails details = new ClassificationFarmDetails();
details.title = tfName.getText();
details.parentItem = selected.getID();
newItem = new DirectoryVidalFarmItem(details);
selected.getItems().append(newItem);
}
}
} else {
tfName.setText("");
int res = JOptionPane.showConfirmDialog(null, pnlNewNode, "Заполните поля", JOptionPane.OK_CANCEL_OPTION, -1);
if (res == JOptionPane.OK_OPTION) {
if (tfName.getText().isEmpty()) {
MessageBox.showWarning(MessageBox.W_INCORRECT_DATA);
return;
} else {
ClassificationFarmDetails details = new ClassificationFarmDetails();
details.title = tfName.getText();
newItem = new DirectoryVidalFarmItem(details);
directoryVidalFarm.getItems().append(newItem);
}
}
}
updateTree();