use of com.servoy.j2db.dataprocessing.RelatedFoundSet in project servoy-client by Servoy.
the class SpecialSplitPane method setForm.
public boolean setForm(boolean bLeftForm, Object form, Object relation) {
FormController f = null;
String fName = null;
boolean readOnly = false;
if (form instanceof FormController) {
f = (FormController) form;
readOnly = f.isReadOnly();
}
if (form instanceof FormController.JSForm) {
f = (FormController) ((FormController.JSForm) form).getFormPanel();
readOnly = f.isReadOnly();
}
if (f != null)
fName = f.getName();
if (form instanceof String)
fName = (String) form;
if (fName != null) {
String name = fName;
RelatedFoundSet relatedFs = null;
String relationName = null;
if (relation instanceof RelatedFoundSet) {
relatedFs = (RelatedFoundSet) relation;
} else if (relation instanceof String) {
relationName = (String) relation;
}
if (relatedFs != null) {
relationName = relatedFs.getRelationName();
if (f != null && !relatedFs.getDataSource().equals(f.getDataSource())) {
return false;
}
// TODO do this check to check if the parent table has this relation? How to get the parent table
// Table parentTable = null;
// application.getSolution().getRelations(Solution.SOLUTION+Solution.MODULES, parentTable, true, false);
}
IFormLookupPanel replacedForm = bLeftForm ? getLeftForm() : getRightForm();
if (replacedForm != null) {
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
boolean bNotifyVisibleForm = notifyVisibleForm(false, (FormLookupPanel) replacedForm, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (!bNotifyVisibleForm)
return false;
}
FormLookupPanel flp = createFormLookupPanel(name, relationName, fName);
if (f != null)
flp.setReadOnly(readOnly);
if (bLeftForm)
setLeftForm(flp);
else
setRightForm(flp);
if (relatedFs != null) {
FormController fp = flp.getFormPanel();
if (fp != null && flp.getRelationName() != null && flp.getRelationName().equals(relationName)) {
fp.loadData(relatedFs, null);
}
}
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
boolean bNotifyVisibleForm = notifyVisibleForm(true, flp, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
return bNotifyVisibleForm;
} else if (form == null) {
IFormLookupPanel replacedForm = bLeftForm ? getLeftForm() : getRightForm();
if (replacedForm != null) {
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>(0);
boolean bNotifyVisibleForm = notifyVisibleForm(false, (FormLookupPanel) replacedForm, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (!bNotifyVisibleForm)
return false;
}
if (bLeftForm)
setLeftForm(null);
else
setRightForm(null);
return true;
}
return false;
}
use of com.servoy.j2db.dataprocessing.RelatedFoundSet in project servoy-client by Servoy.
the class FormManager method ifRootFormInFind.
private boolean ifRootFormInFind(FormController fc) {
boolean result = false;
if (fc.isFormVisible() && fc.isInFindMode()) {
IFoundSetInternal foundSet = fc.getFoundSet();
if (foundSet instanceof RelatedFoundSet) {
// see if any parent foundset is in find mode; if not, then add it as root
// form in find mode
List<IRecordInternal> parentRecords = ((RelatedFoundSet) foundSet).getParents();
boolean hasParentsInFindMode = false;
for (IRecordInternal record : parentRecords) {
IFoundSetInternal parentFoundSet = record.getParentFoundSet();
if (parentFoundSet instanceof FoundSet && ((FoundSet) parentFoundSet).isInFindMode()) {
hasParentsInFindMode = true;
break;
}
}
if (!hasParentsInFindMode) {
result = true;
}
} else {
result = true;
}
}
return result;
}
Aggregations