Search in sources :

Example 6 with SolutionScope

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

the class DataAdapterList method destroy.

/**
 */
public void destroy() {
    if (currentRecord != null) {
        // With prototype you can still get global foundsets
        // setRecord(new PrototypeState(currentRecord.getParentFoundSet()), true);
        setRecord(null, false);
    }
    if (formController != null && !formController.isDestroyed() && formController.getFormScope() != null) {
        formController.getFormScope().getModificationSubject().removeModificationListener(this);
    }
    IExecutingEnviroment er = application.getScriptEngine();
    if (er != null) {
        SolutionScope ss = er.getSolutionScope();
        if (ss != null) {
            ScopesScope gs = ss.getScopesScope();
            if (gs != null) {
                gs.getModificationSubject().removeModificationListener(this);
            }
        }
    }
    if (servoyAwareBeans != null) {
        for (IServoyAwareBean b : servoyAwareBeans) {
            try {
                if (b instanceof IDestroyable) {
                    ((IDestroyable) b).destroy();
                }
            } catch (RuntimeException e) {
                // never make the app break on faulty beans
                Debug.error(e);
            }
        }
    }
    servoyAwareBeans = null;
    if (relatedDataAdapters != null) {
        for (IDisplayRelatedData drd : relatedDataAdapters) {
            drd.destroy();
        }
    }
    relatedDataAdapters = null;
    if (dataDisplays != null) {
        for (IDisplayData dd : dataDisplays) {
            if (dd instanceof IDestroyable) {
                ((IDestroyable) dd).destroy();
            }
        }
    }
    dataDisplays = null;
    if (dataAdapters != null) {
        for (IDataAdapter da : dataAdapters.values()) {
            if (da instanceof IDestroyable) {
                ((IDestroyable) da).destroy();
            }
        }
    }
    dataAdapters = null;
    currentDisplay = null;
    visible = false;
    destroyed = true;
    if (currentRecord != null) {
        // $NON-NLS-1$
        Debug.error("After destroy there is still a current record in DataAdapterList of formcontroller: " + formController, new RuntimeException());
        currentRecord.removeModificationListener(this);
    }
}
Also used : IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) IExecutingEnviroment(com.servoy.j2db.scripting.IExecutingEnviroment) IDestroyable(com.servoy.j2db.util.IDestroyable) ScopesScope(com.servoy.j2db.scripting.ScopesScope) SolutionScope(com.servoy.j2db.scripting.SolutionScope)

Example 7 with SolutionScope

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

the class BasicFormController method destroy.

public void destroy() {
    SolutionScope solScope = application.getScriptEngine().getSolutionScope();
    // $NON-NLS-1$
    ((CreationalPrototype) solScope.get("forms", solScope)).removeFormPanel(this);
    if (scriptableForm != null) {
        scriptableForm.destroy();
    }
    scriptableForm = null;
    if (formScope != null) {
        formScope.destroy();
    }
    formScope = null;
    destroyed = true;
    isFormVisible = false;
}
Also used : CreationalPrototype(com.servoy.j2db.scripting.CreationalPrototype) SolutionScope(com.servoy.j2db.scripting.SolutionScope)

Example 8 with SolutionScope

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

the class FormManager method setCurrentContainer.

/**
 * @param mainContainer
 */
public void setCurrentContainer(IMainContainer mainContainer, String name) {
    if (mainContainer != null) {
        currentContainer = mainContainer;
        if (name != null) {
            // reset it in the containers (must be done for the webclient)
            containers.put(name, mainContainer);
        }
    } else {
        currentContainer = getMainContainer(null);
    }
    enableCmds(true);
    FormController formController = currentContainer.getController();
    if (formController != null) {
        IExecutingEnviroment scriptEngine = application.getScriptEngine();
        if (scriptEngine != null) {
            SolutionScope ss = scriptEngine.getSolutionScope();
            Context.enter();
            try {
                // $NON-NLS-1$
                ss.put("currentcontroller", ss, new NativeJavaObject(ss, formController.initForJSUsage(), new InstanceJavaMembers(ss, JSForm.class)));
            } finally {
                Context.exit();
            }
        }
    }
    application.getRuntimeWindowManager().setCurrentWindowName(name);
}
Also used : InstanceJavaMembers(com.servoy.j2db.scripting.InstanceJavaMembers) IExecutingEnviroment(com.servoy.j2db.scripting.IExecutingEnviroment) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) SolutionScope(com.servoy.j2db.scripting.SolutionScope)

Aggregations

SolutionScope (com.servoy.j2db.scripting.SolutionScope)8 IExecutingEnviroment (com.servoy.j2db.scripting.IExecutingEnviroment)3 NativeJavaObject (org.mozilla.javascript.NativeJavaObject)3 InstanceJavaMembers (com.servoy.j2db.scripting.InstanceJavaMembers)2 ScopesScope (com.servoy.j2db.scripting.ScopesScope)2 BasicFormController (com.servoy.j2db.BasicFormController)1 JSForm (com.servoy.j2db.BasicFormController.JSForm)1 IDebugClient (com.servoy.j2db.IDebugClient)1 ICmdManagerInternal (com.servoy.j2db.cmd.ICmdManagerInternal)1 EditRecordList (com.servoy.j2db.dataprocessing.EditRecordList)1 IServoyAwareBean (com.servoy.j2db.dataui.IServoyAwareBean)1 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)1 Form (com.servoy.j2db.persistence.Form)1 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 CreationalPrototype (com.servoy.j2db.scripting.CreationalPrototype)1 IDestroyable (com.servoy.j2db.util.IDestroyable)1 ServoyException (com.servoy.j2db.util.ServoyException)1 ArrayList (java.util.ArrayList)1 Scriptable (org.mozilla.javascript.Scriptable)1