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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
}
Aggregations