1 | |
package br.mia.test.controler; |
2 | |
|
3 | |
import javax.swing.JOptionPane; |
4 | |
|
5 | |
import br.mia.test.model.dao.DAOErro; |
6 | |
import br.mia.test.view.observers.ObserverFuncionario; |
7 | |
import br.mia.test.view.observers.ObserverPlano; |
8 | |
import br.mia.test.view.observers.ObserverPrincipal; |
9 | |
import br.mia.test.view.observers.ObserverProject; |
10 | |
import br.mia.test.view.observers.ObserverProjetoUsuario; |
11 | |
import br.mia.test.view.observers.ObserverUseCase; |
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | 0 | |
18 | |
|
19 | 0 | public class ControladorErro |
20 | 2 | { |
21 | 0 | |
22 | 0 | public static void trata(Exception e, Object o) { |
23 | 2 | if (e instanceof IndexOutOfBoundsException) { |
24 | 0 | if (o instanceof ObserverPrincipal) { |
25 | 0 | JOptionPane.showMessageDialog(null, "Escolha um dos projetos"); |
26 | 0 | return; |
27 | 0 | } |
28 | 0 | if (o instanceof ObserverProject) { |
29 | 0 | JOptionPane.showMessageDialog(null, |
30 | 0 | "Escolha um dos casos de uso"); |
31 | 0 | return; |
32 | 0 | } |
33 | 0 | if (o instanceof ObserverUseCase) { |
34 | 0 | JOptionPane.showMessageDialog(null, "Escolha um dos Fluxos"); |
35 | 0 | return; |
36 | 0 | } |
37 | 0 | if (o instanceof ObserverFuncionario) { |
38 | 0 | JOptionPane.showMessageDialog(null, "Escolha um dos Usu�rios"); |
39 | 0 | return; |
40 | 0 | } |
41 | 0 | if (o instanceof ObserverPlano) { |
42 | 0 | JOptionPane.showMessageDialog(null, "Escolha um dos Planos"); |
43 | 0 | return; |
44 | 0 | } |
45 | 0 | if (o instanceof ObserverProjetoUsuario) { |
46 | 0 | JOptionPane.showMessageDialog(null, "Escolha um dos Usu�rios"); |
47 | 2 | return; |
48 | 2 | } |
49 | |
} |
50 | 4 | JOptionPane.showMessageDialog(null, e.toString()); |
51 | 2 | DAOErro dao = new DAOErro(); |
52 | 0 | try { |
53 | 2 | dao.inserir(e, o); |
54 | 0 | } catch (Exception e1) { |
55 | 0 | JOptionPane.showMessageDialog(null, |
56 | 2 | "Erro n�o logado em banco de dados"); |
57 | 0 | e1.printStackTrace(); |
58 | 2 | } |
59 | 2 | e.printStackTrace(); |
60 | |
|
61 | 2 | } |
62 | |
|
63 | |
} |