use of com.servoy.j2db.util.IStyleSheet in project servoy-client by Servoy.
the class TemplateGenerator method createFieldHTML.
private static void createFieldHTML(Field field, Form form, StringBuffer html, TextualCSS css, int startY, int endY, boolean enableAnchoring, IServiceProvider sp) {
boolean addWrapperDiv = enableAnchoring && WebAnchoringHelper.needsWrapperDivForAnchoring(field);
TextualStyle styleObj = css.addStyle('#' + ComponentFactory.getWebID(form, field));
boolean[] userCssClassAdded = new boolean[] { false };
Properties minSizeStyle = styleObj;
if (addWrapperDiv) {
// Anchoring fields (<input>s, <textarea>s) with { left: 0px; right: 0px; } pair
// or { top: 0px; bottom: 0px; } does not work. Thus we add a dummy wrapper <div>
// which accepts this kind of anchoring, and we place the field inside the <div>
// with { width: 100%; height: 100%; }, which works fine.
String wrapperId = ComponentFactory.getWebID(form, field) + WRAPPER_SUFFIX;
TextualStyle wrapperStyle = css.addStyle('#' + wrapperId);
wrapperStyle.setProperty("overflow", "visible");
minSizeStyle = wrapperStyle;
html.append("<div ");
html.append(getWicketIDParameter(form, field, "", WRAPPER_SUFFIX));
html.append(getJavaScriptIDParameter(form, field, "", WRAPPER_SUFFIX));
if (field.getDisplayType() == Field.COMBOBOX) {
html.append(getCssClassForElement(field, userCssClassAdded, COMBOBOX_CLASS));
}
html.append(getCssClassForElement(field, userCssClassAdded, ""));
html.append(">");
}
Insets padding = (Insets) DEFAULT_FIELD_PADDING.clone();
Insets border = (Insets) DEFAULT_FIELD_BORDER_SIZE.clone();
if (field.getDisplayType() == Field.COMBOBOX || field.getDisplayType() == Field.LIST_BOX || field.getDisplayType() == Field.MULTISELECT_LISTBOX) {
padding = DEFAULT_LABEL_PADDING;
}
BorderAndPadding ins = applyBaseComponentProperties(field, form, styleObj, padding, border, sp);
Pair<IStyleSheet, IStyleRule> pairStyle = ComponentFactory.getCSSPairStyleForForm(sp, form);
IStyleSheet ss = pairStyle != null ? pairStyle.getLeft() : null;
// By default no css class applied.
String cssClass = "";
switch(field.getDisplayType()) {
case Field.PASSWORD:
{
if (ins == null) {
ins = new BorderAndPadding(DEFAULT_FIELD_BORDER_SIZE, DEFAULT_FIELD_PADDING);
}
html.append("<input ");
html.append(getWicketIDParameter(form, field));
// html.append(getJavaScriptIDParameter(field));
html.append(getDataProviderIDParameter(field));
html.append(getCssClassForElement(field, userCssClassAdded, "field"));
html.append("type='password' ");
if (field.getSelectOnEnter()) {
// $NON-NLS-1$
html.append("onfocus='Servoy.Utils.doSelect(this)'");
}
html.append("/>");
}
break;
case Field.RTF_AREA:
{
applyScrolling(styleObj, field);
html.append("<div ");
html.append(getCssClassForElement(field, userCssClassAdded, "field"));
html.append(getWicketIDParameter(form, field));
// html.append(getJavaScriptIDParameter(field));
html.append(">RTF field not supported in webclient</div>");
}
break;
case Field.HTML_AREA:
if (!field.getEditable()) {
applyScrolling(styleObj, field);
html.append("<div ");
html.append(getWicketIDParameter(form, field));
// html.append(getJavaScriptIDParameter(field));
html.append(getCssClassForElement(field, userCssClassAdded, "field"));
html.append(">non editable HTML field</div>");
boolean hasFontFamily = styleObj.containsKey("font-family");
boolean hasFontSize = styleObj.containsKey("font-size");
if (hasFontFamily || hasFontSize) {
for (String dfe : DEFAULT_FONT_ELEMENTS) {
TextualStyle htmlAreaFont = css.addStyle('#' + ComponentFactory.getWebID(form, field) + " " + dfe);
if (hasFontFamily)
htmlAreaFont.setProperty("font-family", styleObj.getProperty("font-family"));
if (hasFontSize)
htmlAreaFont.setProperty("font-size", styleObj.getProperty("font-size"));
}
}
break;
} else {
String editorId = "editor_" + ComponentFactory.getWebID(form, field);
html.append("<div ");
html.append(getWicketIDParameter(form, field));
html.append("><textarea id='");
html.append(editorId);
html.append("' name='");
html.append(editorId);
html.append("' ");
html.append(getWicketIDParameter(form, field, "editor_", ""));
html.append(" rows=\"20\" cols=\"75\"></textarea></div>");
styleObj.setProperty("padding", "0px");
styleObj.setProperty("overflow", "hidden");
}
break;
case Field.TEXT_AREA:
{
if (ins == null) {
ins = new BorderAndPadding(DEFAULT_FIELD_BORDER_SIZE, DEFAULT_FIELD_PADDING);
}
applyScrolling(styleObj, field);
html.append("<textarea ");
html.append(getWicketIDParameter(form, field));
// html.append(getJavaScriptIDParameter(field));
html.append(getDataProviderIDParameter(field));
html.append(getCssClassForElement(field, userCssClassAdded, "field"));
html.append("></textarea>");
}
break;
case Field.CHECKS:
case Field.RADIOS:
boolean isRadio = (field.getDisplayType() == Field.RADIOS);
String selector = (isRadio ? "radio" : "check");
cssClass = (isRadio ? "radio" : "check");
IValueList val = null;
ValueList valuelist = null;
if (field.getValuelistID() > 0 && sp != null) {
valuelist = sp.getFlattenedSolution().getValueList(field.getValuelistID());
}
boolean addSingle = ComponentFactory.isSingleValue(valuelist);
// If we have multiple checkboxes, then the default is "field".
if (field.getValuelistID() > 0 && !addSingle && !isRadio)
cssClass = "radioCheckField";
// If we have a style for the form, apply "check" class if present, default to "field" if "check" class is not present.
if (ss != null) {
cssClass = "radioCheckField";
String lookUpValue = selector;
IStyleRule s = ss.getCSSRule(lookUpValue);
if (s.getAttributeCount() == 0) {
if ((field.getStyleClass() != null) && (field.getStyleClass().trim().length() > 0)) {
lookUpValue += '.' + field.getStyleClass().trim();
s = ss.getCSSRule(lookUpValue);
if (s.getAttributeCount() > 0)
cssClass = selector;
}
} else {
cssClass = selector;
}
}
if ((field.getValuelistID() > 0 || isRadio) && !addSingle) {
applyScrolling(styleObj, field);
html.append("<div ");
html.append(getWicketIDParameter(form, field));
// html.append(getJavaScriptIDParameter(field));
html.append(getDataProviderIDParameter(field));
html.append(getCssClassForElement(field, userCssClassAdded, cssClass));
html.append(">Multi checkboxes</div>");
} else {
html.append("<div ");
html.append(getCssClassForElement(field, userCssClassAdded, cssClass));
html.append(getWicketIDParameter(form, field));
html.append(" tabIndex=\"-1\" ");
//
html.append(">");
html.append("<table cellspacing='0' cellpadding='0' border='0' width='100%' height='100%'><tr><td id='check_td' style='vertical-align: middle;'><input onmousedown='radioCheckInputMouseDown=true' onmouseup='radioCheckInputMousedDown=false' onmouseout='radioCheckInputMouseDown=false' class='radioCheckInput' style='border-width: 0px; padding: " + (isRadio ? "0px" : "3px") + //
"; margin: 0px; vertical-align: middle;' ");
html.append(getWicketIDParameter(form, field, "check_", ""));
html.append(getDataProviderIDParameter(field));
if (isRadio) {
html.append("type='radio' ");
} else {
html.append("type='checkbox' ");
}
html.append("/>");
html.append("<label style='border-width: 0px; padding-top: " + (isRadio ? "0px" : "2px") + "; padding-left: 3px; margin: 0px; vertical-align: middle;");
html.append("' ");
html.append(getWicketIDParameter(form, field, "text_", ""));
html.append(">");
html.append("</label>");
html.append("</td></tr></table></div>");
}
break;
case Field.COMBOBOX:
{
ins = null;
// if (ins == null)
// {
// ins = new BorderAndPadding(DEFAULT_FIELD_BORDER_SIZE,DEFAULT_FIELD_PADDING);
// }
html.append("<select ");
html.append(getWicketIDParameter(form, field));
// html.append(getJavaScriptIDParameter(field));
html.append(getDataProviderIDParameter(field));
html.append(getCssClassForElement(field, userCssClassAdded, "field"));
html.append(">Combobox</select>");
}
break;
case Field.MULTISELECT_LISTBOX:
case Field.LIST_BOX:
{
ins = null;
html.append("<select ");
if (field.getDisplayType() == Field.MULTISELECT_LISTBOX) {
html.append("multiple=\"multiple\"");
}
html.append(getWicketIDParameter(form, field));
html.append(getDataProviderIDParameter(field));
html.append(getCssClassForElement(field, userCssClassAdded, "listbox"));
html.append(">Listbox</select>");
}
break;
case Field.CALENDAR:
case Field.SPINNER:
createCompositeFieldHTML(html, form, field, styleObj, userCssClassAdded);
break;
case Field.IMAGE_MEDIA:
{
applyScrolling(styleObj, field);
// in tableview position is not set
styleObj.setProperty("position", "relative");
html.append("<div ");
html.append(getWicketIDParameter(form, field));
// html.append(getJavaScriptIDParameter(field));
html.append(getCssClassForElement(field, userCssClassAdded, "field"));
html.append('>');
TextualStyle inline2 = new TextualStyle();
// inline2.setProperty("top", "1px");
// inline2.setProperty("left", "1px");
// inline2.setProperty("position", "absolute");
// inline2.setProperty("cursor", "pointer");
// inline2.setProperty("background-color", "gray");
inline2.setProperty("z-index", "1");
html.append("<img ");
html.append(inline2.toString());
html.append(" border=0 servoy:id='save_icon' src='#' class='image-media-save' alt='Save' />");
html.append("<img ");
// inline2.setProperty("left", "17px");
html.append(inline2.toString());
html.append(" border=0 servoy:id='upload_icon' src='#' class='image-media-upload' alt='Upload' />");
html.append("<img ");
// inline2.setProperty("left", "33px");
html.append(inline2.toString());
html.append(" border=0 servoy:id='remove_icon' src='#' class='image-media-remove' alt='Remove' />");
// html.append("<a ");
// html.append(inline2.toString());
// html.append(" servoy:id='upload' href='#' border=0><img servoy:id='upload_icon' src='#' alt='' /></a>");
// html.append("<a ");
// inline2.setProperty("left","16px");
// html.append(inline2.toString());
// html.append(" servoy:id='save' href='#' border=0><img servoy:id='save_icon' src='#' alt='' /></a>");
TextualStyle inline = new TextualStyle();
inline.setProperty("top", "0px");
inline.setProperty("left", "0px");
inline.setProperty("position", "absolute");
if (field.getOnActionMethodID() < 1) {
inline.setProperty("cursor", "default");
}
html.append("<input ");
html.append(inline.toString());
html.append(getWicketIDParameter(form, field));
html.append(getJavaScriptIDParameter(form, field));
html.append("value='");
if (field.getName() != null)
html.append(field.getName());
html.append("' ");
html.append("type='image' ");
html.append(" src='#' alt='' ");
html.append(" onclick='return false;' ");
html.append("/>");
// html.append("<img ");
// html.append(inline.toString());
// html.append(" src='#' alt='' ");
// html.append(getWicketIDParameter(field));
// html.append(" />");
html.append("</div>");
}
break;
default:
case Field.TYPE_AHEAD:
case Field.TEXT_FIELD:
{
if (ins == null) {
ins = new BorderAndPadding(DEFAULT_FIELD_BORDER_SIZE, DEFAULT_FIELD_PADDING);
}
html.append("<input ");
html.append(getWicketIDParameter(form, field));
// html.append(getJavaScriptIDParameter(field));
html.append(getDataProviderIDParameter(field));
html.append(getCssClassForElement(field, userCssClassAdded, field.getValuelistID() > 0 ? "field typeahead" : "field"));
html.append("type='text' ");
if (field.getSelectOnEnter()) {
// $NON-NLS-1$
html.append("onfocus='Servoy.Utils.doSelect(this)'");
}
html.append("/>");
}
break;
}
if (field.getHorizontalAlignment() != -1) {
if (// all who's actual implementation is based on WebDataCompositeTextField
isCompositeTextField(field.getDisplayType())) {
TextualStyle childTextCSS = css.addStyle('#' + ComponentFactory.getWebID(form, field) + WebDataCompositeTextField.AUGMENTED_FIELD_ID);
applyTextProperties(field, childTextCSS);
} else {
applyTextProperties(field, styleObj);
}
}
Insets borderAndPadding = ins == null ? new Insets(0, 0, 0, 0) : ins.getSum();
WebAnchoringHelper.addMinSize(field.getAnchors(), sp, minSizeStyle, new Dimension(field.getSize().width - borderAndPadding.left - borderAndPadding.right, field.getSize().height - borderAndPadding.top - borderAndPadding.bottom), field);
if (addWrapperDiv) {
html.append("</div>");
styleObj.setProperty("width", "100%");
styleObj.setProperty("height", "100%");
styleObj.setProperty("position", "absolute");
} else {
applyLocationAndSize(field, styleObj, ins, startY, endY, form.getSize().width, enableAnchoring, isListViewBodyElement(form, field.getLocation()) ? new Point(-3, 0) : null);
}
}
use of com.servoy.j2db.util.IStyleSheet in project servoy-client by Servoy.
the class TemplateGenerator method createGraphicalComponentHTML.
private static void createGraphicalComponentHTML(GraphicalComponent label, Form form, StringBuffer html, TextualCSS css, int startY, int endY, boolean enableAnchoring, IServiceProvider sp) {
String styleName = "#";
Insets border = null;
if (ComponentFactory.isButton(label) && !hasHTMLText(label.getText())) {
// styleName = "input.";
border = DEFAULT_BUTTON_BORDER_SIZE;
}
TextualStyle styleObj = css.addStyle(styleName + ComponentFactory.getWebID(form, label));
BorderAndPadding ins = applyBaseComponentProperties(label, form, styleObj, (Insets) DEFAULT_LABEL_PADDING.clone(), border, sp);
// fix the background img, see ComponentFactory.createGraphicalComponent
// background image through css will only be used when repeat or position are set (or linear gradient is used).
// if both are not specified then it is used as the MEDIA of the label/button, so bck_img is removed from the css.
boolean keepBgImageStyle = false;
for (String attribute : ServoyStyleSheet.BACKGROUND_IMAGE_CSS) {
if (attribute.equals(CSS.Attribute.BACKGROUND_IMAGE.toString())) {
if (styleObj.getProperty(attribute) == null) {
keepBgImageStyle = false;
break;
} else if (!styleObj.getProperty(attribute).contains(MediaURLStreamHandler.MEDIA_URL_DEF)) {
keepBgImageStyle = true;
break;
}
} else if (styleObj.getProperty(attribute) != null) {
keepBgImageStyle = true;
break;
}
}
if (!keepBgImageStyle) {
styleObj.remove(CSS.Attribute.BACKGROUND_IMAGE.toString());
}
applyTextProperties(label, styleObj);
Field labelForField = null;
String labelFor = label.getLabelFor();
if (labelFor != null) {
Iterator<IPersist> fields = form.getObjects(IRepository.FIELDS);
while (fields.hasNext()) {
Field fld = (Field) fields.next();
if (labelFor.equals(fld.getName())) {
labelForField = fld;
break;
}
}
}
int labelHAlign = label.getHorizontalAlignment();
int labelVAlign = label.getVerticalAlignment();
Pair<IStyleSheet, IStyleRule> styleInfo = ComponentFactory.getStyleForBasicComponent(sp, label, form);
if (styleInfo != null) {
IStyleSheet ss = styleInfo.getLeft();
IStyleRule s = styleInfo.getRight();
if (labelHAlign == -1)
labelHAlign = ss.getHAlign(s);
if (labelVAlign == -1)
labelVAlign = ss.getVAlign(s);
}
// Defaults are mapped to CENTER (or MIDDLE for vertical) to keep behavior from Smart client.
if (labelHAlign == -1)
labelHAlign = ISupportTextSetup.CENTER;
if (labelVAlign == -1)
labelVAlign = ISupportTextSetup.CENTER;
boolean isButton = ComponentFactory.isButton(label);
boolean[] userCssClassAdded = new boolean[] { false };
TextualStyle wrapperStyle = null;
Properties minSizeStyle = styleObj;
if (isButton && enableAnchoring) {
// Anchoring <button> with { left: 0px; right: 0px; } pair
// or { top: 0px; bottom: 0px; } does not work. Thus we add a dummy wrapper <div>
// which accepts this kind of anchoring, and we place the button inside the <div>
// with { width: 100%; height: 100%; }, which works fine.
String wrapperId = ComponentFactory.getWebID(form, label) + WRAPPER_SUFFIX;
wrapperStyle = css.addStyle(styleName + wrapperId);
minSizeStyle = wrapperStyle;
html.append("<div ");
html.append(getCssClassForElement(label, userCssClassAdded, ""));
html.append(getWicketIDParameter(form, label, "", WRAPPER_SUFFIX));
html.append(getJavaScriptIDParameter(form, label, "", WRAPPER_SUFFIX));
html.append(">");
}
Insets buttonBorder = null;
if (isButton) {
html.append("<button type='submit' ");
html.append(" style=\"white-space: nowrap;\" ");
html.append(getWicketIDParameter(form, label));
html.append(getDataProviderIDParameter(label));
html.append(getCssClassForElement(label, userCssClassAdded, "button"));
html.append(">");
html.append("</button>");
// buttons are border-box by default!!
buttonBorder = ins.getBorder();
ins = null;
} else {
if (labelForField != null) {
html.append("<label ");
// Needed for FF to accept a <div> inside a <label>.
styleObj.setProperty("display", "block");
} else {
html.append("<div ");
}
// we want to wrap only if there is no html content in the label text
if (label.getText() != null && !HtmlUtils.hasUsefulHtmlContent(label.getText())) {
html.append(" style=\"white-space: nowrap;\"");
}
html.append(getWicketIDParameter(form, label));
html.append(getDataProviderIDParameter(label));
html.append(getCssClassForElement(label, userCssClassAdded, "label"));
html.append('>');
boolean hasHtml = hasHTMLText(label.getText());
if (hasHtml && (label.getOnActionMethodID() != 0)) {
html.append("<servoy:remove>");
}
html.append(getSafeText(label.getText()));
if (hasHtml && (label.getOnActionMethodID() != 0)) {
html.append("</servoy:remove>");
}
if (labelForField != null) {
html.append("</label>");
} else {
html.append("</div>");
}
if (label.getOnActionMethodID() > 0)
styleObj.setProperty("cursor", "pointer");
}
Insets borderAndPadding = ins == null ? new Insets(0, 0, 0, 0) : ins.getSum();
WebAnchoringHelper.addMinSize(label.getAnchors(), sp, minSizeStyle, new Dimension(label.getSize().width - borderAndPadding.left - borderAndPadding.right, label.getSize().height - borderAndPadding.top - borderAndPadding.bottom), label);
if (isButton && enableAnchoring) {
html.append("</div>");
styleObj.setProperty("width", "100%");
styleObj.setProperty("height", "100%");
styleObj.setProperty("position", "absolute");
applyLocationAndSize(label, wrapperStyle, ins, startY, endY, form.getSize().width, enableAnchoring, isListViewBodyElement(form, label.getLocation()) ? new Point(-3, 0) : null);
} else {
applyLocationAndSize(label, styleObj, ins, startY, endY, form.getSize().width, enableAnchoring, isListViewBodyElement(form, label.getLocation()) ? new Point(-3, 0) : null);
}
if (label.getRolloverCursor() == Cursor.HAND_CURSOR) {
styleObj.setProperty("cursor", "pointer");
}
int height = label.getSize().height;
// See: http://doctype.com/html-button-tag-renders-strangely-firefox
if (isButton) {
int bottomPadding = 0;
if (labelVAlign != ISupportTextSetup.CENTER) {
bottomPadding = height;
if (buttonBorder != null)
bottomPadding -= buttonBorder.top + buttonBorder.bottom;
}
styleObj.setProperty("padding-bottom", bottomPadding + "px");
}
}
use of com.servoy.j2db.util.IStyleSheet in project servoy-client by Servoy.
the class ScrollResponseHeaderContainer method getStyleAttributeString.
/**
* Returns for styleAttribute:
* <p>
* <b>BGCOLOR</b>: an inline style string with background color to be applied to a component <br/>
* Needed because transparent colors are not supported in all browsers and a fallback color is also applied (if supplied)
* (ex: "background-color: #AAA;background-color: rgba(255,255,255,0.7)" )<br/>
* (<b>doesn't need further processing to be applyed on a component</b>)
* </p>
* <p>
* <b>FGCOLOR</b>: an inline style string to be applied to a component (same logic as GBcolor)
* (doesn't need further processing)
* </p>
* <p>
* <b>FONT</b>: string containing font font css rule values (needs further processing ,ex passed in ChangesRecorder.setFont())
* </p>
* <b>BORDER</b>: string containing font border css rule values (needs further processing ,ex passed inChangesRecorder.setBorder())
* @param style
* @param styleAttribute
* @return
*/
private String getStyleAttributeString(IStyleRule style, ISupportRowStyling.ATTRIBUTE styleAttribute) {
IStyleSheet ss = getRowStyleSheet();
if (ss != null && style != null) {
switch(styleAttribute) {
case BGIMAGE:
String[] bgImageMediaUrls = style.getValues(CSS.Attribute.BACKGROUND_IMAGE.toString());
if (bgImageMediaUrls != null) {
StringBuffer ret = new StringBuffer();
for (String val : bgImageMediaUrls) {
TextualStyle headerStyle = new TemplateGenerator.TextualStyle();
if (val.contains(MediaURLStreamHandler.MEDIA_URL_DEF)) {
// extract media://name from url("media:///name")
String urlContentVal = val.replaceAll(".*url\\([\"']?(.*?)[\"']?\\)", "$1");
String httpUrl = MediaURLStreamHandler.getTranslatedMediaURL(application.getFlattenedSolution(), urlContentVal);
headerStyle.setProperty(CSS.Attribute.BACKGROUND_IMAGE.toString(), "url(" + httpUrl + ")");
} else {
headerStyle.setProperty(CSS.Attribute.BACKGROUND_IMAGE.toString(), val);
}
// the returned string is style='...' , we nedd to get the ... part
String inlineStyle = headerStyle.toString();
if (inlineStyle != null)
ret.append(inlineStyle.substring(inlineStyle.indexOf('\'') + 1, inlineStyle.length() - 2));
}
// .replaceAll("(background-image:)(.*?)(;)(background-image:)", "$1");
return ret.toString();
} else {
return null;
}
case BGCOLOR:
if (style.getValues(CSS.Attribute.BACKGROUND_COLOR.toString()) != null) {
StringBuffer ret = new StringBuffer();
for (Color c : ss.getBackgrounds(style)) {
ret.append(CSS.Attribute.BACKGROUND_COLOR.toString()).append(':').append(PersistHelper.createColorString(c)).append(';');
}
return (ret.length() != 0) ? ret.toString() : null;
} else {
return null;
}
case FGCOLOR:
if (style.getValues(CSS.Attribute.COLOR.toString()) != null) {
StringBuffer ret = new StringBuffer();
for (Color c : ss.getForegrounds(style)) {
ret.append(CSS.Attribute.COLOR.toString()).append(':').append(PersistHelper.createColorString(c)).append(';');
}
return (ret.length() != 0) ? ret.toString() : null;
} else {
return null;
}
case FONT:
return ss.hasFont(style) ? PersistHelper.createFontString(ss.getFont(style)) : null;
case BORDER:
return ss.hasBorder(style) ? ComponentFactoryHelper.createBorderString(ss.getBorder(style)) : null;
case MARGIN:
// !WARNING! : Margin is applied as padding
if (ss.hasMargin(style)) {
TextualStyle marginStyle = new TemplateGenerator.TextualStyle();
String marginTop = style.getValue(CSS.Attribute.MARGIN_TOP.toString());
if (marginTop != null)
marginStyle.setProperty(CSS.Attribute.PADDING_TOP.toString(), marginTop);
String marginBottom = style.getValue(CSS.Attribute.MARGIN_BOTTOM.toString());
if (marginBottom != null)
marginStyle.setProperty(CSS.Attribute.PADDING_BOTTOM.toString(), marginBottom);
String marginLeft = style.getValue(CSS.Attribute.MARGIN_LEFT.toString());
if (marginLeft != null)
marginStyle.setProperty(CSS.Attribute.PADDING_LEFT.toString(), marginLeft);
String marginRight = style.getValue(CSS.Attribute.MARGIN_RIGHT.toString());
if (marginRight != null)
marginStyle.setProperty(CSS.Attribute.PADDING_RIGHT.toString(), marginRight);
StringBuffer ret = new StringBuffer();
// the returned string is style='...' , we nedd to get the ... part
String inlineStyle = marginStyle.toString();
if (inlineStyle != null)
ret.append(inlineStyle.substring(inlineStyle.indexOf('\'') + 1, inlineStyle.length() - 2));
return ret.toString();
}
}
}
return null;
}
use of com.servoy.j2db.util.IStyleSheet in project servoy-client by Servoy.
the class ComponentFactory method getCSSPairStyleForForm.
public static Pair<IStyleSheet, IStyleRule> getCSSPairStyleForForm(IServiceProvider sp, Form form) {
IStyleSheet styleSheet = getCSSStyleForForm(sp, form);
IStyleRule styleRule = getCSSRuleForForm(sp, form);
if (styleSheet != null && styleRule != null) {
return new Pair<IStyleSheet, IStyleRule>(styleSheet, styleRule);
}
return null;
}
use of com.servoy.j2db.util.IStyleSheet in project servoy-client by Servoy.
the class ComponentFactory method flushCachedItems.
@SuppressWarnings("unchecked")
public static void flushCachedItems(IServiceProvider provider) {
parsedStyles = new ConcurrentHashMap<Style, IStyleSheet>();
if (provider != null) {
provider.getRuntimeProperties().put(IServiceProvider.RT_VALUELIST_CACHE, null);
provider.getRuntimeProperties().put(IServiceProvider.RT_OVERRIDESTYLE_CACHE, null);
provider.getRuntimeProperties().put(PARSED_STYLES, null);
}
Iterator<IconHolder> it = lstIcons.values().iterator();
while (it.hasNext()) {
IconHolder ih = it.next();
Icon icon = ih.icon.get();
if (icon instanceof ImageIcon) {
ImageIcon imageIcon = (ImageIcon) icon;
if (imageIcon.getImage() != null) {
imageIcon.getImage().flush();
}
imageIcon.setImageObserver(null);
} else if (icon instanceof MyImageIcon) {
((MyImageIcon) icon).flush();
}
}
lstIcons = new WeakHashMap<Object, IconHolder>();
}
Aggregations