1 | |
package br.mia.test.view; |
2 | |
|
3 | |
import java.awt.GridBagLayout; |
4 | |
import java.io.IOException; |
5 | |
import java.sql.SQLException; |
6 | |
import java.util.ArrayList; |
7 | |
|
8 | |
import javax.swing.JComboBox; |
9 | |
import javax.swing.JInternalFrame; |
10 | |
import javax.swing.JTable; |
11 | |
|
12 | |
import br.mia.test.model.Projeto; |
13 | |
import br.mia.test.model.dao.DAOProject; |
14 | |
import br.mia.test.model.dao.DAOUser; |
15 | |
import br.mia.test.pessoas.Funcionario; |
16 | |
import br.mia.test.view.factory.FabricaView; |
17 | |
import br.mia.test.view.factory.ItemTela; |
18 | |
import br.mia.test.view.observers.ObserverProjetoUsuario; |
19 | |
import br.mia.test.view.tabelas.TabelaModeloFuncionarios; |
20 | |
import br.mia.test.view.tabelas.TabelaModeloProjetoFuncionario; |
21 | |
|
22 | |
public class TelaProjetoUsuario extends JInternalFrame { |
23 | |
|
24 | |
private static final long serialVersionUID = 1L; |
25 | |
|
26 | |
int selectedFlow; |
27 | |
|
28 | |
TabelaModeloFuncionarios modelo; |
29 | |
|
30 | |
JTable datas; |
31 | |
|
32 | |
public TelaProjetoUsuario(Projeto projeto) throws IOException, |
33 | |
InstantiationException, IllegalAccessException, |
34 | |
ClassNotFoundException, SQLException { |
35 | 0 | super(projeto.getNome(), true, true, true, true); |
36 | |
|
37 | 0 | this.setLayout(new GridBagLayout()); |
38 | 0 | this.setTitle("Usuarios: " + projeto.getNome()); |
39 | |
|
40 | 0 | DAOUser dao = new DAOUser(); |
41 | 0 | ArrayList<Funcionario> funcionarios = null; |
42 | |
|
43 | 0 | funcionarios = dao.select(); |
44 | |
|
45 | |
JTable usuarios; |
46 | |
|
47 | 0 | TabelaModeloFuncionarios modelo = new TabelaModeloFuncionarios(); |
48 | 0 | TabelaModeloProjetoFuncionario modeloUsuario = new TabelaModeloProjetoFuncionario(); |
49 | 0 | modelo.setFuncionarios(funcionarios); |
50 | |
|
51 | 0 | this.datas = new JTable(modelo); |
52 | |
|
53 | 0 | this.datas.revalidate(); |
54 | |
|
55 | 0 | DAOProject daoProject = new DAOProject(); |
56 | 0 | JComboBox comboData = null; |
57 | |
|
58 | 0 | comboData = new JComboBox(dao.select().toArray()); |
59 | |
|
60 | 0 | modeloUsuario.setFuncionarios(daoProject.selectUsuarios(projeto)); |
61 | |
|
62 | 0 | usuarios = new JTable(modeloUsuario); |
63 | |
|
64 | 0 | ArrayList<ItemTela> objetos = new ArrayList<ItemTela>(); |
65 | |
|
66 | 0 | ObserverProjetoUsuario observer = new ObserverProjetoUsuario(projeto); |
67 | 0 | datas.addMouseListener(observer); |
68 | |
|
69 | 0 | ItemTela item2 = FabricaView.createItemIconeSemLabelReduzido("novo", |
70 | 0 | "Inserir no Projeto", "InsertProject", "Projeto", observer); |
71 | 0 | objetos.add(item2); |
72 | |
|
73 | 0 | ItemTela item3 = FabricaView.createItemIconeSemLabelReduzido("delete", |
74 | 0 | "Deletar do Projeto", "DeletarProjeto", "Projeto", observer); |
75 | 0 | objetos.add(item3); |
76 | |
|
77 | 0 | ItemTela item8 = FabricaView.createItemCombo(comboData, |
78 | 0 | "Lista de Usu�rios:", "", "Projeto", observer); |
79 | 0 | objetos.add(item8); |
80 | |
|
81 | 0 | ItemTela item9 = FabricaView.createItemJTable(usuarios, |
82 | 0 | "Lista de Usuarios:", "", "Projeto", observer); |
83 | 0 | objetos.add(item9); |
84 | |
|
85 | 0 | FabricaView.createInternal(this, objetos, true); |
86 | |
|
87 | 0 | observer.getTables().add(usuarios); |
88 | |
|
89 | 0 | observer.getModelos().add(modeloUsuario); |
90 | 0 | observer.getModelos().add(modelo); |
91 | 0 | observer.getCombos().add(comboData); |
92 | |
|
93 | 0 | this.setVisible(true); |
94 | 0 | this.pack(); |
95 | |
|
96 | 0 | } |
97 | |
|
98 | |
} |