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 983 984 990 protected void react(Observable o, Object arg){ 991 Cve.errLog.debug(""); 992 if (arg instanceof SentenceEvent ){ 993 SentenceEvent sentEv=(SentenceEvent)arg; 994 String action=sentEv.getActionUser(); 995 996 ViewLog.writeInLog(" #O# Sono in react osservatore ("+action+")"+"\n"); 997 System.out.println(" #O# Sono in react osservatore ("+action+")"); 998 999 if (action.equals("clearSentence")){ 1001 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent per pulizia Sentenza"+"\n"); 1002 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1003 canvas.clear(); 1004 canvas.repaint(); 1005 } 1006 if (action.equals("clearLanguage")){ 1007 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent per pulizia Linguaggio"+"\n"); 1008 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1009 canvas.clear(); 1010 removeElementTool(); 1012 } 1013 if (action.equals("trigger")){ 1014 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent per creazione Oggetto Visuale"+"\n"); 1015 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1016 Vector sentence=new Vector((Collection)eseGS.getSentence()); 1017 canvas.setSentence(sentence); 1018 canvas.computeCoordinate(sentence); 1019 } 1022 if (action.equals("selected")){ 1023 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1024 String stateError=eseGS.getStateError(); 1025 if (stateError.equals("")){ 1026 Vector sentence=new Vector((Collection)eseGS.getSentence()); 1027 canvas.setSentence(sentence); 1029 }else{ 1030 openStateError(stateError); 1032 } 1033 } 1034 if (action.equals("language")){ 1035 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent per Impostazione Linguaggio Visuale"+"\n"); 1036 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1037 Map rap=eseGS.getRappresentations(); 1038 Collection rappre=rap.values(); 1039 setAlfabet(rappre); 1040 tbar.repaint(); 1041 } 1042 if (action.equals("deselectButton")){ 1043 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent per Disabilitazione Pulsanti"+"\n"); 1044 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1045 1048 Collection buttonS=eseGS.getDisableButton(); 1049 setStateButton(buttonS,false); 1050 tbar.repaint(); 1051 } 1052 if (action.equals("selectButton")){ 1053 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent per Abilitazione Pulsanti"+"\n"); 1054 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1055 Collection buttonS=eseGS.getEnableButton(); 1059 setStateButton(buttonS,true); 1060 tbar.repaint(); 1061 } 1062 1063 if (action.equals("query")){ 1064 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent che contiene item selezionato per Query"+"\n"); 1065 System.out.println(" #O# Esecutore ha creato SentenceEvent che contiene item selezionato per Query"+"\n"); 1066 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1067 IResource item=eseGS.getQueryItem(); 1068 1069 viewQuery(item); 1071 } 1072 1073 if (action.equals("setSemantic")){ 1075 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent che contiene modello Semantica da visualizzare"+"\n"); 1076 if (semantic){ 1078 contSemantic.setModel(null); 1080 } 1082 contSemantic.setModel(sentEv.getModelTree()); 1083 semantic = true; 1084 contSemantic.repaint(); 1085 } 1087 if (action.equals("setAlphabet")){ 1088 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent che contiene modello Alfabeto da visualizzare"+"\n"); 1089 fileAlf = sentEv.getFileTree(); 1090 contAlphabet.setModel(sentEv.getModelTree()); 1091 } 1092 if (action.equals("setLanguage")){ 1093 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent che contiene modello Automa di Controllo da visualizzare"+"\n"); 1094 fileLanguage = sentEv.getFileTree(); 1095 contLanguage.setModel(sentEv.getModelTree()); 1096 } 1097 if (action.equals("setSintaxRules")){ 1098 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent che contiene modello Regole Sintattiche da visualizzare"+"\n"); 1099 fileSinRules = sentEv.getFileTree(); 1100 contSintRules.setModel(sentEv.getModelTree()); 1101 } 1102 if (action.equals("setSemanticRules")){ 1103 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent che contiene modello Regole Semantiche da visualizzare"+"\n"); 1104 fileSemRules = sentEv.getFileTree(); 1105 contSemRules.setModel(sentEv.getModelTree()); 1106 } 1107 if (action.equals("setAssociationSemantic")){ 1108 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent che contiene modello Associazione Regole Sintattiche-Semantiche da visualizzare"+"\n"); 1109 fileAssSem = sentEv.getFileTree(); 1110 contAssSem.setModel(sentEv.getModelTree()); 1111 } 1112 if (action.equals("setAssociationFile")){ 1113 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent che contiene modello Associazione File Sintassi-Semantica da visualizzare"+"\n"); 1114 fileAssFile = sentEv.getFileTree(); 1115 contFileAssFile.setModel(sentEv.getModelTree()); 1116 } 1117 if (action.equals("delAll")){ 1118 ViewLog.writeInLog(" #O# Esecutore ha creato SentenceEvent per pulizia ambiente di Lavoro"+"\n"); 1119 contAlphabet.setModel(null); 1120 contLanguage.setModel(null); 1121 contSintRules.setModel(null); 1122 contSemRules.setModel(null); 1123 contAssSem.setModel(null); 1124 contFileAssFile.setModel(null); 1125 contSemantic.setModel(null); 1127 semantic = false; 1128 } 1130 if (action.equals("endSemantic")){ 1131 ViewLog.writeInLog(" #O# Esecutore ha terminato esecuzione Semantica"+"\n"); 1132 enableExecEnd(); 1134 } 1135 1136 repaintAll(); 1137 } 1138 } 1139 1140 1142 1143 1146 private void openStateError(String state){ 1147 Cve.errLog.debug(""); 1148 JOptionPane.showMessageDialog(null,"Utente non abilitato allo stato: " + state,"ATTENZIONE",JOptionPane.WARNING_MESSAGE); 1149 } 1150 1151 1154 private void openConfigFrame(){ 1155 Cve.errLog.debug(""); 1156 if (configFrameIsOpen){ 1157 try{ 1158 configFrame.setSelected(true); 1159 } catch (Exception e){ 1160 Cve.errLog.error(e.toString());} 1161 }else{ 1162 1163 configFrame = new ConfigurationFrame("Configuration Panel","/resource/EditConfig.GIF"); 1165 configFrameIsOpen = true; 1166 1167 configFrame.setOAC(this); 1169 configFrame.init(); 1170 1171 JDesktopPane desktop; 1173 desktop =Cve.getDesktop(); 1174 desktop.add(configFrame); 1175 try{ 1176 configFrame.setSelected(true); 1177 } catch (Exception e){ 1178 Cve.errLog.debug(e.toString());} 1179 } 1180 } 1181 1182 1185 private void openMappingFrame(){ 1186 Cve.errLog.debug(""); 1187 if (getMappingFrameOpen()){ 1188 try{ 1189 mappingEventFrame.setSelected(true); 1190 } catch (Exception e){ 1191 Cve.errLog.error(e.toString()); 1192 } 1193 }else{ 1194 1195 mappingEventFrame = new interactionHandler.MappingEventActivity("Mapping Event-Activity","/resource/INTERACTION.GIF"); 1197 1198 mappingEventFrame.setOAC(this); 1200 mappingEventFrame.init(); 1201 1202 JDesktopPane desktop; 1204 desktop =Cve.getDesktop(); 1205 desktop.add(mappingEventFrame); 1206 1207 try{ 1208 mappingEventFrame.setSelected(true); 1209 } catch (Exception e){ 1210 Cve.errLog.error(e.toString()); 1211 } 1212 setMappingFrameOpen(true); 1213 1214 } 1215 } 1216 1217 1222 private void viewQuery(IResource item){ 1223 1224 Cve.errLog.debug(""); 1225 if (getQueryElementOpen()){ 1226 try{ 1227 queryFrame.setSelected(true); 1228 } catch (Exception e){ 1229 Cve.errLog.error(e.toString()); 1230 } 1231 }else{ 1232 queryFrame = new QueryFrame("Query Item","/resource/QueryView.GIF"); 1234 setQueryElementOpen(true); 1235 1236 queryFrame.setOAC(this); 1238 queryFrame.init(item); 1239 1240 JDesktopPane desktop; 1242 desktop =Cve.getDesktop(); 1243 desktop.add(queryFrame); 1244 try{ 1245 queryFrame.setSelected(true); 1246 } catch (Exception e){ 1247 Cve.errLog.error(e.toString());} 1248 } 1249 } 1250 1251 1254 private void startExecution(){ 1255 1256 Cve.errLog.debug(""); 1257 enableExecStart(); 1258 1259 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1261 eseGS.startSent(); 1262 } 1263 1264 1267 private void stepExecution(){ 1268 Cve.errLog.debug(""); 1269 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1271 eseGS.stepSent(); 1272 } 1273 1274 1277 private void stopExecution(){ 1278 1279 Cve.errLog.debug(""); 1280 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1282 eseGS.stopSent(); 1283 } 1284 1285 1286 1289 private void clearSentence() { 1290 Cve.errLog.debug(""); 1291 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1292 eseGS.clearSentence(); 1294 } 1295 1296 1299 private void saveSentence() { 1300 Cve.errLog.debug(""); 1301 eseGS=(IEsecutionSentenceSemantic)getEsecutore(); 1302 eseGS.saveSentence(); 1304 } 1305 1306 1309 private void repaint(){ 1310 Cve.errLog.debug(""); 1311 canvas.repaint(); 1312 } 1313 1314 1318 private void setButtonAlf(String pathIcon,String id,String tip){ 1319 Cve.errLog.debug(""); 1320 ImageIcon icon=new ImageIcon(pathIcon); 1321 AlfButton but=new AlfButton (med,icon,id,tip); 1322 buttonAlf.put(id,but); 1324 tbar.addCve(but); 1325 } 1326 1327 1331 private void impostaComandi(){ 1332 Cve.errLog.debug(""); 1333 getAssociation.setEnabled(true); 1334 cancAssociation.setEnabled(false); 1335 getSentence.setEnabled(true); 1336 cancSentence.setEnabled(false); 1337 saveSentence.setEnabled(false); 1338 openConfiguration.setEnabled(true); 1339 startSent.setEnabled(false); 1340 stepSent.setEnabled(false); 1341 stopSent.setEnabled(false); 1342 } 1343 1344 1345 1351 private void setAlfabet(Collection rappre) { 1352 Cve.errLog.debug(""); 1353 removeElementTool(); 1355 if (rappre!=null){ 1356 String path=ConfigurationRead.getCveRoot()+"//"; 1357 System.out.println("PATH = " + path); 1358 Iterator itRappre=rappre.iterator(); 1359 while (itRappre.hasNext()) { 1360 1361 Representation istRap=(Representation)itRappre.next(); 1363 1364 System.out.println(" ####O SetAlphabetRepresentation icona= " + path+istRap.getAttribute("icon") + " name: " + istRap.getAttribute("name")); 1365 setButtonAlf(path+istRap.getAttribute("icon"),istRap.getAttribute("name"),istRap.getAttribute("name")); 1366 } 1367 } 1368 repaintAll(); 1369 } 1370 1371 1375 private void removeElementTool(){ 1376 Cve.errLog.debug(""); 1377 tbar.removeAll(); 1378 tbar.repaint(); 1379 } 1380 1381} | Popular Tags |