1 package cve.osservatori; 2 3 import cve.esecutori.*; 4 import cve.core.elementEEL.*; 5 import interactionHandler.*; 6 import interactionGraphics.*; 7 8 import cve.esecutori.servizioEACBuild.*; 9 import cve.staticLayout.*; 10 import cve.util.ConfigurationRead; 11 12 import org.apache.log4j.Logger; 13 14 import java.awt.*; 15 import java.awt.event.*; 16 17 import javax.swing.*; 18 import javax.swing.tree.*; 19 20 21 import java.io.*; 22 import java.util.*; 23 24 import org.jdom.*; 25 26 36 public class OACBuild extends Osservatore{ 37 38 41 private ControllerTree treeContr; 42 private TreeCve contAlf; 44 private TreeCve contSent; 45 private TreeCve contAut; 46 private TreeCve contRules; 47 48 51 private SpecificationLanguage eseS; 52 private String fileReg,fileAlf; 54 private boolean alfabeto=false; 56 private boolean regole=false; 57 58 59 60 63 public Action getAlfabeto = new AbstractAction("") { 64 public void actionPerformed(ActionEvent e) { 65 Cve.errLog.debug(""); 66 ViewLog.writeInLog(" #O# Eseguita attivita' (action) getAlfabeto"+"\n"); 67 File currentAlf=new File(ConfigurationRead.getCveRoot()+ConfigurationRead.getCveVCARWRoot()); 68 fileAlf=Osservatore.getFileXml(currentAlf); 69 70 if (fileAlf.equals("")==false ){ 71 72 setAlphabet(fileAlf); 74 75 cancAlfabeto.setEnabled(true); 77 getAlfabeto.setEnabled(true); 78 getAlfabeto.setEnabled(false); 79 alfabeto=true; 80 getAlfabeto.setEnabled(false); 81 if ((regole)&&(alfabeto)) creaLing.setEnabled(true); 82 83 repaintAll(); 84 contAlf.repaint(); 85 } 86 } 87 88 }; 89 90 93 public Action cancAlfabeto = new AbstractAction("") { 94 public void actionPerformed(ActionEvent e) { 95 Cve.errLog.debug(""); 96 ViewLog.writeInLog(" #O# Eseguita attivita' (action) delAlfabeto"+"\n"); 97 delAlphabet(); 98 getAlfabeto.setEnabled(true); 99 cancAlfabeto.setEnabled(false); 100 alfabeto=false; 101 } 102 }; 103 104 107 public Action getRegole = new AbstractAction("") { 108 public void actionPerformed(ActionEvent e) { 109 Cve.errLog.debug(""); 110 ViewLog.writeInLog(" #O# Eseguita attivita' (action) getRegole"+"\n"); 111 File currentReg=new File(ConfigurationRead.getCveRoot()+ConfigurationRead.getCveVCARWRoot()); 112 fileReg=Osservatore.getFileXml(currentReg); 113 114 if (fileReg.equals("")==false ){ 115 setRules(fileReg); 116 getRegole.setEnabled(false); 118 cancRegole.setEnabled(true); 119 regole=true; 120 if ((regole)&&(alfabeto)) creaLing.setEnabled(true); 121 122 repaintAll(); 123 } 124 } 125 }; 126 127 130 public Action cancRegole = new AbstractAction("") { 131 public void actionPerformed(ActionEvent e) { 132 Cve.errLog.debug(""); 133 ViewLog.writeInLog(" #O# Eseguita attivita' (action) canRegole"+"\n"); 134 delRules(); 135 getRegole.setEnabled(true); 136 cancRegole.setEnabled(false); 137 } 138 }; 139 140 143 public Action creaLing = new AbstractAction("") { 144 public void actionPerformed(ActionEvent e) { 145 Cve.errLog.debug(""); 146 ViewLog.writeInLog(" #O# Eseguita attivita' (action) creaLing"+"\n"); 147 makeLanguage(); 148 149 getAlfabeto.setEnabled(false); 151 cancAlfabeto.setEnabled(false); 152 creaLing.setEnabled(false); 153 getRegole.setEnabled(false); 154 cancRegole.setEnabled(false); 155 saveLing.setEnabled(true); 156 repaintAll(); 157 } 158 }; 159 160 163 public Action saveLing = new AbstractAction("") { 164 public void actionPerformed(ActionEvent e) { 165 Cve.errLog.debug(""); 166 ViewLog.writeInLog(" #O# fatta azione getAlfabeto"+"\n"); 167 } 168 }; 169 170 171 172 181 public OACBuild() { 182 Cve.errLog.debug(""); 183 cveCont.setLayout(new GridLayout(1,2)); 184 treeContr=new ControllerTree(); 186 contAlf=new TreeCve(treeContr); 188 contRules=new TreeCve(treeContr); 189 contSent=new TreeCve(treeContr); 190 contAut=new TreeCve(treeContr); 191 192 JTabbedPane input = new JTabbedPane( JTabbedPane.BOTTOM ); 194 input.setBackground(Color.white); 195 input.addTab( "Alphabet", new JScrollPane( contAlf ) ); 196 input.addTab( "Rules", new JScrollPane( contRules ) ); 197 198 JTabbedPane output = new JTabbedPane( JTabbedPane.BOTTOM ); 200 output.setBackground(Color.white); 201 output.addTab( "Control Automata", new JScrollPane( contAut ) ); 202 output.addTab( "Sentence Rules", new JScrollPane( contSent ) ); 203 204 JSplitPane splitPane = new JSplitPane(); 206 splitPane.setTopComponent( input ); 207 splitPane.setBottomComponent( output ); 208 splitPane.setResizeWeight( 0.5 ); 209 splitPane.setDividerLocation( 380 ); 210 splitPane.setOneTouchExpandable( true ); 211 212 cveCont.add(splitPane, "Center" ); 214 215 impostaComandi(); 217 } 218 219 224 public void setAlphabet(String fileScelto){ 225 Cve.errLog.debug(""); 226 eseS=(SpecificationLanguage)getEsecutore(); 227 eseS.setAlphabet(fileScelto); 228 } 229 230 231 236 public void delAlphabet(){ 237 Cve.errLog.debug(""); 238 eseS=(SpecificationLanguage)getEsecutore(); 239 eseS.delAlphabet(); 240 } 241 242 243 248 public void setRules(String fileScelto){ 249 Cve.errLog.debug(""); 250 eseS=(SpecificationLanguage)getEsecutore(); 251 eseS.setRules(fileScelto); 252 } 253 254 255 258 public void delRules(){ 259 Cve.errLog.debug(""); 260 eseS=(SpecificationLanguage)getEsecutore(); 261 eseS.delRules(); 262 } 263 264 265 269 public void setContAlf(TreeCve contAlf){ 270 Cve.errLog.debug(""); 271 this.contAlf=contAlf; 272 } 273 274 278 public void makeLanguage(){ 279 Cve.errLog.debug(""); 280 File currentReg=new File(ConfigurationRead.getCveRoot()+"/VisualLanguage"); 281 eseS=(SpecificationLanguage)getEsecutore(); 282 eseS.makeLanguage(fileAlf,fileReg); 283 } 284 285 public void setComponents (Collection param){ 286 Cve.errLog.debug(""); 287 } 288 289 296 protected void react(Observable o, Object arg){ 297 Cve.errLog.debug(""); 298 if (arg instanceof SpecificationEvent ){ 299 SpecificationEvent speEv=(SpecificationEvent)arg; 300 String action=speEv.getActionUser(); 301 if (action.equals("setAlphabet")){ 302 eseS=(SpecificationLanguage)getEsecutore(); 303 ViewLog.writeInLog(" #O# Esecutore ha creato SpecificationEvent che contiene modello Alfabeto da visualizzare"+"\n"); 304 ViewLog.writeInLog(" #O# Sono in react osservatore (azione setAlfabeto)"+"\n"); 305 contAlf.setModel(speEv.getModelTree()); 306 } 307 if (action.equals("setRules")){ 308 eseS=(SpecificationLanguage)getEsecutore(); 309 ViewLog.writeInLog(" #O# Esecutore ha creato SpecificationEvent che contiene modello Regole da visualizzare"+"\n"); 310 ViewLog.writeInLog(" #O# Sono in react osservatore (azione setRegole)"+"\n"); 311 contRules.setModel(speEv.getModelTree()); 312 } 313 if (action.equals("setAutoma")){ 314 eseS=(SpecificationLanguage)getEsecutore(); 315 ViewLog.writeInLog(" #O# Esecutore ha creato SpecificationEvent che contiene modello Regole da visualizzare"+"\n"); 316 ViewLog.writeInLog(" #O# Sono in react osservatore (azione setRegole)"+"\n"); 317 contAut.setModel(speEv.getModelTree()); 318 } 319 if (action.equals("setSentenza")){ 320 eseS=(SpecificationLanguage)getEsecutore(); 321 ViewLog.writeInLog(" #O# Esecutore ha creato SpecificationEvent che contiene modello Regole da visualizzare"+"\n"); 322 ViewLog.writeInLog(" #O# Sono in react osservatore (azione setRegole)"+"\n"); 323 contSent.setModel(speEv.getModelTree()); 324 } 325 if (action.equals("delAlphabet")){ 326 eseS=(SpecificationLanguage)getEsecutore(); 327 ViewLog.writeInLog(" #O# Esecutore ha creato SpecificationEvent che contiene modello Alfabeto da visualizzare"+"\n"); 328 ViewLog.writeInLog(" #O# Sono in react osservatore (azione delAlfabeto)"+"\n"); 329 contAlf.setModel(null); 330 } 331 if (action.equals("delRules")){ 332 eseS=(SpecificationLanguage)getEsecutore(); 333 ViewLog.writeInLog(" #O# Esecutore ha creato SpecificationEvent che contiene modello Regole da visualizzare"+"\n"); 334 ViewLog.writeInLog(" #O# Sono in react osservatore (azione delRules)"+"\n"); 335 contRules.setModel(null); 336 } 337 repaintAll(); 338 ViewLog.writeInLog(" "+"\n"); 339 } 340 } 341 342 343 344 345 346 private void impostaComandi(){ 347 Cve.errLog.debug(""); 348 cancAlfabeto.setEnabled(false); 349 cancRegole.setEnabled(false); 350 creaLing.setEnabled(false); 351 saveLing.setEnabled(false); 352 } 353 354 } | Popular Tags |