Search in sources :

Example 1 with ScopesScope

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

the class BasicFormManager method canBeDeleted.

protected boolean canBeDeleted(IFormController fp) {
    if (fp.isFormVisible()) {
        if (Debug.tracing())
            Debug.trace("Couldn't destroy form " + fp.getName() + "  instance because it is still visible");
        return false;
    }
    // cannot be deleted if a global var has a ref
    ScopesScope scopesScope = application.getScriptEngine().getScopesScope();
    if (hasReferenceInScriptable(scopesScope, fp, new HashSet<Scriptable>())) {
        if (Debug.tracing())
            Debug.trace("Couldn't destroy form " + fp.getName() + "  instance because it has references in scripting");
        return false;
    }
    if (fp.isFormExecutingFunction()) {
        if (Debug.tracing())
            Debug.trace("Couldn't destroy form " + fp.getName() + "  instance because it is executing a function");
        return false;
    }
    // if this controller uses a separate foundset
    if (fp.getForm().getUseSeparateFoundSet()) {
        // test if that foundset has edited records that can't be saved
        EditRecordList editRecordList = application.getFoundSetManager().getEditRecordList();
        if (editRecordList.stopIfEditing(fp.getFoundSet()) != ISaveConstants.STOPPED) {
            if (Debug.tracing())
                Debug.trace("Couldn't destroy form " + fp.getName() + "  instance because it has a seperate foundset that has editing records");
            return false;
        }
    }
    // the cached currentcontroller may not be destroyed
    SolutionScope ss = application.getScriptEngine().getSolutionScope();
    // $NON-NLS-1$
    return ss == null || fp.initForJSUsage() != ss.get("currentcontroller", ss);
}
Also used : EditRecordList(com.servoy.j2db.dataprocessing.EditRecordList) ScopesScope(com.servoy.j2db.scripting.ScopesScope) Scriptable(org.mozilla.javascript.Scriptable) SolutionScope(com.servoy.j2db.scripting.SolutionScope)

Example 2 with ScopesScope

use of com.servoy.j2db.scripting.ScopesScope 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 3 with ScopesScope

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

the class DataAdapterList method isGlobalDataprovider.

protected final boolean isGlobalDataprovider(String dataprovider) {
    if (dataprovider == null)
        return false;
    ScopesScope ss = formController.getApplication().getScriptEngine().getScopesScope();
    Pair<String, String> scope = ScopesUtils.getVariableScope(dataprovider);
    if (scope.getLeft() != null) {
        GlobalScope gs = ss.getGlobalScope(scope.getLeft());
        return gs != null && gs.has(scope.getRight(), gs);
    }
    return false;
}
Also used : GlobalScope(com.servoy.j2db.scripting.GlobalScope) ScopesScope(com.servoy.j2db.scripting.ScopesScope)

Aggregations

ScopesScope (com.servoy.j2db.scripting.ScopesScope)3 SolutionScope (com.servoy.j2db.scripting.SolutionScope)2 EditRecordList (com.servoy.j2db.dataprocessing.EditRecordList)1 IServoyAwareBean (com.servoy.j2db.dataui.IServoyAwareBean)1 GlobalScope (com.servoy.j2db.scripting.GlobalScope)1 IExecutingEnviroment (com.servoy.j2db.scripting.IExecutingEnviroment)1 IDestroyable (com.servoy.j2db.util.IDestroyable)1 Scriptable (org.mozilla.javascript.Scriptable)1