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);
}
}
}
}
}
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);
}
});
}
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.");
}
}
});
}
Aggregations