use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class WebSplitPane 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 BasicFormController.JSForm) {
f = (FormController) ((BasicFormController.JSForm) form).getFormPanel();
readOnly = f.isReadOnly();
}
if (f != null)
fName = f.getName();
if (form instanceof String)
fName = (String) form;
if (fName != null) {
String tabname = 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, bLeftForm ? 0 : 1, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (!bNotifyVisibleForm)
return false;
}
WebTabFormLookup flp = (WebTabFormLookup) createFormLookupPanel(tabname, relationName, fName);
if (f != null)
flp.setReadOnly(readOnly);
if (bLeftForm)
setLeftForm(flp);
else
setRightForm(flp);
if (relatedFs != null) {
FormController fp = flp.getWebForm().getController();
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, bLeftForm ? 0 : 1, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (bNotifyVisibleForm) {
paneChanged[bLeftForm ? 0 : 1] = true;
}
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, bLeftForm ? 0 : 1, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
if (!bNotifyVisibleForm)
return false;
}
splitComponents[bLeftForm ? 0 : 1].replace(new Label("webform", new Model<String>("")));
webTabs[bLeftForm ? 0 : 1] = null;
paneChanged[bLeftForm ? 0 : 1] = true;
return true;
}
return false;
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class WebTabFormLookup method notifyVisible.
public boolean notifyVisible(boolean b, List invokeLaterRunnables) {
if (isReady()) {
IFormUIInternal ui = webForm;
FormController child = ui.getController();
return child.notifyVisible(b, invokeLaterRunnables);
}
return true;
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class WebTabFormLookup method getWebForm.
private WebForm getWebForm(boolean removeFromParent) {
if (webForm != null && webForm.isDestroyed()) {
webForm = null;
}
if (webForm == null) {
FormManager fm = (FormManager) application.getFormManager();
FormController fc = fm.getFormController(formName, this);
if (fc == null) {
fc = fm.leaseFormPanel(formName);
}
if (fc != null) {
// delegate readOnly, really set it once from the form manager state
fc.setReadOnly(fm.isFormReadOnly(formName));
webForm = (WebForm) fc.getFormUI();
if (removeFromParent && webForm.getParent() != null && webForm.getParent() != parent) {
webForm.remove();
}
}
}
return webForm;
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class WebTabPanel method showFoundSet.
protected void showFoundSet(WebTabFormLookup flp, IRecordInternal parentState, List<SortColumn> sort) {
deregisterSelectionListeners();
if (!flp.isReady())
return;
FormController fp = flp.getWebForm().getController();
if (fp != null && flp.getRelationName() != null) {
IFoundSetInternal relatedFoundset = parentState == null ? null : parentState.getRelatedFoundSet(flp.getRelationName(), sort);
registerSelectionListeners(parentState, flp.getRelationName());
fp.loadData(relatedFoundset, null);
}
ITagResolver resolver = getTagResolver(parentState);
// refresh tab text
for (int i = 0; i < allTabs.size(); i++) {
WebTabHolder element = allTabs.get(i);
if (element.getPanel() == flp) {
element.refreshTagStrings(resolver);
break;
}
}
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class WebTabPanel method notifyResized.
public void notifyResized() {
if (currentForm != null && currentForm.isReady()) {
WebForm webForm = currentForm.getWebForm();
FormController controller = webForm.getController();
if (controller != null && webForm.isFormWidthHeightChanged()) {
controller.notifyResized();
webForm.clearFormWidthHeightChangedFlag();
}
}
}
Aggregations