use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class JSForm method js_setOnDeleteAllRecordsCmdMethod.
/**
* @deprecated As of release 4.1, replaced by setOnDeleteAllRecordsCmd(JSMethod).
*/
@Deprecated
public void js_setOnDeleteAllRecordsCmdMethod(Object functionOrInteger) {
checkModification();
if (functionOrInteger instanceof Function) {
Function function = (Function) functionOrInteger;
ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
if (scriptMethod != null) {
getForm().setOnDeleteAllRecordsCmdMethodID(scriptMethod.getID());
} else {
getForm().setOnDeleteAllRecordsCmdMethodID(0);
}
} else if (functionOrInteger instanceof Number) {
getForm().setOnDeleteAllRecordsCmdMethodID(((Number) functionOrInteger).intValue());
}
}
use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class JSForm method getEventHandler.
public static <T extends AbstractBase> JSMethod getEventHandler(IApplication application, T persist, int methodid, IJSParent<?> parent, String propertyName) {
if (methodid > 0) {
IJSScriptParent<?> scriptParent = null;
ScriptMethod scriptMethod = null;
if (parent instanceof JSForm) {
// form method
scriptMethod = ((JSForm) parent).getSupportChild().getScriptMethod(methodid);
if (scriptMethod == null) {
Form f = ((JSForm) parent).getSupportChild();
while (f != null && f.getExtendsID() > 0 && scriptMethod == null) {
f = application.getFlattenedSolution().getForm(f.getExtendsID());
if (f != null)
scriptMethod = f.getScriptMethod(methodid);
}
if (scriptMethod != null) {
scriptParent = application.getScriptEngine().getSolutionModifier().instantiateForm(f, false);
}
}
}
if (scriptMethod == null) {
// foundset method
if (parent instanceof JSDataSourceNode) {
scriptMethod = ((JSDataSourceNode) parent).getSupportChild().getFoundsetMethod(methodid);
} else if (parent instanceof JSForm && ((JSForm) parent).getForm().getDataSource() != null) {
Iterator<ScriptMethod> foundsetMethods = application.getFlattenedSolution().getFoundsetMethods(((JSForm) parent).getForm().getDataSource(), false);
scriptMethod = AbstractBase.selectById(foundsetMethods, methodid);
if (scriptMethod != null) {
scriptParent = new JSDataSourceNode(application, ((JSForm) parent).getForm().getDataSource());
}
}
}
if (scriptMethod == null) {
// global method
scriptMethod = application.getFlattenedSolution().getScriptMethod(methodid);
}
if (scriptMethod != null) {
if (scriptParent == null) {
if (scriptMethod.getParent() instanceof TableNode && parent instanceof JSDataSourceNode) {
scriptParent = (JSDataSourceNode) parent;
} else if (scriptMethod.getParent() instanceof Solution) {
// global
scriptParent = null;
} else {
// form method
scriptParent = getJSFormParent(parent);
}
}
List<Object> arguments = persist.getFlattenedMethodArguments(propertyName);
if (arguments == null || arguments.size() == 0) {
return new JSMethod(scriptParent, scriptMethod, application, false);
} else {
return new JSMethodWithArguments(application, scriptParent, scriptMethod, false, arguments.toArray());
}
}
} else if (methodid == 0 && BaseComponent.isCommandProperty(propertyName)) {
return (JSMethod) ISMDefaults.COMMAND_DEFAULT;
}
return null;
}
use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class JSForm method js_setOnNewRecordCmdMethod.
/**
* @deprecated As of release 4.1, replaced by setOnNewRecordCmd(JSMethod).
*/
@Deprecated
public void js_setOnNewRecordCmdMethod(Object functionOrInteger) {
checkModification();
if (functionOrInteger instanceof Function) {
Function function = (Function) functionOrInteger;
ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
if (scriptMethod != null) {
getForm().setOnNewRecordCmdMethodID(scriptMethod.getID());
} else {
getForm().setOnNewRecordCmdMethodID(0);
}
} else if (functionOrInteger instanceof Number) {
getForm().setOnNewRecordCmdMethodID(((Number) functionOrInteger).intValue());
}
}
use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class JSForm method js_setOnShowOmittedRecordsCmdMethod.
/**
* @deprecated As of release 4.1, replaced by setOnShowOmittedRecordsCmd(JSMethod).
*/
@Deprecated
public void js_setOnShowOmittedRecordsCmdMethod(Object functionOrInteger) {
checkModification();
if (functionOrInteger instanceof Function) {
Function function = (Function) functionOrInteger;
ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
if (scriptMethod != null) {
getForm().setOnShowOmittedRecordsCmdMethodID(scriptMethod.getID());
} else {
getForm().setOnShowOmittedRecordsCmdMethodID(0);
}
} else if (functionOrInteger instanceof Number) {
getForm().setOnShowOmittedRecordsCmdMethodID(((Number) functionOrInteger).intValue());
}
}
use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class JSForm method getEventHandler.
public static <T extends AbstractBase> JSMethod getEventHandler(IApplication application, T persist, String uuidOrName, IJSParent<?> parent, String propertyName) {
if (uuidOrName != null) {
IJSScriptParent<?> scriptParent = null;
ScriptMethod scriptMethod = application.getFlattenedSolution().getScriptMethod(uuidOrName);
;
if (scriptMethod != null) {
if (scriptMethod.getParent() instanceof TableNode && parent instanceof JSDataSourceNode) {
scriptParent = (JSDataSourceNode) parent;
} else if (scriptMethod.getParent() instanceof Solution) {
// global
scriptParent = null;
} else {
// form method
scriptParent = getJSFormParent(parent);
if (scriptMethod.getParent() != scriptParent.getSupportChild() && scriptParent.getSupportChild() instanceof Form) {
scriptParent = application.getScriptEngine().getSolutionModifier().instantiateForm((Form) scriptParent.getSupportChild(), false);
}
}
List<Object> arguments = persist.getFlattenedMethodArguments(propertyName);
if (arguments == null || arguments.size() == 0) {
return new JSMethod(scriptParent, scriptMethod, application, false);
} else {
return new JSMethodWithArguments(application, scriptParent, scriptMethod, false, arguments.toArray());
}
}
}
return null;
}
Aggregations