01: package org.romaframework.aspect.view.echo2.layout.impl;
02:
03: import nextapp.echo2.app.Component;
04:
05: import org.romaframework.aspect.view.ViewConstants;
06: import org.romaframework.aspect.view.echo2.component.ComponentFactory;
07: import org.romaframework.aspect.view.echo2.form.AccordionForm;
08: import org.romaframework.aspect.view.form.ContentComponent;
09: import org.romaframework.aspect.view.form.ContentForm;
10: import org.romaframework.aspect.view.form.FormViewer;
11: import org.romaframework.aspect.view.layout.InvalidLayoutMode;
12: import org.romaframework.aspect.view.layout.LayoutMode;
13: import org.romaframework.aspect.view.screen.Screen;
14: import org.romaframework.core.flow.ObjectContext;
15: import org.romaframework.core.schema.SchemaAction;
16: import org.romaframework.core.schema.SchemaField;
17:
18: public class AccordionLayout implements LayoutMode<Component> {
19: public AccordionLayout() {
20: componentFactory = ObjectContext.getInstance().getComponent(
21: ComponentFactory.class);
22: }
23:
24: public String layoutClass(ContentForm iForm, Component iComponent,
25: String iWhere, Screen iDesktop) throws InvalidLayoutMode {
26: return FormViewer.getInstance().display(iWhere, iComponent,
27: iDesktop);
28: }
29:
30: public String layoutField(SchemaField iField, ContentForm iForm,
31: Component iComponent, String iMode)
32: throws InvalidLayoutMode {
33: try {
34: AccordionForm menu = (AccordionForm) iForm;
35: menu.getContainer().add(iComponent);
36: return null;
37: } catch (Throwable e) {
38: throw new InvalidLayoutMode(toString(), e);
39: }
40: }
41:
42: public String layoutAction(SchemaAction iAction, ContentForm iForm,
43: Component iComponent, String iMode)
44: throws InvalidLayoutMode {
45: try {
46: AccordionForm menu = (AccordionForm) iForm;
47: menu.getContainer().add(iComponent);
48: return null;
49: } catch (Throwable e) {
50: throw new InvalidLayoutMode(toString(), e);
51: }
52: }
53:
54: public ContentComponent getContainerForm(ContentComponent iForm) {
55: return iForm;
56: }
57:
58: public boolean renderOwnerField() {
59: return true;
60: }
61:
62: @Override
63: public String toString() {
64: return NAME;
65: }
66:
67: protected ComponentFactory componentFactory;
68:
69: public final static String NAME = ViewConstants.LAYOUT_ACCORDION;
70: }
|