Search in sources :

Example 1 with Form

use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.

the class EventCallTest method fillTestSolution.

@Override
protected void fillTestSolution() throws ServoyException {
    Form form = solution.createNewForm(validator, null, "test", null, false, new Dimension(600, 400));
    form.setNavigatorID(-1);
    form.createNewScriptVariable(DummyValidator.INSTANCE, "testVar", IColumnTypes.INTEGER);
    GraphicalComponent button = form.createNewGraphicalComponent(new Point(10, 10));
    button.setShowClick(true);
    button.setShowFocus(true);
    ScriptMethod sm = form.createNewScriptMethod(DummyValidator.INSTANCE, "test");
    sm.setDeclaration("function test() {testVar = 10}");
    button.setOnActionMethodID(sm.getID());
    form.createNewScriptVariable(DummyValidator.INSTANCE, "testVar2", IColumnTypes.TEXT);
    GraphicalComponent button2 = form.createNewGraphicalComponent(new Point(10, 10));
    button2.setName(uuid);
    button2.setShowClick(true);
    button2.setShowFocus(true);
    ScriptMethod sm2 = form.createNewScriptMethod(DummyValidator.INSTANCE, "test2");
    sm2.setDeclaration("function test2() {testVar2 = elements['" + uuid + "'].getName()}");
    button2.setOnActionMethodID(sm2.getID());
}
Also used : Form(com.servoy.j2db.persistence.Form) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) Dimension(java.awt.Dimension) Point(java.awt.Point) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod)

Example 2 with Form

use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.

the class PersistFieldInstanceTest method testTabPanelWithTabs.

@Test
public void testTabPanelWithTabs() throws RepositoryException {
    Form form = solution.getForm("test");
    Assert.assertNotNull(form);
    Form tabForm = solution.createNewForm(validator, null, "tabform", null, false, new Dimension(600, 400));
    tabForm.setNavigatorID(-1);
    DataAdapterList dataAdapterList = new DataAdapterList(new TestFormController(tabForm, client));
    TabPanel tabpanel = form.createNewTabPanel("tabpanel");
    tabpanel.createNewTab("tab1", null, tabForm);
    tabpanel.createNewTab("tab2", null, tabForm);
    List<FormElement> formElements = FormElementHelper.INSTANCE.getFormElements(form.getAllObjects(), new ServoyDataConverterContext(client));
    Assert.assertEquals(1, formElements.size());
    WebFormComponent wc = ComponentFactory.createComponent(client, dataAdapterList, formElements.get(0), null, form);
    List<Map<String, Object>> tabs = (List) wc.getProperty("tabs");
    Assert.assertEquals(2, tabs.size());
    Map<String, Object> map = tabs.get(1);
    Assert.assertSame(tabForm.getName(), map.get("containsFormId"));
}
Also used : TabPanel(com.servoy.j2db.persistence.TabPanel) Form(com.servoy.j2db.persistence.Form) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) IDataAdapterList(com.servoy.j2db.server.ngclient.IDataAdapterList) DataAdapterList(com.servoy.j2db.server.ngclient.DataAdapterList) Dimension(java.awt.Dimension) FormElement(com.servoy.j2db.server.ngclient.FormElement) ServoyDataConverterContext(com.servoy.j2db.server.ngclient.ServoyDataConverterContext) ValueList(com.servoy.j2db.persistence.ValueList) IDataAdapterList(com.servoy.j2db.server.ngclient.IDataAdapterList) CustomValueList(com.servoy.j2db.dataprocessing.CustomValueList) IValueList(com.servoy.j2db.dataprocessing.IValueList) List(java.util.List) DataAdapterList(com.servoy.j2db.server.ngclient.DataAdapterList) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 3 with Form

use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.

the class PersistFieldInstanceTest method testSettingTextOfTabInTabpanel.

