view.getPopupMenu().show(e.getComponent(), e.getX(), e.getY());
}
}
});
createHeaderMenuItens();
projetoDAO = new ProjetoDAO();
KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
this.view.getGrid().getInputMap(JTable.WHEN_FOCUSED).put(enter, "selectNextColumnCell");
new ExcelAdapter(view.getGrid());
this.view.getGrid().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SHIFT || e.getKeyCode() == KeyEvent.VK_CONTROL) {
view.getViewState().selecionaArvore();
}
if (e.getKeyCode() == KeyEvent.VK_DELETE && view.getViewState() instanceof Remocao) {
removeArvore();
}
}
});
this.view.getGrid().addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(final MouseEvent e) {
view.getViewState().selecionaArvore();
}
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
}
});
// view.getBtnFechar().addActionListener(new ActionListener() {
//
// @Override
// public void actionPerformed(final ActionEvent e) {
// try {
//// Command fecharCommand = new FecharCommand(view, "Fechando o projeto");
// // fecharCommand.execute();
// } catch (Exception ex) {
// ErrorInfo info = new ErrorInfo("Erro", ex.getMessage(), null, "category", ex, Level.SEVERE, null);
// JXErrorPane.showDialog(view, info);
//
// }
// }
// });
//
// abrirCommand = new AbrirCommand(pView, "Abrindo o projeto...");
// view.getBtnAbrir().addActionListener(new ActionListener() {
//
// @Override
// public void actionPerformed(java.awt.event.ActionEvent evt) {
// view.getViewState().abrirProjeto();
// try {
// if (view.getTxtIdProjeto().getText().isEmpty()) {
// throw new Exception("Informe um projeto");
// } else {
// abrirCommand.execute();
// }
// } catch (Exception ex) {
// ErrorInfo info = new ErrorInfo("Erro", ex.getMessage(), null, "category", ex, Level.SEVERE, null);
// JXErrorPane.showDialog(view, info);
// view.revertToPreviousState();
// }
// }
// });
view.getBtnSalvar().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
try {
view.getViewState().salvaDados();
Command salvarCommand = new SalvarArvoresCommand(pView, "Salvando o projeto...");
salvarCommand.execute();
} catch (Exception ex) {
ErrorInfo info = new ErrorInfo("Erro", ex.getMessage(), null, "category", ex, Level.SEVERE, null);
JXErrorPane.showDialog(view, info);
}
}
});
view.getBtnNovaArvore().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
view.getViewState().novaArvore();
cenarioTM.addLinha();
GUIUtils.selectAndScroll(view.getGrid(), view.getGrid().getRowCount() - 1);
}
});
view.getBtnRemoverArvore().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
removeArvore();
}
});
view.getBtnCancelar().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
view.getViewState().cancela();
}
});
view.getBtnImportar().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
try {
Command importarArvores = new ImportarArvoresCommand(pView, "Gravando dados importados...");
importarArvores.execute();
} catch (Exception ex) {
ErrorInfo info = new ErrorInfo("Erro", ex.getMessage(), null, "category", ex, Level.SEVERE, null);
JXErrorPane.showDialog(view, info);
}
}
});
projetoDAO = new ProjetoDAO();
projetoDAO.addObserver(this);
// numberCF2 = new NumberColumnFormat();
view.setState(new Fechado(view));