Search in sources :

Example 6 with RelatedFoundSet

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

the class SpecialSplitPane 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 FormController.JSForm) {
        f = (FormController) ((FormController.JSForm) form).getFormPanel();
        readOnly = f.isReadOnly();
    }
    if (f != null)
        fName = f.getName();
    if (form instanceof String)
        fName = (String) form;
    if (fName != null) {
        String name = 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, (FormLookupPanel) replacedForm, invokeLaterRunnables);
            Utils.invokeLater(application, invokeLaterRunnables);
            if (!bNotifyVisibleForm)
                return false;
        }
        FormLookupPanel flp = createFormLookupPanel(name, relationName, fName);
        if (f != null)
            flp.setReadOnly(readOnly);
        if (bLeftForm)
            setLeftForm(flp);
        else
            setRightForm(flp);
        if (relatedFs != null) {
            FormController fp = flp.getFormPanel();
            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, flp, invokeLaterRunnables);
        Utils.invokeLater(application, invokeLaterRunnables);
        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, (FormLookupPanel) replacedForm, invokeLaterRunnables);
            Utils.invokeLater(application, invokeLaterRunnables);
            if (!bNotifyVisibleForm)
                return false;
        }
        if (bLeftForm)
            setLeftForm(null);
        else
            setRightForm(null);
        return true;
    }
    return false;
}
Also used : FormController(com.servoy.j2db.FormController) RelatedFoundSet(com.servoy.j2db.dataprocessing.RelatedFoundSet) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel) IFormLookupPanel(com.servoy.j2db.ui.IFormLookupPanel)

Example 7 with RelatedFoundSet

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

the class FormManager method ifRootFormInFind.

private boolean ifRootFormInFind(FormController fc) {
    boolean result = false;
    if (fc.isFormVisible() && fc.isInFindMode()) {
        IFoundSetInternal foundSet = fc.getFoundSet();
        if (foundSet instanceof RelatedFoundSet) {
            // see if any parent foundset is in find mode; if not, then add it as root
            // form in find mode
            List<IRecordInternal> parentRecords = ((RelatedFoundSet) foundSet).getParents();
            boolean hasParentsInFindMode = false;
            for (IRecordInternal record : parentRecords) {
                IFoundSetInternal parentFoundSet = record.getParentFoundSet();
                if (parentFoundSet instanceof FoundSet && ((FoundSet) parentFoundSet).isInFindMode()) {
                    hasParentsInFindMode = true;
                    break;
                }
            }
            if (!hasParentsInFindMode) {
                result = true;
            }
        } else {
            result = true;
        }
    }
    return result;
}
Also used : IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) RelatedFoundSet(com.servoy.j2db.dataprocessing.RelatedFoundSet) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) RelatedFoundSet(com.servoy.j2db.dataprocessing.RelatedFoundSet) FoundSet(com.servoy.j2db.dataprocessing.FoundSet)

Aggregations

RelatedFoundSet (com.servoy.j2db.dataprocessing.RelatedFoundSet)7 RepositoryException (com.servoy.j2db.persistence.RepositoryException)3 BasicFormController (com.servoy.j2db.BasicFormController)2 FormController (com.servoy.j2db.FormController)2 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)2 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)2 IFormLookupPanel (com.servoy.j2db.ui.IFormLookupPanel)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JSFunction (org.mozilla.javascript.annotations.JSFunction)2 IForm (com.servoy.j2db.IForm)1 FoundSet (com.servoy.j2db.dataprocessing.FoundSet)1 PrototypeState (com.servoy.j2db.dataprocessing.PrototypeState)1 IDataProvider (com.servoy.j2db.persistence.IDataProvider)1 LiteralDataprovider (com.servoy.j2db.persistence.LiteralDataprovider)1 Portal (com.servoy.j2db.persistence.Portal)1 Relation (com.servoy.j2db.persistence.Relation)1 Tab (com.servoy.j2db.persistence.Tab)1 Point (java.awt.Point)1 Label (org.apache.wicket.markup.html.basic.Label)1