1 | |
package br.mia.test.view.observers; |
2 | |
|
3 | |
import java.awt.event.ActionEvent; |
4 | |
import java.awt.event.ActionListener; |
5 | |
import java.awt.event.MouseListener; |
6 | |
import java.io.BufferedWriter; |
7 | |
import java.io.FileWriter; |
8 | |
import java.io.IOException; |
9 | |
import java.util.List; |
10 | |
|
11 | |
import javax.swing.JComboBox; |
12 | |
import javax.swing.JInternalFrame; |
13 | |
import javax.swing.JOptionPane; |
14 | |
import javax.swing.JTable; |
15 | |
|
16 | |
import org.w3c.dom.events.EventTarget; |
17 | |
import org.w3c.dom.events.MouseEvent; |
18 | |
import org.w3c.dom.views.AbstractView; |
19 | |
|
20 | |
import br.mia.test.controler.ControladorCronograma; |
21 | |
import br.mia.test.controler.ControladorErro; |
22 | |
import br.mia.test.model.Atividade; |
23 | |
import br.mia.test.model.Cronograma; |
24 | |
import br.mia.test.model.PlanoTeste; |
25 | |
import br.mia.test.model.Projeto; |
26 | |
import br.mia.test.view.CronogramaPane; |
27 | |
import br.mia.test.view.Global; |
28 | |
import br.mia.test.view.graph.WBSPane; |
29 | |
import br.mia.test.view.tabelas.TabelaModeloCronograma; |
30 | |
|
31 | |
import com.toedter.calendar.JDateChooser; |
32 | |
|
33 | |
public class ObserverCronograma extends Observer implements ActionListener, |
34 | |
MouseEvent, MouseListener { |
35 | |
|
36 | 0 | public ObserverCronograma(Projeto projeto, PlanoTeste plano) { |
37 | 0 | this.projeto = projeto; |
38 | 0 | this.planoTeste = plano; |
39 | 0 | } |
40 | |
|
41 | |
private PlanoTeste planoTeste; |
42 | |
|
43 | |
private Projeto projeto; |
44 | |
|
45 | |
private JInternalFrame frame; |
46 | |
|
47 | |
public JInternalFrame getFrame() { |
48 | 0 | return frame; |
49 | |
} |
50 | |
|
51 | |
public void setFrame(JInternalFrame frame) { |
52 | 0 | this.frame = frame; |
53 | 0 | } |
54 | |
|
55 | |
@SuppressWarnings("unchecked") |
56 | |
public void actionPerformed(ActionEvent arg0) { |
57 | |
|
58 | 0 | JTable tarefas = (JTable) this.getTables().get(0); |
59 | 0 | TabelaModeloCronograma modelo = (TabelaModeloCronograma) this |
60 | 0 | .getModelos().get(0); |
61 | 0 | JComboBox comboEstados = this.getCombos().get(0); |
62 | 0 | JComboBox comboUsers = this.getCombos().get(1); |
63 | 0 | JDateChooser calendario = this.getComboCalendarios().get(0); |
64 | 0 | JDateChooser calendario1 = this.getComboCalendarios().get(1); |
65 | 0 | List<Atividade> atividades = (List<Atividade>) this |
66 | 0 | .getArrayList().get(0); |
67 | |
|
68 | 0 | if (arg0.getActionCommand().equals("EAP")) { |
69 | |
WBSPane grafoPane; |
70 | |
try { |
71 | 0 | grafoPane = new WBSPane(this.getFrame(), projeto, null, |
72 | 0 | atividades); |
73 | 0 | grafoPane.setVisible(true); |
74 | 0 | grafoPane.pack(); |
75 | 0 | Global.mostraFrame(grafoPane, "Casos de Teste"); |
76 | 0 | } catch (IOException erro) { |
77 | 0 | ControladorErro.trata(erro,this); |
78 | |
} |
79 | |
|
80 | |
} |
81 | 0 | if (arg0.getActionCommand().equals("GeraCronograma")) { |
82 | |
|
83 | |
try { |
84 | 0 | CronogramaPane pane = (CronogramaPane) this.getInternalFrames() |
85 | 0 | .get(0); |
86 | |
|
87 | 0 | ControladorCronograma controlador = new ControladorCronograma(); |
88 | |
|
89 | 0 | controlador.gera(projeto, pane.getBuild()); |
90 | |
|
91 | 0 | pane.recarregar(projeto, pane.getBuild()); |
92 | |
|
93 | 0 | this.atualiza(); |
94 | 0 | } catch (Exception erro) { |
95 | 0 | ControladorErro.trata(erro,this); |
96 | |
} |
97 | |
} |
98 | |
|
99 | 0 | if (arg0.getActionCommand().equals("AtualizarTarefa")) { |
100 | |
|
101 | 0 | Atividade atividade = (Atividade) modelo.getAtividades().get( |
102 | 0 | tarefas.getSelectedRow()); |
103 | |
|
104 | 0 | atividade.setResponsavel(comboUsers.getSelectedItem().toString()); |
105 | 0 | atividade.setStatus(comboEstados.getSelectedItem().toString()); |
106 | |
|
107 | 0 | atividade.setInicio(calendario.getDate()); |
108 | 0 | atividade.setFim(calendario1.getDate()); |
109 | |
|
110 | 0 | ControladorCronograma controlador = new ControladorCronograma(); |
111 | 0 | controlador.atualiza(atividade); |
112 | |
|
113 | |
} |
114 | |
|
115 | 0 | if (arg0.getActionCommand().equals("DeletarTarefa")) { |
116 | |
|
117 | 0 | Atividade atividade = (Atividade) modelo.getAtividades().get( |
118 | 0 | tarefas.getSelectedRow()); |
119 | |
|
120 | 0 | ControladorCronograma controlador = new ControladorCronograma(); |
121 | 0 | controlador.deletar(atividade); |
122 | |
|
123 | 0 | modelo.getAtividades().remove(atividade); |
124 | |
|
125 | |
} |
126 | 0 | if (arg0.getActionCommand().equals("Exportar")) { |
127 | 0 | String fileName = JOptionPane |
128 | 0 | .showInputDialog(null, |
129 | 0 | "Digite o nome do arquivo a ser gravados os casos de teste"); |
130 | |
FileWriter fstream; |
131 | |
try { |
132 | 0 | fstream = new FileWriter(fileName); |
133 | 0 | BufferedWriter out = new BufferedWriter(fstream); |
134 | 0 | Cronograma cronograma = new Cronograma(); |
135 | 0 | out.write(cronograma.criaExportacao(modelo.getAtividades())); |
136 | 0 | out.flush(); |
137 | 0 | } catch (IOException e) { |
138 | 0 | ControladorErro.trata(e,this); |
139 | |
} |
140 | |
|
141 | |
} |
142 | 0 | this.atualiza(); |
143 | 0 | } |
144 | |
|
145 | |
public int getScreenX() { |
146 | |
|
147 | 0 | return 0; |
148 | |
} |
149 | |
|
150 | |
public int getScreenY() { |
151 | |
|
152 | 0 | return 0; |
153 | |
} |
154 | |
|
155 | |
public int getClientX() { |
156 | |
|
157 | 0 | return 0; |
158 | |
} |
159 | |
|
160 | |
public int getClientY() { |
161 | |
|
162 | 0 | return 0; |
163 | |
} |
164 | |
|
165 | |
public boolean getCtrlKey() { |
166 | |
|
167 | 0 | return false; |
168 | |
} |
169 | |
|
170 | |
public boolean getShiftKey() { |
171 | |
|
172 | 0 | return false; |
173 | |
} |
174 | |
|
175 | |
public boolean getAltKey() { |
176 | |
|
177 | 0 | return false; |
178 | |
} |
179 | |
|
180 | |
public boolean getMetaKey() { |
181 | |
|
182 | 0 | return false; |
183 | |
} |
184 | |
|
185 | |
public short getButton() { |
186 | |
|
187 | 0 | return 0; |
188 | |
} |
189 | |
|
190 | |
public EventTarget getRelatedTarget() { |
191 | |
|
192 | 0 | return null; |
193 | |
} |
194 | |
|
195 | |
public void initMouseEvent(String arg0, boolean arg1, boolean arg2, |
196 | |
AbstractView arg3, int arg4, int arg5, int arg6, int arg7, |
197 | |
int arg8, boolean arg9, boolean arg10, boolean arg11, |
198 | |
boolean arg12, short arg13, EventTarget arg14) { |
199 | |
|
200 | |
|
201 | 0 | } |
202 | |
|
203 | |
public AbstractView getView() { |
204 | |
|
205 | 0 | return null; |
206 | |
} |
207 | |
|
208 | |
public int getDetail() { |
209 | |
|
210 | 0 | return 0; |
211 | |
} |
212 | |
|
213 | |
public void initUIEvent(String arg0, boolean arg1, boolean arg2, |
214 | |
AbstractView arg3, int arg4) { |
215 | |
|
216 | |
|
217 | 0 | } |
218 | |
|
219 | |
public String getType() { |
220 | |
|
221 | 0 | return null; |
222 | |
} |
223 | |
|
224 | |
public EventTarget getTarget() { |
225 | |
|
226 | 0 | return null; |
227 | |
} |
228 | |
|
229 | |
public EventTarget getCurrentTarget() { |
230 | |
|
231 | 0 | return null; |
232 | |
} |
233 | |
|
234 | |
public short getEventPhase() { |
235 | |
|
236 | 0 | return 0; |
237 | |
} |
238 | |
|
239 | |
public boolean getBubbles() { |
240 | |
|
241 | 0 | return false; |
242 | |
} |
243 | |
|
244 | |
public boolean getCancelable() { |
245 | |
|
246 | 0 | return false; |
247 | |
} |
248 | |
|
249 | |
public long getTimeStamp() { |
250 | |
|
251 | 0 | return 0; |
252 | |
} |
253 | |
|
254 | |
public void stopPropagation() { |
255 | |
|
256 | |
|
257 | 0 | } |
258 | |
|
259 | |
public void preventDefault() { |
260 | |
|
261 | |
|
262 | 0 | } |
263 | |
|
264 | |
public void initEvent(String arg0, boolean arg1, boolean arg2) { |
265 | |
|
266 | |
|
267 | 0 | } |
268 | |
|
269 | |
public void mouseClicked(java.awt.event.MouseEvent arg0) { |
270 | 0 | JTable tarefas = (JTable) this.getTables().get(0); |
271 | 0 | TabelaModeloCronograma modelo = (TabelaModeloCronograma) this |
272 | 0 | .getModelos().get(0); |
273 | 0 | JComboBox comboEstados = this.getCombos().get(0); |
274 | 0 | JComboBox comboUsers = this.getCombos().get(1); |
275 | 0 | JDateChooser calendario = this.getComboCalendarios().get(0); |
276 | 0 | JDateChooser calendario1 = this.getComboCalendarios().get(1); |
277 | 0 | Atividade atividade = (Atividade) modelo.getAtividades().get( |
278 | 0 | tarefas.getSelectedRow()); |
279 | |
|
280 | 0 | calendario.setDate(atividade.getInicio()); |
281 | 0 | calendario1.setDate(atividade.getFim()); |
282 | 0 | comboUsers.setSelectedItem(atividade.getResponsavel()); |
283 | 0 | comboEstados.setSelectedItem(atividade.getStatus()); |
284 | 0 | tarefas.revalidate(); |
285 | |
|
286 | 0 | } |
287 | |
|
288 | |
public void mousePressed(java.awt.event.MouseEvent arg0) { |
289 | |
|
290 | |
|
291 | 0 | } |
292 | |
|
293 | |
public void mouseReleased(java.awt.event.MouseEvent arg0) { |
294 | |
|
295 | |
|
296 | 0 | } |
297 | |
|
298 | |
public void mouseEntered(java.awt.event.MouseEvent arg0) { |
299 | |
|
300 | |
|
301 | 0 | } |
302 | |
|
303 | |
public void mouseExited(java.awt.event.MouseEvent arg0) { |
304 | |
|
305 | |
|
306 | 0 | } |
307 | |
|
308 | |
public Projeto getProjeto() { |
309 | 0 | return projeto; |
310 | |
} |
311 | |
|
312 | |
public void setProjeto(Projeto projeto) { |
313 | 0 | this.projeto = projeto; |
314 | 0 | } |
315 | |
|
316 | |
public PlanoTeste getPlanoTeste() { |
317 | 0 | return planoTeste; |
318 | |
} |
319 | |
|
320 | |
public void setPlanoTeste(PlanoTeste planoTeste) { |
321 | 0 | this.planoTeste = planoTeste; |
322 | 0 | } |
323 | |
|
324 | |
} |