Search in sources :

Example 46 with IFoundSetInternal

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

the class WebSplitPane method showFoundSet.

private 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);
    }
}
Also used : FormController(com.servoy.j2db.FormController) BasicFormController(com.servoy.j2db.BasicFormController) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal)

Example 47 with IFoundSetInternal

use of com.servoy.j2db.dataprocessing.IFoundSetInternal 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)

Example 48 with IFoundSetInternal

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

the class RowReferencePropertyType method toRhinoValue.

@Override
public Object toRhinoValue(final String webComponentValue, PropertyDescription pd, IWebObjectContext componentOrService, Scriptable startScriptable) {
    // TODO change this to another function class as it's not a call-to-client function in it's javadoc maybe? this is actually all on server
    return new WebBaseFunction(null) {

        @Override
        public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
            IRecordInternal record = null;
            if (args != null && args.length == 1 && args[0] instanceof IFoundSetInternal) {
                Pair<String, Integer> splitHashAndIndex = FoundsetTypeSabloValue.splitPKHashAndIndex(webComponentValue);
                int recordIndex = ((IFoundSetInternal) args[0]).getRecordIndex(splitHashAndIndex.getLeft(), splitHashAndIndex.getRight().intValue());
                if (recordIndex != -1)
                    record = ((IFoundSetInternal) args[0]).getRecord(recordIndex);
            }
            return record;
        }
    };
}
Also used : Context(org.mozilla.javascript.Context) IWebObjectContext(org.sablo.IWebObjectContext) IBrowserConverterContext(org.sablo.specification.property.IBrowserConverterContext) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) WebBaseFunction(com.servoy.j2db.server.ngclient.scripting.WebBaseFunction) Scriptable(org.mozilla.javascript.Scriptable)

Example 49 with IFoundSetInternal

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

the class WebForm method printXML.

/**
 * @see com.servoy.j2db.IFormUIInternal#printXML(boolean)
 */
public String printXML(boolean printCurrentRecordOnly) {
    IApplication application = formController.getApplication();
    IFoundSetInternal fs = formController.getFoundSet();
    try {
        if (printCurrentRecordOnly) {
            fs = fs.copyCurrentRecordFoundSet();
        }
        FormPreviewPanel fpp = new FormPreviewPanel(application, formController, fs);
        // AWT stuff happens here, so execute it in the AWT Event Thread - else exceptions can occur
        // for example in JEditorPane while getting the preferred size & stuff
        processFppInAWTEventQueue(fpp, application);
        StringWriter w = new StringWriter();
        ((PageList) fpp.getPageable()).toXML(w);
        fpp.destroy();
        return w.toString();
    } catch (Throwable ex) {
        // $NON-NLS-1$
        application.reportError(application.getI18NMessage("servoy.formPanel.error.printDocument"), ex);
    }
    return null;
}
Also used : IApplication(com.servoy.j2db.IApplication) StringWriter(java.io.StringWriter) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) FormPreviewPanel(com.servoy.j2db.printing.FormPreviewPanel) PageList(com.servoy.j2db.printing.PageList)

Example 50 with IFoundSetInternal

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

the class WebFormManager method reload.

