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 PropertySetTest method fillTestSolution.
@Override
protected void fillTestSolution() throws ServoyException {
Form form = solution.createNewForm(validator, null, "test", null, false, new Dimension(600, 400));
form.setNavigatorID(-2);
com.servoy.j2db.persistence.WebComponent bean = form.createNewWebComponent("mycustombean", "mycomponent");
bean.setProperty("background", Color.black);
}
use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.
the class NGClient method changesWillBeSend.
@Override
public void changesWillBeSend() {
reloadClientFunctionsSend = false;
if (toRecreate.size() > 0) {
NGClientWebsocketSessionWindows allWindowsProxy = new NGClientWebsocketSessionWindows(getWebsocketSession());
for (Pair<Form, String> pair : toRecreate) {
IFormHTMLAndJSGenerator generator = getWebsocketSession().getFormHTMLAndJSGenerator(pair.getLeft(), pair.getRight());
allWindowsProxy.updateForm(pair.getLeft(), pair.getRight(), generator);
}
toRecreate.clear();
}
if (showUrl != null) {
this.getWebsocketSession().getClientService(NGClient.APPLICATION_SERVICE).executeAsyncServiceCall("showUrl", new Object[] { showUrl.url, showUrl.target, showUrl.target_options, Integer.valueOf(showUrl.timeout) });
showUrl = null;
}
}
use of com.servoy.j2db.persistence.Form in project servoy-client by Servoy.
the class NGClientEntryFilter method getFormScriptReferences.
/**
* Get form script references, useful for debugging
* @param fs the flattened solution
* @return the form script contributions
*/
private Collection<String> getFormScriptReferences(FlattenedSolution fs) {
List<String> formScripts = new ArrayList<>();
if (Boolean.valueOf(System.getProperty("servoy.generateformscripts", "false")).booleanValue()) {
Iterator<Form> it = fs.getForms(false);
while (it.hasNext()) {
Form form = it.next();
Solution sol = (Solution) form.getAncestor(SOLUTIONS);
formScripts.add("solutions/" + sol.getName() + "/forms/" + form.getName() + ".js");
}
}
return formScripts;
}
Aggregations