Search in sources :

Example 1 with SimpleFormPanel

use of org.activityinfo.ui.client.component.form.SimpleFormPanel in project activityinfo by bedatadriven.

the class RepeatingSubFormPanel method addForm.

private void addForm(final FormInstance instance, int panelIndex) {
    final SimpleFormPanel formPanel = new SimpleFormPanel(formModel.getLocator(), formModel.getStateProvider());
    formPanel.asWidget().addStyleName(FormPanelStyles.INSTANCE.subformPanel());
    formPanel.addDeleteButton().addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            panel.remove(formPanel);
            forms.remove(instance);
            if (loader.isPersisted(instance)) {
                // schedule deletion only if instance is persisted
                formModel.getPersistedInstanceToRemoveByLocator().add(instance);
            }
            getInstances().remove(instance);
            formModel.getChangedInstances().remove(instance);
            setDeleteButtonsState();
        }
    });
    formPanel.show(instance);
    forms.put(instance, formPanel);
    if (panelIndex == -1) {
        panel.add(formPanel);
    } else {
        panel.insert(formPanel, panelIndex);
    }
    setDeleteButtonsState();
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) SimpleFormPanel(org.activityinfo.ui.client.component.form.SimpleFormPanel)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 SimpleFormPanel (org.activityinfo.ui.client.component.form.SimpleFormPanel)1