Search in sources :

Example 16 with Solution

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

the class FlattenedSolution method createFlattenedForm.

/*
	 * Create a flattened form for the form that is child of the current solution.
	 */
public FlattenedForm createFlattenedForm(Form form) {
    Form myForm;
    Solution solcopy = getSolutionCopy(false);
    if (form.getParent() == getSolution() || form.getParent() == solcopy) {
        myForm = form;
    } else {
        myForm = null;
        if (solcopy != null) {
            myForm = (Form) solcopy.getChild(form.getUUID());
        }
        if (myForm == null) {
            myForm = (Form) getSolution().getChild(form.getUUID());
        }
        if (myForm == null && modules != null) {
            for (Solution mod : modules) {
                myForm = (Form) mod.getChild(form.getUUID());
                if (myForm != null)
                    break;
            }
        }
        if (myForm == null) {
            throw new RuntimeException("Cannot find form '" + form + "' in solution '" + getSolution() + "'");
        }
    }
    try {
        return new FlattenedForm(this, myForm);
    } catch (RuntimeException ex) {
        Debug.error("Error while creating full hierarchy form (flattened form) for: " + (myForm != null ? myForm.getName() : "<form not found>"), ex);
        throw ex;
    }
}
Also used : FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Form(com.servoy.j2db.persistence.Form) FlattenedForm(com.servoy.j2db.persistence.FlattenedForm) Solution(com.servoy.j2db.persistence.Solution)

Example 17 with Solution

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

the class FlattenedSolution method buildOrderedList.

private static List<Solution> buildOrderedList(Collection<Solution> modules, List<Solution> orderedSolutions, Solution solution) {
    if (solution != null && solution.getModulesNames() != null) {
        for (// $NON-NLS-1$
        String moduleName : // $NON-NLS-1$
        Utils.getTokenElements(solution.getModulesNames(), ",", true)) {
            Solution module = null;
            for (Solution sol : modules) {
                if (sol.getName().equals(moduleName)) {
                    module = sol;
                    break;
                }
            }
            if (module != null && !orderedSolutions.contains(module)) {
                orderedSolutions.add(module);
                buildOrderedList(modules, orderedSolutions, module);
            }
        }
    }
    return orderedSolutions;
}
Also used : Solution(com.servoy.j2db.persistence.Solution)

Example 18 with Solution

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

the class FormManager method propertyChange.

public void propertyChange(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (// $NON-NLS-1$
    "solution".equals(name)) {
        final Solution s = (Solution) evt.getNewValue();
        // must run on same thread
        destroySolutionSettings();
        if (s != null) {
            application.invokeLater(new Runnable() {

                public void run() {
                    makeSolutionSettings(s);
                }
            });
        } else {
            lastModalContainer = null;
        }
    } else if (// $NON-NLS-1$
    "mode".equals(name)) {
        int oldmode = ((Integer) evt.getOldValue()).intValue();
        int newmode = ((Integer) evt.getNewValue()).intValue();
        handleModeChange(oldmode, newmode);
    }
}
Also used : Solution(com.servoy.j2db.persistence.Solution)

Example 19 with Solution

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

the class Messages method isI18NTable.

public static boolean isI18NTable(String serverName, String tableName, IApplication application) {
    Solution solution = application.getSolution();
    IFoundSetManagerInternal fm = application.getFoundSetManager();
    if (solution != null && fm != null) {
        String i18nDatasource = solution.getI18nDataSource();
        String[] names = getServerTableNames(i18nDatasource, application.getSettings());
        return names[0] != null && names[0].equals(serverName) && names[1] != null && ((tableName == null) || names[1].equals(tableName));
    }
    return false;
}
Also used : IFoundSetManagerInternal(com.servoy.j2db.dataprocessing.IFoundSetManagerInternal) Solution(com.servoy.j2db.persistence.Solution)

Example 20 with Solution

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

the class ScriptEngine method compileFunction.

@SuppressWarnings("nls")
public Function compileFunction(IScriptProvider sp, Scriptable scope) throws Exception {
    Context cx = Context.enter();
    int iOp = cx.getOptimizationLevel();
    String sourceName = sp.getDataProviderID();
    if (sp.getScopeName() != null) {
        Solution sol = (Solution) sp.getAncestor(IRepository.SOLUTIONS);
        sourceName = sol.getName() + "/scopes/" + sp.getScopeName() + '/' + sourceName;
    } else if (sp.getParent() instanceof Form) {
        Solution sol = (Solution) sp.getAncestor(IRepository.SOLUTIONS);
        sourceName = sol.getName() + "/forms/" + ((Form) sp.getParent()).getName() + '/' + sourceName;
    } else if (sp.getParent() instanceof TableNode) {
        Solution sol = (Solution) sp.getAncestor(IRepository.SOLUTIONS);
        sourceName = sol.getName() + '/' + ((TableNode) sp.getParent()).getDataSource() + '/' + sourceName;
        if (sp instanceof ScriptCalculation) {
            sourceName = sourceName.replace("db:", "calculations");
        } else {
            sourceName = sourceName.replace("db:", "entities");
        }
    }
    try {
        if (// flag should only be used in rich client
        Utils.getAsBoolean(System.getProperty(SERVOY_DISABLE_SCRIPT_COMPILE_PROPERTY, "false"))) {
            cx.setOptimizationLevel(-1);
        } else {
            cx.setOptimizationLevel(9);
        }
        cx.setGeneratingSource(Boolean.getBoolean("servoy.generateJavascriptSource"));
        return compileScriptProvider(sp, scope, cx, sourceName);
    } catch (Exception e) {
        Debug.error("Compilation failed for method: " + sourceName);
        throw e;
    } finally {
        cx.setOptimizationLevel(iOp);
        Context.exit();
    }
}
Also used : Context(org.mozilla.javascript.Context) ScriptCalculation(com.servoy.j2db.persistence.ScriptCalculation) Form(com.servoy.j2db.persistence.Form) TableNode(com.servoy.j2db.persistence.TableNode) Solution(com.servoy.j2db.persistence.Solution) ApplicationException(com.servoy.j2db.ApplicationException) ExitScriptException(com.servoy.j2db.ExitScriptException) DataException(com.servoy.j2db.dataprocessing.DataException) ServoyException(com.servoy.j2db.util.ServoyException) JavaScriptException(org.mozilla.javascript.JavaScriptException) RepositoryException(com.servoy.j2db.persistence.RepositoryException)

Aggregations

Solution (com.servoy.j2db.persistence.Solution)59 FlattenedSolution (com.servoy.j2db.FlattenedSolution)17 Form (com.servoy.j2db.persistence.Form)16 ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)14 RepositoryException (com.servoy.j2db.persistence.RepositoryException)12 ArrayList (java.util.ArrayList)9 RemoteException (java.rmi.RemoteException)8 HashMap (java.util.HashMap)8 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)7 IPersist (com.servoy.j2db.persistence.IPersist)6 TableNode (com.servoy.j2db.persistence.TableNode)6 ServoyException (com.servoy.j2db.util.ServoyException)6 JSONObject (org.json.JSONObject)6 IFormController (com.servoy.j2db.IFormController)5 Map (java.util.Map)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)5 JavaScriptException (org.mozilla.javascript.JavaScriptException)5 IRepository (com.servoy.j2db.persistence.IRepository)4 List (java.util.List)4 ApplicationException (com.servoy.j2db.ApplicationException)3