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