View Javadoc

1   package org.telscenter.pas.otrunk.skeleton.controllers;
2   
3   import java.util.Iterator;
4   
5   import org.concord.framework.otrunk.DefaultOTController;
6   import org.concord.framework.otrunk.OTObjectList;
7   import org.concord.framework.otrunk.OTObjectService;
8   import org.concord.otrunk.view.OTFolderObject;
9   import org.telscenter.pas.beans.PasStep;
10  import org.telscenter.pas.hint.Hint;
11  import org.telscenter.pas.otrunk.skeleton.OTPasHint;
12  import org.telscenter.pas.otrunk.skeleton.OTPasStep;
13  import org.telscenter.pas.properties.HintSet;
14  
15  public class OTPasStepController extends DefaultOTController {
16  
17  	public void loadRealObject(Object realObject) {
18  		PasStep step = (PasStep) realObject;
19  		OTPasStep otStep = (OTPasStep) otObject;
20  
21  		// FIXME use beanutils property mapper for all this
22  
23  		
24  		// property:title
25  		step.setTitle(otStep.getTitle());
26  
27  		// property:authorNotes
28  		step.setAuthorNotes(otStep.getAuthorNotes());
29  
30  		// property:hoverString
31  		step.setHoverString(otStep.getHoverString());
32  		
33  		// property:hintList
34  		OTObjectList otHintList = otStep.getHintList();
35  		
36  		HintSet hintSet = new HintSet();
37  		
38  		for(int i=0; i<otHintList.size(); i++){
39  			OTPasHint otHint = (OTPasHint) otHintList.get(i);
40  			Hint newHint = new Hint();
41  			newHint.setText(otHint.getText());
42  			hintSet.add(newHint);
43  		}// for
44  		step.setHintSet(hintSet);
45  	}
46  
47  	public void registerRealObject(Object arg0) {
48  	}
49  
50  	public void saveRealObject(Object realObject) {
51  		PasStep pasStep = (PasStep) realObject;
52  		OTPasStep otPasStep = (OTPasStep) otObject;
53  		
54  		otPasStep.setTitle(pasStep.getTitle());
55  		otPasStep.setAuthorNotes(pasStep.getAuthorNotes());
56  		otPasStep.setHoverString(pasStep.getHoverString());
57  		
58  		HintSet hintSet = pasStep.getHintSet();
59  
60  		if( hintSet != null ) {
61  			OTObjectList otHintList = otPasStep.getHintList();
62  
63  			/* remove all the previous hints because the for loop below adds 
64  			   all the previous hints from the otml file as well as the new 
65  			   hints that the user has just added. if you don't remove all 
66  			   these hints from before, you will end up with duplicate hints */
67  			otHintList.removeAll();
68  			
69  			OTObjectService objService = otObject.getOTObjectService();
70  			for (Hint hint : hintSet) {
71  				try {
72  					OTPasHint otHint = (OTPasHint) objService.createObject(OTPasHint.class);
73  					otHint.setText(hint.getText());
74  					otHintList.add(otHint);
75  				} catch (Exception e) {
76  					e.printStackTrace();
77  				}// try
78  			}// for
79  			//otPasStep.setHintList(otHintList);
80  		}// if
81  		
82  		
83  		
84  	}
85  
86  }