Package dao

Examples of dao.ProjetoDAO


        this.doEntry();
    }

    @Override
    public void doEntry() {
        ProjetoDAO dao = new ProjetoDAO();
        dao.connect();
        Projeto projeto = dao.find(idProjeto);
        view.getTextNomeProj().setText(projeto.getNome());
        view.getTextDescProj().setText(projeto.getDescricao());
        view.getTextAutorProj().setText(projeto.getAutor());
        dao.close();
        projeto = null;
        view.setTitle("Alterar dados básicos do projeto");
    }
View Full Code Here


        view.setTitle("Alterar dados básicos do projeto");
    }

    @Override
    public void salvarProjeto(Main main) throws Exception {
        ProjetoDAO projetoDAO = new ProjetoDAO();
        projetoDAO.connect();
     
        Projeto projeto = projetoDAO.find(main.getProjeto().getId());
        projeto.setNome(view.getTextNomeProj().getText());
        projeto.setDescricao(view.getTextDescProj().getText());
        projeto.setAutor(view.getTextAutorProj().getText());

        projetoDAO.update(projeto, false, projeto.getId());
       
        projetoDAO.close();

        view.setVisible(false);
        projetoDAO.connect();
        main.abreProjeto(projetoDAO.find(projeto.getId()));
        main.getDesktop().closeAll();
        projetoDAO.close();
        view.dispose();
    }
View Full Code Here

    // @Ignore
    @Test
    public void testFindCenario() throws Exception {
        long tempoInicialT = System.currentTimeMillis();
        ProjetoDAO dao = new ProjetoDAO();
        dao.connect();
        Projeto p = dao.find(1);
        CenarioVolume c = p.getCenarioById(1);
        System.out.println(c);
        assertNotNull(c);
        dao.close();
        long tempoFinalT = System.currentTimeMillis();
        System.out.printf("Tempo: %.3f ms%n", (tempoFinalT - tempoInicialT) / 1000d);
    }
View Full Code Here

    }

    @Ignore
    @Test
    public void testSaveProjeto() throws Exception {
        ProjetoDAO dao = new ProjetoDAO();
        dao.connect();
        Projeto p = new Projeto();
        p.setNome(JOptionPane.showInputDialog(null, "Entre com o nome do projeto"));
        p.setId(dao.getNewId());
        Arvore a = new Arvore(1);
        a.put("DAP", 18.0);
        a.put("H", 19.0);
        p.addArvore(a);
        dao.save(p);
        dao.close();
    }
View Full Code Here

    }

  //  @Ignore
    @Test
    public void testUpdateProjeto() throws Exception {
        final ProjetoDAO dao = new ProjetoDAO();
        dao.connect();
        Projeto projeto = dao.find(1);
        projeto.setDescricao("Uma descrição");
        CenarioVolume cenario = new CenarioVolume(projeto.getNewCenarioVolumeId());
        cenario.setNome("c1");
        projeto.addCenario(cenario);
        System.out.println(projeto);
        //dao.save(projeto);
        dao.update(projeto, true, projeto.getId());
    }
View Full Code Here

                    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));
View Full Code Here

    }

    @Ignore
    @Test
    public void testeUpdateProjeto2() throws Exception {
        final ProjetoDAO dao = new ProjetoDAO();
        dao.connect();
        Projeto projeto = dao.find(1);
        Arvore arvore = new Arvore(2);
        arvore.put("DAP", 21.0);
        arvore.put("H", 26.0);
        projeto.addArvore(arvore);
        dao.update(projeto, false, projeto.getId());
        dao.close();
        assertNotNull("Nulo", projeto);
    }
View Full Code Here

        assertNotNull("Nulo", projeto);
    }

    @Test
    public void testListaProjetos() throws Exception {
        ProjetoDAO dao = new ProjetoDAO();
        dao.connect();
        List<Projeto> projetos = dao.getAll("id", true);
        for (Projeto projeto : projetos) {
            System.out.println(projeto);
        }
        dao.close();
    }
View Full Code Here

            this.view.setLocationRelativeTo(null);

            this.view.getGridProjetos().getColumnExt(0).setVisible(false);
            this.view.getGridProjetos().getColumnExt(0).setResizable(false);

            this.projetoDAO = new ProjetoDAO();

            projetoDAO.connect();
            projetos = projetoDAO.getAll("id", true);
            Iterator it = projetos.iterator();
            mod = (DefaultTableModel) view.getTableProjetos().getModel();
View Full Code Here

    private JPopupMenu menuTree;
    private IconNode noSelecionado;

    public Main() {
        this.setVisible(false);
        projetoDAO = new ProjetoDAO();
        initComponents();
    }
View Full Code Here

TOP

Related Classes of dao.ProjetoDAO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.