source: tol/TolJava/WebTOLJavaDEMO/src/java/com/hcarralero/toljava/demo/SessionBean1.java @ 9887b93

1941-docker-image-to-testdevel
Last change on this file since 9887b93 was 9887b93, checked in by Humberto Carralero <hacarralero@…>, 15 years ago

Importing TolJava

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3900 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 8.3 KB
Line 
1
2package com.hcarralero.toljava.demo;
3
4import com.hcarralero.toljava.TOLMachine;
5import com.hcarralero.toljava.TOLVariable;
6import com.sun.rave.web.ui.appbase.AbstractSessionBean;
7import com.sun.webui.jsf.model.Option;
8import javax.faces.FacesException;
9
10/**
11 * <p>Session scope data bean for your application.  Create properties
12 *  here to represent cached data that should be made available across
13 *  multiple HTTP requests for an individual user.</p>
14 *
15 * <p>An instance of this class will be created for you automatically,
16 * the first time your application evaluates a value binding expression
17 * or method binding expression that references a managed bean using
18 * this class.</p>
19 *
20 * @version SessionBean1.java
21 * @version Created on Nov 28, 2010, 5:30:40 AM
22 * @author hcarralero
23 */
24
25public class SessionBean1 extends AbstractSessionBean {
26    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
27
28    /**
29     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
30     * This method is automatically generated, so any user-specified code inserted
31     * here is subject to being replaced.</p>
32     */
33    private void _init() throws Exception {
34    }
35    // </editor-fold>
36
37    /**
38     * <p>Construct a new session data bean instance.</p>
39     */
40    public SessionBean1() {
41    }
42
43    /**
44     * <p>This method is called when this bean is initially added to
45     * session scope.  Typically, this occurs as a result of evaluating
46     * a value binding or method binding expression, which utilizes the
47     * managed bean facility to instantiate this bean and store it into
48     * session scope.</p>
49     *
50     * <p>You may customize this method to initialize and cache data values
51     * or resources that are required for the lifetime of a particular
52     * user session.</p>
53     */
54    @Override
55    public void init() {
56        // Perform initializations inherited from our superclass
57        super.init();
58        // Perform application initialization that must complete
59        // *before* managed components are initialized
60        // TODO - add your own initialiation code here
61       
62        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
63        // Initialize automatically managed components
64        // *Note* - this logic should NOT be modified
65        try {
66            _init();
67        } catch (Exception e) {
68            log("SessionBean1 Initialization Failure", e);
69            throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
70        }
71       
72        // </editor-fold>
73        // Perform application initialization that must complete
74        // *after* managed components are initialized
75        // TODO - add your own initialization code here
76    }
77
78    /**
79     * <p>This method is called when the session containing it is about to be
80     * passivated.  Typically, this occurs in a distributed servlet container
81     * when the session is about to be transferred to a different
82     * container instance, after which the <code>activate()</code> method
83     * will be called to indicate that the transfer is complete.</p>
84     *
85     * <p>You may customize this method to release references to session data
86     * or resources that can not be serialized with the session itself.</p>
87     */
88    @Override
89    public void passivate() {
90    }
91
92    /**
93     * <p>This method is called when the session containing it was
94     * reactivated.</p>
95     *
96     * <p>You may customize this method to reacquire references to session
97     * data or resources that could not be serialized with the
98     * session itself.</p>
99     */
100    @Override
101    public void activate() {
102    }
103
104    /**
105     * <p>This method is called when this bean is removed from
106     * session scope.  Typically, this occurs as a result of
107     * the session timing out or being terminated by the application.</p>
108     *
109     * <p>You may customize this method to clean up resources allocated
110     * during the execution of the <code>init()</code> method, or
111     * at any later time during the lifetime of the application.</p>
112     */
113    @Override
114    public void destroy() {
115    }
116   
117    /**
118     * <p>Return a reference to the scoped data bean.</p>
119     *
120     * @return reference to the scoped data bean
121     */
122    protected ApplicationBean1 getApplicationBean1() {
123        return (ApplicationBean1) getBean("ApplicationBean1");
124    }
125
126    private TOLMachine tm = new TOLMachine();
127
128    /**
129     * Get the value of tm
130     *
131     * @return the value of tm
132     */
133    public TOLMachine getTm() {
134        return tm;
135    }
136
137    /**
138     * Set the value of tm
139     *
140     * @param tm new value of tm
141     */
142    public void setTm(TOLMachine tm) {
143        this.tm = tm;
144    }
145
146
147    private TOLVariable[] vars = null;
148
149    /**
150     * Get the value of vars
151     *
152     * @return the value of vars
153     */
154    public TOLVariable[] getVars() {
155        return vars;
156    }
157
158    /**
159     * Set the value of vars
160     *
161     * @param vars new value of vars
162     */
163    public void setVars(TOLVariable[] vars) {
164        this.vars = vars;
165    }
166
167    protected Option[] optVARS;
168
169    /**
170     * Get the value of optVARS
171     *
172     * @return the value of optVARS
173     */
174    public Option[] getOptVARS() {
175        return optVARS;
176    }
177
178    private TOLVariable varActual;
179
180    /**
181     * Get the value of varActual
182     *
183     * @return the value of varActual
184     */
185    public TOLVariable getVarActual() {
186        return varActual;
187    }
188
189    /**
190     * Set the value of varActual
191     *
192     * @param varActual new value of varActual
193     */
194    public void setVarActual(TOLVariable varActual) {
195        this.varActual = varActual;
196    }
197
198    private void actualizarOptVARS() {
199        int nv= 0;
200        if (vars!=null&&vars.length>0) {
201            nv= vars.length;
202            optVARS= new Option[nv];
203            for (int i= 0; i<nv; ++i) {
204                String name= vars[i].getName();
205                if (name==null) {
206                    name= "Unknow";
207                } else {
208                    name= name.trim();
209                    if (name.length()==0) {
210                        name= "Unknow";
211                    }
212                }
213                String desc= vars[i].getDesc();
214                if (desc!=null) {
215                    desc= desc.trim();
216                    if (desc.length()==0) {
217                        desc= null;
218                    }
219                }
220                String nd= name;
221                if (desc!=null) {
222                    nd+= "==>"+desc;
223                }
224                optVARS[i]= new Option(i, nd);
225            }
226        }
227    }
228    public void actualizarVARSText() {
229        vars= tm.getTextVariables();
230        actualizarOptVARS();
231    }
232
233    public void actualizarVARSReal() {
234        vars= tm.getRealVariables();
235        actualizarOptVARS();
236    }
237
238    public void actualizarVARSDate() {
239        vars= tm.getDateVariables();
240        actualizarOptVARS();
241    }
242
243    public void actualizarVARSComplex() {
244        vars= tm.getComplexVariables();
245        actualizarOptVARS();
246    }
247
248    public void actualizarVARSMatrix() {
249        vars= tm.getMatrixVariables();
250        actualizarOptVARS();
251    }
252
253    public void actualizarVARSVMatrix() {
254        vars= tm.getVMatrixVariables();
255        actualizarOptVARS();
256    }
257
258    public void actualizarVARSPolyn() {
259        vars= tm.getPolynVariables();
260        actualizarOptVARS();
261    }
262
263    public void actualizarVARSRatio() {
264        vars= tm.getRatioVariables();
265        actualizarOptVARS();
266    }
267
268    public void actualizarVARSCode() {
269        vars= tm.getCodeVariables();
270        actualizarOptVARS();
271    }
272
273    public void actualizarVARSSerie() {
274        vars= tm.getSerieVariables();
275        actualizarOptVARS();
276    }
277
278    public void actualizarVARSTimeSet() {
279        vars= tm.getTimeSetVariables();
280        actualizarOptVARS();
281    }
282
283    public void actualizarVARSSet() {
284        vars= tm.getSetVariables();
285        actualizarOptVARS();
286    }
287
288    private String varType= null;
289
290    /**
291     * Get the value of varType
292     *
293     * @return the value of varType
294     */
295    public String getVarType() {
296        return varType;
297    }
298
299    /**
300     * Set the value of varType
301     *
302     * @param varType new value of varType
303     */
304    public void setVarType(String varType) {
305        this.varType = varType;
306    }
307
308}
Note: See TracBrowser for help on using the repository browser.