Search in sources :

Example 1 with TextBoxFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.

the class FormEditorHelperTest method testRemoveUnboundField.

protected void testRemoveUnboundField(boolean addToAvailables) {
    content.getDefinition().getFields().addAll(employeeFields);
    formEditorHelper.getAvailableFields().clear();
    TextBoxFieldDefinition textBoxFieldDefinition = new TextBoxFieldDefinition();
    formDefinition.getFields().add(textBoxFieldDefinition);
    formEditorHelper.removeField(textBoxFieldDefinition.getId(), true);
    Assertions.assertThat(formEditorHelper.getAvailableFields()).isNotNull().isEmpty();
}
Also used : TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)

Example 2 with TextBoxFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.

the class EditorFieldLayoutComponentTest method init.

@Before
public void init() {
    fieldManager = spy(new TestFieldManager());
    when(editorFieldLayoutComponents.get()).thenAnswer(invocationOnMock -> {
        final EditorFieldLayoutComponent mocked = mock(EditorFieldLayoutComponent.class);
        return mocked;
    });
    formEditorHelper = spy(new FormEditorHelper(new TestFieldManager(), editorFieldLayoutComponents, mock(SyncBeanManager.class)));
    fieldDefinition = new TextBoxFieldDefinition();
    fieldDefinition.setId(EditorFieldLayoutComponent.FIELD_ID);
    fieldDefinition.setName(EditorFieldLayoutComponent.FIELD_ID);
    fieldDefinition.setBinding(EditorFieldLayoutComponent.FIELD_ID);
    when(formDefinition.getId()).thenReturn(EditorFieldLayoutComponent.FORM_ID);
    when(formDefinition.getFieldById(anyString())).thenReturn(fieldDefinition);
    when(formDefinition.getModel()).thenReturn(formModel);
    when(context.getRootForm()).thenReturn(formDefinition);
    content = new FormModelerContent();
    content.setDefinition(formDefinition);
    content.setOverview(mock(Overview.class));
    formEditorHelper.initHelper(content);
    when(formEditorHelper.getRenderingContext()).thenReturn(context);
    when(formEditorHelper.getFormField(any())).thenReturn(fieldDefinition);
    layoutComponent.addProperty(EditorFieldLayoutComponent.FIELD_ID, EditorFieldLayoutComponent.FIELD_ID);
    layoutComponent.addProperty(EditorFieldLayoutComponent.FORM_ID, EditorFieldLayoutComponent.FORM_ID);
    ctx = new RenderingContext(layoutComponent, widget);
    when(fieldRendererManager.getRendererForField(any())).thenReturn(fieldRenderer);
    when(fieldRenderer.renderWidget()).thenReturn(widget);
    when(propertiesRenderer.getView()).thenReturn(fieldPropertiesRendererView);
    FormEditorContext.setActiveEditorHelper(formEditorHelper);
    editorFieldLayoutComponent = spy(new EditorFieldLayoutComponent(fieldRendererManager, translationService, propertiesRenderer, fieldManager, syncPaletteEvent));
    editorFieldLayoutComponent.initPropertiesConfig();
    propertiesRendererHelper = spy(editorFieldLayoutComponent.getPropertiesRendererHelper());
}
Also used : FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) RenderingContext(org.uberfire.ext.layout.editor.client.api.RenderingContext) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) SyncBeanManager(org.jboss.errai.ioc.client.container.SyncBeanManager) Overview(org.guvnor.common.services.shared.metadata.model.Overview) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper) Before(org.junit.Before)

Example 3 with TextBoxFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.

the class FormGeneratorDriverTest method init.

