use of com.servoy.j2db.ui.scripting.RuntimePortal in project servoy-client by Servoy.
the class ComponentFactory method createPortal.
private static IComponent createPortal(IApplication application, Form form, Portal meta, IDataProviderLookup dataProviderLookup, IScriptExecuter el, boolean printing) {
RuntimePortal scriptable = new RuntimePortal(application.getItemFactory().createChangesRecorder(), application);
IPortalComponent portalComponent = application.getItemFactory().createPortalComponent(scriptable, meta, form, dataProviderLookup, el, printing);
scriptable.setComponent(portalComponent, meta);
IStyleSheet ss = ComponentFactory.getCSSStyleForForm(application, form);
if (ss != null) {
String lookupname = "portal";
if (meta.getStyleClass() != null && !"".equals(meta.getStyleClass())) {
lookupname += '.' + meta.getStyleClass();
}
portalComponent.setRowStyles(ss, ss.getCSSRule(lookupname + " " + ISupportRowStyling.CLASS_ODD), ss.getCSSRule(lookupname + " " + ISupportRowStyling.CLASS_EVEN), ss.getCSSRule(lookupname + " " + ISupportRowStyling.CLASS_SELECTED), ss.getCSSRule(lookupname + " " + ISupportRowStyling.CLASS_HEADER));
}
return portalComponent;
}
use of com.servoy.j2db.ui.scripting.RuntimePortal in project servoy-client by Servoy.
the class WebForm method initView.
/**
* @see com.servoy.j2db.IFormUIInternal#initView(com.servoy.j2db.IApplication, com.servoy.j2db.FormController, int)
*/
public IView initView(IApplication app, FormController fp, int viewType) {
boolean addHeaders = true;
view = null;
final Form f = fp.getForm();
DataRendererRecordModel rendererModel = new DataRendererRecordModel();
// int viewType = f.getView();
if (viewType == IForm.LIST_VIEW || viewType == FormController.LOCKED_LIST_VIEW) {
// list views do not have headers
addHeaders = false;
}
// String orientation = OrientationApplier.getHTMLContainerOrientation(app.getLocale(), app.getSolution().getTextOrientation());
IDataRenderer[] dataRenderers = fp.getDataRenderers();
for (int i = 0; i < dataRenderers.length; i++) {
if (i == Part.TITLE_HEADER || i == Part.HEADER || i == Part.LEADING_GRAND_SUMMARY || i == Part.TRAILING_GRAND_SUMMARY || i == Part.FOOTER) {
if (dataRenderers[Part.HEADER] != null) {
addHeaders = false;
}
WebDataRenderer dr = (WebDataRenderer) dataRenderers[i];
if (dr != null) {
dr.setDefaultModel(rendererModel);
container.add(dr);
}
}
}
defaultNavigator = null;
if (viewType == IForm.RECORD_VIEW || viewType == IForm.LOCKED_RECORD_VIEW) {
// $NON-NLS-1$
view = new WebRecordView("View");
if (f.getNavigatorID() == Form.NAVIGATOR_DEFAULT) {
defaultNavigator = new WebDefaultRecordNavigator(this);
((WebRecordView) view).add(defaultNavigator);
}
// Body
WebDataRenderer body = (WebDataRenderer) dataRenderers[FormController.FORM_EDITOR];
if (body != null) {
((WebRecordView) view).add(body);
body.setDefaultModel(rendererModel);
body.setParentView(view);
} else {
// ((WebRecordView)view).add(new WebMarkupContainer());
}
} else if (viewType == FormController.TABLE_VIEW || viewType == FormController.LOCKED_TABLE_VIEW || viewType == IForm.LIST_VIEW || viewType == FormController.LOCKED_LIST_VIEW) {
// try
// {
// Iterator it = f.getParts();
// while (it.hasNext())
// {
// Part p = (Part) it.next();
// if (p.getPartType() == Part.HEADER)
// {
// addHeaders = false;
// break;
// }
// }
// }
// catch (RepositoryException e)
// {
// Debug.error(e);
// }
Part body = null;
Iterator<Part> e2 = fp.getForm().getParts();
while (e2.hasNext()) {
Part part = e2.next();
if (part.getPartType() == Part.BODY) {
body = part;
break;
}
}
if (body == null) {
// Special case, form in tableview with no body. just create a default view object.
// $NON-NLS-1$
view = new WebRecordView("View");
return view;
} else {
int startY = fp.getForm().getPartStartYPos(body.getID());
int endY = body.getHeight();
int sizeHint = endY;
if (// small body and body is last
(sizeHint - startY) <= 40 && fp.getForm().getSize().height == sizeHint) {
sizeHint += Math.max(endY, 200 - sizeHint);
}
RuntimePortal viewScriptable = new RuntimePortal(new ChangesRecorder(null, null), app);
view = new WebCellBasedView("View", app, viewScriptable, f, f, app.getFlattenedSolution().getDataproviderLookup(app.getFoundSetManager(), f), fp.getScriptExecuter(), addHeaders, startY, endY, sizeHint, viewType);
viewScriptable.setComponent((WebCellBasedView) view, f);
if (dataRenderers[FormController.FORM_EDITOR] != null)
dataRenderers[FormController.FORM_EDITOR].destroy();
dataRenderers[FormController.FORM_EDITOR] = (WebCellBasedView) view;
}
}
if (container.get("View") != null) {
container.replace((WebMarkupContainer) view);
} else {
container.add((WebMarkupContainer) view);
}
return view;
}
Aggregations