@Test
public void testSettingTextOfTabInTabpanel() throws RepositoryException, JSONException {
    Form form = solution.getForm("test");
    Assert.assertNotNull(form);
    DataAdapterList dataAdapterList = new DataAdapterList(new TestFormController(form, client));
    Form tabForm = solution.createNewForm(validator, null, "tabform", null, false, new Dimension(600, 400));
    tabForm.setNavigatorID(-1);
    TabPanel tabpanel = form.createNewTabPanel("tabpanel");
    tabpanel.createNewTab("tab1", null, tabForm);
    tabpanel.createNewTab("tab2", null, tabForm);
    List<FormElement> formElements = FormElementHelper.INSTANCE.getFormElements(form.getAllObjects(), new ServoyDataConverterContext(client));
    Assert.assertEquals(1, formElements.size());
    WebFormComponent wc = ComponentFactory.createComponent(client, dataAdapterList, formElements.get(0), null, form);
    TypedData<Map<String, Object>> changes = wc.getAndClearChanges();
    Assert.assertEquals(0, changes.content.size());
    List<Map<String, Object>> tabs = (List) wc.getProperty("tabs");
    Assert.assertEquals(2, tabs.size());
    Map<String, Object> map = tabs.get(0);
    map.put("text", new BasicTagStringTypeSabloValue("a test", null));
    changes = wc.getAndClearChanges();
    Assert.assertEquals(1, changes.content.size());
    String json = JSONUtils.writeChangesWithConversions(changes.content, changes.contentType, null);
    JSONAssert.assertEquals("{\"tabs\":{\"vEr\":1,\"g\":[{\"op\":[0,0,0],\"d\":[{\"rt\":\"servoydefault-tabpanel.tab\",\"vEr\":1,\"u\":[{\"k\":\"text\",\"v\":\"a test\"}]}],\"svy_types\":{\"0\":\"JSON_obj\"}}]},\"svy_types\":{\"tabs\":\"JSON_arr\"}}", json, true);
}
Also used : TabPanel(com.servoy.j2db.persistence.TabPanel) BasicTagStringTypeSabloValue(com.servoy.j2db.server.ngclient.property.types.BasicTagStringTypeSabloValue) Form(com.servoy.j2db.persistence.Form) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) IDataAdapterList(com.servoy.j2db.server.ngclient.IDataAdapterList) DataAdapterList(com.servoy.j2db.server.ngclient.DataAdapterList) Dimension(java.awt.Dimension) FormElement(com.servoy.j2db.server.ngclient.FormElement) ServoyDataConverterContext(com.servoy.j2db.server.ngclient.ServoyDataConverterContext) ValueList(com.servoy.j2db.persistence.ValueList) IDataAdapterList(com.servoy.j2db.server.ngclient.IDataAdapterList) CustomValueList(com.servoy.j2db.dataprocessing.CustomValueList) IValueList(com.servoy.j2db.dataprocessing.IValueList) List(java.util.List) DataAdapterList(com.servoy.j2db.server.ngclient.DataAdapterList) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 4 with Form

use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.

the class PersistFieldInstanceTest method testFieldWithValueList.

