Coverage Report - br.mia.test.view.observers.ObserverPlano
 
Classes in this File Line Coverage Branch Coverage Complexity
ObserverPlano
0%
0/134
0%
0/16
1,235
 
 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  
 
 7  
 import javax.swing.JFrame;
 8  
 import javax.swing.JTable;
 9  
 import javax.swing.JTextField;
 10  
 
 11  
 import org.w3c.dom.events.EventTarget;
 12  
 import org.w3c.dom.events.MouseEvent;
 13  
 import org.w3c.dom.views.AbstractView;
 14  
 
 15  
 import br.mia.test.controler.ControladorErro;
 16  
 import br.mia.test.model.PlanoTeste;
 17  
 import br.mia.test.model.Projeto;
 18  
 import br.mia.test.model.dao.DAOPlano;
 19  
 import br.mia.test.view.Global;
 20  
 import br.mia.test.view.TelaBuild;
 21  
 import br.mia.test.view.tabelas.TabelaModeloPlano;
 22  
 
 23  0
 public class ObserverPlano extends Observer implements ActionListener,
 24  
         MouseEvent, MouseListener
 25  
 {
 26  
 
 27  
     private Projeto projeto;
 28  
 
 29  
     private JFrame frame;
 30  
 
 31  0
     public JFrame getFrame() {
 32  0
         return frame;
 33  
     }
 34  
 
 35  0
     public void setFrame(JFrame frame) {
 36  0
         this.frame = frame;
 37  0
     }
 38  
 
 39  
     public void actionPerformed(ActionEvent arg0) {
 40  0
 
 41  0
         JTable planosTable = (JTable) this.getTables().get(0);
 42  0
         JTextField userName = (JTextField) this.getTextFields().get(0);
 43  0
         TabelaModeloPlano modelo = (TabelaModeloPlano) this.getModelos().get(0);
 44  0
         DAOPlano dao = new DAOPlano();
 45  0
 
 46  0
         if (arg0.getActionCommand().equals("Insert")) {
 47  0
 
 48  0
             PlanoTeste plano = new PlanoTeste();
 49  0
             plano.setNome(userName.getText());
 50  
 
 51  
             try {
 52  0
 
 53  0
                 plano = dao.insert(plano, projeto);
 54  0
 
 55  0
             } catch (Exception erro) {
 56  0
                 ControladorErro.trata(erro, this);
 57  0
             }
 58  
 
 59  
         }
 60  0
         if (arg0.getActionCommand().equals("atualizarPlano")) {
 61  0
 
 62  0
             PlanoTeste plano = (PlanoTeste) modelo.getPlanos().get(
 63  0
                     planosTable.getSelectedRow());
 64  0
             plano.setNome(userName.getText());
 65  0
 
 66  
             try {
 67  
 
 68  0
                 plano = dao.update(plano, projeto);
 69  0
 
 70  0
             } catch (Exception erro) {
 71  0
                 ControladorErro.trata(erro, this);
 72  0
             }
 73  0
             this.atualiza();
 74  0
 
 75  
         }
 76  0
         if (arg0.getActionCommand().equals("Delete")) {
 77  0
 
 78  0
             PlanoTeste plano = (PlanoTeste) modelo.getPlanos().get(
 79  0
                     planosTable.getSelectedRow());
 80  0
 
 81  
             try {
 82  
 
 83  0
                 dao.delete(plano);
 84  0
 
 85  0
                 modelo.getPlanos().remove(plano);
 86  0
 
 87  0
             } catch (Exception erro) {
 88  0
                 ControladorErro.trata(erro, this);
 89  0
             }
 90  
 
 91  
         }
 92  0
         if (arg0.getActionCommand().equals("Edit")) {
 93  0
             try {
 94  0
                 PlanoTeste plano = (PlanoTeste) modelo.getPlanos().get(
 95  0
                         planosTable.getSelectedRow());
 96  0
 
 97  
                 TelaBuild escopo;
 98  
 
 99  0
                 escopo = new TelaBuild(this.projeto, plano);
 100  0
                 escopo.setVisible(true);
 101  0
 
 102  0
                 Global.mostraFrame(escopo, "Escopo");
 103  0
             } catch (Exception erro) {
 104  0
                 ControladorErro.trata(erro, this);
 105  0
             }
 106  
 
 107  
         }
 108  
 
 109  0
         this.atualiza();
 110  0
 
 111  0
     }
 112  0
 
 113  
     public int getScreenX() {
 114  
         // TODO Auto-generated method stub
 115  0
         return 0;
 116  0
     }
 117  
 
 118  
     public int getScreenY() {
 119  
         // TODO Auto-generated method stub
 120  0
         return 0;
 121  0
     }
 122  
 
 123  
     public int getClientX() {
 124  
         // TODO Auto-generated method stub
 125  0
         return 0;
 126  0
     }
 127  
 
 128  
     public int getClientY() {
 129  
         // TODO Auto-generated method stub
 130  0
         return 0;
 131  0
     }
 132  
 
 133  
     public boolean getCtrlKey() {
 134  
         // TODO Auto-generated method stub
 135  0
         return false;
 136  0
     }
 137  
 
 138  
     public boolean getShiftKey() {
 139  
         // TODO Auto-generated method stub
 140  0
         return false;
 141  0
     }
 142  
 
 143  
     public boolean getAltKey() {
 144  
         // TODO Auto-generated method stub
 145  0
         return false;
 146  0
     }
 147  
 
 148  
     public boolean getMetaKey() {
 149  
         // TODO Auto-generated method stub
 150  0
         return false;
 151  0
     }
 152  
 
 153  
     public short getButton() {
 154  
         // TODO Auto-generated method stub
 155  0
         return 0;
 156  0
     }
 157  
 
 158  
     public EventTarget getRelatedTarget() {
 159  
         // TODO Auto-generated method stub
 160  0
         return null;
 161  0
     }
 162  
 
 163  
     public void initMouseEvent(String arg0, boolean arg1, boolean arg2,
 164  
             AbstractView arg3, int arg4, int arg5, int arg6, int arg7,
 165  
             int arg8, boolean arg9, boolean arg10, boolean arg11,
 166  
             boolean arg12, short arg13, EventTarget arg14) {
 167  
         // TODO Auto-generated method stub
 168  
 
 169  0
     }
 170  0
 
 171  
     public AbstractView getView() {
 172  
         // TODO Auto-generated method stub
 173  0
         return null;
 174  0
     }
 175  
 
 176  
     public int getDetail() {
 177  
         // TODO Auto-generated method stub
 178  0
         return 0;
 179  0
     }
 180  
 
 181  
     public void initUIEvent(String arg0, boolean arg1, boolean arg2,
 182  
             AbstractView arg3, int arg4) {
 183  
         // TODO Auto-generated method stub
 184  
 
 185  0
     }
 186  0
 
 187  
     public String getType() {
 188  
         // TODO Auto-generated method stub
 189  0
         return null;
 190  0
     }
 191  
 
 192  
     public EventTarget getTarget() {
 193  
         // TODO Auto-generated method stub
 194  0
         return null;
 195  0
     }
 196  
 
 197  
     public EventTarget getCurrentTarget() {
 198  
         // TODO Auto-generated method stub
 199  0
         return null;
 200  0
     }
 201  
 
 202  
     public short getEventPhase() {
 203  
         // TODO Auto-generated method stub
 204  0
         return 0;
 205  0
     }
 206  
 
 207  
     public boolean getBubbles() {
 208  
         // TODO Auto-generated method stub
 209  0
         return false;
 210  0
     }
 211  
 
 212  
     public boolean getCancelable() {
 213  
         // TODO Auto-generated method stub
 214  0
         return false;
 215  0
     }
 216  
 
 217  
     public long getTimeStamp() {
 218  
         // TODO Auto-generated method stub
 219  0
         return 0;
 220  0
     }
 221  
 
 222  
     public void stopPropagation() {
 223  
         // TODO Auto-generated method stub
 224  
 
 225  0
     }
 226  0
 
 227  
     public void preventDefault() {
 228  
         // TODO Auto-generated method stub
 229  
 
 230  0
     }
 231  0
 
 232  
     public void initEvent(String arg0, boolean arg1, boolean arg2) {
 233  
         // TODO Auto-generated method stub
 234  
 
 235  0
     }
 236  0
 
 237  
     public void mouseClicked(java.awt.event.MouseEvent arg0) {
 238  
 
 239  0
         JTable planosTable = (JTable) this.getTables().get(0);
 240  0
         JTextField userName = (JTextField) this.getTextFields().get(0);
 241  0
         TabelaModeloPlano modelo = (TabelaModeloPlano) this.getModelos().get(0);
 242  0
 
 243  0
         PlanoTeste plano = (PlanoTeste) modelo.getPlanos().get(
 244  0
                 planosTable.getSelectedRow());
 245  0
 
 246  0
         userName.setText(plano.getNome());
 247  0
     }
 248  0
 
 249  
     public void mousePressed(java.awt.event.MouseEvent arg0) {
 250  
         // TODO Auto-generated method stub
 251  
 
 252  0
     }
 253  0
 
 254  
     public void mouseReleased(java.awt.event.MouseEvent arg0) {
 255  
         // TODO Auto-generated method stub
 256  
 
 257  0
     }
 258  0
 
 259  
     public void mouseEntered(java.awt.event.MouseEvent arg0) {
 260  
         // TODO Auto-generated method stub
 261  
 
 262  0
     }
 263  0
 
 264  
     public void mouseExited(java.awt.event.MouseEvent arg0) {
 265  
         // TODO Auto-generated method stub
 266  
 
 267  0
     }
 268  0
 
 269  
     public Projeto getProjeto() {
 270  0
         return projeto;
 271  0
     }
 272  
 
 273  
     public void setProjeto(Projeto projeto) {
 274  0
         this.projeto = projeto;
 275  0
     }
 276  0
 
 277  
 }