01: package com.xoetrope.swing.survey;
02:
03: import com.xoetrope.swing.*;
04: import com.xoetrope.swing.forms.XFormBuilder;
05: import java.util.Locale;
06: import com.xoetrope.carousel.build.BuildProperties;
07: import com.xoetrope.survey.XSurveyManager;
08: import net.xoetrope.xui.XComponentFactory;
09: import net.xoetrope.xui.XPageLoader;
10: import net.xoetrope.xui.XLifeCycleListener;
11: import net.xoetrope.xui.XProject;
12: import net.xoetrope.xui.XProjectManager;
13:
14: /**
15: * Implements XLifeCycleListener so as to add additional support for surveys.
16: *
17: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
18: * the GNU Public License (GPL), please see license.txt for more details. If
19: * you make commercial use of this software you must purchase a commercial
20: * license from Xoetrope.</p>
21: * <p> $Revision: 1.6 $</p>
22: */
23: public class XSurveyApplication implements XLifeCycleListener {
24: private XSurveyManager surveyManager;
25: private XProject currentProject;
26:
27: public XSurveyApplication() {
28: }
29:
30: public void initialize(XProject project) {
31: currentProject = project;
32: try {
33: surveyManager = (XSurveyManager) currentProject
34: .getObject("SurveyManager");
35: if (surveyManager == null) {
36: surveyManager = new XSurveyManager(currentProject);
37: currentProject
38: .setObject("SurveyManager", surveyManager);
39: }
40: String surveyFileName = currentProject
41: .getStartupParam("Survey");
42: if (surveyFileName == null)
43: surveyFileName = "survey";
44: surveyManager.loadSurvey(0, surveyFileName, Locale
45: .getDefault().getLanguage());
46: } catch (Exception ex) {
47: if (BuildProperties.DEBUG)
48: ex.printStackTrace();
49: }
50: }
51:
52: protected XPageLoader getSecondaryClassLoader(String cl) {
53: return new XFormBuilder(currentProject);
54: }
55:
56: protected void register() {
57: XComponentFactory.registerComponentFactory(
58: "XuiProComponentFactory", new XuiProComponentFactory(
59: currentProject));
60: }
61:
62: /**
63: * Prepare for shutdown by saving the data.
64: */
65: public void shutdown() {
66: surveyManager.saveSessions();
67: }
68:
69: public boolean canClose(XProject xProject) {
70: return false;
71: }
72: }
|