@Before
public void init() {
    when(beanManager.lookupBeans(Mockito.<String>any())).thenAnswer(invocationOnMock -> {
        SyncBeanDef beanDef = mock(SyncBeanDef.class);
        when(beanDef.getBeanClass()).thenReturn(FieldLayoutComponent.class);
        return Collections.singletonList(beanDef);
    });
    when(instance.select(any(Class.class))).thenAnswer(invocationOnMock -> {
        ManagedInstance<FieldLayoutComponent> nestedInstance = mock(ManagedInstance.class);
        FieldLayoutComponent component = mock(FieldLayoutComponent.class);
        when(component.getContentPart(any(), any())).thenReturn(Optional.of(mock(IsWidget.class)));
        when(nestedInstance.get()).thenReturn(component);
        return nestedInstance;
    });
    when(document.createElement(Mockito.<String>any())).thenAnswer(invocationOnMock -> mock(HTMLElement.class));
    driver = new FormGeneratorDriver(beanManager, instance, wrapperWidgetUtil, document) {

        @Override
        FieldDefinition getFieldForLayoutComponent(LayoutComponent layoutComponent) {
            return new TextBoxFieldDefinition();
        }

        @Override
        public FieldLayoutComponent getFieldLayoutComponentForField(FieldDefinition field) {
            return driver.getLayoutFields().get(0);
        }
    };
    driver.setRenderingContext(context);
}
Also used : HTMLElement(org.jboss.errai.common.client.dom.HTMLElement) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) LayoutComponent(org.uberfire.ext.layout.editor.api.editor.LayoutComponent) SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef) Before(org.junit.Before)

Example 4 with TextBoxFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.

the class FormLayoutTemplateGeneratorTest method init.

@Before
public void init() {
    templateGenerator = getTemplateGenerator();
    form = new FormDefinition();
    form.setName("Test");
    form.setId("Test-ID");
    TextBoxFieldDefinition name = new TextBoxFieldDefinition();
    name.setId("name");
    name.setName("employee_name");
    name.setLabel("Name");
    name.setPlaceHolder("Name");
    name.setBinding("name");
    name.setStandaloneClassName(String.class.getName());
    TextBoxFieldDefinition lastName = new TextBoxFieldDefinition();
    lastName.setId("lastName");
    lastName.setName("employee_lastName");
    lastName.setLabel("Last Name");
    lastName.setPlaceHolder("Last Name");
    lastName.setBinding("lastName");
    lastName.setStandaloneClassName(String.class.getName());
    DatePickerFieldDefinition birthday = new DatePickerFieldDefinition();
    birthday.setId("birthday");
    birthday.setName("employee_birthday");
    birthday.setLabel("Birthday");
    birthday.setBinding("birthday");
    birthday.setStandaloneClassName(Date.class.getName());
    CheckBoxFieldDefinition married = new CheckBoxFieldDefinition();
    married.setId("married");
    married.setName("employee_married");
    married.setLabel("Married");
    married.setBinding("married");
    married.setStandaloneClassName(Boolean.class.getName());
    form.getFields().add(name);
    form.getFields().add(lastName);
    form.getFields().add(birthday);
    form.getFields().add(married);
}
Also used : TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Date(java.util.Date) Before(org.junit.Before)

Example 5 with TextBoxFieldDefinition

use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition in project kie-wb-common by kiegroup.

the class FormLayoutTemplateGeneratorTest method testLayoutTemplateUpdate.

@Test
public void testLayoutTemplateUpdate() {
    testTemplateGeneration();
    TextBoxFieldDefinition address = new TextBoxFieldDefinition();
    address.setId("address");
    address.setName("employee_Address");
    address.setLabel("Address");
    address.setPlaceHolder("Address");
    address.setBinding("Address");
    address.setStandaloneClassName(String.class.getName());
    TextBoxFieldDefinition age = new TextBoxFieldDefinition();
    age.setId("age");
    age.setName("employee_age");
    age.setLabel("age");
    age.setPlaceHolder("age");
    age.setBinding("age");
    age.setStandaloneClassName(Integer.class.getName());
    List<FieldDefinition> newFields = new ArrayList<>();
    newFields.add(address);
    newFields.add(age);
    templateGenerator.updateLayoutTemplate(form, newFields);
    testGeneratedLayout();
}
Also used : TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)16 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)7 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)6 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)6 Test (org.junit.Test)5 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)4 Before (org.junit.Before)3 DecimalBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.decimalBox.definition.DecimalBoxFieldDefinition)3 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)3 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)3 FormModelerContent (org.kie.workbench.common.forms.editor.model.FormModelerContent)2 TextAreaFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textArea.definition.TextAreaFieldDefinition)2 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)2 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)2 FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)2 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)2 Mockito.anyString (org.mockito.Mockito.anyString)2