Detailverbesserungen und Reparaturen an Survey. Zeigt jetzt wieder die Widgets auf der Webseite an.
Benutzt dafür nun seinen eigenen XMLGenerator und TraversalAdapter. git-svn-id: https://svn.libreccm.org/ccm/trunk@380 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
5cd3d70eb9
commit
6a00eb6cb5
|
|
@ -4,8 +4,10 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||
|
||||
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
|
||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.Survey" extends="com.arsdigita.cms.ContentPage" traversalClass="com.arsdigita.cms.contenttypes.SurveyTraversalAdapter">
|
||||
<xrd:context name="com.arsdigita.cms.contenttypes.SurveyXMLGenerator">
|
||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.Survey"
|
||||
extends="com.arsdigita.cms.ContentPage"
|
||||
traversalClass="com.arsdigita.cms.contenttypes.SurveyTraversalAdapter">
|
||||
<xrd:attributes rule="exclude">
|
||||
<xrd:property name="/object/form/id"/>
|
||||
<xrd:property name="/object/form/defaultDomainClass"/>
|
||||
|
|
|
|||
|
|
@ -268,7 +268,8 @@ public class Survey extends ContentPage implements XMLGenerator {
|
|||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return hasStarted() && !hasEnded();
|
||||
return true;
|
||||
// return hasStarted() && !hasEnded();
|
||||
}
|
||||
|
||||
public void generateXML(PageState state, Element parent, String useContext) {
|
||||
|
|
|
|||
|
|
@ -37,10 +37,15 @@ public class SurveyInitializer extends ContentTypeInitializer {
|
|||
@Override
|
||||
public void init(DomainInitEvent evt) {
|
||||
|
||||
super.init(evt);
|
||||
|
||||
List widgets = Arrays.asList(
|
||||
Arrays.asList("ct_survey", "Checkbox group", "Checkbox groups",
|
||||
"com.arsdigita.formbuilder.PersistentCheckboxGroup",
|
||||
"com.arsdigita.formbuilder.ui.editors.CheckboxGroupEditor"),
|
||||
Arrays.asList("ct_survey", "Scale", "Scales",
|
||||
"com.arsdigita.cms.contenttypes.PersistentScale",
|
||||
"com.arsdigita.cms.contenttypes.ui.editors.ScaleEditor"),
|
||||
Arrays.asList("ct_survey", "Date field", "Date fields",
|
||||
"com.arsdigita.formbuilder.PersistentDate",
|
||||
"com.arsdigita.formbuilder.ui.editors.DateForm"),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
*/
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.dispatcher.*;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.Label;
|
||||
|
|
@ -14,6 +13,7 @@ import com.arsdigita.bebop.form.Widget;
|
|||
import com.arsdigita.bebop.util.Traversal;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.contenttypes.ui.SurveyProcessListener;
|
||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||
import com.arsdigita.cms.formbuilder.FormUnavailableException;
|
||||
import com.arsdigita.cms.formbuilder.NoParametersHttpServletRequest;
|
||||
import com.arsdigita.formbuilder.PersistentForm;
|
||||
|
|
@ -33,6 +33,8 @@ import com.arsdigita.xml.Element;
|
|||
*/
|
||||
public class SurveyXMLGenerator extends SimpleXMLGenerator {
|
||||
|
||||
public static final String ADAPTER_CONTEXT = SurveyXMLGenerator.class.getName();
|
||||
|
||||
@Override
|
||||
public void generateXML(PageState state, Element parent, String useContext) {
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public class SurveyPropertiesForm extends BasicPageForm implements FormProcessLi
|
|||
add(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.should_quiz_responses_be_public").localize()));
|
||||
ParameterModel responsesPublicParam = new BooleanParameter(RESPONSES_PUBLIC);
|
||||
responsesPublicParam.addParameterListener(new NotNullValidationListener());
|
||||
RadioGroup responsesPublic = new RadioGroup("responsesPublic");
|
||||
RadioGroup responsesPublic = new RadioGroup(responsesPublicParam);
|
||||
Option rp1 = new Option("true", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.Yes").localize()));
|
||||
Option rp2 = new Option("false", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.No").localize()));
|
||||
responsesPublic.addOption(rp1);
|
||||
|
|
@ -112,17 +112,17 @@ public class SurveyPropertiesForm extends BasicPageForm implements FormProcessLi
|
|||
add(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.show_results_during_survey").localize()));
|
||||
ParameterModel resultsDuringSurveyParam = new BooleanParameter(RESULTS_DURING_SURVEY);
|
||||
resultsDuringSurveyParam.addParameterListener(new NotNullValidationListener());
|
||||
RadioGroup resultsDuringSurvey = new RadioGroup("resultsDuringSurvey");
|
||||
RadioGroup resultsDuringSurvey = new RadioGroup(resultsDuringSurveyParam);
|
||||
Option rds1 = new Option("true", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.Yes").localize()));
|
||||
Option rds2 = new Option("false", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.No").localize()));
|
||||
resultsDuringSurvey.addOption(rp1);
|
||||
resultsDuringSurvey.addOption(rp2);
|
||||
resultsDuringSurvey.addOption(rds1);
|
||||
resultsDuringSurvey.addOption(rds2);
|
||||
add(resultsDuringSurvey);
|
||||
|
||||
add(new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.should_quiz_responses_be_anonym").localize()));
|
||||
ParameterModel responsesAnonymParam = new BooleanParameter(RESPONSES_ANONYM);
|
||||
responsesAnonymParam.addParameterListener(new NotNullValidationListener());
|
||||
RadioGroup responsesAnonym = new RadioGroup("responsesAnonym");
|
||||
RadioGroup responsesAnonym = new RadioGroup(responsesAnonymParam);
|
||||
Option ra1 = new Option("true", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.Yes").localize()));
|
||||
Option ra2 = new Option("false", new Label((String) SurveyGlobalizationUtil.globalize("cms.contenttypes.ui.survey.No").localize()));
|
||||
responsesAnonym.addOption(ra1);
|
||||
|
|
@ -160,9 +160,9 @@ public class SurveyPropertiesForm extends BasicPageForm implements FormProcessLi
|
|||
survey.setDescription((String) data.get(DESCRIPTION));
|
||||
survey.setStartDate((java.util.Date) data.get(START_DATE));
|
||||
survey.setEndDate((java.util.Date) data.get(END_DATE));
|
||||
survey.setResponsesPublic(new Boolean((String) data.get(RESPONSES_PUBLIC)));
|
||||
survey.setResultsDuringSurvey(new Boolean((String) data.get(RESULTS_DURING_SURVEY)));
|
||||
survey.setResponsesAnonym(new Boolean((String) data.get(RESPONSES_ANONYM)));
|
||||
survey.setResponsesPublic((Boolean) data.get(RESPONSES_PUBLIC));
|
||||
survey.setResultsDuringSurvey((Boolean) data.get(RESULTS_DURING_SURVEY));
|
||||
survey.setResponsesAnonym((Boolean) data.get(RESPONSES_ANONYM));
|
||||
|
||||
survey.save();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui.editors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author quasi
|
||||
*/
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.cms.contenttypes.PersistentScale;
|
||||
import com.arsdigita.formbuilder.PersistentOptionGroup;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.formbuilder.ui.PropertiesEditor;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ScaleEditor extends PropertiesEditor {
|
||||
|
||||
private Form m_editor;
|
||||
private Form m_buttons;
|
||||
private Submit m_props;
|
||||
private Submit m_done;
|
||||
private SingleSelectionModel m_control;
|
||||
private SingleSelectionModel m_form;
|
||||
|
||||
public ScaleEditor(String name,
|
||||
SingleSelectionModel form,
|
||||
SingleSelectionModel control) {
|
||||
|
||||
super(new ScaleForm(name, form, control));
|
||||
|
||||
|
||||
super.addProcessListener(
|
||||
new FormProcessListener() {
|
||||
|
||||
public void process(FormSectionEvent e)
|
||||
throws FormProcessException {
|
||||
PageState state = e.getPageState();
|
||||
|
||||
getPropertiesForm().setVisible(state, false);
|
||||
m_editor.setVisible(state, true);
|
||||
m_buttons.setVisible(state, true);
|
||||
}
|
||||
});
|
||||
|
||||
m_form = form;
|
||||
m_control = control;
|
||||
|
||||
m_editor = new Form("option_editor", new BoxPanel(BoxPanel.VERTICAL));
|
||||
m_editor.add(new ScaleOptionEditor(control) {
|
||||
@Override
|
||||
protected PersistentOptionGroup getOptionGroup(BigDecimal id)
|
||||
throws DataObjectNotFoundException {
|
||||
return new PersistentScale(id).getOptionList();
|
||||
}
|
||||
});
|
||||
add(m_editor);
|
||||
|
||||
m_props = new Submit("props", "Properties");
|
||||
m_done = new Submit("done", "Done");
|
||||
|
||||
m_buttons = new Form("buttons");
|
||||
m_buttons.add(m_props);
|
||||
m_buttons.add(m_done);
|
||||
add(m_buttons);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateXML(PageState state, Element parent) {
|
||||
if (m_control.getSelectedKey(state) == null
|
||||
|| m_props.isSelected(state)) {
|
||||
getPropertiesForm().setVisible(state, true);
|
||||
m_buttons.setVisible(state, false);
|
||||
m_editor.setVisible(state, false);
|
||||
|
||||
|
||||
} else {
|
||||
getPropertiesForm().setVisible(state, false);
|
||||
m_buttons.setVisible(state, true);
|
||||
m_editor.setVisible(state, true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
super.generateXML(state, parent);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProcessListener(FormProcessListener l) {
|
||||
super.addProcessListener(l);
|
||||
|
||||
m_buttons.addProcessListener(new PropertiesFormProcessListener(l));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(PageState state) {
|
||||
return m_done.isSelected(state);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui.editors;
|
||||
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.FormSection;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.RequestLocal;
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.form.OptionGroup;
|
||||
import com.arsdigita.cms.contenttypes.PersistentScale;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.formbuilder.PersistentWidget;
|
||||
import com.arsdigita.formbuilder.ui.editors.WidgetForm;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author quasi
|
||||
*/
|
||||
public class ScaleForm extends WidgetForm {
|
||||
|
||||
private OptionGroup m_optionGroup;
|
||||
private Label m_optionGroupLabel;
|
||||
private SingleSelectionModel m_control;
|
||||
private RequestLocal m_scale = new RequestLocal();
|
||||
|
||||
public ScaleForm(String name,
|
||||
SingleSelectionModel form,
|
||||
SingleSelectionModel control) {
|
||||
super(name, form, control);
|
||||
|
||||
m_control = control;
|
||||
}
|
||||
|
||||
|
||||
protected PersistentWidget getWidget() {
|
||||
return new PersistentScale();
|
||||
}
|
||||
|
||||
protected PersistentWidget getWidget(BigDecimal id)
|
||||
throws DataObjectNotFoundException {
|
||||
return new PersistentScale(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets(FormSection section) {
|
||||
super.addWidgets(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateXML(PageState state, Element parent) {
|
||||
super.generateXML(state, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initWidgets(FormSectionEvent event, PersistentWidget widget)
|
||||
throws FormProcessException {
|
||||
super.initWidgets(event, widget);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processWidgets(FormSectionEvent event,
|
||||
PersistentWidget widget)
|
||||
throws FormProcessException {
|
||||
super.processWidgets(event, widget);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.arsdigita.cms.contenttypes.ui.editors;
|
||||
|
||||
import com.arsdigita.bebop.SingleSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.PersistentScale;
|
||||
import com.arsdigita.formbuilder.PersistentOptionGroup;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.formbuilder.ui.editors.OptionEditor;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author quasi
|
||||
*/
|
||||
public class ScaleOptionEditor extends OptionEditor {
|
||||
|
||||
public ScaleOptionEditor(SingleSelectionModel control) {
|
||||
|
||||
super(control);
|
||||
|
||||
}
|
||||
|
||||
protected PersistentOptionGroup getOptionGroup(BigDecimal id)
|
||||
throws DataObjectNotFoundException {
|
||||
return new PersistentScale(id).getOptionList();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue