Blame view
BRIC/.svn/tmp/svn.2.tmp
21 KB
eeb5cac08
![]() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package GUI; import CSP_ANALYSE.CSPVerificationRules; import CSP_ANALYSE.FDRResult; import CSP_CREATOR.CreatorNewComponent; import LOGIC.Channel; import LOGIC.Instance; import LOGIC.Internacional; import LOGIC.ObjectList; import LOGIC.Protocols; import java.util.ArrayList; import java.util.LinkedList; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JComboBox; import javax.swing.JOptionPane; /** * * @author Dalay */ public class SystemCompositionSimplesGUI extends javax.swing.JFrame { public SystemCompositionSimplesGUI(Internacional inter, ObjectList listas) { initComponents(); this.inter = inter; combo1.removeAllItems(); combo2.removeAllItems(); combo3.removeAllItems(); combo4.removeAllItems(); combo5.removeAllItems(); combo1.addItem(inter.retornarMensagem("COD0013")); combo2.addItem(inter.retornarMensagem("COD0012")); combo3.addItem(inter.retornarMensagem("COD0013")); combo4.addItem(inter.retornarMensagem("COD0012")); combo5.addItem(inter.retornarMensagem("COD0014")); this.listas = listas; criarListas(); listar(); compor.setText(inter.retornarMensagem("COD0011")); } LinkedList<Instance> listaInstances = new LinkedList<Instance>(); LinkedList<Protocols> listaProtocols = new LinkedList(); ObjectList listas; Internacional inter; CreatorNewComponent newComp; LinkedList<Instance> instancias = new LinkedList<Instance>(); LinkedList<Channel> canais; public void criarListas() { for (int i = 0; i < listas.getInstanceList().size(); i++) { if (listas.getInstanceList().get(i).getFlag()) { instancias.add(listas.getInstanceList().get(i)); } } } public void listarRegra() { if (combo1.getSelectedItem().equals(inter.retornarMensagem("COD0013")) || combo3.getSelectedItem().equals(inter.retornarMensagem("COD0013"))) { combo5.removeAllItems(); combo5.addItem(inter.retornarMensagem("COD0014")); } else { if (combo2.getSelectedItem().equals(inter.retornarMensagem("COD0012")) && combo4.getSelectedItem().equals(inter.retornarMensagem("COD0012"))) { combo5.removeAllItems(); combo5.addItem(inter.retornarMensagem("COD0014")); combo5.addItem("Interleaving"); } else { if (!combo2.getSelectedItem().equals(inter.retornarMensagem("COD0012")) && !combo4.getSelectedItem().equals(inter.retornarMensagem("COD0012"))) { if (combo1.getSelectedItem().equals(combo3.getSelectedItem())) { combo5.removeAllItems(); combo5.addItem(inter.retornarMensagem("COD0014")); combo5.addItem("Feedback"); combo5.addItem("Reflexive"); } else { combo5.removeAllItems(); combo5.addItem(inter.retornarMensagem("COD0014")); combo5.addItem("Interleaving"); combo5.addItem("Communication"); } } } } } private void listar() { // System.out.println(listas.getInstanceList()); for (int i = 0; i < instancias.size(); i++) { combo1.addItem(instancias.get(i).getName()); } for (int i = 0; i < instancias.size(); i++) { combo3.addItem(instancias.get(i).getName()); } } public void compor() throws InterruptedException { if (combo5.getSelectedItem().equals(inter.retornarMensagem("COD0014"))) { JOptionPane.showMessageDialog(null, "Selecione um modo de composição e os componentes..."); } if (combo5.getSelectedItem().equals("Interleaving")) { listaInstances.add(instancias.get(combo1.getSelectedIndex() - 1)); listaInstances.add(instancias.get(combo3.getSelectedIndex() - 1)); CSPVerificationRules r = new CSPVerificationRules(listaInstances, listaProtocols, listas); ArrayList<FDRResult> result = new ArrayList<FDRResult>(); result = r.RuleInterleaveIsDeadlockFree(); CreatorNewComponent newComp = new CreatorNewComponent(listaInstances, listaProtocols); excluiPais(listaInstances.get(0), listaInstances.get(1)); listas.getInstanceList().add(newComp.creatorNewComponentIterleave()); new ShowResultIOProcessGUI(inter, result, "composition").setVisible(true); this.dispose(); } if (combo5.getSelectedItem().equals("Communication")) { listaInstances.add(instancias.get(combo1.getSelectedIndex() - 1)); listaInstances.add(instancias.get(combo3.getSelectedIndex() - 1)); listaProtocols.add(instancias.get(combo1.getSelectedIndex() - 1).getProtocolos().get(combo2.getSelectedIndex() - 1)); listaProtocols.add(instancias.get(combo3.getSelectedIndex() - 1).getProtocolos().get(combo4.getSelectedIndex() - 1)); CSPVerificationRules r = new CSPVerificationRules(listaInstances, listaProtocols, listas); ArrayList<FDRResult> result = new ArrayList<FDRResult>(); result = r.RuleCommunicationIsDeadlockFree(); CreatorNewComponent newComp = new CreatorNewComponent(listaInstances, listaProtocols); excluiPais(listaInstances.get(0), listaInstances.get(1)); listas.getInstanceList().add(newComp.creatorNewComponentComunication()); new ShowResultIOProcessGUI(inter, result, "composition").setVisible(true); this.dispose(); } if (combo5.getSelectedItem().equals("Feedback")) { listaInstances.add(instancias.get(combo1.getSelectedIndex() - 1)); listaInstances.add(instancias.get(combo3.getSelectedIndex() - 1)); listaProtocols.add(instancias.get(combo1.getSelectedIndex() - 1).getProtocolos().get(combo2.getSelectedIndex() - 1)); listaProtocols.add(instancias.get(combo3.getSelectedIndex() - 1).getProtocolos().get(combo4.getSelectedIndex() - 1)); CSPVerificationRules r = new CSPVerificationRules(listaInstances, listaProtocols, listas); ArrayList<FDRResult> result = new ArrayList<FDRResult>(); result = r.RuleFeedbackIsDeadlockFree(); CreatorNewComponent newComp = new CreatorNewComponent(listaInstances, listaProtocols); excluiPais(listaInstances.get(0), listaInstances.get(1)); listas.getInstanceList().add(newComp.creatorNewComponentFeedBack()); new ShowResultIOProcessGUI(inter, result, "composition").setVisible(true); this.dispose(); } if (combo5.getSelectedItem().equals("Reflexive")) { listaInstances.add(instancias.get(combo1.getSelectedIndex() - 1)); listaInstances.add(instancias.get(combo3.getSelectedIndex() - 1)); listaProtocols.add(instancias.get(combo1.getSelectedIndex() - 1).getProtocolos().get(combo2.getSelectedIndex() - 1)); listaProtocols.add(instancias.get(combo3.getSelectedIndex() - 1).getProtocolos().get(combo4.getSelectedIndex() - 1)); CSPVerificationRules r = new CSPVerificationRules(listaInstances, listaProtocols, listas); ArrayList<FDRResult> result = new ArrayList<FDRResult>(); result = r.RuleReflexiveIsDeadlockFree(); //trocar essa linha CreatorNewComponent newComp = new CreatorNewComponent(listaInstances, listaProtocols); excluiPais(listaInstances.get(0), listaInstances.get(1)); listas.getInstanceList().add(newComp.creatorNewComponentReflexive()); new ShowResultIOProcessGUI(inter, result, "composition").setVisible(true); this.dispose(); } } public void excluiPais(Instance instancia1, Instance instancia2) { if(listas.getInstanceList().contains(instancia1)){ listas.getInstanceList().remove(instancia1); } if(listas.getInstanceList().contains(instancia2)){ listas.getInstanceList().remove(instancia2); } } private void listarCanais1() { if (!combo1.getSelectedItem().equals(inter.retornarMensagem("COD0013"))) { combo2.removeAllItems(); combo2.addItem(inter.retornarMensagem("COD0012")); //System.out.println("hvjhgvfjbvkjhvb " + instancias.get(combo1.getSelectedIndex() - 1).getProtocolos()); for (int i = 0; i < instancias.get(combo1.getSelectedIndex() - 1).getProtocolos().size(); i++) { if (!instancias.get(combo1.getSelectedIndex() - 1).getProtocolos().get(i).getProtocol().equals("") && !instancias.get(combo1.getSelectedIndex() - 1).getProtocolos().get(i).getDualProtocol().equals("")) { combo2.addItem(instancias.get(combo1.getSelectedIndex() - 1).getProtocolos().get(i).getCc()); System.out.println("COISASS "+instancias.get(combo1.getSelectedIndex() - 1).getProtocolos().get(i).getCanal().getName()); } } } else { combo2.removeAllItems(); combo2.addItem(inter.retornarMensagem("COD0012")); } } private void listarCanais2() { if (!combo3.getSelectedItem().equals(inter.retornarMensagem("COD0013"))) { combo4.removeAllItems(); combo4.addItem(inter.retornarMensagem("COD0012")); for (int i = 0; i < instancias.get(combo3.getSelectedIndex() - 1).getProtocolos().size(); i++) { if (!instancias.get(combo3.getSelectedIndex() - 1).getProtocolos().get(i).getProtocol().equals("") && !instancias.get(combo3.getSelectedIndex() - 1).getProtocolos().get(i).getDualProtocol().equals("")) { combo4.addItem(instancias.get(combo3.getSelectedIndex() - 1).getProtocolos().get(i).getCc()); } } } else { combo4.removeAllItems(); combo4.addItem(inter.retornarMensagem("COD0012")); } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { combo1 = new javax.swing.JComboBox(); combo2 = new javax.swing.JComboBox(); combo3 = new javax.swing.JComboBox(); combo4 = new javax.swing.JComboBox(); combo5 = new javax.swing.JComboBox(); compor = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setMinimumSize(new java.awt.Dimension(358, 100)); combo1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); combo1.setMaximumSize(new java.awt.Dimension(190, 27)); combo1.setMinimumSize(new java.awt.Dimension(190, 27)); combo1.setPreferredSize(new java.awt.Dimension(190, 27)); combo1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { combo1ActionPerformed(evt); } }); combo2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); combo2.setMaximumSize(new java.awt.Dimension(190, 27)); combo2.setMinimumSize(new java.awt.Dimension(190, 27)); combo2.setPreferredSize(new java.awt.Dimension(190, 27)); combo2.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { combo2MouseEntered(evt); } }); combo2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { combo2ActionPerformed(evt); } }); combo3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); combo3.setMaximumSize(new java.awt.Dimension(190, 27)); combo3.setMinimumSize(new java.awt.Dimension(190, 27)); combo3.setPreferredSize(new java.awt.Dimension(190, 27)); combo4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); combo4.setMaximumSize(new java.awt.Dimension(190, 27)); combo4.setMinimumSize(new java.awt.Dimension(190, 27)); combo4.setPreferredSize(new java.awt.Dimension(190, 27)); combo4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { combo4MouseEntered(evt); } }); combo4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { combo4ActionPerformed(evt); } }); combo5.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); combo5.setMaximumSize(new java.awt.Dimension(190, 27)); combo5.setMinimumSize(new java.awt.Dimension(190, 27)); combo5.setPreferredSize(new java.awt.Dimension(190, 27)); combo5.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { combo5MouseEntered(evt); } }); compor.setText("compor"); compor.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { comporActionPerformed(evt); } }); jLabel1.setText("Componente 1:"); jLabel2.setText("Canal:"); jLabel3.setText("Componente 2:"); jLabel4.setText("Canal:"); jLabel5.setText("Regra:"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel1) .addComponent(jLabel3) .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(combo1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(combo2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(combo3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(combo4, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(combo5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGap(146, 146, 146) .addComponent(compor))) .addContainerGap(34, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(combo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(combo2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addGap(19, 19, 19) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel3) .addComponent(combo3, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(combo4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(combo5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addGap(18, 18, 18) .addComponent(compor) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void comporActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comporActionPerformed try { /*CSPVerificationRules r = new CSPVerificationRules(listaInstances, listas); ArrayList<FDRResult> result = new ArrayList<FDRResult>(); result = r.RuleIsDeadlockFree(); CreatorNewComponent newComp = new CreatorNewComponent(listaInstances); listas.getInstanceList().add(newComp); new ShowResultIOProcessGUI(inter, result, "composition").setVisible(true);*/ compor(); } catch (InterruptedException ex) { Logger.getLogger(SystemCompositionSimplesGUI.class.getName()).log(Level.SEVERE, null, ex); } }//GEN-LAST:event_comporActionPerformed private void combo5MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_combo5MouseEntered listarRegra(); // TODO add your handling code here: }//GEN-LAST:event_combo5MouseEntered private void combo2MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_combo2MouseEntered listarCanais1(); // TODO add your handling code here: }//GEN-LAST:event_combo2MouseEntered private void combo4MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_combo4MouseEntered listarCanais2(); // TODO add your handling code here: }//GEN-LAST:event_combo4MouseEntered private void combo2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo2ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_combo2ActionPerformed private void combo4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo4ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_combo4ActionPerformed private void combo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_combo1ActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox combo1; private javax.swing.JComboBox combo2; private javax.swing.JComboBox combo3; private javax.swing.JComboBox combo4; private javax.swing.JComboBox combo5; private javax.swing.JButton compor; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; // End of variables declaration//GEN-END:variables } |