pos = view.getTableModelos().getSelectedRow();
if (pos >= 0) {
if (JOptionPane.showConfirmDialog(view, "Confirma a exclusão?", "Exclusão", JOptionPane.YES_NO_OPTION) == 0) {
try {
modelosDAO.connect();
Modelo m = modelosDAO.find(modelos.get(pos).getId());
modelosDAO.delete(m);
mod.removeRow(pos);
modelos.remove(pos);
modelosDAO.close();
view.getViewState().acionaConfirma();
view.getViewState().habilitar();
} catch (Exception ex) {
ErrorInfo info = new ErrorInfo("Erro", ex.getMessage(), null, "category", ex, Level.SEVERE, null);
JXErrorPane.showDialog(null, info);
}
}
}
}
});
view.getBtnAltModelo().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
view.getViewState().acionaAlterar();
}
});
view.getBtnCancModelo().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
view.getViewState().acionaCancela();
view.getViewState().habilitar();
if (mod.getRowCount() > 0) {
view.getTxtNome().setText(view.getTableModelos().getValueAt(0, 0).toString());
view.getTxtExpressao().setText(view.getTableModelos().getValueAt(0, 1).toString());
view.getListTipoMod().setSelectedIndex(modelo.getTipoExp());
}
}
});
view.getBtnConfModelo().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
Object linha[] = new Object[4];
int linhaAtual;
linhaAtual = view.getTableModelos().getSelectedRow();
if (view.getViewState().getClass().getName().toLowerCase().equals("view.states.modelos.inclusao")) {
view.getViewState().acionaConfirma();
if (view.getViewState().getClass().getName().toLowerCase().equals("view.states.modelos.navegacao")) {
try {
modelosDAO.connect();
modelo = new Modelo();
modelo.setId(modelosDAO.getNewId());
modelo.setNome(view.getTxtNome().getText());
modelo.setExpressao(view.getTxtExpressao().getText());
modelo.setTipoExp(view.getListTipoMod().getSelectedIndex());
modelosDAO.save(modelo);