Search in sources :

Example 6 with IBasicFormManager

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

the class RuntimeWindow method showObject.

public void showObject(Object form) throws ServoyException {
    String f = null;
    if (form instanceof BasicFormController) {
        f = ((BasicFormController) form).getName();
    } else if (form instanceof FormScope) {
        f = ((FormScope) form).getFormController().getName();
    } else if (form instanceof FormController.JSForm) {
        f = ((FormController.JSForm) form).getFormPanel().getName();
    } else if (form instanceof String) {
        f = (String) form;
    } else if (form instanceof JSForm) {
        f = ((JSForm) form).getName();
    }
    if (f != null) {
        Form frm = application.getFlattenedSolution().getForm(f);
        IBasicFormManager fm = application.getFormManager();
        if (frm == null && fm.isPossibleForm(f))
            frm = fm.getPossibleForm(f);
        if (!application.getFlattenedSolution().formCanBeInstantiated(frm)) {
            // abstract form
            throw new ApplicationException(ServoyException.ABSTRACT_FORM, new Object[] { f });
        }
        show(f);
    }
}
Also used : ApplicationException(com.servoy.j2db.ApplicationException) JSForm(com.servoy.j2db.scripting.solutionmodel.JSForm) Form(com.servoy.j2db.persistence.Form) JSForm(com.servoy.j2db.scripting.solutionmodel.JSForm) IBasicFormManager(com.servoy.j2db.IBasicFormManager) BasicFormController(com.servoy.j2db.BasicFormController)

Example 7 with IBasicFormManager

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

the class CreationalPrototype method get.

@Override
public Object get(java.lang.String name, Scriptable start) {
    if (// $NON-NLS-1$
    "allnames".equals(name)) {
        ArrayList<String> al = new ArrayList<String>();
        IBasicFormManager fm = application.getFormManager();
        if (fm == null)
            throw new IllegalStateException(// should never happen during normal operation; see case 251716
            "Trying to access forms after client was shut down? This JS code was probably running decoupled from client shut down but at the same time.");
        Iterator<String> it = fm.getPossibleFormNames();
        while (it.hasNext()) {
            al.add(it.next());
        }
        Context.enter();
        try {
            return new NativeJavaArray(this, al.toArray());
        } finally {
            Context.exit();
        }
    }
    Object o = super.get(name, start);
    if ((o == null || o == Scriptable.NOT_FOUND)) {
        IBasicFormManager fm = application.getFormManager();
        if (fm == null)
            throw new IllegalStateException(// should never happen during normal operation; see case 251716
            "Trying to access forms after client was shut down? This JS code was probably running decoupled from client shut down but at the same time.");
        if (!fm.isPossibleForm(name)) {
            return o;
        }
        Context.enter();
        try {
            // $NON-NLS-1$ //$NON-NLS-2$
            Debug.trace("CreationalPrototype:get " + name + " scope " + start);
            if (!application.isEventDispatchThread()) {
                // $NON-NLS-1$ //$NON-NLS-2$
                Debug.log("Form " + name + " is not created because it is CreationalPrototype.get(formname) is called outside of the event thread");
                // $NON-NLS-1$ //$NON-NLS-2$
                return "<Form " + name + " not loaded yet>";
            }
            IFormController fp = fm.leaseFormPanel(name);
            if (fp != null) {
                // This registers the object in this scopes, this must called before anything else! (to prevent repeative calls/lookups here)
                fp.initForJSUsage(this);
                // re-get
                o = super.get(name, this);
            }
            if (o == null)
                o = Scriptable.NOT_FOUND;
        } finally {
            Context.exit();
        }
    }
    if (o instanceof FormScope) {
        IFormController fp = ((FormScope) o).getFormController();
        fp.setView(fp.getView());
        fp.executeOnLoadMethod();
        try {
            if (!fp.isShowingData()) {
                if (fp.wantEmptyFoundSet()) {
                    if (fp.getFormModel() != null)
                        fp.getFormModel().clear();
                } else {
                    fp.loadAllRecordsImpl(true);
                }
            }
        } catch (Exception ex) {
            Debug.error(ex);
            // $NON-NLS-1$
            application.handleException(application.getI18NMessage("servoy.formPanel.error.formData"), ex);
        }
    }
    return o;
}
Also used : ArrayList(java.util.ArrayList) IBasicFormManager(com.servoy.j2db.IBasicFormManager) IFormController(com.servoy.j2db.IFormController) NativeJavaArray(org.mozilla.javascript.NativeJavaArray)

Example 8 with IBasicFormManager

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

the class CreationalPrototype method getInitializedIds.

/**
 * @see org.eclipse.dltk.rhino.dbgp.LazyInitScope#getInitializedIds()
 */
public Object[] getInitializedIds() {
    ArrayList<String> al = new ArrayList<String>();
    // $NON-NLS-1$
    al.add("allnames");
    // $NON-NLS-1$
    al.add("length");
    IBasicFormManager fm = application.getFormManager();
    if (fm == null)
        return new Object[0];
    Iterator<String> it = fm.getPossibleFormNames();
    while (it.hasNext()) {
        String form = it.next();
        Object o = super.get(form, this);
        if (o != null && o != Scriptable.NOT_FOUND) {
            if (o instanceof FormScope) {
                IFormController fp = ((FormScope) o).getFormController();
                if (!fp.isShowingData())
                    continue;
            }
            al.add(form);
        }
    }
    return al.toArray();
}
Also used : ArrayList(java.util.ArrayList) IBasicFormManager(com.servoy.j2db.IBasicFormManager) IFormController(com.servoy.j2db.IFormController)

Aggregations

IBasicFormManager (com.servoy.j2db.IBasicFormManager)8 ApplicationException (com.servoy.j2db.ApplicationException)3 BasicFormController (com.servoy.j2db.BasicFormController)3 Form (com.servoy.j2db.persistence.Form)3 ArrayList (java.util.ArrayList)3 IFormController (com.servoy.j2db.IFormController)2 Rectangle (java.awt.Rectangle)2 ScriptableObject (org.mozilla.javascript.ScriptableObject)2 FormController (com.servoy.j2db.FormController)1 FormExecutionState (com.servoy.j2db.FormExecutionState)1 IBasicMainContainer (com.servoy.j2db.IBasicMainContainer)1 ISupportFormExecutionState (com.servoy.j2db.ISupportFormExecutionState)1 JSForm (com.servoy.j2db.scripting.solutionmodel.JSForm)1 NativeJavaArray (org.mozilla.javascript.NativeJavaArray)1