public void reload(FormController[] fcontrollers) {
    HashSet<MainPage> mainPages = new HashSet<MainPage>();
    for (FormController fc : fcontrollers) {
        WebForm formUI = (WebForm) fc.getFormUI();
        MainPage mp = formUI.findParent(MainPage.class);
        if (mp != null && mainPages.add(mp)) {
            mp.setVersioned(false);
            mp.setMainPageSwitched();
        }
    }
    String navigatorName = null;
    Set<MainPage> parents = new HashSet<MainPage>();
    for (FormController fp : fcontrollers) {
        if (fp != null) {
            boolean formVisible = fp.isFormVisible();
            IFoundSetInternal foundset = fp.getFormModel();
            WebForm wf = (WebForm) fp.getFormUI();
            MarkupContainer wfParent = wf.getParent();
            boolean refresh = false;
            // datasource has changed, but foundset has not
            if (foundset != null && !Utils.equalObjects(foundset.getDataSource(), fp.getDataSource())) {
                try {
                    foundset = (getApplication()).getFoundSetManager().getSharedFoundSet(fp.getDataSource());
                    foundset.loadAllRecords();
                    refresh = true;
                } catch (ServoyException e) {
                    // $NON-NLS-1$
                    Debug.error("Failed to reload foundset.", e);
                }
            }
            MainPage page = wf.findParent(MainPage.class);
            try {
                if (page != null) {
                    page.setTempRemoveMainForm(true);
                }
                fp.destroy();
            } finally {
                if (page != null) {
                    page.setTempRemoveMainForm(false);
                }
            }
            while (wfParent != null && !(wfParent instanceof IWebFormContainer) && !(wfParent.getParent() instanceof MainPage) && !(wfParent.getParent() instanceof WebForm)) {
                wfParent = wfParent.getParent();
            }
            if (wfParent instanceof IWebFormContainer) {
                if (formVisible) {
                    FormController fc = leaseFormPanel(fp.getName());
                    if (fc != null) {
                        // form was deleted in developer?
                        fc.loadData(foundset, null);
                        if (refresh)
                            fc.recreateUI();
                        List<Runnable> runnables = new ArrayList<Runnable>();
                        ((IWebFormContainer) wfParent).notifyVisible(true, runnables);
                        Utils.invokeLater(getApplication(), runnables);
                    }
                }
            } else if (wfParent != null) {
                WebForm parentWF = wfParent.findParent(WebForm.class);
                if (parentWF != null) {
                    if (!Arrays.asList(fcontrollers).contains(parentWF.getController()))
                        parentWF.getController().destroy();
                } else {
                    MainPage parent = wfParent.findParent(MainPage.class);
                    if (parent != null && !parents.contains(parent)) {
                        parents.add(parent);
                        if (parent.getNavigator() == fp) {
                            navigatorName = fp.getName();
                            FormController navigator = getFormController(navigatorName, parent);
                            if (navigator != null) {
                                List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
                                navigator.notifyVisible(true, invokeLaterRunnables);
                                Utils.invokeLater(getApplication(), invokeLaterRunnables);
                                parent.setNavigator(navigator);
                            // parent.triggerBrowserRequestIfNeeded(); // FIXME: this is needed here but currently does nothing because the request target is not yet set
                            }
                        }
                        FormController previousMainShowingForm = (parent != null ? parent.getController() : null);
                        if (previousMainShowingForm != null) {
                            FormController previousNavigator = parent.getNavigator();
                            parent.setController(null);
                            // navigator is not re-applied so apply it manually
                            int navigatorID = previousMainShowingForm.getForm().getNavigatorID();
                            if (navigatorID == Form.NAVIGATOR_IGNORE || (previousNavigator != null && previousNavigator.getForm().getID() == navigatorID)) {
                                parent.setNavigator(previousNavigator);
                            } else if (navigatorID > 0) {
                                Form newNavigator = application.getFlattenedSolution().getForm(navigatorID);
                                if (newNavigator != null) {
                                    parent.setNavigator(leaseFormPanel(newNavigator.getName()));
                                }
                            }
                            showFormInMainPanel(previousMainShowingForm.getName(), parent, null, true, null);
                        // parent.triggerBrowserRequestIfNeeded(); // FIXME: this is needed here but currently does nothing because the request target is not yet set
                        }
                    }
                }
            }
        }
    }
    for (MainPage mainPage : mainPages) {
        mainPage.setVersioned(true);
    }
}
Also used : FormController(com.servoy.j2db.FormController) BasicFormController(com.servoy.j2db.BasicFormController) MarkupContainer(org.apache.wicket.MarkupContainer) Form(com.servoy.j2db.persistence.Form) SwingForm(com.servoy.j2db.smart.SwingForm) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) ArrayList(java.util.ArrayList) ServoyException(com.servoy.j2db.util.ServoyException) IWebFormContainer(com.servoy.j2db.server.headlessclient.dataui.IWebFormContainer) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)55 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)26 Point (java.awt.Point)13 FormController (com.servoy.j2db.FormController)12 ISwingFoundSet (com.servoy.j2db.dataprocessing.ISwingFoundSet)11 ServoyException (com.servoy.j2db.util.ServoyException)8 ArrayList (java.util.ArrayList)8 IApplication (com.servoy.j2db.IApplication)6 FoundSet (com.servoy.j2db.dataprocessing.FoundSet)6 EventObject (java.util.EventObject)6 ITagResolver (com.servoy.base.util.ITagResolver)5 FindState (com.servoy.j2db.dataprocessing.FindState)5 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)5 PrototypeState (com.servoy.j2db.dataprocessing.PrototypeState)5 RepositoryException (com.servoy.j2db.persistence.RepositoryException)5 JSONObject (org.json.JSONObject)5 FormManager (com.servoy.j2db.FormManager)4 SortColumn (com.servoy.j2db.dataprocessing.SortColumn)4 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)4 Color (java.awt.Color)4