use of com.servoy.j2db.smart.dataui.StyledEnablePanel in project servoy-client by Servoy.
the class SwingForm method initView.
public IView initView(IApplication application, FormController fp, int viewType) {
view = null;
IDataRenderer[] dataRenderers = fp.getDataRenderers();
setTitleHeader((JComponent) dataRenderers[Part.TITLE_HEADER]);
setHeader((JComponent) dataRenderers[Part.HEADER]);
setLeadingGrandSummary((JComponent) dataRenderers[Part.LEADING_GRAND_SUMMARY]);
setTrailingGrandSummary((JComponent) dataRenderers[Part.TRAILING_GRAND_SUMMARY]);
setFooter((JComponent) dataRenderers[Part.FOOTER]);
// remove any left slider
setWest(null);
switch(viewType) {
case FormController.LOCKED_LIST_VIEW:
case IForm.LIST_VIEW:
view = new ListView();
PrototypeState proto = null;
if (fp.getFoundSet() != null) {
proto = fp.getFoundSet().getPrototypeState();
} else {
proto = new PrototypeState(null);
}
// this call is extreemly inportant, it prevent all rows retrieval
((ListView) view).setPrototypeCellValue(proto);
FormBodyEditor editor = null;
if (dataRenderers[FormController.FORM_RENDERER] != null) {
Component[] rendererComponents = ((Container) dataRenderers[FormController.FORM_RENDERER]).getComponents();
for (Component rendererComponent : rendererComponents) {
if (rendererComponent instanceof ISupportAsyncLoading) {
// in listview it is impossible to get lazy loaded images displaying correctly, due to needed repaintfire, which we cannot initiate
((ISupportAsyncLoading) rendererComponent).setAsyncLoadingEnabled(false);
}
rendererComponent.setFocusable(false);
}
((Component) dataRenderers[FormController.FORM_RENDERER]).setFocusable(false);
}
editor = new FormBodyEditor((DataRenderer) dataRenderers[FormController.FORM_EDITOR]);
if (dataRenderers[FormController.FORM_RENDERER] != null) {
DataRenderer dr = (DataRenderer) dataRenderers[FormController.FORM_RENDERER];
dr.setRenderer(true);
String bgcolorCalc = fp.getForm().getRowBGColorCalculation();
if (bgcolorCalc != null) {
// dr.setRowBGColorProvider(bgcolorCalc);
dr.setShowSelection(false);
// $NON-NLS-1$
((ListView) view).setRowBGColorScript(bgcolorCalc, fp.getForm().getFlattenedMethodArguments("rowBGColorCalculation"));
((DataRenderer) dataRenderers[FormController.FORM_EDITOR]).setShowSelection(false);
}
((ListView) view).setCellRenderer(dr);
} else {
// form with no body part - used only for printing probably
((ListView) view).setCellRenderer(new ListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
// $NON-NLS-1$
return new JLabel("");
}
});
}
((ListView) view).setCellEditor(editor);
((ListView) view).setRendererSameAsEditor(false);
((ListView) view).setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
break;
case FormController.LOCKED_TABLE_VIEW:
case FormController.TABLE_VIEW:
view = new TableView(application, fp, fp.getForm(), fp.getForm(), fp.getScriptExecuter(), dataRenderers[Part.HEADER], dataRenderers[Part.LEADING_GRAND_SUMMARY], false);
if (dataRenderers[FormController.FORM_EDITOR] != null)
dataRenderers[FormController.FORM_EDITOR].destroy();
dataRenderers[FormController.FORM_EDITOR] = (IDataRenderer) view;
if (formController.getBodyStyle() != null) {
Pair<IStyleSheet, IStyleRule> pairStyle = ComponentFactory.getCSSPairStyleForForm(application, fp.getForm());
if (pairStyle != null && pairStyle.getLeft() != null) {
Border border = pairStyle.getLeft().getBorder(formController.getBodyStyle());
if (border != null) {
innerPanel.setBorder(border);
}
}
}
break;
case IForm.LOCKED_RECORD_VIEW:
case IForm.RECORD_VIEW:
default:
view = new RecordView(formController);
if (dataRenderers[FormController.FORM_EDITOR] != null) {
((DataRenderer) dataRenderers[FormController.FORM_EDITOR]).setShowSelection(false);
((RecordView) view).setCellRenderer((DataRenderer) dataRenderers[FormController.FORM_EDITOR]);
}
int form_id = fp.getForm().getNavigatorID();
if (form_id == 0) {
StyledEnablePanel slider = ((RecordView) view).getSliderComponent();
if (bgColor != null)
slider.setBackground(bgColor);
setWest(slider);
}
}
getVerticalScrollBar().setValue(1);
getVerticalScrollBar().setValue(0);
setViewportView((JComponent) view);
if (view instanceof TableView) {
// the table view needs it's orientation set correctly
OrientationApplier.setOrientationToAWTComponent(this, application.getLocale(), application.getSolution().getTextOrientation());
}
if (view instanceof ListView) {
view.requestFocus();
}
OrientationApplier.setOrientationToAWTComponent(this, application.getLocale(), application.getSolution().getTextOrientation());
if ((bgColor != null) && (view instanceof ListView))
((ListView) view).setBackground(bgColor);
// except if it's a table view, that is always transparent
if (!(view instanceof TableView)) {
setOpaque(isOpaque());
} else {
for (int i = FormController.FORM_RENDERER + 1; i < dataRenderers.length; i++) {
if (dataRenderers[i] != null && !(dataRenderers[i] instanceof TableView)) {
dataRenderers[i].setOpaque(isOpaque());
}
}
}
return view;
}
Aggregations