use of com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method applyStyleOnComponent.
private void applyStyleOnComponent(Component comp, Object bgColor, Object fgColor, Object compFont, Object listItemBorder) {
if (comp instanceof IScriptableProvider) {
IScriptable s = ((IScriptableProvider) comp).getScriptObject();
if (s instanceof IRuntimeComponent) {
IRuntimeComponent sbm = (IRuntimeComponent) s;
RenderableWrapper sbmRW = null;
if (s instanceof ISupportOnRenderCallback) {
IScriptRenderMethods sr = ((ISupportOnRenderCallback) s).getRenderable();
if (sr instanceof RenderableWrapper)
sbmRW = (RenderableWrapper) sr;
}
if (bgColor != null) {
if (sbmRW != null)
sbmRW.clearProperty(RenderableWrapper.PROPERTY_BGCOLOR);
String oldColor = sbm.getBgcolor();
sbm.setBgcolor(bgColor.toString());
if (sbm instanceof AbstractRuntimeBaseComponent && ((AbstractRuntimeBaseComponent) sbm).getComponent() instanceof WebDataLookupField) {
((WebDataLookupField) ((AbstractRuntimeBaseComponent) sbm).getComponent()).setListColor(PersistHelper.createColor(oldColor));
}
if (sbm.isTransparent()) {
// apply the bg color even if transparent by clearing the transparent flag in the property changes map
if (comp instanceof IProviderStylePropertyChanges && ((IProviderStylePropertyChanges) comp).getStylePropertyChanges() instanceof IStylePropertyChangesRecorder) {
((IStylePropertyChangesRecorder) (((IProviderStylePropertyChanges) comp).getStylePropertyChanges())).setTransparent(false);
}
}
} else {
if (sbmRW != null && !Utils.equalObjects(sbmRW.getOnRenderSetProperties().get(RenderableWrapper.PROPERTY_BGCOLOR), sbm.getBgcolor()))
sbmRW.clearProperty(RenderableWrapper.PROPERTY_BGCOLOR);
sbm.setBgcolor(sbm.getBgcolor());
setParentBGcolor(comp, "");
}
if (fgColor != null) {
if (sbmRW != null)
sbmRW.clearProperty(RenderableWrapper.PROPERTY_FGCOLOR);
sbm.setFgcolor(fgColor.toString());
} else {
if (sbmRW != null && !Utils.equalObjects(sbmRW.getOnRenderSetProperties().get(RenderableWrapper.PROPERTY_FGCOLOR), sbm.getFgcolor())) {
sbmRW.clearProperty(RenderableWrapper.PROPERTY_FGCOLOR);
}
sbm.setFgcolor(sbm.getFgcolor());
}
if (compFont != null) {
if (sbmRW != null && !Utils.equalObjects(sbmRW.getOnRenderSetProperties().get(RenderableWrapper.PROPERTY_FONT), sbm.getFont()))
sbmRW.clearProperty(RenderableWrapper.PROPERTY_FONT);
sbm.setFont(compFont.toString());
} else {
if (sbmRW != null)
sbmRW.clearProperty(RenderableWrapper.PROPERTY_FONT);
sbm.setFont(sbm.getFont());
}
if (listItemBorder != null) {
// TODO left / right part of this list item border should only be applied on first / last components in the row (for table view)
// like it is done in servoy.js when client side styling is used
String newBorder = listItemBorder.toString();
Border currentBorder = ComponentFactoryHelper.createBorder(sbm.getBorder());
Border marginBorder = null;
if (currentBorder instanceof EmptyBorder) {
marginBorder = currentBorder;
} else if (currentBorder instanceof CompoundBorder && ((CompoundBorder) currentBorder).getInsideBorder() instanceof EmptyBorder) {
marginBorder = ((CompoundBorder) currentBorder).getInsideBorder();
}
if (marginBorder != null) {
newBorder = ComponentFactoryHelper.createBorderString(BorderFactory.createCompoundBorder(ComponentFactoryHelper.createBorder(newBorder), marginBorder));
}
if (sbmRW != null)
sbmRW.clearProperty(RenderableWrapper.PROPERTY_BORDER);
sbm.setBorder(newBorder);
// reset size so the web size will be recalculated based on the new border
sbm.setSize(sbm.getWidth(), sbm.getHeight());
} else {
if (sbmRW != null && !Utils.equalObjects(sbmRW.getOnRenderSetProperties().get(RenderableWrapper.PROPERTY_BORDER), sbm.getBorder()))
sbmRW.clearProperty(RenderableWrapper.PROPERTY_BORDER);
sbm.setBorder(sbm.getBorder());
}
}
}
}
use of com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent in project servoy-client by Servoy.
the class CellNativeJavaObject method get.
@Override
public Object get(String name, Scriptable start) {
Object val = super.get(name, start);
if (val instanceof Function) {
if ("requestFocus".equals(name)) {
// must remember to request focus for the according cell in the cell view...
// when that cell's component is created
view.setColumnThatRequestsFocus(uiComponent);
val = new BaseFunction();
} else if ("putClientProperty".equals(name) && javaObject instanceof AbstractRuntimeBaseComponent) {
// put client properties for all elements in table view
val = new WebCellBasedViewPutClientPropertyFunction(view, ((AbstractRuntimeBaseComponent<?>) javaObject).getPersist(), (Function) val);
} else if ("getClientProperty".equals(name) && javaObject instanceof AbstractRuntimeBaseComponent) {
// put client properties for all elements in table view
val = new WebCellBasedViewGetClientPropertyFunction(view, ((AbstractRuntimeBaseComponent<?>) javaObject).getPersist(), (Function) val);
}
}
return val;
}
Aggregations