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