Fixed display of FormHeading and FormText in the Content Centre.
git-svn-id: https://svn.libreccm.org/ccm/trunk@3493 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
e83147bbfe
commit
c9db46ce01
|
|
@ -28,14 +28,18 @@ import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.metadata.ObjectType;
|
import com.arsdigita.persistence.metadata.ObjectType;
|
||||||
|
|
||||||
// ACS objects are identified by a number
|
// ACS objects are identified by a number
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
// The factory creates Bebop Components
|
// The factory creates Bebop Components
|
||||||
|
|
||||||
// Every PersistentComponentFactory can create a Bebop Component
|
// Every PersistentComponentFactory can create a Bebop Component
|
||||||
|
|
||||||
import com.arsdigita.bebop.Component;
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
|
||||||
// ACS 5 uses Log4J for logging
|
// ACS 5 uses Log4J for logging
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -121,6 +125,7 @@ public class PersistentHeading extends PersistentText {
|
||||||
public Component createComponent() {
|
public Component createComponent() {
|
||||||
Component component = super.createComponent();
|
Component component = super.createComponent();
|
||||||
component.setClassAttr("persistenceHeading");
|
component.setClassAttr("persistenceHeading");
|
||||||
|
((Label) component).setOutputEscaping(false);
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,9 +119,11 @@ public class PersistentText extends PersistentComponent {
|
||||||
* Create the Text whose persistence is managed
|
* Create the Text whose persistence is managed
|
||||||
* by this domain object.
|
* by this domain object.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Component createComponent() {
|
public Component createComponent() {
|
||||||
Label label = new Label(getText());
|
Label label = new Label(getText());
|
||||||
label.setClassAttr("persistenceText");
|
label.setClassAttr("persistenceText");
|
||||||
|
label.setOutputEscaping(false);
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.formbuilder.ui;
|
package com.arsdigita.formbuilder.ui;
|
||||||
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.BaseLink;
|
import com.arsdigita.bebop.BaseLink;
|
||||||
import com.arsdigita.bebop.BoxPanel;
|
import com.arsdigita.bebop.BoxPanel;
|
||||||
import com.arsdigita.bebop.ColumnPanel;
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
|
@ -70,7 +69,8 @@ import org.apache.log4j.Logger;
|
||||||
* additional infrasructure
|
* additional infrasructure
|
||||||
*/
|
*/
|
||||||
public class ControlEditor extends SimpleContainer {
|
public class ControlEditor extends SimpleContainer {
|
||||||
private static final Logger s_log = Logger.getLogger( ControlEditor.class );
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(ControlEditor.class);
|
||||||
|
|
||||||
private ParameterSingleSelectionModel m_control;
|
private ParameterSingleSelectionModel m_control;
|
||||||
|
|
||||||
|
|
@ -85,8 +85,8 @@ public class ControlEditor extends SimpleContainer {
|
||||||
/**
|
/**
|
||||||
* Constructor creates a new control editor widget, for editing the form
|
* Constructor creates a new control editor widget, for editing the form
|
||||||
* specified in the single selection model. The key returned by the single
|
* specified in the single selection model. The key returned by the single
|
||||||
* selection model should be an instance of the
|
* selection model should be an instance of the {@link java.math.BigDecimal}
|
||||||
* {@link java.math.BigDecimal} class.
|
* class.
|
||||||
*
|
*
|
||||||
* @param app the application type
|
* @param app the application type
|
||||||
* @param form the form to edit
|
* @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
|
* Constructor creates a new control editor widget, for editing the form
|
||||||
* specified in the single selection model. The key returned by the single
|
* specified in the single selection model. The key returned by the single
|
||||||
* selection model should be an instance of the
|
* selection model should be an instance of the {@link java.math.BigDecimal}
|
||||||
* {@link java.math.BigDecimal} class.
|
* class.
|
||||||
*
|
*
|
||||||
* This constructor also allows the programmer to turn on the use of
|
* This constructor also allows the programmer to turn on the use of form
|
||||||
* form sections, although they must also call the setFormSectionModelBuilder
|
* sections, although they must also call the setFormSectionModelBuilder
|
||||||
* method to populate the list box.
|
* method to populate the list box.
|
||||||
*
|
*
|
||||||
* @param app the application type
|
* @param app the application type
|
||||||
* @param form the form to edit
|
* @param form the form to edit
|
||||||
* @param wantFormSeciton whether to display list box for
|
* @param wantFormSeciton whether to display list box for adding form
|
||||||
* adding form sections.
|
* sections.
|
||||||
*/
|
*/
|
||||||
public ControlEditor(String app,
|
public ControlEditor(String app,
|
||||||
SingleSelectionModel form,
|
SingleSelectionModel form,
|
||||||
|
|
@ -123,12 +123,13 @@ public class ControlEditor extends SimpleContainer {
|
||||||
// system doesn't work at all. Config should return null constant.
|
// system doesn't work at all. Config should return null constant.
|
||||||
String helpURL = FormBuilderUtil.getConfig().getControlsHelpLink();
|
String helpURL = FormBuilderUtil.getConfig().getControlsHelpLink();
|
||||||
if (helpURL != null) {
|
if (helpURL != null) {
|
||||||
add(new Link(new Label(GlobalizationUtil.globalize
|
add(new Link(new Label(GlobalizationUtil.globalize(
|
||||||
("formbuilder.ui.help")), helpURL));
|
"formbuilder.ui.help")), helpURL));
|
||||||
add(new Label("")); // spacer
|
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);
|
m_view_form = new BoxPanel(BoxPanel.VERTICAL);
|
||||||
|
|
||||||
|
|
@ -150,7 +151,8 @@ public class ControlEditor extends SimpleContainer {
|
||||||
|
|
||||||
m_new_section.addProcessListener(new NewSectionProcessListener());
|
m_new_section.addProcessListener(new NewSectionProcessListener());
|
||||||
m_new_control.addProcessListener(new NewControlProcessListener());
|
m_new_control.addProcessListener(new NewControlProcessListener());
|
||||||
m_control_props.addCompletionListener(new ControlPropsCompletionListener());
|
m_control_props.addCompletionListener(
|
||||||
|
new ControlPropsCompletionListener());
|
||||||
m_move_control.addActionListener(new MoveControlActionListener());
|
m_move_control.addActionListener(new MoveControlActionListener());
|
||||||
|
|
||||||
add(m_view_form);
|
add(m_view_form);
|
||||||
|
|
@ -165,19 +167,18 @@ public class ControlEditor extends SimpleContainer {
|
||||||
|
|
||||||
protected PersistentComponent getFormSection(PageState state,
|
protected PersistentComponent getFormSection(PageState state,
|
||||||
BigDecimal sectionID) {
|
BigDecimal sectionID) {
|
||||||
OID componentOID = new OID( PersistentComponent.BASE_DATA_OBJECT_TYPE,
|
OID componentOID = new OID(PersistentComponent.BASE_DATA_OBJECT_TYPE,
|
||||||
sectionID );
|
sectionID);
|
||||||
return (PersistentComponent)
|
return (PersistentComponent) DomainObjectFactory.newInstance(
|
||||||
DomainObjectFactory.newInstance( componentOID );
|
componentOID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX PrintListener will change to ListModel when (if)
|
// XXX PrintListener will change to ListModel when (if)
|
||||||
// optiongroups finally become model driven
|
// optiongroups finally become model driven
|
||||||
/**
|
/**
|
||||||
* Sets the form section model builder for populating
|
* Sets the form section model builder for populating the drop down list of
|
||||||
* the drop down list of form sections. The model
|
* form sections. The model builder is actually a PrintListener, which
|
||||||
* builder is actually a PrintListener, which should
|
* should add new Options to the select box
|
||||||
* add new Options to the select box
|
|
||||||
*
|
*
|
||||||
* @param l the print listener for populating the list
|
* @param l the print listener for populating the list
|
||||||
*/
|
*/
|
||||||
|
|
@ -199,22 +200,23 @@ public class ControlEditor extends SimpleContainer {
|
||||||
} else if (name.equals("delete")) {
|
} else if (name.equals("delete")) {
|
||||||
m_control.setSelectedKey(state, new BigDecimal(value));
|
m_control.setSelectedKey(state, new BigDecimal(value));
|
||||||
|
|
||||||
OID formOID = new OID( PersistentFormSection.BASE_DATA_OBJECT_TYPE,
|
OID formOID = new OID(PersistentFormSection.BASE_DATA_OBJECT_TYPE,
|
||||||
m_form.getSelectedKey(state) );
|
m_form.getSelectedKey(state));
|
||||||
PersistentFormSection fs = (PersistentFormSection)
|
PersistentFormSection fs
|
||||||
DomainObjectFactory.newInstance( formOID );
|
= (PersistentFormSection) DomainObjectFactory
|
||||||
|
.newInstance(formOID);
|
||||||
|
|
||||||
OID controlOID = new OID( PersistentComponent.BASE_DATA_OBJECT_TYPE,
|
OID controlOID = new OID(PersistentComponent.BASE_DATA_OBJECT_TYPE,
|
||||||
m_control.getSelectedKey(state) );
|
m_control.getSelectedKey(state));
|
||||||
PersistentComponent c = (PersistentComponent)
|
PersistentComponent c = (PersistentComponent) DomainObjectFactory
|
||||||
DomainObjectFactory.newInstance( controlOID );
|
.newInstance(controlOID);
|
||||||
|
|
||||||
fs.removeComponent(c);
|
fs.removeComponent(c);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PersistentWidget w = (PersistentWidget)c;
|
PersistentWidget w = (PersistentWidget) c;
|
||||||
WidgetLabel label = WidgetLabel.findByWidget(w);
|
WidgetLabel label = WidgetLabel.findByWidget(w);
|
||||||
if( null != label ) {
|
if (null != label) {
|
||||||
fs.removeComponent(label);
|
fs.removeComponent(label);
|
||||||
label.delete();
|
label.delete();
|
||||||
}
|
}
|
||||||
|
|
@ -222,8 +224,9 @@ public class ControlEditor extends SimpleContainer {
|
||||||
// Nada
|
// Nada
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(c instanceof PersistentFormSection))
|
if (!(c instanceof PersistentFormSection)) {
|
||||||
c.delete();
|
c.delete();
|
||||||
|
}
|
||||||
m_control.setSelectedKey(state, null);
|
m_control.setSelectedKey(state, null);
|
||||||
} else if (name.equals("move")) {
|
} else if (name.equals("move")) {
|
||||||
m_control.setSelectedKey(state, new BigDecimal(value));
|
m_control.setSelectedKey(state, new BigDecimal(value));
|
||||||
|
|
@ -234,9 +237,9 @@ public class ControlEditor extends SimpleContainer {
|
||||||
state.clearControlEvent();
|
state.clearControlEvent();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
throw new RedirectSignal( state.stateAsURL(), true );
|
throw new RedirectSignal(state.stateAsURL(), true);
|
||||||
} catch( IOException ex ) {
|
} catch (IOException ex) {
|
||||||
throw new UncheckedWrapperException( ex );
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -255,59 +258,68 @@ public class ControlEditor extends SimpleContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NewSectionProcessListener implements FormProcessListener {
|
private class NewSectionProcessListener implements FormProcessListener {
|
||||||
|
|
||||||
public void process(FormSectionEvent e)
|
public void process(FormSectionEvent e)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
s_log.debug( "NewSectionProcessListener().process()" );
|
s_log.debug("NewSectionProcessListener().process()");
|
||||||
|
|
||||||
PageState state = e.getPageState();
|
PageState state = e.getPageState();
|
||||||
|
|
||||||
OID formOID = new OID( PersistentFormSection.BASE_DATA_OBJECT_TYPE,
|
OID formOID = new OID(PersistentFormSection.BASE_DATA_OBJECT_TYPE,
|
||||||
m_form.getSelectedKey(state) );
|
m_form.getSelectedKey(state));
|
||||||
PersistentFormSection form = (PersistentFormSection)
|
PersistentFormSection form
|
||||||
DomainObjectFactory.newInstance( formOID );
|
= (PersistentFormSection) DomainObjectFactory
|
||||||
|
.newInstance(formOID);
|
||||||
|
|
||||||
BigDecimal id = m_new_section.getSelectedSection(state);
|
BigDecimal id = m_new_section.getSelectedSection(state);
|
||||||
PersistentComponent section = getFormSection(state, id);
|
PersistentComponent section = getFormSection(state, id);
|
||||||
form.addComponent(section);
|
form.addComponent(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NewControlProcessListener implements FormProcessListener {
|
private class NewControlProcessListener implements FormProcessListener {
|
||||||
|
|
||||||
public void process(FormSectionEvent e)
|
public void process(FormSectionEvent e)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
s_log.debug( "NewControlProcessListener.process()" );
|
s_log.debug("NewControlProcessListener.process()");
|
||||||
|
|
||||||
m_control.setSelectedKey(e.getPageState(), null);
|
m_control.setSelectedKey(e.getPageState(), null);
|
||||||
m_view_form.setVisible(e.getPageState(), false);
|
m_view_form.setVisible(e.getPageState(), false);
|
||||||
m_control_props.setVisible(e.getPageState(), true);
|
m_control_props.setVisible(e.getPageState(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ControlPropsCompletionListener implements FormCompletionListener {
|
private class ControlPropsCompletionListener implements
|
||||||
|
FormCompletionListener {
|
||||||
|
|
||||||
public void complete(FormSectionEvent e)
|
public void complete(FormSectionEvent e)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
s_log.debug( "ControlPropsCompletionListener.complete()" );
|
s_log.debug("ControlPropsCompletionListener.complete()");
|
||||||
|
|
||||||
m_control.setSelectedKey(e.getPageState(), null);
|
m_control.setSelectedKey(e.getPageState(), null);
|
||||||
m_view_form.setVisible(e.getPageState(), true);
|
m_view_form.setVisible(e.getPageState(), true);
|
||||||
m_control_props.setVisible(e.getPageState(), false);
|
m_control_props.setVisible(e.getPageState(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MoveControlActionListener implements ActionListener {
|
private class MoveControlActionListener implements ActionListener {
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
s_log.debug( "MoveControlActionListener.actionPerformed()" );
|
s_log.debug("MoveControlActionListener.actionPerformed()");
|
||||||
|
|
||||||
m_control.setSelectedKey(e.getPageState(), null);
|
m_control.setSelectedKey(e.getPageState(), null);
|
||||||
m_view_form.setVisible(e.getPageState(), true);
|
m_view_form.setVisible(e.getPageState(), true);
|
||||||
m_move_control.setVisible(e.getPageState(), false);
|
m_move_control.setVisible(e.getPageState(), false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows subclasses to control when to add the edit/move/delete links
|
* Allows subclasses to control when to add the edit/move/delete links
|
||||||
|
|
@ -317,19 +329,21 @@ public class ControlEditor extends SimpleContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FormItemControlsForm extends MetaForm {
|
private class FormItemControlsForm extends MetaForm {
|
||||||
|
|
||||||
public FormItemControlsForm(String name) {
|
public FormItemControlsForm(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Form buildForm(PageState state) {
|
public Form buildForm(PageState state) {
|
||||||
OID formOID = new OID( PersistentFormSection.BASE_DATA_OBJECT_TYPE,
|
OID formOID = new OID(PersistentFormSection.BASE_DATA_OBJECT_TYPE,
|
||||||
m_form.getSelectedKey(state) );
|
m_form.getSelectedKey(state));
|
||||||
PersistentFormSection section = (PersistentFormSection)
|
PersistentFormSection section
|
||||||
DomainObjectFactory.newInstance( formOID );
|
= (PersistentFormSection) DomainObjectFactory
|
||||||
|
.newInstance(formOID);
|
||||||
|
|
||||||
if (addItemEditObserver(state)) {
|
if (addItemEditObserver(state)) {
|
||||||
section.setComponentAddObserver(new
|
section.setComponentAddObserver(new ItemEditAddObserver(
|
||||||
ItemEditAddObserver(ControlEditor.this, state));
|
ControlEditor.this, state));
|
||||||
section.setFormContainer(new ColumnPanel(3));
|
section.setFormContainer(new ColumnPanel(3));
|
||||||
} else {
|
} else {
|
||||||
section.setFormContainer(new ColumnPanel(2));
|
section.setFormContainer(new ColumnPanel(2));
|
||||||
|
|
@ -337,31 +351,34 @@ public class ControlEditor extends SimpleContainer {
|
||||||
|
|
||||||
Form f = null;
|
Form f = null;
|
||||||
if (section instanceof PersistentForm) {
|
if (section instanceof PersistentForm) {
|
||||||
f = (Form)section.createComponent();
|
f = (Form) section.createComponent();
|
||||||
} else {
|
} else {
|
||||||
f = new Form("view_form", new ColumnPanel(1));
|
f = new Form("view_form", new ColumnPanel(1));
|
||||||
f.add((FormSection)section.createComponent());
|
f.add((FormSection) section.createComponent());
|
||||||
}
|
}
|
||||||
|
|
||||||
f.addInitListener(new PlaceholdersInitListener());
|
f.addInitListener(new PlaceholdersInitListener());
|
||||||
|
|
||||||
// Make the controls readonly
|
// Make the controls readonly
|
||||||
Traversal t = new Traversal() {
|
Traversal t = new Traversal() {
|
||||||
|
|
||||||
public void act(Component c) {
|
public void act(Component c) {
|
||||||
try {
|
try {
|
||||||
Widget widget = (Widget)c;
|
Widget widget = (Widget) c;
|
||||||
widget.setDisabled();
|
widget.setDisabled();
|
||||||
widget.setReadOnly();
|
widget.setReadOnly();
|
||||||
} catch (ClassCastException ex) {
|
} catch (ClassCastException ex) {
|
||||||
// Nada
|
// Nada
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
t.preorder(f);
|
t.preorder(f);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ItemEditAddObserver extends BaseEditAddObserver {
|
private class ItemEditAddObserver extends BaseEditAddObserver {
|
||||||
|
|
||||||
Component m_handler;
|
Component m_handler;
|
||||||
PageState m_state;
|
PageState m_state;
|
||||||
|
|
||||||
|
|
@ -375,7 +392,9 @@ public class ControlEditor extends SimpleContainer {
|
||||||
*
|
*
|
||||||
* @param dest
|
* @param dest
|
||||||
* @param component
|
* @param component
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
|
*
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
protected BaseLink createLink(String dest,
|
protected BaseLink createLink(String dest,
|
||||||
|
|
@ -431,7 +450,11 @@ public class ControlEditor extends SimpleContainer {
|
||||||
public void setControlEvent(PageState state) {
|
public void setControlEvent(PageState state) {
|
||||||
state.setControlEvent(m_handler, m_action, m_component);
|
state.setControlEvent(m_handler, m_action, m_component);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue