use of com.servoy.j2db.scripting.FormScope in project servoy-client by Servoy.
the class DataAdapterList method getFormScope.
public FormScope getFormScope() {
if (// can happen for a design component
formController == null) {
return null;
}
if (destroyed) {
Debug.error("calling getFormScope on a destroyed DataAdapterList, formcontroller: " + formController + ", currentRecord: " + currentRecord, new RuntimeException());
return null;
}
FormScope formScope = formController.getFormScope();
if (formScope == null && formController.isDestroyed()) {
Debug.error("calling getFormScope in none destroyed DataAdapterList (destroying it now) for a destroyed formcontroller: " + formController + ", currentRecord: " + currentRecord, new RuntimeException());
destroy();
return null;
}
return formScope;
}
use of com.servoy.j2db.scripting.FormScope in project servoy-client by Servoy.
the class DataAdapterList method valueChanged.
/*
* _____________________________________________________________ JavaScriptModificationListner
*/
/**
* listen for global var changes via own listener and state vars(mainly columns) via state listener if via javascript any var is changed it will be noted
* here,and dispatched to refresh the displays
*/
public void valueChanged(ModificationEvent e) {
if (destroyed) {
Debug.error("Destroyed DataAdapterList " + formController + " was still attached to the record: " + e.getRecord() + ", removing it if possible, currentRecord: " + currentRecord, new RuntimeException());
if (e.getRecord() != null)
e.getRecord().removeModificationListener(this);
else if (currentRecord != null)
currentRecord.removeModificationListener(this);
return;
}
if (formController != null && formController.isDestroyed()) {
Debug.error("Destroying DataAdapterList of a destroyed " + formController, new RuntimeException());
destroy();
return;
}
FormScope formScope = getFormScope();
if (visible && (currentRecord != null || (formScope != null && formScope.has(e.getName(), formScope)))) {
for (IDataAdapter da : dataAdapters.values()) {
// dataAdapter should call state.getValue if name from event is same as its dataProviderID
da.valueChanged(e);
}
// check if a related adapter depends on he global
if (e != null && e.getName() != null) {
for (IDisplayRelatedData drd : relatedDataAdapters) {
boolean depends = false;
String[] allRelationNames = drd.getAllRelationNames();
for (int a = 0; !depends && allRelationNames != null && a < allRelationNames.length; a++) {
Relation[] relations = application.getFlattenedSolution().getRelationSequence(allRelationNames[a]);
for (int r = 0; !depends && relations != null && r < relations.length; r++) {
try {
IDataProvider[] primaryDataProviders = relations[r].getPrimaryDataProviders(application.getFlattenedSolution());
for (int p = 0; !depends && primaryDataProviders != null && p < primaryDataProviders.length; p++) {
depends = e.getName().equals(primaryDataProviders[p].getDataProviderID());
}
} catch (RepositoryException ex) {
Debug.log(ex);
}
}
}
if (depends) {
// related adapter depends on the modified global
if (drd instanceof IDisplayDependencyData)
((IDisplayDependencyData) drd).dependencyChanged(currentRecord);
else
drd.setRecord(currentRecord, true);
}
}
}
// inform servoy aware beans
for (IServoyAwareBean drd : servoyAwareBeans) {
if (drd instanceof IModificationListener) {
try {
((IModificationListener) drd).valueChanged(e);
} catch (RuntimeException ex) {
// never make the app break on faulty beans
Debug.error(ex);
}
}
}
}
}
use of com.servoy.j2db.scripting.FormScope in project servoy-client by Servoy.
the class JSForm method checkModification.
@Override
public final void checkModification() {
// make copy if needed
if (!isCopy) {
setForm(application.getFlattenedSolution().createPersistCopy(getForm()));
application.getFormManager().addForm(getForm(), false);
// forms scope still uses the old copy of Script Providers
Form oldform = getForm();
List<IFormController> controllers = application.getFormManager().getCachedFormControllers(getForm());
for (IFormController formController : controllers) {
FormScope formScope = formController.getFormScope();
formScope.updateProviderswithCopy(oldform, getForm());
}
isCopy = true;
} else {
application.getFlattenedSolution().flushFlattendFormCache(getForm(), true);
}
getForm().setLastModified(System.currentTimeMillis());
application.getFlattenedSolution().registerChangedForm(getForm());
useFormCache = false;
}
use of com.servoy.j2db.scripting.FormScope in project servoy-client by Servoy.
the class JSForm method refreshFromScopes.
private void refreshFromScopes() {
List<IFormController> controllers = application.getFormManager().getCachedFormControllers(getForm());
for (IFormController formController : controllers) {
FormScope formScope = formController.getFormScope();
formScope.updateProviderswithCopy(getForm(), getForm());
formScope.reload();
}
}
use of com.servoy.j2db.scripting.FormScope in project servoy-client by Servoy.
the class JSForm method removeVariableFromScopes.
private void removeVariableFromScopes(ScriptVariable var) {
List<IFormController> controllers = application.getFormManager().getCachedFormControllers(getForm());
for (IFormController formController : controllers) {
FormScope formScope = formController.getFormScope();
formScope.updateProviderswithCopy(getForm(), getForm());
formScope.remove(var);
}
}
Aggregations