| 1 | |
package br.mia.test.view; |
| 2 | |
|
| 3 | |
import java.awt.GridBagConstraints; |
| 4 | |
import java.awt.Insets; |
| 5 | |
import java.util.HashMap; |
| 6 | |
import java.util.LinkedHashMap; |
| 7 | |
|
| 8 | |
import javax.swing.JInternalFrame; |
| 9 | |
import javax.swing.JOptionPane; |
| 10 | |
|
| 11 | |
import org.openqa.selenium.server.RemoteControlConfiguration; |
| 12 | |
import org.openqa.selenium.server.SeleniumServer; |
| 13 | |
|
| 14 | |
import watij.runtime.ie.IE; |
| 15 | |
import br.mia.test.controler.ControladorErro; |
| 16 | |
import br.mia.test.model.Projeto; |
| 17 | |
import br.mia.test.pessoas.Funcionario; |
| 18 | |
import br.mia.test.testcase.DadosTeste; |
| 19 | |
import br.mia.test.util.Util; |
| 20 | |
|
| 21 | |
import com.thoughtworks.selenium.DefaultSelenium; |
| 22 | |
import com.thoughtworks.selenium.Selenium; |
| 23 | |
|
| 24 | 0 | public class Global { |
| 25 | |
|
| 26 | |
public static void mostraFrame(JInternalFrame frame, String nome) { |
| 27 | 0 | Global.getMidpane().desktop.add(frame); |
| 28 | 0 | frame.setVisible(true); |
| 29 | 0 | NoArvore no = new NoArvore(nome); |
| 30 | 0 | frame.show(); |
| 31 | 0 | no.setFrame(frame); |
| 32 | |
|
| 33 | 0 | Global.getMidpane().desktop.getDesktopManager().maximizeFrame(frame); |
| 34 | |
|
| 35 | 0 | } |
| 36 | |
|
| 37 | |
public static Funcionario usuario; |
| 38 | |
|
| 39 | |
public static Funcionario getUsuario() { |
| 40 | 0 | return usuario; |
| 41 | |
} |
| 42 | |
|
| 43 | |
public static void setUsuario(Funcionario usuario) { |
| 44 | 0 | Global.usuario = usuario; |
| 45 | 0 | } |
| 46 | |
|
| 47 | |
private static MDIPane midpane; |
| 48 | |
|
| 49 | |
private static IE ie; |
| 50 | |
|
| 51 | |
private static Selenium selenium; |
| 52 | |
|
| 53 | |
private static SeleniumServer seleniumServer; |
| 54 | |
|
| 55 | |
public static Selenium getSelenium(String endereco) throws Exception { |
| 56 | 0 | if (selenium == null) { |
| 57 | 0 | selenium = getNovoSelenium(endereco); |
| 58 | |
} |
| 59 | |
|
| 60 | 0 | return selenium; |
| 61 | |
|
| 62 | |
} |
| 63 | |
|
| 64 | |
public static Selenium getNovoSelenium(String endereco) throws Exception { |
| 65 | |
|
| 66 | 0 | if (seleniumServer == null) { |
| 67 | 0 | seleniumServer = new SeleniumServer(); |
| 68 | 0 | seleniumServer.start(); |
| 69 | |
} |
| 70 | |
|
| 71 | 0 | String browser = Util.getPropriedade("browser-selenium"); |
| 72 | 0 | selenium = new DefaultSelenium("localhost", RemoteControlConfiguration |
| 73 | 0 | .getDefaultPort(), browser, endereco); |
| 74 | 0 | selenium.start(); |
| 75 | |
|
| 76 | 0 | return selenium; |
| 77 | |
|
| 78 | |
} |
| 79 | |
|
| 80 | |
public static IE getIE() { |
| 81 | 0 | if (ie == null) { |
| 82 | 0 | ie = new IE(); |
| 83 | |
try { |
| 84 | 0 | ie.start(); |
| 85 | 0 | } catch (Exception e) { |
| 86 | 0 | ControladorErro.trata(e, new Global()); |
| 87 | |
} |
| 88 | |
try { |
| 89 | 0 | ie.goTo("http://www.serpro.gov.br"); |
| 90 | 0 | } catch (Exception e) { |
| 91 | 0 | ControladorErro.trata(e, new Global()); |
| 92 | |
} |
| 93 | |
} |
| 94 | 0 | return ie; |
| 95 | |
} |
| 96 | |
|
| 97 | |
public GridBagConstraints getLayout1() { |
| 98 | 0 | return layout1; |
| 99 | |
} |
| 100 | |
|
| 101 | |
public void setLayout1(GridBagConstraints layout1) { |
| 102 | 0 | this.layout1 = layout1; |
| 103 | 0 | } |
| 104 | |
|
| 105 | |
public static int confirma(String item) { |
| 106 | 0 | String[] options = new String[] { "Sim", "N�o" }; |
| 107 | 0 | return JOptionPane.showOptionDialog(null, "Deseja Deletar " + item, |
| 108 | 0 | "Delecao", JOptionPane.YES_NO_OPTION, |
| 109 | 0 | JOptionPane.QUESTION_MESSAGE, null, options, options[0]); |
| 110 | |
|
| 111 | |
} |
| 112 | |
|
| 113 | 0 | public Global() { |
| 114 | |
|
| 115 | 0 | this.layout1 = new GridBagConstraints(); |
| 116 | 0 | this.layout2 = new GridBagConstraints(); |
| 117 | 0 | this.layout3 = new GridBagConstraints(); |
| 118 | 0 | this.layout4 = new GridBagConstraints(); |
| 119 | 0 | this.layout5 = new GridBagConstraints(); |
| 120 | 0 | this.layout6 = new GridBagConstraints(); |
| 121 | 0 | this.layout7 = new GridBagConstraints(); |
| 122 | 0 | layout1.fill = GridBagConstraints.HORIZONTAL; |
| 123 | 0 | layout1.gridwidth = 1; |
| 124 | 0 | layout1.ipady = 0; |
| 125 | 0 | layout1.insets = new Insets(0, 0, 0, 0); |
| 126 | 0 | layout1.anchor = GridBagConstraints.NORTH; |
| 127 | |
|
| 128 | 0 | layout2.fill = GridBagConstraints.HORIZONTAL; |
| 129 | |
|
| 130 | 0 | layout2.gridwidth = GridBagConstraints.REMAINDER; |
| 131 | 0 | layout2.insets = new Insets(0, 0, 0, 0); |
| 132 | 0 | layout2.ipady = 0; |
| 133 | 0 | layout2.anchor = GridBagConstraints.NORTH; |
| 134 | |
|
| 135 | 0 | layout3.fill = GridBagConstraints.BOTH; |
| 136 | 0 | layout3.gridheight = 3; |
| 137 | 0 | layout3.gridwidth = 3; |
| 138 | 0 | layout3.weightx = 1; |
| 139 | 0 | layout3.weighty = 1; |
| 140 | |
|
| 141 | 0 | layout3.gridwidth = GridBagConstraints.REMAINDER; |
| 142 | |
|
| 143 | 0 | layout6.fill = GridBagConstraints.HORIZONTAL; |
| 144 | 0 | layout6.gridheight = 1; |
| 145 | 0 | layout6.gridwidth = 1; |
| 146 | |
|
| 147 | 0 | layout6.gridwidth = GridBagConstraints.REMAINDER; |
| 148 | |
|
| 149 | 0 | layout5.fill = GridBagConstraints.BOTH; |
| 150 | 0 | layout5.gridheight = 3; |
| 151 | 0 | layout5.gridwidth = 2; |
| 152 | 0 | layout5.weightx = 1; |
| 153 | 0 | layout5.weighty = 1; |
| 154 | |
|
| 155 | 0 | layout4.fill = GridBagConstraints.BOTH; |
| 156 | |
|
| 157 | 0 | layout4.gridheight = 1; |
| 158 | 0 | layout4.gridwidth = 2; |
| 159 | 0 | layout4.weightx = 1; |
| 160 | 0 | layout4.weighty = 1; |
| 161 | |
|
| 162 | 0 | layout7.fill = GridBagConstraints.HORIZONTAL; |
| 163 | |
|
| 164 | 0 | layout7.gridwidth = 2; |
| 165 | 0 | layout7.weightx = 1; |
| 166 | |
|
| 167 | 0 | } |
| 168 | |
|
| 169 | |
private GridBagConstraints layout1; |
| 170 | |
|
| 171 | |
private GridBagConstraints layout2; |
| 172 | |
|
| 173 | |
private GridBagConstraints layout3; |
| 174 | |
|
| 175 | |
private GridBagConstraints layout4; |
| 176 | |
|
| 177 | |
private GridBagConstraints layout5; |
| 178 | |
|
| 179 | |
private GridBagConstraints layout6; |
| 180 | |
|
| 181 | |
private GridBagConstraints layout7; |
| 182 | |
|
| 183 | |
private static Projeto projeto; |
| 184 | |
|
| 185 | 0 | private static HashMap<Object, Object> flowsMapa = new HashMap<Object, Object>(); |
| 186 | |
|
| 187 | 0 | private static LinkedHashMap<String, DadosTeste> ruleMapaGlobal = new LinkedHashMap<String, DadosTeste>(); |
| 188 | |
|
| 189 | |
public static HashMap<Object, Object> getFlowsMapa() { |
| 190 | 0 | return flowsMapa; |
| 191 | |
} |
| 192 | |
|
| 193 | |
public static void setFlowsMapa(HashMap<Object, Object> flowsMapa) { |
| 194 | 0 | Global.flowsMapa = flowsMapa; |
| 195 | 0 | } |
| 196 | |
|
| 197 | |
public static Projeto getProjeto() { |
| 198 | 0 | return projeto; |
| 199 | |
} |
| 200 | |
|
| 201 | |
public static void setProjeto(Projeto projeto) { |
| 202 | 0 | Global.projeto = projeto; |
| 203 | 0 | } |
| 204 | |
|
| 205 | |
public GridBagConstraints getLayout2() { |
| 206 | 0 | return layout2; |
| 207 | |
} |
| 208 | |
|
| 209 | |
public void setLayout2(GridBagConstraints layout2) { |
| 210 | 0 | this.layout2 = layout2; |
| 211 | 0 | } |
| 212 | |
|
| 213 | |
public GridBagConstraints getLayout3() { |
| 214 | 0 | return layout3; |
| 215 | |
} |
| 216 | |
|
| 217 | |
public void setLayout3(GridBagConstraints layout3) { |
| 218 | 0 | this.layout3 = layout3; |
| 219 | 0 | } |
| 220 | |
|
| 221 | |
public GridBagConstraints getLayout4() { |
| 222 | 0 | return layout4; |
| 223 | |
} |
| 224 | |
|
| 225 | |
public void setLayout4(GridBagConstraints layout4) { |
| 226 | 0 | this.layout4 = layout4; |
| 227 | 0 | } |
| 228 | |
|
| 229 | |
public GridBagConstraints getLayout5() { |
| 230 | 0 | return layout5; |
| 231 | |
} |
| 232 | |
|
| 233 | |
public void setLayout5(GridBagConstraints layout5) { |
| 234 | 0 | this.layout5 = layout5; |
| 235 | 0 | } |
| 236 | |
|
| 237 | |
public GridBagConstraints getLayout6() { |
| 238 | 0 | return layout6; |
| 239 | |
} |
| 240 | |
|
| 241 | |
public void setLayout6(GridBagConstraints layout6) { |
| 242 | 0 | this.layout6 = layout6; |
| 243 | 0 | } |
| 244 | |
|
| 245 | |
public static LinkedHashMap<String, DadosTeste> getRuleMapaGlobal() { |
| 246 | 0 | return ruleMapaGlobal; |
| 247 | |
} |
| 248 | |
|
| 249 | |
public static void setRuleMapaGlobal( |
| 250 | |
LinkedHashMap<String, DadosTeste> ruleMapaGlobal) { |
| 251 | 0 | Global.ruleMapaGlobal = ruleMapaGlobal; |
| 252 | 0 | } |
| 253 | |
|
| 254 | |
public static MDIPane getMidpane() { |
| 255 | 0 | return midpane; |
| 256 | |
} |
| 257 | |
|
| 258 | |
public static void setMidpane(MDIPane midpane) { |
| 259 | 0 | Global.midpane = midpane; |
| 260 | 0 | } |
| 261 | |
|
| 262 | |
public GridBagConstraints getLayout7() { |
| 263 | 0 | return layout7; |
| 264 | |
} |
| 265 | |
|
| 266 | |
public void setLayout7(GridBagConstraints layout7) { |
| 267 | 0 | this.layout7 = layout7; |
| 268 | 0 | } |
| 269 | |
} |