Search in sources :

Example 11 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 12 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 13 with Form

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);
}
Also used : Form(com.servoy.j2db.persistence.Form) Dimension(java.awt.Dimension)

Example 14 with Form

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;
    }
}
Also used : Form(com.servoy.j2db.persistence.Form) NGClientWebsocketSessionWindows(com.servoy.j2db.server.ngclient.eventthread.NGClientWebsocketSessionWindows) IFormHTMLAndJSGenerator(com.servoy.j2db.server.ngclient.INGClientWindow.IFormHTMLAndJSGenerator)

Example 15 with Form

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;
}
Also used : Form(com.servoy.j2db.persistence.Form) ArrayList(java.util.ArrayList) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Solution(com.servoy.j2db.persistence.Solution)

Aggregations

Form (com.servoy.j2db.persistence.Form)146 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)35 ArrayList (java.util.ArrayList)32 Point (java.awt.Point)26 FlattenedSolution (com.servoy.j2db.FlattenedSolution)24 IPersist (com.servoy.j2db.persistence.IPersist)22 ISMForm (com.servoy.j2db.solutionmodel.ISMForm)20 JSONObject (org.json.JSONObject)20 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 HashMap (java.util.HashMap)11 JSFunction (org.mozilla.javascript.annotations.JSFunction)11