| 1 package cve.osservatori; 2 3 import cve.core.elementEEL.*; 4 5 import cve.esecutori.*; 6 import cve.esecutori.servizioEACesecSemantic.*; 7 import cve.esecutori.components.specificaSem.*; 8 import cve.esecutori.components.specificaLV.*; 9 10 import cve.osservatori.servizioOACesecSemantic.*; 11 import interactionHandler.*; 12 import interactionGraphics.*; 13 14 import cve.staticLayout.*; 15 import org.apache.log4j.Logger; 16 17 import cve.util.ConfigurationRead; 18 19 import wippog.*; 20 21 import java.io.File ; 22 import java.io.IOException ; 23 import java.io.*; 24 25 import java.awt.*; 26 import java.awt.event.*; 27 import java.util.*; 28 29 import javax.swing.text.*; 31 import javax.swing.*; 32 import javax.swing.event.*; 33 34 52 public class OACesecSemantic extends Osservatore { 53 56 private ControllerOACesecSemantic med; 57 58 61 private ControllerTree treeContr; 62 private TreeCve contSemantic; 64 private TreeCve contAlphabet; 65 private TreeCve contLanguage; 66 private TreeCve contSintRules; 67 private TreeCve contSemRules; 68 private TreeCve contAssSem; 69 private TreeCve contFileAssFile; 70 71 72 75 private HashMap buttonAlf=new HashMap(); 76 77 80 private IJTool tbar; 81 82 85 private IJCanvas canvas; 86 87 90 private IJTabbed tab; 91 92 95 private IEsecutionSentenceSemantic eseGS; 96 97 100 private String modality="Modality 1"; 101 102 105 private OACesecSemantic istOACesec=this; 106 107 private String fileAlf = null; 110 private String fileLanguage = null; 111 private String fileSinRules = null; 112 private String fileSemRules = null; 113 private String fileAssSem = null; 114 private String fileAssFile = null; 115 116 private boolean semantic = false; 117 118 private int orientation = TOKEN; 121 final private static int TOKEN=1; 122 final private static int HOLDER=2; 123 124 private int typeSemantic = PN_CE; 126 final private static int PN_CE=1; final private static int PN_PT=2; 130 private int fase = CREATION; 133 final private static int CREATION=1; 134 final private static int INITIALIZE=2; 135 final private static int EXECUTION=3; 136 137 private String activator; 139 140 private Vector disabledButton; 142 private boolean disButton = false; 143 144 private ConfigurationFrame configFrame; 146 private QueryFrame queryFrame; 147 private interactionHandler.MappingEventActivity mappingEventFrame; 148 149 private boolean configFrameIsOpen = false; 151 private boolean configElementIsOpen = false; 152 154 private Presenter pre; 155 private String titlePresenter; 156 157 159 160 161 163 169 public Action getAssociation = new AbstractAction("") { 170 public void actionPerformed(ActionEvent e) { 171 Cve.errLog.debug(""); 172 ViewLog.writeInLog(" #O# Eseguita attivita' (action) getAssociation"+"\n"); 173 174 File current=new File (ConfigurationRead.getCveRoot()+"/VisualLanguage/SpecificheWippog"); 175 String fileAssFile=Osservatore.getFileXml(current); 176 177 if (fileAssFile.equals("")==false ){ 178 setAssociation(fileAssFile); 180 181 getAssociation.setEnabled(false); 183 cancAssociation.setEnabled(true); 184 cancSentence.setEnabled(false); 185 saveSentence.setEnabled(false); 186 187 pre = getPresenter(); 189 if (titlePresenter == null){ 190 titlePresenter = pre.getTitle(); 191 } 192 setTitle(); 193 }else { 194 195 } 196 repaint(); 197 repaintAll(); 198 } 199 }; 200 201 204 public Action cancAssociation = new AbstractAction("") { 205 public void actionPerformed(ActionEvent e) { 206 Cve.errLog.debug(""); 207 ViewLog.writeInLog(" #O# Eseguita attivita' (action) cancAssociation"+"\n"); 208 209 fileAlf = null; 211 fileLanguage = null; 212 fileSinRules = null; 213 fileSemRules = null; 214 fileAssSem = null; 215 fileAssFile = null; 216 217 clearAssociation(); 219 220 cancAssociation.setEnabled(false); 222 cancSentence.setEnabled(false); 223 saveSentence.setEnabled(false); 224 getAssociation.setEnabled(true); 225 repaint(); 226 repaintAll(); 227 } 228 }; 229 230 233 public Action getSentence = new AbstractAction("") { 234 public void actionPerformed(ActionEvent e) { 235 Cve.errLog.debug(""); 236 ViewLog.writeInLog(" #O# Eseguita attivita' (action) getSentence"+"\n"); 237 } 239 }; 240 241 244 public Action saveSentence = new AbstractAction("") { 245 public void actionPerformed(ActionEvent e) { 246 Cve.errLog.debug(""); 247 ViewLog.writeInLog(" #O# Eseguita attivita' (action) saveSentence"+"\n"); 248 saveSentence(); 249 } 250 }; 251 252 253 256 public Action cancSentence = new AbstractAction("") { 257 public void actionPerformed(ActionEvent e) { 258 ViewLog.writeInLog(" #O# Eseguita attivita' (action) cancSentence"+"\n"); 259 clearSentence(); 260 repaint(); 262 repaintAll(); 263 } 264 }; 265 266 268 273 public Action openConfiguration = new AbstractAction("") { 274 public void actionPerformed(ActionEvent e) { 275 Cve.errLog.debug(""); 276 ViewLog.writeInLog(" #O# Eseguita attivita' (action) openConfiguration"+"\n"); 277 278 openConfigFrame(); 279 } 280 }; 281 282 286 public Action startSent = new AbstractAction("") { 287 public void actionPerformed(ActionEvent e) { 288 Cve.errLog.debug(""); 289 ViewLog.writeInLog(" #O# Eseguita attivita' (action) startSent"+"\n"); 290 System.out.println(" #O# Eseguita attivita' (action) startSent"); 291 292 startExecution(); 293 } 294 }; 295 296 297 301 public Action stepSent = new AbstractAction("") { 302 public void actionPerformed(ActionEvent e) { 303 Cve.errLog.debug(""); 304 ViewLog.writeInLog(" #O# Eseguita attivita' (action) stepSent"+"\n"); 305 System.out.println(" #O# Eseguita attivita' (action) stepSent"); 306 stepExecution(); 307 } 308 }; 309 310 311 315 public Action stopSent = new AbstractAction("") { 316 public void actionPerformed(ActionEvent e) { 317 Cve.errLog.debug(""); 318 ViewLog.writeInLog(" #O# Eseguita attivita' (action) stopSent"+"\n"); 319 stopExecution(); 320 } 321 }; 322 323 325 328 public Action changeEventAction = new AbstractAction("") { 329 public void actionPerformed(ActionEvent e) { 330 Cve.errLog.debug(""); 331 ViewLog.writeInLog(" #O# Eseguita attivita' (action) changeEventAction"+"\n"); 332 333 openMappingFrame(); 335 } 337 }; 338 339 340 343 public Action colorSelect = new AbstractAction("") { 344 public void actionPerformed(ActionEvent e) { 345 Cve.errLog.debug(""); 346 ViewLog.writeInLog(" #O# Eseguita attivita' (action) colorSelect"+"\n"); 347 canvas.setColorSelected(); 348 } 349 }; 350 351 354 public Action colorDummy = new AbstractAction("") { 355 public void actionPerformed(ActionEvent e) { 356 Cve.errLog.debug(""); 357 ViewLog.writeInLog(" #O# Eseguita attivita' (action) colorDummy"+"\n"); 358 canvas.setColorDummy(); 359 } 360 }; 361 362 365 public Action advancedFeature = new AbstractAction("") { 366 public void actionPerformed(ActionEvent e) { 367 Cve.errLog.debug(""); 368 ViewLog.writeInLog(" #O# Eseguita attivita' (action) advancedFeature"+"\n"); 369 370 canvas.advanced(); 371 } 372 }; 373 374 375 377 378 public void setMediator(Controller med){ 379 Cve.errLog.debug(""); 380 } 382 383 386 public OACesecSemantic(){ 387 Cve.errLog.debug(""); 388 med = new ControllerOACesecSemantic(this); 389 setMediator(med); 390 391 treeContr=new ControllerTree(); 393 394 contSemantic = new TreeCve(treeContr); 396 contAlphabet = new TreeCve(treeContr); 397 contLanguage = new TreeCve(treeContr); 398 contSintRules = new TreeCve(treeContr); 399 contSemRules = new TreeCve(treeContr); 400 contAssSem = new TreeCve(treeContr); 401 contFileAssFile = new TreeCve(treeContr); 402 403 setMappingFrameOpen(false); 405 setQueryElementOpen(false); 406 407 } 408 409 414 public void setAssociation(String file) { 415 Cve.errLog.debug(""); 416 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 417 if (eseGS!=null){ 418 eseGS.setAssociation(file); 419 } 420 } 421 422 425 public void clearAssociation() { 426 Cve.errLog.debug(""); 427 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 428 eseGS.clearAssociation(); 429 } 430 431 436 public void setComponents (Collection param){ 437 Cve.errLog.debug(""); 438 Iterator itParam=param.iterator(); 439 while (itParam.hasNext()){ 440 Object component=itParam.next(); 441 if (component instanceof IJCanvas){ 442 canvas=(IJCanvas)component; 443 } 444 if (component instanceof IJTool){ 445 tbar=(IJTool)component; 446 } 447 if (component instanceof IJTabbed){ 448 tab=(IJTabbed)component; 449 } 450 } 451 canvas.setController(med); 453 tbar.setController(med); 454 tab.setController(med); 455 456 tab = (JTabbed)tab.addCve("Sentence", (ACanvas)canvas); 457 tab = (JTabbed)tab.addCve("Semantic", contSemantic); 458 tab = (JTabbed)tab.addCve("Alphabet", contAlphabet); 459 tab = (JTabbed)tab.addCve("Automata", contLanguage); 460 tab = (JTabbed)tab.addCve("Synt.Rules", contSintRules); 461 tab = (JTabbed)tab.addCve("Sem.Rules", contSemRules); 462 tab = (JTabbed)tab.addCve("Ass.Rules", contAssSem); 463 tab = (JTabbed)tab.addCve("Ass.File", contFileAssFile); 464 465 cveCont.setLayout(new BorderLayout()); 466 cveCont.add("Center",(Component)tab); 467 468 473 474 cveCont.add("East",(Component)tbar); 475 impostaComandi(); 476 477 } 478 479 483 public Controller getMediator() { 484 Cve.errLog.debug(""); 485 return med; 486 } 487 488 489 490 491 497 public void setOrientation(int Orientation){ 498 Cve.errLog.debug(""); 499 if (semantic && Orientation!=orientation){ 501 JOptionPane.showMessageDialog(null,"L'orientazione della Semantica non č modificabile in creazione della Sentenza!","ATTENZIONE",JOptionPane.WARNING_MESSAGE); 502 }else{ 503 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 504 eseGS.setOrientation(Orientation); 505 orientation = Orientation; 506 } 507 } 508 509 514 public int getOrientation(){ 515 Cve.errLog.debug(""); 516 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 517 return eseGS.getOrientation(); 518 } 519 520 521 526 public boolean getSemanticFlag(){ 527 Cve.errLog.debug(""); 528 return semantic; 529 } 530 531 532 538 public void setFase(int fase_in){ 539 Cve.errLog.debug(""); 540 System.out.println(" #O Eseguita Impostazione Fase Manipolazione: " + fase_in); 541 542 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 544 eseGS.setFase(fase_in); 545 fase = fase_in; 546 547 setTitle(); 548 } 549 550 555 public int getFase(){ 556 Cve.errLog.debug(""); 557 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 558 fase = eseGS.getFase(); 559 System.out.println(" #O Eseguita lettura Fase Manipolazione: " + fase); 560 return fase; 561 } 562 563 569 public void setActivator(String act){ 570 Cve.errLog.debug(""); 571 System.out.println(" #O Eseguita Impostazione Attivatore Semantico: " + act); 572 activator = act; 573 574 if (activator.equals("StepActivator")==false && activator.equals("SeqActivator")==false){ 576 JOptionPane.showMessageDialog(null,"Attivatore Non Gestito!Viene impostato lo StepActivator per Default.","ATTENZIONE",JOptionPane.WARNING_MESSAGE); 578 activator = "StepActivator"; 579 } 580 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 581 eseGS.setActivator(activator); 582 } 583 584 589 public String getActivator(){ 590 Cve.errLog.debug(""); 591 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 592 activator = eseGS.getActivator(); 593 System.out.println(" #O Eseguita lettura Attivatore Semantico: " + activator); 594 return activator; 595 } 596 597 601 public void setTitle(){ 602 603 Cve.errLog.debug(""); 604 String appo_fase = new String (); 605 606 if (fase==CREATION) appo_fase = " - FASE: CREATION"; 607 if (fase==INITIALIZE) appo_fase = " - FASE: INITIALIZE"; 608 if (fase==EXECUTION) appo_fase = " - FASE: EXECUTION"; 609 610 if (titlePresenter == null) { 611 } 612 pre.setTitle(titlePresenter + appo_fase); 613 614 } 615 616 622 public void configElement(String idTipo,String idIstanza){ 623 624 Cve.errLog.debug(""); 626 if (fase==EXECUTION){ 627 JOptionPane.showMessageDialog(null,"La modifica dello stato di un'oggetto č possibile solo nelle fasi di CREATION ed INITIALIZE!!!","ATTENZIONE",JOptionPane.WARNING_MESSAGE); 628 }else{ 629 ViewLog.writeInLog(" #O# Eseguita attivita' configElement id: "+ id + " idIstanza: "+ idIstanza +"\n"); 630 System.out.println(" #O# Eseguita attivita' configElement id: "+ id + " idIstanza: "+ idIstanza +"\n"); 631 632 ConfigElementFrame configElementFrame = new ConfigElementFrame("Config Element","/resource/QueryView.GIF"); 634 635 configElementFrame.setOAC(this); 637 configElementFrame.init(idIstanza); 638 639 JDesktopPane desktop; 641 desktop =Cve.getDesktop(); 642 desktop.add(configElementFrame); 643 644 try{ 645 configElementFrame.setSelected(true); 646 }catch (Exception e){ 647 Cve.errLog.error(e.toString()); 648 } 649 } 650 651 } 652 653 658 public void setConfigFrameOpen(boolean flag){ 659 Cve.errLog.debug(""); 660 configFrameIsOpen = flag; 661 } 662 663 668 public boolean getConfigFrameOpen(){ 669 Cve.errLog.debug(""); 670 return configFrameIsOpen; 671 } 672 673 674 679 public void setConfigElementOpen(boolean flag){ 680 Cve.errLog.debug(""); 681 configElementIsOpen = flag; 682 } 683 684 689 public boolean getConfigElementOpen(){ 690 Cve.errLog.debug(""); 691 return configElementIsOpen; 692 } 693 694 695 701 public void addInternalPool(String id, int num_token){ 702 Cve.errLog.debug(""); 703 ViewLog.writeInLog(" #O# Eseguita attivita' addInternalPool id: "+ id + " Num.Token: "+ num_token+"\n"); 704 System.out.println(" #O# Eseguita attivita' addInternalPool id: "+ id + " Num.Token: "+ num_token); 705 706 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 708 eseGS.addInternalPool(id,num_token); 709 710 } 711 712 718 public void updateWeight(String id, int num_weight){ 719 Cve.errLog.debug(""); 720 ViewLog.writeInLog(" #O# Eseguita attivita' updateWeight id: "+ id + " Weight: "+ num_weight+"\n"); 721 System.out.println(" #O# Eseguita attivita' updateWeight id: "+ id + " Weight: "+ num_weight); 722 723 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 725 eseGS.updateWeight(id,num_weight); 726 727 } 728 729 736 public void updateMaxToken(String id, int max_token){ 737 Cve.errLog.debug(""); 738 ViewLog.writeInLog(" #O# Eseguita attivita' updateMaxToken id: "+ id + " MaxToken: "+ max_token+"\n"); 739 System.out.println(" #O# Eseguita attivita' updateMaxToken id: "+ id + " MaxToken: "+ max_token); 740 741 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 743 eseGS.updateMaxToken(id,max_token); 744 745 } 746 747 753 public ConfigElement getConfigElement(String idIstanza){ 754 Cve.errLog.debug(""); 755 ViewLog.writeInLog(" #O# Eseguita attivita' getConfigElement id: "+ idIstanza+"\n"); 756 System.out.println(" #O# Eseguita attivita' getConfigElement id: "+ idIstanza); 757 758 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 760 return eseGS.getConfigElement(idIstanza); 761 } 762 763 764 767 772 public void trigger(String idTipo){ 773 Cve.errLog.debug(""); 774 if (eseGS!=null) { 775 eseGS.inputTrigger(idTipo); 776 } 777 } 778 779 786 public void inputSelected(String id,String idIstanza, boolean selected){ 787 Cve.errLog.debug(""); 788 ViewLog.writeInLog(" #O# Eseguita attivita' inputSelected id: "+ id + " idIstanza: "+ idIstanza + " selected: "+ selected +"\n"); 789 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 790 eseGS.inputSelected(id,idIstanza,selected); 791 } 792 793 799 public void query(String idTipo,String idIstanza){ 800 Cve.errLog.debug(""); 801 ViewLog.writeInLog(" #O# Eseguita attivita' query id: "+ id + " idIstanza: "+ idIstanza +"\n"); 802 System.out.println(" #O# Eseguita attivita' query id: "+ id + " idIstanza: "+ idIstanza); 803 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 804 eseGS.inputQuery(idTipo,idIstanza); 805 } 806 807 808 809 813 817 public void disableButton(){ 818 819 Cve.errLog.debug(""); 820 disButton = true; 822 823 Vector allButton=new Vector (buttonAlf.values()); 825 826 disabledButton = new Vector(); 828 for (int i=0;i<allButton.size();i++){ 829 AlfButton ref=(AlfButton)allButton.elementAt(i); 830 831 if (ref.isEnabled()==false){ 832 disabledButton.add(ref.getActionCommand()); 833 } 834 } 835 for (int j=0;j<allButton.size();j++){ 837 AlfButton ref1=(AlfButton)allButton.elementAt(j); 838 ref1.setEnabled(false); 839 } 840 } 841 842 847 public Collection getDisabledButton(){ 848 Cve.errLog.debug(""); 849 return disabledButton; 850 } 851 852 857 public boolean getDisButton(){ 858 Cve.errLog.debug(""); 859 return disButton; 860 } 861 862 869 public void setStateButton(Collection disab, boolean enable){ 870 871 Cve.errLog.debug(""); 872 disButton = false; 873 874 Vector allButton=new Vector (buttonAlf.values()); 877 878 Iterator disabIt=disab.iterator(); 880 while (disabIt.hasNext()){ 881 Object idButton=disabIt.next(); 883 String idButtonS=idButton.toString(); 885 886 AlfButton refButton=(AlfButton)buttonAlf.get(idButtonS); 887 if (enable) 888 refButton.setEnabled(true); 889 else 890 refButton.setEnabled(false); 891 } 892 repaint(); 893 } 894 895 896 898 902 public void enableCreate(){ 903 Cve.errLog.debug(""); 904 startSent.setEnabled(false); 905 stopSent.setEnabled(false); 906 907 getAssociation.setEnabled(false); 909 cancAssociation.setEnabled(true); 910 getSentence.setEnabled(true); 911 cancSentence.setEnabled(true); 912 saveSentence.setEnabled(false); 913 openConfiguration.setEnabled(true); 914 } 915 916 920 public void enableInit(){ 921 Cve.errLog.debug(""); 922 startSent.setEnabled(false); 923 stopSent.setEnabled(false); 924 925 getAssociation.setEnabled(false); 927 cancAssociation.setEnabled(false); 928 getSentence.setEnabled(false); 929 cancSentence.setEnabled(false); 930 saveSentence.setEnabled(false); 931 openConfiguration.setEnabled(true); 932 } 933 934 938 public void enableExecution(){ 939 Cve.errLog.debug(""); 940 startSent.setEnabled(true); 941 943 getAssociation.setEnabled(false); 945 cancAssociation.setEnabled(false); 946 getSentence.setEnabled(false); 947 cancSentence.setEnabled(false); 948 saveSentence.setEnabled(false); 949 openConfiguration.setEnabled(true); 950 } 951 952 956 public void enableExecStart(){ 957 Cve.errLog.debug(""); 958 startSent.setEnabled(false); 959 stopSent.setEnabled(true); 960 961 if (activator.equals("StepActivator")){ 962 stepSent.setEnabled(true); 963 } else { 964 stepSent.setEnabled(false); 965 } 966 } 967 968 972 public void enableExecEnd(){ 973 Cve.errLog.debug(""); 974 startSent.setEnabled(true); 975 stepSent.setEnabled(false); 976 stopSent.setEnabled(false); 977 } 978 979 981 |