Search in sources :

Example 1 with WidgetContainer

use of org.activityinfo.ui.client.component.formdesigner.container.WidgetContainer in project activityinfo by bedatadriven.

the class DropPanelDropController method updateModel.

private void updateModel(Widget draggable, DropController dropController) {
    DropPanelDropController panelDropController = (DropPanelDropController) dropController;
    for (WidgetContainer container : getAllContainers()) {
        if (draggable.equals(container.asWidget())) {
            if (container instanceof FieldWidgetContainer) {
                FormField formField = ((FieldWidgetContainer) container).getFormField();
                removeFromSourceFormClass(formField);
                insertIntoTargetFormClass(panelDropController, container, formField);
            } else if (container instanceof FieldsHolderWidgetContainer) {
                FieldsHolderWidgetContainer fieldsHolderContainer = (FieldsHolderWidgetContainer) container;
                if (fieldsHolderContainer.isSubform()) {
                    // subform
                    FormClass subForm = (FormClass) fieldsHolderContainer.getElementContainer();
                    FormField subformOwnerField = formDesigner.getModel().getSubformOwnerField(subForm);
                    removeFromSourceFormClass(subformOwnerField);
                    insertIntoTargetFormClass(panelDropController, container, subformOwnerField);
                } else {
                    // form section
                    FormSection formSection = (FormSection) fieldsHolderContainer.getElementContainer();
                    FormClass sourceFormClass = formDesigner.getModel().getFormClassByElementId(formSection.getId());
                    sourceFormClass.remove(formSection);
                    insertIntoTargetFormClass(panelDropController, container, formSection);
                }
            }
        }
    }
}
Also used : FieldWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.FieldWidgetContainer) WidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.WidgetContainer) FieldsHolderWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.FieldsHolderWidgetContainer) FieldWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.FieldWidgetContainer) LabelWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.LabelWidgetContainer) FieldsHolderWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.FieldsHolderWidgetContainer)

Example 2 with WidgetContainer

use of org.activityinfo.ui.client.component.formdesigner.container.WidgetContainer in project activityinfo by bedatadriven.

the class FieldEditor method start.

public void start(FormDesigner formDesigner) {
    this.formDesigner = formDesigner;
    formDesigner.getEventBus().addHandler(WidgetContainerSelectionEvent.TYPE, event -> {
        WidgetContainer widgetContainer = event.getSelectedItem();
        if (widgetContainer instanceof FieldWidgetContainer) {
            show((FieldWidgetContainer) widgetContainer);
        }
    });
}
Also used : FieldWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.FieldWidgetContainer) WidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.WidgetContainer) FieldWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.FieldWidgetContainer)

Example 3 with WidgetContainer

use of org.activityinfo.ui.client.component.formdesigner.container.WidgetContainer in project activityinfo by bedatadriven.

the class FormDesignerPanel method fillPanel.

private void fillPanel(final FormClass formClass, final FormDesigner formDesigner) {
    formClass.traverse(formClass, new TraverseFunction() {

        @Override
        public void apply(FormElement element, FormElementContainer container) {
            if (isSubFormKey(formClass, element)) {
            // NOOP
            } else if (element instanceof FormField) {
                FormField formField = (FormField) element;
                WidgetContainer widgetContainer = containerMap.get(formField.getId());
                if (widgetContainer != null) {
                    // widget container may be null if domain is not supported, should be removed later
                    Widget widget = widgetContainer.asWidget();
                    formDesigner.getDragController().makeDraggable(widget, widgetContainer.getDragHandle());
                    FlowPanel parentDropPanel = (FlowPanel) formDesigner.getDropControllerRegistry().getDropController(widgetContainer.getParentId()).getDropTarget();
                    parentDropPanel.add(widget);
                }
                if (formField.getType() instanceof SubFormReferenceType) {
                    ResourceId subFormId = ((SubFormReferenceType) formField.getType()).getClassId();
                    FormClass subForm = (FormClass) formDesigner.getModel().getElementContainer(subFormId);
                    if (subForm == null) {
                        throw new IllegalStateException("Subform " + subFormId + " does not exist.");
                    }
                    fillPanel(subForm, formDesigner);
                }
            } else if (element instanceof FormSection) {
                FormSection section = (FormSection) element;
                WidgetContainer widgetContainer = containerMap.get(section.getId());
                Widget widget = widgetContainer.asWidget();
                formDesigner.getDragController().makeDraggable(widget, widgetContainer.getDragHandle());
                dropPanel.add(widget);
            } else if (element instanceof FormLabel) {
                FormLabel label = (FormLabel) element;
                WidgetContainer widgetContainer = containerMap.get(label.getId());
                Widget widget = widgetContainer.asWidget();
                formDesigner.getDragController().makeDraggable(widget, widgetContainer.getDragHandle());
                dropPanel.add(widget);
            } else {
                throw new UnsupportedOperationException("Unknown form element.");
            }
        }
    });
}
Also used : FormFieldWidget(org.activityinfo.ui.client.component.form.field.FormFieldWidget) SubFormReferenceType(org.activityinfo.model.type.subform.SubFormReferenceType) ResourceId(org.activityinfo.model.resource.ResourceId) WidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.WidgetContainer) FieldsHolderWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.FieldsHolderWidgetContainer) FieldWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.FieldWidgetContainer) LabelWidgetContainer(org.activityinfo.ui.client.component.formdesigner.container.LabelWidgetContainer)

Aggregations

FieldWidgetContainer (org.activityinfo.ui.client.component.formdesigner.container.FieldWidgetContainer)3 WidgetContainer (org.activityinfo.ui.client.component.formdesigner.container.WidgetContainer)3 FieldsHolderWidgetContainer (org.activityinfo.ui.client.component.formdesigner.container.FieldsHolderWidgetContainer)2 LabelWidgetContainer (org.activityinfo.ui.client.component.formdesigner.container.LabelWidgetContainer)2 ResourceId (org.activityinfo.model.resource.ResourceId)1 SubFormReferenceType (org.activityinfo.model.type.subform.SubFormReferenceType)1 FormFieldWidget (org.activityinfo.ui.client.component.form.field.FormFieldWidget)1