@Test
public void testFieldWithValueList() throws RepositoryException {
    Form form = solution.getForm("test");
    Assert.assertNotNull(form);
    ValueList vl = solution.getValueList("test");
    Assert.assertNotNull(vl);
    Field field = form.createNewField(new Point(0, 0));
    field.setDataProviderID("mycolumn");
    field.setFormat("#,###.00");
    field.setDisplayType(Field.TYPE_AHEAD);
    field.setValuelistID(vl.getID());
    // needed for a valuelist property type that searches it's form's table via the webform ui
    WebFormUI formUI = new WebFormUI(client.getFormManager().getForm(form.getName()));
    IDataAdapterList dataAdapterList = formUI.getDataAdapterList();
    List<FormElement> formElements = FormElementHelper.INSTANCE.getFormElements(form.getAllObjects(), new ServoyDataConverterContext(client));
    Assert.assertEquals(1, formElements.size());
    WebFormComponent wc = ComponentFactory.createComponent(client, dataAdapterList, formElements.get(0), formUI, form);
    Object property = wc.getProperty("valuelistID");
    Assert.assertTrue(property != null ? property.getClass().getName() : "null", property instanceof ValueListTypeSabloValue && ((ValueListTypeSabloValue) property).getValueList() instanceof CustomValueList);
    Assert.assertEquals("#,###.00", ((CustomValueList) ((ValueListTypeSabloValue) property).getValueList()).getFormat().getDisplayFormat());
}
Also used : CustomValueList(com.servoy.j2db.dataprocessing.CustomValueList) Form(com.servoy.j2db.persistence.Form) ValueList(com.servoy.j2db.persistence.ValueList) CustomValueList(com.servoy.j2db.dataprocessing.CustomValueList) IValueList(com.servoy.j2db.dataprocessing.IValueList) ValueListTypeSabloValue(com.servoy.j2db.server.ngclient.property.types.ValueListTypeSabloValue) WebFormComponent(com.servoy.j2db.server.ngclient.WebFormComponent) Point(java.awt.Point) FormElement(com.servoy.j2db.server.ngclient.FormElement) Field(com.servoy.j2db.persistence.Field) WebFormUI(com.servoy.j2db.server.ngclient.WebFormUI) ServoyDataConverterContext(com.servoy.j2db.server.ngclient.ServoyDataConverterContext) IDataAdapterList(com.servoy.j2db.server.ngclient.IDataAdapterList) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) Test(org.junit.Test)

Example 5 with Form

use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.

the class TabPanelTest method fillTestSolution.

/*
	 * @see com.servoy.j2db.server.ngclient.property.AbstractSolutionTest#fillTestSolution()
	 */
@Override
protected void fillTestSolution() throws ServoyException {
    Form f1 = solution.createNewForm(validator, null, "f1", null, false, new Dimension(600, 400));
    f1.setNavigatorID(-1);
    Form f2 = solution.createNewForm(validator, null, "f2", null, false, new Dimension(600, 400));
    Form f3 = solution.createNewForm(validator, null, "f3", null, false, new Dimension(600, 400));
    Form f4 = solution.createNewForm(validator, null, "f4", null, false, new Dimension(600, 400));
    TabPanel tabpanelF2 = f1.createNewTabPanel("tabpanel");
    tabpanelF2.createNewTab("tab1", "relation2", f2);
    tabpanelF2.createNewTab("tab2", "relation3", f3);
    tabpanelF2.createNewTab("tab3", "relation4", f4);
}
Also used : TabPanel(com.servoy.j2db.persistence.TabPanel) Form(com.servoy.j2db.persistence.Form) Dimension(java.awt.Dimension)

Aggregations

Form (com.servoy.j2db.persistence.Form)145 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)34 ArrayList (java.util.ArrayList)31 Point (java.awt.Point)25 FlattenedSolution (com.servoy.j2db.FlattenedSolution)24 IPersist (com.servoy.j2db.persistence.IPersist)22 ISMForm (com.servoy.j2db.solutionmodel.ISMForm)20 JSONObject (org.json.JSONObject)19 Solution (com.servoy.j2db.persistence.Solution)16 Dimension (java.awt.Dimension)15 Part (com.servoy.j2db.persistence.Part)14 RepositoryException (com.servoy.j2db.persistence.RepositoryException)14 FormController (com.servoy.j2db.FormController)13 WebFormComponent (com.servoy.j2db.server.ngclient.WebFormComponent)12 IMobileSMForm (com.servoy.base.solutionmodel.mobile.IMobileSMForm)11 IForm (com.servoy.j2db.IForm)11 ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)11 FormElement (com.servoy.j2db.server.ngclient.FormElement)11 JSFunction (org.mozilla.javascript.annotations.JSFunction)11 JSForm (com.servoy.j2db.scripting.solutionmodel.JSForm)10