Search in sources :

Example 46 with RepositoryException

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

the class JSSolutionModel method newFormInternal.

/**
 * @param name
 * @param superForm
 * @param isResponsive
 * @return
 */
private JSForm newFormInternal(String name, ISMForm superForm, Boolean isResponsive) {
    if (superForm == null) {
        throw new IllegalArgumentException("superForm cannot be null");
    }
    if (isResponsive != null && (superForm.isResponsiveLayout() || superForm.getParts().length > 0)) {
        throw new IllegalArgumentException("Cannot set the layout type of the child form because the superform '" + superForm.getName() + "' is not a logical form.");
    }
    try {
        Form form = createNewForm(null, name, null, superForm.getShowInMenu(), ((JSForm) superForm).getSupportChild().getSize());
        if (isResponsive != null)
            form.setResponsiveLayout(isResponsive.booleanValue());
        form.clearProperty(StaticContentSpecLoader.PROPERTY_DATASOURCE.getPropertyName());
        application.getFormManager().addForm(form, false);
        form.setExtendsID(((JSForm) superForm).getSupportChild().getID());
        return instantiateForm(form, true);
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : Form(com.servoy.j2db.persistence.Form) ISMForm(com.servoy.j2db.solutionmodel.ISMForm) IBaseSMForm(com.servoy.base.solutionmodel.IBaseSMForm) RepositoryException(com.servoy.j2db.persistence.RepositoryException)

Example 47 with RepositoryException

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

the class JSSolutionModel method newGlobalVariable.

/**
 * Creates a new global variable with the specified name and number type.
 *
 * NOTE: The global variable number type is based on the value assigned from the SolutionModel-JSVariable node; for example: JSVariable.INTEGER.
 *
 * @sample
 * var myGlobalVariable = solutionModel.newGlobalVariable('globals', 'newGlobalVariable', JSVariable.INTEGER);
 * myGlobalVariable.defaultValue = 12;
 * //myGlobalVariable.defaultValue = "{a:'First letter',b:'Second letter'}" // an js object, type must be media.
 * //myGlobalVariable.defaultValue = '"some text"'; // Use two pairs of quotes if you want to assign a String as default value.
 * @param scopeName the scope in which the variable is created
 * @param name the specified name for the global variable
 *
 * @param type the specified number type for the global variable
 *
 * @return a JSVariable object
 */
@JSFunction
public JSVariable newGlobalVariable(String scopeName, String name, int type) {
    FlattenedSolution fs = application.getFlattenedSolution();
    try {
        String scope = scopeName == null ? ScriptVariable.GLOBAL_SCOPE : scopeName;
        ScriptVariable variable = fs.getSolutionCopy().createNewScriptVariable(new ScriptNameValidator(application.getFlattenedSolution()), scope, name, type);
        application.getScriptEngine().getScopesScope().getGlobalScope(scope).put(variable);
        return new JSVariable(application, variable, true);
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : ScriptVariable(com.servoy.j2db.persistence.ScriptVariable) FlattenedSolution(com.servoy.j2db.FlattenedSolution) RepositoryException(com.servoy.j2db.persistence.RepositoryException) ScriptNameValidator(com.servoy.j2db.persistence.ScriptNameValidator) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 48 with RepositoryException

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

the class JSSolutionModel method newGlobalMethod.

/**
 * Creates a new global method with the specified code in a scope.
 *
 * @sample
 * var method = solutionModel.newGlobalMethod('globals', 'function myglobalmethod(){foundset.newRecord()}')
 *
 * @param scopeName the scope in which the method is created
 * @param code the specified code for the global method
 *
 * @return a JSMethod object
 */
@JSFunction
public JSMethod newGlobalMethod(String scopeName, String code) {
    FlattenedSolution fs = application.getFlattenedSolution();
    String name = JSMethod.parseName(code);
    try {
        String scope = scopeName == null ? ScriptVariable.GLOBAL_SCOPE : scopeName;
        ScriptMethod method = fs.getSolutionCopy().createNewGlobalScriptMethod(new ScriptNameValidator(application.getFlattenedSolution()), scope, name);
        method.setDeclaration(code);
        application.getScriptEngine().getScopesScope().getGlobalScope(scope).put(method, method);
        JSMethod jsMethod = new JSMethod(method, application, true);
        return jsMethod;
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : FlattenedSolution(com.servoy.j2db.FlattenedSolution) RepositoryException(com.servoy.j2db.persistence.RepositoryException) ScriptMethod(com.servoy.j2db.persistence.ScriptMethod) ScriptNameValidator(com.servoy.j2db.persistence.ScriptNameValidator) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 49 with RepositoryException

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

the class JSSolutionModel method newForm.

protected JSForm newForm(String name, String dataSource, String styleName, boolean show_in_menu, int width, int height, boolean isResponsive) {
    FlattenedSolution fs = application.getFlattenedSolution();
    try {
        Style style = null;
        if (styleName != null) {
            style = fs.getStyle(styleName);
        }
        Form form = createNewForm(style, IdentDocumentValidator.checkName(name), dataSource, show_in_menu, new Dimension(width, height));
        if (!isResponsive) {
            form.createNewPart(Part.BODY, height);
        } else {
            form.setResponsiveLayout(true);
        }
        if (fs.getSolution().getSolutionType() == SolutionMetaData.MOBILE) {
            // mobile solution, make the form mobile
            form.putCustomMobileProperty(IMobileProperties.MOBILE_FORM.propertyName, Boolean.TRUE);
            // set internal style name
            form.setStyleName("_servoy_mobile");
        }
        application.getFormManager().addForm(form, false);
        return instantiateForm(form, true);
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : Form(com.servoy.j2db.persistence.Form) ISMForm(com.servoy.j2db.solutionmodel.ISMForm) IBaseSMForm(com.servoy.base.solutionmodel.IBaseSMForm) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Style(com.servoy.j2db.persistence.Style) RepositoryException(com.servoy.j2db.persistence.RepositoryException) Dimension(java.awt.Dimension)

Example 50 with RepositoryException

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

the class JSCalculation method checkModification.

private void checkModification() {
    if (!isCopy) {
        try {
            TableNode tableNode = application.getFlattenedSolution().getSolutionCopyTableNode(parent.getDataSource());
            ScriptCalculation sc = tableNode.getScriptCalculation(scriptCalculation.getName());
            if (sc == null) {
                sc = (ScriptCalculation) scriptCalculation.clonePersist(tableNode);
                scriptCalculation = sc;
            }
            isCopy = true;
        } catch (RepositoryException e) {
            Debug.error(e);
            throw new RuntimeException("Can't alter ScriptCalculation " + scriptCalculation.getName() + ", clone failed", e);
        }
    }
}
Also used : ScriptCalculation(com.servoy.j2db.persistence.ScriptCalculation) TableNode(com.servoy.j2db.persistence.TableNode) RepositoryException(com.servoy.j2db.persistence.RepositoryException)

Aggregations

RepositoryException (com.servoy.j2db.persistence.RepositoryException)116 RemoteException (java.rmi.RemoteException)45 QuerySelect (com.servoy.j2db.query.QuerySelect)25 ITable (com.servoy.j2db.persistence.ITable)22 JSFunction (org.mozilla.javascript.annotations.JSFunction)22 ServoyException (com.servoy.j2db.util.ServoyException)21 Column (com.servoy.j2db.persistence.Column)19 ArrayList (java.util.ArrayList)19 BaseQueryTable (com.servoy.base.query.BaseQueryTable)16 Table (com.servoy.j2db.persistence.Table)16 QueryTable (com.servoy.j2db.query.QueryTable)16 FlattenedSolution (com.servoy.j2db.FlattenedSolution)14 Point (java.awt.Point)14 IDataProvider (com.servoy.j2db.persistence.IDataProvider)13 QueryColumn (com.servoy.j2db.query.QueryColumn)13 IColumn (com.servoy.j2db.persistence.IColumn)12 ApplicationException (com.servoy.j2db.ApplicationException)11 ScriptNameValidator (com.servoy.j2db.persistence.ScriptNameValidator)10 SafeArrayList (com.servoy.j2db.util.SafeArrayList)10 FoundSetManager (com.servoy.j2db.dataprocessing.FoundSetManager)8