Fixed display of FormHeading and FormText in the Content Centre.

git-svn-id: https://svn.libreccm.org/ccm/trunk@3493 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2015-06-22 07:43:17 +00:00
parent e83147bbfe
commit c9db46ce01
3 changed files with 115 additions and 85 deletions

View File

@ -28,14 +28,18 @@ import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.metadata.ObjectType;
// ACS objects are identified by a number
import java.math.BigDecimal;
// The factory creates Bebop Components
// Every PersistentComponentFactory can create a Bebop Component
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Label;
// ACS 5 uses Log4J for logging
import org.apache.log4j.Logger;
@ -121,6 +125,7 @@ public class PersistentHeading extends PersistentText {
public Component createComponent() {
Component component = super.createComponent();
component.setClassAttr("persistenceHeading");
((Label) component).setOutputEscaping(false);
return component;
}

View File

@ -119,9 +119,11 @@ public class PersistentText extends PersistentComponent {
* Create the Text whose persistence is managed
* by this domain object.
*/
@Override
public Component createComponent() {
Label label = new Label(getText());
label.setClassAttr("persistenceText");
label.setOutputEscaping(false);
return label;
}

View File

@ -18,7 +18,6 @@
*/
package com.arsdigita.formbuilder.ui;
import com.arsdigita.bebop.BaseLink;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.ColumnPanel;
@ -70,6 +69,7 @@ import org.apache.log4j.Logger;
* additional infrasructure
*/
public class ControlEditor extends SimpleContainer {
private static final Logger s_log = Logger.getLogger(ControlEditor.class);
private ParameterSingleSelectionModel m_control;
@ -85,8 +85,8 @@ public class ControlEditor extends SimpleContainer {
/**
* Constructor creates a new control editor widget, for editing the form
* specified in the single selection model. The key returned by the single
* selection model should be an instance of the
* {@link java.math.BigDecimal} class.
* selection model should be an instance of the {@link java.math.BigDecimal}
* class.
*
* @param app the application type
* @param form the form to edit
@ -99,17 +99,17 @@ public class ControlEditor extends SimpleContainer {
/**
* Constructor creates a new control editor widget, for editing the form
* specified in the single selection model. The key returned by the single
* selection model should be an instance of the
* {@link java.math.BigDecimal} class.
* selection model should be an instance of the {@link java.math.BigDecimal}
* class.
*
* This constructor also allows the programmer to turn on the use of
* form sections, although they must also call the setFormSectionModelBuilder
* This constructor also allows the programmer to turn on the use of form
* sections, although they must also call the setFormSectionModelBuilder
* method to populate the list box.
*
* @param app the application type
* @param form the form to edit
* @param wantFormSeciton whether to display list box for
* adding form sections.
* @param wantFormSeciton whether to display list box for adding form
* sections.
*/
public ControlEditor(String app,
SingleSelectionModel form,
@ -123,12 +123,13 @@ public class ControlEditor extends SimpleContainer {
// system doesn't work at all. Config should return null constant.
String helpURL = FormBuilderUtil.getConfig().getControlsHelpLink();
if (helpURL != null) {
add(new Link(new Label(GlobalizationUtil.globalize
("formbuilder.ui.help")), helpURL));
add(new Link(new Label(GlobalizationUtil.globalize(
"formbuilder.ui.help")), helpURL));
add(new Label("")); // spacer
}
m_control = new ParameterSingleSelectionModel(new BigDecimalParameter("control"));
m_control = new ParameterSingleSelectionModel(new BigDecimalParameter(
"control"));
m_view_form = new BoxPanel(BoxPanel.VERTICAL);
@ -150,7 +151,8 @@ public class ControlEditor extends SimpleContainer {
m_new_section.addProcessListener(new NewSectionProcessListener());
m_new_control.addProcessListener(new NewControlProcessListener());
m_control_props.addCompletionListener(new ControlPropsCompletionListener());
m_control_props.addCompletionListener(
new ControlPropsCompletionListener());
m_move_control.addActionListener(new MoveControlActionListener());
add(m_view_form);
@ -167,17 +169,16 @@ public class ControlEditor extends SimpleContainer {
BigDecimal sectionID) {
OID componentOID = new OID(PersistentComponent.BASE_DATA_OBJECT_TYPE,
sectionID);
return (PersistentComponent)
DomainObjectFactory.newInstance( componentOID );
return (PersistentComponent) DomainObjectFactory.newInstance(
componentOID);
}
// XXX PrintListener will change to ListModel when (if)
// optiongroups finally become model driven
/**
* Sets the form section model builder for populating
* the drop down list of form sections. The model
* builder is actually a PrintListener, which should
* add new Options to the select box
* Sets the form section model builder for populating the drop down list of
* form sections. The model builder is actually a PrintListener, which
* should add new Options to the select box
*
* @param l the print listener for populating the list
*/
@ -201,13 +202,14 @@ public class ControlEditor extends SimpleContainer {
OID formOID = new OID(PersistentFormSection.BASE_DATA_OBJECT_TYPE,
m_form.getSelectedKey(state));
PersistentFormSection fs = (PersistentFormSection)
DomainObjectFactory.newInstance( formOID );
PersistentFormSection fs
= (PersistentFormSection) DomainObjectFactory
.newInstance(formOID);
OID controlOID = new OID(PersistentComponent.BASE_DATA_OBJECT_TYPE,
m_control.getSelectedKey(state));
PersistentComponent c = (PersistentComponent)
DomainObjectFactory.newInstance( controlOID );
PersistentComponent c = (PersistentComponent) DomainObjectFactory
.newInstance(controlOID);
fs.removeComponent(c);
@ -222,8 +224,9 @@ public class ControlEditor extends SimpleContainer {
// Nada
}
if (!(c instanceof PersistentFormSection))
if (!(c instanceof PersistentFormSection)) {
c.delete();
}
m_control.setSelectedKey(state, null);
} else if (name.equals("move")) {
m_control.setSelectedKey(state, new BigDecimal(value));
@ -255,6 +258,7 @@ public class ControlEditor extends SimpleContainer {
}
private class NewSectionProcessListener implements FormProcessListener {
public void process(FormSectionEvent e)
throws FormProcessException {
@ -264,16 +268,19 @@ public class ControlEditor extends SimpleContainer {
OID formOID = new OID(PersistentFormSection.BASE_DATA_OBJECT_TYPE,
m_form.getSelectedKey(state));
PersistentFormSection form = (PersistentFormSection)
DomainObjectFactory.newInstance( formOID );
PersistentFormSection form
= (PersistentFormSection) DomainObjectFactory
.newInstance(formOID);
BigDecimal id = m_new_section.getSelectedSection(state);
PersistentComponent section = getFormSection(state, id);
form.addComponent(section);
}
}
private class NewControlProcessListener implements FormProcessListener {
public void process(FormSectionEvent e)
throws FormProcessException {
@ -283,9 +290,12 @@ public class ControlEditor extends SimpleContainer {
m_view_form.setVisible(e.getPageState(), false);
m_control_props.setVisible(e.getPageState(), true);
}
}
private class ControlPropsCompletionListener implements FormCompletionListener {
private class ControlPropsCompletionListener implements
FormCompletionListener {
public void complete(FormSectionEvent e)
throws FormProcessException {
@ -295,9 +305,11 @@ public class ControlEditor extends SimpleContainer {
m_view_form.setVisible(e.getPageState(), true);
m_control_props.setVisible(e.getPageState(), false);
}
}
private class MoveControlActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
s_log.debug("MoveControlActionListener.actionPerformed()");
@ -306,8 +318,8 @@ public class ControlEditor extends SimpleContainer {
m_view_form.setVisible(e.getPageState(), true);
m_move_control.setVisible(e.getPageState(), false);
}
}
}
/**
* Allows subclasses to control when to add the edit/move/delete links
@ -317,6 +329,7 @@ public class ControlEditor extends SimpleContainer {
}
private class FormItemControlsForm extends MetaForm {
public FormItemControlsForm(String name) {
super(name);
}
@ -324,12 +337,13 @@ public class ControlEditor extends SimpleContainer {
public Form buildForm(PageState state) {
OID formOID = new OID(PersistentFormSection.BASE_DATA_OBJECT_TYPE,
m_form.getSelectedKey(state));
PersistentFormSection section = (PersistentFormSection)
DomainObjectFactory.newInstance( formOID );
PersistentFormSection section
= (PersistentFormSection) DomainObjectFactory
.newInstance(formOID);
if (addItemEditObserver(state)) {
section.setComponentAddObserver(new
ItemEditAddObserver(ControlEditor.this, state));
section.setComponentAddObserver(new ItemEditAddObserver(
ControlEditor.this, state));
section.setFormContainer(new ColumnPanel(3));
} else {
section.setFormContainer(new ColumnPanel(2));
@ -347,6 +361,7 @@ public class ControlEditor extends SimpleContainer {
// Make the controls readonly
Traversal t = new Traversal() {
public void act(Component c) {
try {
Widget widget = (Widget) c;
@ -356,12 +371,14 @@ public class ControlEditor extends SimpleContainer {
// Nada
}
}
};
t.preorder(f);
return f;
}
private class ItemEditAddObserver extends BaseEditAddObserver {
Component m_handler;
PageState m_state;
@ -375,7 +392,9 @@ public class ControlEditor extends SimpleContainer {
*
* @param dest
* @param component
*
* @return
*
* @deprecated
*/
protected BaseLink createLink(String dest,
@ -431,7 +450,11 @@ public class ControlEditor extends SimpleContainer {
public void setControlEvent(PageState state) {
state.setControlEvent(m_handler, m_action, m_component);
}
}
}
}
}