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