Newer
Older
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
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.fr
*
* This software is a computer program whose purpose is to allow the
* edition of TURTLE analysis, design and deployment diagrams, to
* allow the generation of RT-LOTOS or Java code from this diagram,
* and at last to allow the analysis of formal validation traces
* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
* from INRIA Rhone-Alpes.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
import translator.*;
import ui.procsd.*;
import ui.prosmd.*;
import ui.prosmd.util.CorrespondanceSMDManager;
/**
* Class GProactiveDesign
* Translation of graphical proactive designs into TURTLE modeling
* Creation: 10/07/2006
* @version 1.0 10/07/2006
* @author Ludovic APVRILLE
*/
public class GProactiveDesign {
private TURTLEModeling tm;
private ProactiveDesignPanel pdp;
private List<ProCSDPort> portsList=new LinkedList<ProCSDPort>(); //list of ProCSDPort
private List<TGConnectorProCSD> connectorsList =new LinkedList<TGConnectorProCSD>(); //list of TGConnectorProCSD
private List<TGConnectorPortInterface> connectorsPortInterfacesList=new LinkedList<TGConnectorPortInterface>();
private List<ProCSDInterface> interfacesList =new LinkedList<ProCSDInterface>(); //list of ProCSDInterface
private List<ProCSDComponent> proCSDComponentsList=new LinkedList<ProCSDComponent>();
private List<CheckingError> checkingErrors=new LinkedList<CheckingError> ();
// private CorrespondanceTGElement listE;
private CorrespondanceSMDManager corespManager;
private boolean buildErrors;
//Added by Solange ...and removed by Emil ..
// private ProCSDPort puerto, puerto2;
private Component mainModelComp;
public GProactiveDesign(ProactiveDesignPanel _pdp) {
pdp = _pdp;
init();
//System.out.println(mainModelComp.prettyPrint());
}
private void init()
Florian Lugou
committed
{ checkingErrors = new LinkedList<CheckingError> ();
// listE = new CorrespondanceTGElement();
portsList=new LinkedList<ProCSDPort>(); //list of ProCSDPort
connectorsList =new LinkedList<TGConnectorProCSD>(); //list of TGConnectorProCSD
interfacesList =new LinkedList<ProCSDInterface>(); //list of ProCSDInterface
proCSDComponentsList=new LinkedList<ProCSDComponent>();
ProactiveCSDPanel csd = (ProactiveCSDPanel)(pdp.panels.elementAt(0));
List<TGComponent> list = csd.getComponentList();
boolean cyclefound=false;
for (int i=0;i<list.size();i++)
{
TGComponent tmp= list.get(i);
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
// listElement(tmp);
if (!parseStructureAndFillUpLists(tmp)) cyclefound=true;
}
if (cyclefound)
addCheckingError(new CheckingError(CheckingError.STRUCTURE_ERROR,"Cycle found in component diagrams structure."));
updatePortsInformation();
// updateAllMembranes();
}
public void updateAllMembranes()
{
this.pdp.updateAllMembranes();
}
private Component createModelComp(ProCSDComponent comp)
{
String modelCompName=comp.getValue();
if (comp.getThisCompDesign()!=null)
{comp=comp.getThisCompDesign();
// modelCompName+="_"+comp.getValue();
}
Component modelComp=new ComponentImpl(modelCompName,isPrimitive(comp));
//we add attributes
List<TAttribute> attribs=comp.getMyAttributes();
for (int at=0;at<attribs.size();at++)
{
TAttribute a= attribs.get(at);
Attribute attrib=new fr.inria.oasis.vercors.cttool.model.AttributeImpl(a.getId(),a.getType(),a.getAccess(),a.getInitialValue());
modelComp.addAttribute(attrib);
}
//we add ports
//we do not set the ports bindings at this time as all ports in the model
//are not already
//created
Vector<ProCSDPort> portsList=comp.getPortsList();
for (int k=0;k<portsList.size();k++)
{
ProCSDPort p = portsList.get(k);
Port modelPort=null;
if (p instanceof ProCSDInPort)
{
modelPort=new InPort(p.getValue(),modelComp);
}
if (p instanceof ProCSDOutPort)
{
modelPort=new OutPort(p.getValue(),modelComp);
}
if (p.getMyInterface()!=null)
{
ProCSDInterface proI=p.getMyInterface();
Interface modelI=new InterfaceImpl(proI.getValue(),proI.isMandatory());
List<TAttribute> proMsgs=proI.getMyMessages();
for(int i=0; i<proMsgs.size(); i++)
{
TAttribute a = proMsgs.get(i);
Message m=new MessageImpl(a.getId());
modelI.addMessage(m);
}
modelPort.setInterface(modelI);
}
modelComp.addPort(modelPort);
}
//we add the behaviour Panel
modelComp.setBehaviour(comp.getMySMD());
Vector<ProCSDComponent> subComps=comp.getComponentList();
for (int k=0;k<subComps.size();k++)
{
ProCSDComponent subComp= subComps.get(k);
Component sc=createModelComp(subComp);
modelComp.addSubComponent(sc);
sc.setFather(modelComp);
}
return modelComp;
}
private Component initModel(ProactiveCSDPanel mainCsd) throws Exception
{
Component mainAppComp=new ComponentImpl("Application");
List<TGComponent> comps = mainCsd.getComponentList();
for (int k=0;k<comps.size();k++)
{
TGComponent t= comps.get(k);
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
if (t instanceof ProCSDComponent)
{
ProCSDComponent comp=(ProCSDComponent)t;
Component modelComp=createModelComp(comp);
mainAppComp.addSubComponent(modelComp);
modelComp.setFather(mainAppComp);
}
}
mainAppComp=updatePortsBindingInModel(mainAppComp,mainCsd);
return mainAppComp;
}
/*
* if the father of this port is designed in other diagram,
* it returns the port in that diagram corresponding to this port
* if not it return this port
*/
private ProCSDPort getRealPort(ProCSDPort p)
{
if (p==null) return null;
ProCSDComponent father=(ProCSDComponent)p.getFather();
ProCSDComponent fatherDesign=father.getThisCompDesign();
if (fatherDesign!=null)
{
return fatherDesign.getPortByName(p.getValue());
}
else
return p;
}
private void updatePortsBindingInModel(Component modelComp, ProCSDComponent proComp) throws Exception
{
//we consider pairs of (model Out Port, ProCSDOutPort)
Vector<ProCSDPort> ports=proComp.getPortsList();
for (int k=0;k<ports.size();k++)
{
ProCSDPort p= ports.get(k);
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
if (p instanceof ProCSDOutPort)
{
ProCSDOutPort proPort=(ProCSDOutPort)p;
Port modelPort=modelComp.getPortByName(proPort.getValue());
ProCSDPort proToPort=getRealPort(proPort.getToPort());
if (proToPort!=null)
{
Port modelToPort=null;
ProCSDComponent proToPortFather =(ProCSDComponent)proToPort.getFather();
Component modelToPortFather=null;
if (proToPortFather==proComp.getFather())
{
modelToPortFather=modelComp.getFather();
}
else
{
String modelToPortFatherName=proPort.getToPort().getFather().getValue();
// if (proToPortFather.getThisCompDesign()!=null)
// modelToPortFatherName+="_"+proToPortFather.getThisCompDesign().getValue();
modelToPortFather=modelComp.getFather().getSubComponentByName(modelToPortFatherName);
}
modelToPort=modelToPortFather.getPortByName(proToPort.getValue());
modelPort.setToPort(modelToPort);
modelToPort.setFromPort(modelPort);
}//if proToPort!=null
ProCSDPort proFromPort=getRealPort(proPort.getFromPort());
if (proFromPort!=null)
{
Port modelFromPort=null;
//ProCSDComponent proFromPortFather =(ProCSDComponent)proFromPort.getFather();
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
String modelFromPortFatherName=proPort.getFromPort().getFather().getValue();
if (proFromPort!=proPort.getFromPort())
{
modelFromPortFatherName=proPort.getFromPort().getFather().getValue();
}
//if (proFromPortFather.getThisCompDesign()!=null)
// modelFromPortFatherName+="_"+proFromPortFather.getThisCompDesign().getValue();
Component modelFromPortFather=modelComp.getSubComponentByName(modelFromPortFatherName);
modelFromPort=modelFromPortFather.getPortByName(proFromPort.getValue());
modelPort.setFromPort(modelFromPort);
modelFromPort.setToPort(modelPort);
}//if proFromPort!=null
}//if p is ProCSDOutPort
else
if (p instanceof ProCSDInPort)
{
ProCSDInPort proPort=(ProCSDInPort)p;
Port modelPort=modelComp.getPortByName(proPort.getValue());
ProCSDPort proFromPort=getRealPort(proPort.getFromPort());
if (proFromPort!=null)
{
if (proFromPort instanceof ProCSDInPort)
{
Port modelFromPort=null;
ProCSDComponent proFromPortFather=(ProCSDComponent)proFromPort.getFather();
Component modelFromPortFather=null;
if (proFromPortFather==proComp.getFather())
{
modelFromPortFather=modelComp.getFather();
}
else
{
String modelFromPortFatherName=proPort.getFromPort().getFather().getValue();
if (proFromPortFather.getThisCompDesign()!=null)
modelFromPortFatherName=proFromPortFather.getThisCompDesign().getValue();
modelFromPortFather=modelComp.getFather().getSubComponentByName(modelFromPortFatherName);
}
modelFromPort=modelFromPortFather.getPortByName(proFromPort.getValue());
modelPort.setFromPort(modelFromPort);
modelFromPort.setToPort(modelPort);
}//if fromport=ProCSDInPort
}//if proFromPort!=null
}//if p instanceof ProCSDInport
}//for all ports
if (proComp.getThisCompDesign()!=null)
proComp=proComp.getThisCompDesign();
Vector<ProCSDComponent> v = proComp.getComponentList();
for (int k=0;k<v.size();k++)
{
ProCSDComponent proSubComp= v.get(k);
String proSubCompName=proSubComp.getValue();
//if (proSubComp.getThisCompDesign()!=null)
//proSubCompName+="_"+proSubComp.getThisCompDesign().getValue();
Component modelSubComp=modelComp.getSubComponentByName(proSubCompName);
updatePortsBindingInModel(modelSubComp,proSubComp);
}
}//method update ports bindings in model
private Component updatePortsBindingInModel(Component mainComp, ProactiveCSDPanel mainCsd ) throws Exception
{
//we consider pairs of components (Component c, ProCSDComponent pc) and update potrs bindings in
List<TGComponent> comps = mainCsd.getComponentList();
for (int k=0;k<comps.size();k++)
{
TGComponent t= comps.get(k);
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
if (t instanceof ProCSDComponent)
{
ProCSDComponent proComp=(ProCSDComponent)t;
String proCompName=proComp.getValue();
//if (proComp.getThisCompDesign()!=null)
// proCompName+="_"+proComp.getThisCompDesign().getValue();
Component modelComp=mainComp.getSubComponentByName(proCompName);
if (modelComp==null) {System.out.println("This is a fatal problem.");
addCheckingError(new CheckingError(CheckingError.STRUCTURE_ERROR,"Fatal error in the model translator. Please excuse us for this problem. "));
}
updatePortsBindingInModel(modelComp,proComp);
}
}
return mainComp;
}
public TURTLEModeling generateTURTLEModeling() {
tm = new TURTLEModeling();
init();
if (checkingErrors.size()==0)
try{
mainModelComp=initModel((ProactiveCSDPanel)(pdp.panels.elementAt(0)));
}
catch (Exception e)
{
System.out.println("This is probably just litle nice bug: Could not initializate model. Exception is: \n");
e.printStackTrace();
}
if (checkingErrors.size()!=0) return null;
addTClasses(tm,mainModelComp);
if (checkingErrors.size()==0) addSynchronisations(tm,mainModelComp);
return tm;
}
public boolean checkSyntax() {
return checkingErrors.size() <= 0;
}
/*
* for each port :
* update the interface wich contains methods who pass through this port
* "push" the connection into the inside ports in order to have
* the connections between the primitives
*
*/
private void updatePortsInformation()
{
for (int k=0;k<connectorsList.size();k++)
{
TGConnectorProCSD c= connectorsList.get(k);
c.doPostLoading();
}
for (int k=0;k<connectorsPortInterfacesList.size();k++)
{
TGConnectorPortInterface c= connectorsPortInterfacesList.get(k);
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
c.doPostLoading();
}
//ok
//we need to update the toPort and fromPort for the ports
//of the components who are designed in a diffrent diagram:
/* for (int k=0;k<portsList.size();k++)
{
ProCSDPort p=(ProCSDPort)portsList.get(k);
ProCSDComponent portFather=(ProCSDComponent)p.getFather();
ProCSDPort pOkBindings=portFather.getThisCompDesign().getPort(p.getValue());
if(pOkBindings!=null)
{
p.setToPort(pOkBindings.getToPort());
p.setFromPort(pOkBindings.getFromPort());
}
}
*/
//all this code is just used for compatibility with old CTTool versions.
//normaly we shouldn't do this
//at least I think...
//needs to be verified
//and verry well improved before
//all this very-badly-designed-software will be well packed
//and nicelly put into a trash bin
//Added by Solange
int isCompatible; //0: OK
//1: Port error
//2: compatibility error
ProCSDInterface myInterface=null;
TGConnectorAttribute myInterfaceConnector;
//first we consider all out ports
for (int i=0;i<portsList.size();i++)
{
ProCSDPort op= portsList.get(i);
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
if (op.getType()==TGComponentManager.PROCSD_OUT_PORT)
{
try {
myInterface=op.getMyInterface(interfacesList);
//Added by Solange
op.setMyInterface(myInterface);
// Added by Solange
myInterfaceConnector=op.getTGConnectorInterface();
// Added by Solange
myInterface.setMyConnector(myInterfaceConnector);
}
catch (Exception e)
{
if (op.getFather()==null)
{
this.addCheckingError(new CheckingError(CheckingError.STRUCTURE_ERROR,"Port "+op.getValue()+" doesn't belong to a component"));
return;
}
if (((ProCSDComponent)op.getFather()).getThisCompDesign()==null)
{this.addCheckingError(new CheckingError(CheckingError.STRUCTURE_ERROR,"No interface found corresponding to port "+op.getValue()));
return;
}
}
ProCSDPort toP=op.getToPort();
// if (toP==null) toP=getConnectedProCSDPort(op);
//if(toP==null) toP=getDelegateConnectorProCSDPort(op);
//Commented because is not always an error to be free, by Solange
/* if (toP==null)
{
addCheckingError(CheckingError.STRUCTURE_ERROR,"Error: out connection not found for "+op.toString()+" in component "+op.getFather().getValue());
//System.out.println("Error: no connection found for "+op.toString());
return;
}*/
if (toP!=null)
{
op.setToPort(toP);
toP.setFromPort(op);
}
//Added by Solange
if (myInterface!=null)
{
isCompatible=op.Compatibility(op,myInterface,interfacesList);
//Added by Solange
switch(isCompatible)
{
case 0:// System.out.println("Compatibility test Out port... OK");
break;
case 1: this.addCheckingError(new CheckingError(CheckingError.STRUCTURE_ERROR,"Port "+ op.toString() + " not connected"));
break;
case 2: this.addCheckingError(new CheckingError(CheckingError.STRUCTURE_ERROR,"No Interface Compatibility"));
break;
}
}
/* Delegate ports removed, by Solange
ProCSDPort dp = getConnectedDelegatePort(op);
if (dp!=null)
{ dp.setMyInterface(myInterface);
dp.setToPort(toP);
toP.setFromPort(dp);
ProCSDPort ddp=getFromInsideConnectedPort(dp);
while (ddp!=null)
{ ddp.setMyInterface(myInterface);
ddp.setToPort(toP);
toP.setFromPort(ddp);
ddp=getFromInsideConnectedPort(ddp);
}//while ddp!=null
}//if dp!=null
*/
}//if this port is an out port
}//for all ports (out)
//now we consider all in ports
for (int i=0;i<portsList.size();i++)
{
ProCSDPort ip= portsList.get(i);
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
if (ip.getType()==TGComponentManager.PROCSD_IN_PORT)
{ myInterface=ip.getMyInterface(interfacesList);
if (myInterface!=null)
{
//Added by Solange
ip.setMyInterface(myInterface);
// Added by Solange
myInterfaceConnector=ip.getTGConnectorInterface();
// Added by Solange
myInterface.setMyConnector(myInterfaceConnector);
//
}
ProCSDPort fromPort=ip.getFromPort();
//Added by Solange
// if(fromPort==null) fromPort=getDelegateConnectorProCSDPort(ip);
if (fromPort!=null)
{
ip.setFromPort(fromPort);
fromPort.setToPort(ip);
}
//Commented because is not always an error to be free, by Solange
/*if (fromPort==null)
{
addCheckingError(CheckingError.STRUCTURE_ERROR,"Error: in connection not found for "+ip.toString()+" in component "+ip.getFather().getValue());
return;
}*/
//Added by Solange
isCompatible=ip.Compatibility(ip, myInterface, interfacesList);
//Added by Solange
switch(isCompatible)
{
case 0: //System.out.println("Compatibility test In port... OK");
break;
case 1: this.addCheckingError(new CheckingError(CheckingError.STRUCTURE_ERROR,"Port "+ ip.toString() + " not connected"));
break;
case 2: this.addCheckingError(new CheckingError(CheckingError.STRUCTURE_ERROR,"No Interface Compatibility"));
break;
}
/* Delegate ports removed, by Solange
ProCSDPort dp=getConnectedDelegatePort(ip);
if (dp!=null)
{ dp.setMyInterface(myInterface);
dp.setFromPort(fromPort);
fromPort.setToPort(dp);
ProCSDPort ddp=getToInsideConnectedPort(dp);
while (ddp!=null)
{ ddp.setMyInterface(myInterface);
ddp.setFromPort(fromPort);
fromPort.setToPort(ddp);
ddp=getToInsideConnectedPort(ddp);
}//while ddp!=null
}//dp!=null
*/
}// ip is an input port
} // for all ports in
}
private boolean isPrimitive(ProCSDComponent comp)
{
List<TGComponent> l=getSubComponents(comp,TGComponentManager.PROCSD_COMPONENT);
return l.size() == 0;
}
/*
* get subcomponents of type given as parameter
* @param type The type id from TGComponentManager
* @param tgc A component
* @return selectedSubComps A LinkedList of subcomponents of the type
*/
private List<TGComponent> getSubComponents(TGComponent tgc, int type)
{
if (!(tgc.getType()==TGComponentManager.PROCSD_COMPONENT)) return null;
List<TGComponent> subcompList=getSubComponents(tgc);
List<TGComponent> selectedSubComps=new LinkedList<TGComponent>();
for (int i=0;i<subcompList.size();i++)
{
TGComponent tmp=subcompList.get(i);
if (tmp.getType()==type)
selectedSubComps.add(tmp);
}
return selectedSubComps;
}
/*
* get subcomponents of all types
* @param tgc A component
* @return subcompList A LinkedList of subcomponents
*/
private List<TGComponent> getSubComponents(TGComponent tgc)
List<TGComponent> subcompList=new LinkedList<TGComponent>();
int nb=tgc.getNbInternalTGComponent();
for (int j=0;j<nb;j++)
{
TGComponent tmp=tgc.getInternalTGComponent(j);
subcompList.add(tmp);
}
return subcompList;
}
/*
* returns all ports of this component
* @param tgc A component
* @return portsList A LinkedList with ports of the component
*/
// private List<ProCSDPort> getPorts(TGComponent tgc)
// {
// if (!(tgc.getType()==TGComponentManager.PROCSD_COMPONENT)) return null;
// List<TGComponent> subcompList=getSubComponents(tgc);
// List<ProCSDPort> portsList=new LinkedList<ProCSDPort>();
// for (int i=0;i<subcompList.size();i++)
// {
// TGComponent tmp=subcompList.get(i);
// //Remove option delegate ports, by Solange
// if ((tmp.getType()==TGComponentManager.PROCSD_IN_PORT) || (tmp.getType()==TGComponentManager.PROCSD_OUT_PORT))// || ( tmp.getType()==TGComponentManager.PROCSD_DELEGATE_PORT))
// portsList.add( (ProCSDPort) tmp);
// }
// return portsList;
// }
/*
* gets the port connected to the port in parameter via a TGConnector ProCSD if there is one, null if not
* @param port A port
* @return p1 (or p2) The connected port, or null if not connected
*/
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
// private ProCSDPort getConnectedProCSDPort(ProCSDPort port)
// {
// //Remove option delegate ports, by Solange
// //if (port.getType()==TGComponentManager.PROCSD_DELEGATE_PORT) return null;
//
// //System.out.println("cherche un port pour le port " +port.getValue()); comented by Emil
//
// TGConnectorProCSD myConnector=port.getTGConnector();
//
// if (myConnector==null)
// {
// //Commented because is not always an error to be free, by Solange
// //addCheckingError(CheckingError.STRUCTURE_ERROR,"We didn't find any connector for the port " +port.getValue());
// return null;
// }
//
// // System.out.println("...... (ProCSDPort).. my connector is "+myConnector.toString());
//
// //ProCSDPort p1=myConnector.getMyPort1(portsList);
// ProCSDPort p1=myConnector.getMyPort1();
//
// /* if (p1!=null) System.out.println(p1.toString());
// else
// System.out.println("NULL!!!!!!!!!");
// */
//
// //System.out.println("......... my connector's Port1 is "+p1.toString());
//
// if ((p1!=null) && (!p1.equals(port))) return p1;
//
// ProCSDPort p2=myConnector.getMyPort2();
//
// if ((p2!=null) && (!p2.equals(port))) return p2;
//
// return null;
// }
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
//Added by Solange for the subcomponents
/*
* Method to find the port connected to a port when there are subcomponents involved
* @param port The port to be analyzed
* @return p1 (or p2) The port connected or null if not connected
*/
/*
public ProCSDPort getDelegateConnectorProCSDPort(ProCSDPort port)
{
TGConnectorDelegateProCSD myDelegateConnector=port.getTGConnectorDelegateIn();
if (myDelegateConnector==null)
myDelegateConnector=port.getTGConnectorDelegateOut();
if (myDelegateConnector==null)
{
// System.out.println("We didn't find any delegate connector for the port " +port.getValue());
return null;
}
ProCSDPort p1=myDelegateConnector.getMyPort1(portsList);
if ((p1!=null) && (!p1.equals(port))) return p1;
ProCSDPort p2=myDelegateConnector.getMyPort2(portsList);
if ((p2!=null) && (!p2.equals(port))) return p2;
return null;
}
*/
/*
* gets the delegate port connected to the port in parameter via a TGConnectorDelegateProCSD if there is one, null if not
* returns null for delegate ports
*
*/
//Delegate ports removes. Method is no t needed. By Solange
/*
private ProCSDPort getConnectedDelegatePort(ProCSDPort port)
{
if (port.getType()==TGComponentManager.PROCSD_DELEGATE_PORT) return null;
//System.out.println("cherche un port pour le port " +port.getValue());
TGConnectorDelegateProCSD myDelegateConnector=port.getTGConnectorDelegateIn();
if (myDelegateConnector==null)
myDelegateConnector=port.getTGConnectorDelegateOut();
if (myDelegateConnector==null)
{
//System.out.println("We didn't find any connector for the port " +port.getValue());
return null;
}
// System.out.println("...... (ProCSDPort).. my connector is "+myConnector.toString());
ProCSDPort p1=myDelegateConnector.getMyPort1(portsList);
//if (p1!=null) System.out.println(p1.toString());
//else
// System.out.println("NULL!!!!!!!!!");
//System.out.println("......... my connector's Port1 is "+p1.toString());
if ((p1!=null) && (!p1.equals(port))) return p1;
ProCSDPort p2=myDelegateConnector.getMyPort2(portsList);
if ((p2!=null) && (!p2.equals(port))) return p2;
return null;
}
*/
/* private ProCSDPort getToOutsideConnectedPort(ProCSDPort dp)
{
TGComponent father=dp.getFather().getFather();
if (father==null)
{
addCheckingError(CheckingError.STRUCTURE_ERROR,"Error: forbiden delegate port at this level "+dp.getValue());
return null;
}
LinkedList fatherPorts=getPorts(father);
TGConnectorDelegateProCSD myDelegateConnectorOut=dp.getTGConnectorDelegateOut();
if (myDelegateConnectorOut==null) return null;
ProCSDPort p2=myDelegateConnectorOut.getMyPort2(fatherPorts);
if ((p2!=null) && (!p2.equals(dp))) return p2;
return null;
}
*/
/*
private ProCSDPort getFromOutsideConnectedPort(ProCSDPort dp)
{
TGComponent father=dp.getFather().getFather();
if (father==null)
{
addCheckingError(CheckingError.STRUCTURE_ERROR,"Error: forbiden delegate port at this level "+dp.getValue());
return null;
}
LinkedList fatherPorts=getPorts(father);
TGConnectorDelegateProCSD myDelegateConnectorIn=dp.getTGConnectorDelegateIn();
if (myDelegateConnectorIn==null) return null;
ProCSDPort p2=myDelegateConnectorIn.getMyPort1(fatherPorts);
if ((p2!=null) && (!p2.equals(dp))) return p2;
return null;
}
*/
// private ProCSDPort getToInsideConnectedPort(ProCSDPort dp)
// {
// //we're looking for a port who's not a father port
// TGComponent father=dp.getFather().getFather();
// if (father==null)
// {
// addCheckingError(CheckingError.STRUCTURE_ERROR,"Error: forbiden delegate port at this level "+dp.getValue());
// return null;
// }
// LinkedList fatherPorts=getPorts(father);
//
// TGConnectorDelegateProCSD myDelegateConnectorOut=dp.getTGConnectorDelegateOut();
// if (myDelegateConnectorOut==null) return null;
// ProCSDPort p2=myDelegateConnectorOut.getMyPort2(portsList);
//
// if ((p2!=null) && (!p2.equals(dp)) && !fatherPorts.contains(p2)) return p2;
//
// return null;
//
//
//
// }
// private ProCSDPort getFromInsideConnectedPort(ProCSDPort dp)
// {
//
//// we're looking for a port who's not a father's port
// TGComponent father=dp.getFather().getFather();
// if (father==null)
// {
// addCheckingError(CheckingError.STRUCTURE_ERROR,"Error: forbiden delegate port at this level "+dp.getValue());
//
// return null;
// }
// LinkedList fatherPorts=getPorts(father);
//
// TGConnectorDelegateProCSD myDelegateConnectorIn=dp.getTGConnectorDelegateIn();
// if (myDelegateConnectorIn==null) return null;
// ProCSDPort p1=myDelegateConnectorIn.getMyPort1(portsList);
//
// if ((p1!=null) && (!p1.equals(dp)) && !fatherPorts.contains(p1)) return p1;
//
// return null;
//
// }
/*
* we are dealing with a comp specification within a
* ProActiveCompSpecificationCSDPanel
*
*/
private boolean parseStructureAndFillUpListsForCompDefinition(TGComponent t)
{
if (t.getType()==TGComponentManager.PROCSD_INTERFACE)
{
interfacesList.add( (ProCSDInterface) t);
}
if (t.getType()==TGComponentManager.CONNECTOR_PROCSD)
{
connectorsList.add( (TGConnectorProCSD) t);
}
if (t.getType()==TGComponentManager.CONNECTOR_PROCSD_PORT_INTERFACE)
{
connectorsPortInterfacesList.add( (TGConnectorPortInterface) t);
}
/*
//Delegate ports removed, by Solange
if ( (t.getType()==TGComponentManager.PROCSD_IN_PORT) || (t.getType()==TGComponentManager.PROCSD_OUT_PORT))// || (t.getType()==TGComponentManager.PROCSD_DELEGATE_PORT))
portsList.add(t);
*/
if ((t.getType()==TGComponentManager.PROCSD_COMPONENT) )
// if (ProCSDComponentsList.contains(t))
// return false;
// else
{
proCSDComponentsList.add( (ProCSDComponent) t);
int nb=t.getNbInternalTGComponent();
for (int j=0;j<nb;j++)
{
TGComponent tgc=t.getInternalTGComponent(j);
if (!parseStructureAndFillUpListsForCompDefinition(tgc)) return false;
}
if (((ProCSDComponent)t).getMyDesignPanel()!=null)
{
ProActiveCompSpecificationCSDPanel specPanel=((ProCSDComponent)t).getMyDesignPanel();
for (int q=0;q<specPanel.componentList.size();q++)
{
TGComponent component= specPanel.componentList.get(q);
if (!parseStructureAndFillUpListsForCompDefinition(component)) return false;
}
}
}
return true;
}
/*
* Add a component to the corresponding list according to his type (interface, connector, port, component)
* @param t The component
*/
private boolean parseStructureAndFillUpLists(TGComponent t)
{
if (t.getType()==TGComponentManager.PROCSD_INTERFACE)
{
interfacesList.add((ProCSDInterface) t);
}
if (t.getType()==TGComponentManager.CONNECTOR_PROCSD)
{
connectorsList.add( (TGConnectorProCSD) t);
}
if (t.getType()==TGComponentManager.CONNECTOR_PROCSD_PORT_INTERFACE)
{
connectorsPortInterfacesList.add( (TGConnectorPortInterface) t );
}
//Delegate ports removed, by Solange
if ( (t.getType()==TGComponentManager.PROCSD_IN_PORT) || (t.getType()==TGComponentManager.PROCSD_OUT_PORT))// || (t.getType()==TGComponentManager.PROCSD_DELEGATE_PORT))
portsList.add( (ProCSDPort) t);
if ((t.getType()==TGComponentManager.PROCSD_COMPONENT) )
{
// if (ProCSDComponentsList.contains(t))