projetoDAO.connect();
projetoDAO.delete(projetoDAO.find(projeto.getId()));
projetoDAO.close();
}
} catch (Exception ex) {
ErrorInfo info = new ErrorInfo("Erro", ex.getMessage(), null, "category", ex, Level.SEVERE, null);
JXErrorPane.showDialog(null, info);
}
}
});
menuTree.setInvoker(treeNavigator);
menuTree.add(miExcluir);
treeNavigator.remove(menuTree);
treeNavigator.add(menuTree);
treeNavigator.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.getClickCount() == 1) {
switch (e.getButton()) {
case MouseEvent.BUTTON1: {
if (treeNavigator.getLastSelectedPathComponent() != null) {
String noSelecionado = ((IconNode) treeNavigator.getLastSelectedPathComponent()).toString();
IconNode no = ((IconNode) treeNavigator.getLastSelectedPathComponent());
if (noSelecionado.equals("Projeto")) {
ProjetoPresenter projetoPresenter = new ProjetoPresenter(Main.this);
projetoPresenter.setStrategy(new EdicaoProjeto(projeto.getId(), projetoPresenter.getView()));
activePanel(projetoPresenter.getView());
} else if ((((ImageIcon) no.getIcon()).getDescription().contains("cenario2.png"))) {
CenarioVolume cenario = projeto.getCenarioById(no.getId());
CenarioVolumePresenter presenterEditaCenario = new CenarioVolumePresenter(Main.this);
removeFrameVolume();
presenterEditaCenario.setStrategy(new EdicaoCenario(projeto.getId(), cenario.getId(), presenterEditaCenario.getView()));
activePanel(presenterEditaCenario.getView());
} else {
desktop.removeAll();
desktop.updateUI();
}
treeNavigator.updateUI();
treeNavigator.expandPath(treeNavigator.getLeadSelectionPath());
break;
}
}
default: {
if (e.isPopupTrigger() && projeto != null) {
noSelecionado = ((IconNode) treeNavigator.getLastSelectedPathComponent());
JMenuItem miExcluirCenario = new JMenuItem("Excluir cenário", new ImageIcon(Configuracao.getPath() + "images/deleteCenario.png"));
miExcluirCenario.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
try {
projetoDAO.connect();
projeto.removeCenario(noSelecionado.toString());
removeFrameVolume();
projetoDAO.update(projeto, false, projeto.getId());
state.updateTreeModel();
projetoDAO.close();
} catch (Exception ex) {
ErrorInfo info = new ErrorInfo("Erro", ex.getMessage(), null, "category", ex, Level.SEVERE, null);
JXErrorPane.showDialog(null, info);
}
}
});