use of com.servoy.j2db.dataprocessing.IDisplay in project servoy-client by Servoy.
the class WebDataRendererFactory method placeElements.
protected Map placeElements(IApplication app, Form form, IScriptExecuter listener, Map emptyDataRenderers, boolean printing, ControllerUndoManager undoManager, TabSequenceHelper<Component> tabSequence) throws Exception {
// $NON-NLS-1$
final boolean useAJAX = Utils.getAsBoolean(app.getRuntimeProperties().get("useAJAX"));
IDataProviderLookup dataProviderLookup = app.getFlattenedSolution().getDataproviderLookup(app.getFoundSetManager(), form);
Map listTocomplete = new HashMap();
Map labelForComponents = new HashMap();
String orientation = OrientationApplier.getHTMLContainerOrientation(app.getLocale(), app.getSolution().getTextOrientation());
// $NON-NLS-1$
boolean leftToRight = !"rtl".equalsIgnoreCase(orientation);
// $NON-NLS-1$
boolean isAnchoringEnabled = Utils.getAsBoolean(app.getRuntimeProperties().get("enableAnchors"));
// Insets insets = new Insets(0, 0, 0, 0);
for (IFormElement obj : Utils.iterate(form.getFormElementsSortedByFormIndex())) {
Point l = null;
l = (obj).getLocation();
// unknown where to add
if (l == null)
continue;
if (printing && obj instanceof ISupportPrinting) {
if (!((ISupportPrinting) obj).getPrintable())
continue;
}
Iterator it = emptyDataRenderers.values().iterator();
while (it.hasNext()) {
WebDataRenderer panel = (WebDataRenderer) it.next();
// Border border = panel.getBorder();
// if (border instanceof EmptyBorder)
// {
// insets = ((EmptyBorder)border).getBorderInsets();
// }
int start = panel.getLocation().y;
if (l.y >= start && l.y < start + panel.getSize().height) {
org.apache.wicket.Component comp = (org.apache.wicket.Component) ComponentFactory.createComponent(app, form, obj, dataProviderLookup, listener, printing);
if (comp != null) {
if (obj instanceof Field) {
String name = ((Field) obj).getName();
if (name != null && !"".equals(name)) {
labelForComponents.put(name, comp);
}
} else if (obj instanceof GraphicalComponent && (comp instanceof WebBaseLabel || comp instanceof WebBaseSubmitLink)) {
String labelFor = ((GraphicalComponent) obj).getLabelFor();
if (labelFor != null && !"".equals(labelFor)) {
labelForComponents.put(comp, labelFor);
}
}
if ((obj instanceof ISupportTabSeq) && (tabSequence != null)) {
tabSequence.add(panel, (ISupportTabSeq) obj, comp);
}
org.apache.wicket.Component newComp = comp;
if (newComp instanceof IDisplay) {
panel.addDisplayComponent(obj, (IDisplay) newComp);
} else if (newComp instanceof WebImageBeanHolder) {
WebImageBeanHolder wiBeanHolder = (WebImageBeanHolder) newComp;
Object bean = wiBeanHolder.getDelegate();
if (bean instanceof IServoyAwareBean) {
IServoyAwareBean ourBean = (IServoyAwareBean) bean;
panel.addDisplayComponent(obj, ourBean);
}
}
((IComponent) comp).setLocation(new Point((l.x), (l.y - start)));
if (form.getOnRecordEditStartMethodID() > 0 && comp instanceof IFieldComponent) {
if (useAJAX && comp instanceof IDisplayData && ((IDisplayData) comp).getDataProviderID() != null && !ScopesUtils.isVariableScope(((IDisplayData) comp).getDataProviderID())) {
StartEditOnFocusGainedEventBehavior.addNewBehaviour(comp);
}
}
// - beans
if (isAnchoringEnabled && (((obj instanceof Field) && WebAnchoringHelper.needsWrapperDivForAnchoring((Field) obj)) || (obj instanceof Bean) || ((obj instanceof GraphicalComponent) && ComponentFactory.isButton((GraphicalComponent) obj)))) {
panel.add(WebAnchoringHelper.getWrapperComponent(comp, obj, start, panel.getSize(), leftToRight, false));
} else {
panel.add(comp);
}
}
}
}
}
Iterator it = labelForComponents.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Entry) it.next();
Object key = entry.getKey();
if (key instanceof WebBaseLabel || key instanceof WebBaseSubmitLink) {
IFieldComponent component = (IFieldComponent) labelForComponents.get(entry.getValue());
if (component != null) {
if (key instanceof WebBaseLabel) {
((WebBaseLabel) entry.getKey()).setLabelFor(component);
} else {
((WebBaseSubmitLink) entry.getKey()).setLabelFor(component);
}
(component).addLabelFor((ILabel) entry.getKey());
if (!component.isVisible()) {
component.setComponentVisible(component.isVisible());
}
if (!component.isEnabled()) {
component.setComponentEnabled(component.isEnabled());
}
}
}
}
it = emptyDataRenderers.values().iterator();
while (it.hasNext()) {
WebDataRenderer panel = (WebDataRenderer) it.next();
panel.createDataAdapter(app, dataProviderLookup, listener, undoManager);
}
return listTocomplete;
}
use of com.servoy.j2db.dataprocessing.IDisplay in project servoy-client by Servoy.
the class FormController method propagateFindMode.
/*
* _____________________________________________________________ The methods below belong to this class
*/
@Override
public void propagateFindMode(boolean findMode) {
if (!findMode) {
application.getFoundSetManager().getEditRecordList().prepareForSave(true);
}
if (isReadOnly()) {
if (view != null) {
view.setEditable(findMode);
}
}
for (IDataRenderer dataRenderer : dataRenderers) {
if (dataRenderer != null) {
// see web cell based view that is used as a tableview and portal.
if (dataRenderer instanceof IDisplay) {
((IDisplay) dataRenderer).setValidationEnabled(!findMode);
} else {
DataAdapterList dal = dataRenderer.getDataAdapterList();
// disables related data en does getText instead if getValue on fields
dal.setFindMode(findMode);
dataRenderer.setAllNonFieldsEnabled(!findMode);
}
// }
// else
// {
// //dataRenderers[i].setUIEnabled(!findMode);
// }
}
}
}
use of com.servoy.j2db.dataprocessing.IDisplay in project servoy-client by Servoy.
the class PartNode method getAggregatesFromRenderer.
private void getAggregatesFromRenderer(final List<AggregateVariable> aggregates, final Form f, DataRenderer a_renderer) throws RepositoryException {
Map<IPersist, IDisplay> allFields = a_renderer.getFieldComponents();
Iterator<IDisplay> it = allFields.values().iterator();
while (it.hasNext()) {
IDisplay display = it.next();
if (display instanceof IDisplayData) {
String dataProviderID = ((IDisplayData) display).getDataProviderID();
if (dataProviderID != null) {
IDataProvider dp = application.getFlattenedSolution().getDataproviderLookup(application.getFoundSetManager(), f).getDataProvider(dataProviderID);
if (dp instanceof AggregateVariable) {
if (!aggregates.contains(dp))
aggregates.add((AggregateVariable) dp);
}
} else if (display instanceof IDisplayTagText) {
String tagText = ((IDisplayTagText) display).getTagText();
Text.processTags(tagText, new ITagResolver() {
public String getStringValue(String name) {
try {
IDataProvider dp = application.getFlattenedSolution().getDataproviderLookup(application.getFoundSetManager(), f).getDataProvider(name);
if (dp instanceof AggregateVariable) {
if (!aggregates.contains(dp))
aggregates.add((AggregateVariable) dp);
}
} catch (Exception e) {
Debug.error(e);
}
return null;
}
});
}
}
}
}
use of com.servoy.j2db.dataprocessing.IDisplay in project servoy-client by Servoy.
the class DataRenderer method createDataAdapter.
void createDataAdapter(IApplication app, IDataProviderLookup dataProviderLookup, IScriptExecuter el, ControllerUndoManager undoManager) throws Exception {
// IScriptExecutor can be null for a design component
FormController formController = el == null ? null : el.getFormController();
dataAdapterList = new DataAdapterList(app, dataProviderLookup, fieldComponents, formController, null, undoManager);
// make it really fields only
HashMap<IPersist, IDisplay> f = new HashMap<IPersist, IDisplay>();
Iterator<Map.Entry<IPersist, IDisplay>> it = fieldComponents.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<IPersist, IDisplay> element = it.next();
if (element.getValue() instanceof IDisplayData) {
String id = ((IDisplayData) element.getValue()).getDataProviderID();
if (dataProviderLookup.getDataProvider(id) instanceof ScriptVariable) {
globalFields.add(element.getValue());
}
f.put(element.getKey(), element.getValue());
}
}
fieldComponents = f;
}
use of com.servoy.j2db.dataprocessing.IDisplay in project servoy-client by Servoy.
the class DataRendererFactory method placeElements.
// returns usesSliding
private Map placeElements(Iterator<IFormElement> e1, IApplication app, Form form, IScriptExecuter listner, Map emptyDataRenderers, int width, int XCorrection, int YCorrection, boolean printing, boolean cutDataProviderNames, ControllerUndoManager undoManager, boolean isPortal, TabSequenceHelper<Component> tabSequence) throws Exception {
IDataProviderLookup dataProviderLookup = app.getFlattenedSolution().getDataproviderLookup(app.getFoundSetManager(), form);
Map listTocomplete = new HashMap();
Map labelForComponents = new HashMap();
// Insets insets = new Insets(0, 0, 0, 0);
while (e1.hasNext()) {
Point l = null;
IPersist obj = e1.next();
l = ((IFormElement) obj).getLocation();
// unkown where to add
if (l == null)
continue;
if (printing && obj instanceof ISupportPrinting) {
if (!((ISupportPrinting) obj).getPrintable())
continue;
}
Iterator it = emptyDataRenderers.values().iterator();
while (it.hasNext()) {
DataRenderer panel = (DataRenderer) it.next();
int start = panel.getLocation().y;
if (l.y >= start && l.y < start + panel.getSize().height) {
Component comp = (Component) ComponentFactory.createComponent(app, form, obj, dataProviderLookup, listner, printing);
// Test for a visible bean, then get the real component
if (comp instanceof VisibleBean) {
comp = ((VisibleBean) comp).getDelegate();
}
if (comp != null) {
if (obj instanceof Field && comp instanceof JComponent) {
String name = ((Field) obj).getName();
if (name != null && !"".equals(name)) {
labelForComponents.put(name, comp);
}
} else if (obj instanceof GraphicalComponent && comp instanceof JLabel) {
String labelFor = ((GraphicalComponent) obj).getLabelFor();
if (labelFor != null && !"".equals(labelFor)) {
labelForComponents.put(comp, labelFor);
}
}
if (obj instanceof ISupportTabSeq && comp instanceof JComponent && (tabSequence != null)) {
tabSequence.add(panel, (ISupportTabSeq) obj, comp);
}
Component newComp = comp;
if (newComp instanceof IDisplay) {
// HACK:don;t no other way to do this.........
if (newComp instanceof IDisplayData && cutDataProviderNames) {
IDisplayData da = (IDisplayData) newComp;
String id = da.getDataProviderID();
if (id != null && !ScopesUtils.isVariableScope(id)) {
// only cut first relation (so you can have relation chain inside portal)
int index = id.indexOf('.');
// TODO:check if part before . is same as relation name (objToRender.getRelationID() )
if (index > 0) {
id = id.substring(index + 1);
}
da.setDataProviderID(id);
}
}
panel.addDisplayComponent(obj, (IDisplay) newComp);
}
comp.setLocation((l.x) + XCorrection, (l.y - start) + YCorrection);
int index = 0;
if (!printing && obj instanceof ISupportAnchors) {
panel.add(comp, new Integer(((ISupportAnchors) obj).getAnchors()), index);
} else if (printing) {
if (obj instanceof ISupportPrintSliding && !isPortal) {
int slide = ((ISupportPrintSliding) obj).getPrintSliding();
if (slide != ISupportPrintSliding.NO_SLIDING) {
listTocomplete.put(comp, new Integer(slide));
panel.setUsingSliding(true);
}
}
panel.add(comp, index);
} else {
panel.add(comp, index);
}
}
}
}
}
if (!printing) {
Iterator it = labelForComponents.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Entry) it.next();
if (entry.getKey() instanceof JLabel) {
JComponent component = (JComponent) labelForComponents.get(entry.getValue());
if (component != null) {
((JLabel) entry.getKey()).setLabelFor(component);
if (component instanceof IFieldComponent) {
((IFieldComponent) component).addLabelFor((ILabel) entry.getKey());
if (!((IFieldComponent) component).isVisible()) {
((IFieldComponent) component).setComponentVisible(((IFieldComponent) component).isVisible());
}
if (!((IFieldComponent) component).isEnabled()) {
((IFieldComponent) component).setComponentEnabled(((IFieldComponent) component).isEnabled());
}
}
}
}
}
}
Iterator it = emptyDataRenderers.values().iterator();
while (it.hasNext()) {
DataRenderer panel = (DataRenderer) it.next();
panel.createDataAdapter(app, dataProviderLookup, listner, undoManager);
}
return listTocomplete;
}
Aggregations