Search in sources :

Example 1 with FormController

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

the class WebSplitPane method setForm.

public boolean setForm(boolean bLeftForm, Object form, Object relation) {
    FormController f = null;
    String fName = null;
    boolean readOnly = false;
    if (form instanceof FormController) {
        f = (FormController) form;
        readOnly = f.isReadOnly();
    }
    if (form instanceof BasicFormController.JSForm) {
        f = (FormController) ((BasicFormController.JSForm) form).getFormPanel();
        readOnly = f.isReadOnly();
    }
    if (f != null)
        fName = f.getName();
    if (form instanceof String)
        fName = (String) form;
    if (fName != null) {
        String tabname = fName;
        RelatedFoundSet relatedFs = null;
        String relationName = null;
        if (relation instanceof RelatedFoundSet) {
            relatedFs = (RelatedFoundSet) relation;
        } else if (relation instanceof String) {
            relationName = (String) relation;
        }
        if (relatedFs != null) {
            relationName = relatedFs.getRelationName();
            if (f != null && !relatedFs.getDataSource().equals(f.getDataSource())) {
                return false;
            }
        // TODO do this check to check if the parent table has this relation? How to get the parent table
        // Table parentTable = null;
        // application.getSolution().getRelations(Solution.SOLUTION+Solution.MODULES, parentTable, true, false);
        }
        IFormLookupPanel replacedForm = bLeftForm ? getLeftForm() : getRightForm();
        if (replacedForm != null) {
            List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
            boolean bNotifyVisibleForm = notifyVisibleForm(false, bLeftForm ? 0 : 1, invokeLaterRunnables);
            Utils.invokeLater(application, invokeLaterRunnables);
            if (!bNotifyVisibleForm)
                return false;
        }
        WebTabFormLookup flp = (WebTabFormLookup) createFormLookupPanel(tabname, relationName, fName);
        if (f != null)
            flp.setReadOnly(readOnly);
        if (bLeftForm)
            setLeftForm(flp);
        else
            setRightForm(flp);
        if (relatedFs != null) {
            FormController fp = flp.getWebForm().getController();
            if (fp != null && flp.getRelationName() != null && flp.getRelationName().equals(relationName)) {
                fp.loadData(relatedFs, null);
            }
        }
        List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
        boolean bNotifyVisibleForm = notifyVisibleForm(true, bLeftForm ? 0 : 1, invokeLaterRunnables);
        Utils.invokeLater(application, invokeLaterRunnables);
        if (bNotifyVisibleForm) {
            paneChanged[bLeftForm ? 0 : 1] = true;
        }
        return bNotifyVisibleForm;
    } else if (form == null) {
        IFormLookupPanel replacedForm = bLeftForm ? getLeftForm() : getRightForm();
        if (replacedForm != null) {
            List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
            boolean bNotifyVisibleForm = notifyVisibleForm(false, bLeftForm ? 0 : 1, invokeLaterRunnables);
            Utils.invokeLater(application, invokeLaterRunnables);
            if (!bNotifyVisibleForm)
                return false;
        }
        splitComponents[bLeftForm ? 0 : 1].replace(new Label("webform", new Model<String>("")));
        webTabs[bLeftForm ? 0 : 1] = null;
        paneChanged[bLeftForm ? 0 : 1] = true;
        return true;
    }
    return false;
}
Also used : FormController(com.servoy.j2db.FormController) BasicFormController(com.servoy.j2db.BasicFormController) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel) RelatedFoundSet(com.servoy.j2db.dataprocessing.RelatedFoundSet) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with FormController

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

the class WebTabFormLookup method notifyVisible.

public boolean notifyVisible(boolean b, List invokeLaterRunnables) {
    if (isReady()) {
        IFormUIInternal ui = webForm;
        FormController child = ui.getController();
        return child.notifyVisible(b, invokeLaterRunnables);
    }
    return true;
}
Also used : FormController(com.servoy.j2db.FormController) IFormUIInternal(com.servoy.j2db.IFormUIInternal)

Example 3 with FormController

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

the class WebTabFormLookup method getWebForm.

private WebForm getWebForm(boolean removeFromParent) {
    if (webForm != null && webForm.isDestroyed()) {
        webForm = null;
    }
    if (webForm == null) {
        FormManager fm = (FormManager) application.getFormManager();
        FormController fc = fm.getFormController(formName, this);
        if (fc == null) {
            fc = fm.leaseFormPanel(formName);
        }
        if (fc != null) {
            // delegate readOnly, really set it once from the form manager state
            fc.setReadOnly(fm.isFormReadOnly(formName));
            webForm = (WebForm) fc.getFormUI();
            if (removeFromParent && webForm.getParent() != null && webForm.getParent() != parent) {
                webForm.remove();
            }
        }
    }
    return webForm;
}
Also used : FormController(com.servoy.j2db.FormController) FormManager(com.servoy.j2db.FormManager)

Example 4 with FormController

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

the class WebTabPanel method showFoundSet.

protected void showFoundSet(WebTabFormLookup flp, IRecordInternal parentState, List<SortColumn> sort) {
    deregisterSelectionListeners();
    if (!flp.isReady())
        return;
    FormController fp = flp.getWebForm().getController();
    if (fp != null && flp.getRelationName() != null) {
        IFoundSetInternal relatedFoundset = parentState == null ? null : parentState.getRelatedFoundSet(flp.getRelationName(), sort);
        registerSelectionListeners(parentState, flp.getRelationName());
        fp.loadData(relatedFoundset, null);
    }
    ITagResolver resolver = getTagResolver(parentState);
    // refresh tab text
    for (int i = 0; i < allTabs.size(); i++) {
        WebTabHolder element = allTabs.get(i);
        if (element.getPanel() == flp) {
            element.refreshTagStrings(resolver);
            break;
        }
    }
}
Also used : FormController(com.servoy.j2db.FormController) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) ITagResolver(com.servoy.base.util.ITagResolver) Point(java.awt.Point)

Example 5 with FormController

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

the class WebTabPanel method notifyResized.

public void notifyResized() {
    if (currentForm != null && currentForm.isReady()) {
        WebForm webForm = currentForm.getWebForm();
        FormController controller = webForm.getController();
        if (controller != null && webForm.isFormWidthHeightChanged()) {
            controller.notifyResized();
            webForm.clearFormWidthHeightChangedFlag();
        }
    }
}
Also used : FormController(com.servoy.j2db.FormController) WebForm(com.servoy.j2db.server.headlessclient.WebForm)

Aggregations

FormController (com.servoy.j2db.FormController)70 FormManager (com.servoy.j2db.FormManager)15 Form (com.servoy.j2db.persistence.Form)13 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)12 RepositoryException (com.servoy.j2db.persistence.RepositoryException)10 Point (java.awt.Point)10 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)9 ArrayList (java.util.ArrayList)9 IFormController (com.servoy.j2db.IFormController)8 BasicFormController (com.servoy.j2db.BasicFormController)7 IForm (com.servoy.j2db.IForm)7 WebForm (com.servoy.j2db.server.headlessclient.WebForm)7 FlattenedSolution (com.servoy.j2db.FlattenedSolution)6 IFormUIInternal (com.servoy.j2db.IFormUIInternal)5 IDataProvider (com.servoy.j2db.persistence.IDataProvider)5 List (java.util.List)5 ApplicationException (com.servoy.j2db.ApplicationException)4 IMainContainer (com.servoy.j2db.IMainContainer)4 PrototypeState (com.servoy.j2db.dataprocessing.PrototypeState)4 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)4