use of com.servoy.j2db.persistence.Style in project servoy-client by Servoy.
the class TemplateGenerator method getStyleCSS.
public static String getStyleCSS(String name) throws RepositoryException, RemoteException {
if (name != null && name.toLowerCase().endsWith(".css")) {
name = name.substring(0, name.length() - 4);
}
TextualCSS css = new TextualCSS();
TextualStyle styleObj = null;
// loading indicator stuff
styleObj = css.addStyle("span.indicator");
styleObj.setProperty("z-index", "99999");
styleObj.setProperty("position", "absolute");
styleObj.setProperty("right", "0px");
styleObj.setProperty("top", "0px");
styleObj.setProperty("background-color", "#FAD163");
styleObj.setProperty("color", "#000000");
// default field stuff
// input, select, textarea, listbox");
styleObj = css.addStyle(".field , .listbox, .spinner");
styleObj.setProperty("padding", createInsetsText(DEFAULT_FIELD_PADDING));
styleObj.setProperty("margin", "0");
styleObj.setProperty("border-style", "inset");
styleObj.setProperty("border-width", createInsetsText(DEFAULT_FIELD_BORDER_SIZE));
styleObj.setProperty("border-spacing", "0px 0px");
styleObj.setProperty("border-color", "#D4D0C8");
styleObj.setProperty("background-color", "#FFFFFF");
// default list separator stuff
// combobox, listbox
styleObj = css.addStyle("optgroup.separator");
// trying to make a gray horizontal line here with style - but <optgroup> element is very restricted on most browsers (couldn't make IE/FF/Opera work here)
// styleObj.setProperty("background-image", "url('/images/grayDot.gif')");
// styleObj.setProperty("background-repeat", "repeat-x");
// styleObj.setProperty("background-position", "0% 50%");
// styleObj.setProperty("height", "1px");
// styleObj.setProperty("margin-top", "7px");
// styleObj.setProperty("margin-bottom", "7px");
// or the same effect only works in FF
styleObj.setProperty("border-top", "1px solid gray");
styleObj.setProperty("margin-top", "7px");
styleObj.setProperty("margin-bottom", "7px");
// default radio/check field stuff
styleObj = css.addStyle(".radioCheckField");
styleObj.setProperty("padding", createInsetsText(DEFAULT_FIELD_PADDING));
styleObj.setProperty("margin", "0");
styleObj.setProperty("border-style", "inset");
styleObj.setProperty("border-width", createInsetsText(DEFAULT_FIELD_BORDER_SIZE));
styleObj.setProperty("border-spacing", "0px 0px");
styleObj.setProperty("border-color", IStyleSheet.COLOR_TRANSPARENT);
styleObj.setProperty("background-color", "#FFFFFF");
// default label stuff
// input, select, textarea");
styleObj = css.addStyle(".label");
styleObj.setProperty("padding", createInsetsText(DEFAULT_LABEL_PADDING));
styleObj.setProperty("overflow", "hidden");
// default button stuff
styleObj = css.addStyle(".button");
styleObj.setProperty("padding", createInsetsText(DEFAULT_BUTTON_PADDING));
styleObj.setProperty("overflow", "hidden");
Style s = (Style) ApplicationServerRegistry.get().getLocalRepository().getActiveRootObject(name, IRepository.STYLES);
boolean bodyMarginAdded = false;
if (s != null) {
FixedStyleSheet ss = new FixedStyleSheet();
try {
String styleText = s.getCSSText();
// System.out.println(styleText);
ss.addRule(styleText);
} catch (Exception e) {
// parsing can fail in java 1.5
Debug.error(e);
}
Enumeration<?> e = ss.getStyleNames();
while (e.hasMoreElements()) {
javax.swing.text.Style a_style = ss.getStyle((String) e.nextElement());
String a_style_name = a_style.getName();
if ("default".equalsIgnoreCase(a_style_name))
continue;
// a_style_name = Utils.stringReplaceExact(a_style_name, "button", "input.button");
a_style_name = Utils.stringReplaceExact(a_style_name, "label", ".label");
// a_style_name = Utils.stringReplaceExact(a_style_name, "form", "body");
a_style_name = Utils.stringReplaceExact(a_style_name, "tabpanel", ".tabpanel");
a_style_name = Utils.stringReplaceExact(a_style_name, "portal", "table.portal");
a_style_name = Utils.stringReplaceExact(a_style_name, "field", ".field");
a_style_name = Utils.stringReplaceExact(a_style_name, "check", ".check");
a_style_name = Utils.stringReplaceExact(a_style_name, "radio", ".radio");
a_style_name = Utils.stringReplaceExact(a_style_name, "listbox", ".listbox");
a_style_name = Utils.stringReplaceExact(a_style_name, "spinner", ".spinner");
// hack if previous command replaced label_field with label_.field
a_style_name = Utils.stringReplace(a_style_name, "..field", ".field");
a_style_name = Utils.stringReplace(a_style_name, ".", "_", 1);
styleObj = css.addStyle(a_style_name);
if (a_style_name.equals("body")) {
styleObj.setProperty("margin", "0px 0px 0px 0px");
bodyMarginAdded = true;
}
Enumeration<?> names = a_style.getAttributeNames();
while (names.hasMoreElements()) {
Object attr = names.nextElement();
if ("name".equalsIgnoreCase(attr.toString()))
continue;
Object val = a_style.getAttribute(attr);
String s_attr = attr.toString();
s_attr = Utils.stringReplace(s_attr, "margin", "padding");
if (s_attr.equals("font-size")) {
String tmp = val.toString();
if (tmp.endsWith("px")) {
int size = Utils.getAsInteger(tmp.substring(0, tmp.length() - 2));
// 9 should be defined hard. Because 12 (1.33*9) is to big.
if (size == 9) {
size = 11;
} else {
size = (int) (size * (4 / (double) 3));
}
styleObj.setProperty(s_attr, size + "px");
} else {
int size = 0;
if (tmp.endsWith("pt")) {
size = Utils.getAsInteger(tmp.substring(0, tmp.length() - 2));
} else {
size = Utils.getAsInteger(tmp);
}
// 9 should be defined hard. Because 6 (0.75*9) is to small.
if (size == 9) {
size = 7;
} else {
size = (int) (size * (3 / (double) 4));
}
styleObj.setProperty(s_attr, size + "pt");
}
} else {
styleObj.setProperty(s_attr, val.toString());
}
}
// enhance existing button def
if (a_style_name.startsWith("button")) {
// enhanceInputButton(styleObj);
}
}
}
// create button def if missing
if (!css.containsKey("button")) {
styleObj = css.addStyle("button");
// enhanceInputButton(styleObj);
}
if (!bodyMarginAdded) {
styleObj = css.addStyle("body");
styleObj.setProperty("margin", "0px 0px 0px 0px");
}
int h1 = 0;
int h2 = 2;
// default tab panel stuff
styleObj = css.addStyle("div.tabs");
// controls position of bottom line of tab strip
styleObj.setProperty("padding", "3px 0px " + (h1) + "px 2px");
// controls the space outside the tabs rect.
styleObj.setProperty("margin", h2 + "px 0px 0px 0px");
styleObj.setProperty("border-bottom", "1px solid #9ac");
styleObj.setProperty("left", "0px");
styleObj.setProperty("right", "0px");
styleObj.setProperty("position", "absolute");
// $NON-NLS-1$
styleObj = css.addStyle("div.webform");
styleObj.setProperty("background-color", PersistHelper.createColorString(DEFAULT_FORM_BG_COLOR));
// $NON-NLS-1$
styleObj = css.addStyle("div.opaquecontainer");
styleObj.setProperty("background-color", PersistHelper.createColorString(DEFAULT_FORM_BG_COLOR));
// default tab stuff
styleObj = css.addStyle("div.tabs div");
styleObj.setProperty("display", "inline");
styleObj.setProperty("float", "left");
styleObj.setProperty("clear", "none");
styleObj = css.addStyle("div.tabs div a");
styleObj.setProperty("text-decoration", "none");
// space inside tab arround the text
styleObj.setProperty("padding", (h2 - 1) + "px 10px " + (h1 + 1) + "px 1px");
// space betweens tabs
styleObj.setProperty("margin-top", "0.2em");
// space betweens tabs
styleObj.setProperty("margin-left", "0.2em");
styleObj.setProperty("background-color", "#e7e7f7");
styleObj.setProperty("border", "1px solid #9ac");
styleObj.setProperty("border-bottom", "1px solid #9ac");
styleObj.setProperty("float", "left");
styleObj.setProperty("position", "relative");
styleObj.setProperty("top", "1px");
styleObj = css.addStyle("div.tabs div a span");
styleObj.setProperty("padding-left", "10px");
styleObj = css.addStyle("div.tabs div a:hover");
styleObj.setProperty("color", "#fff");
styleObj.setProperty("background-color", "#c7cce7");
styleObj = css.addStyle("div.tabs div.selected_tab a");
styleObj.setProperty("color", "#000");
styleObj.setProperty("background-color", "#fff");
styleObj.setProperty("border-bottom", "1px solid #fff");
styleObj = css.addStyle("div.tabs div.disabled_tab a");
styleObj.setProperty("color", "lightslategrey");
styleObj.setProperty("background-color", "#e7e7f7");
styleObj = css.addStyle("div.tabs div.disabled_selected_tab a");
styleObj.setProperty("color", "lightslategrey");
styleObj.setProperty("background-color", "#fff");
styleObj.setProperty("border-bottom", "1px solid #fff");
styleObj = css.addStyle(".tabcontainer");
styleObj.setProperty("border-width", "0px 1px 1px 1px");
styleObj.setProperty("border-color", "#99AACC");
styleObj.setProperty("border-style", "solid");
// default font stuff
StringBuilder defaultFontElements = new StringBuilder();
defaultFontElements.append("body");
for (String dfe : DEFAULT_FONT_ELEMENTS) {
defaultFontElements.append(", ");
defaultFontElements.append(dfe);
}
styleObj = css.addStyle(defaultFontElements.toString());
styleObj.setProperty("font-family", "Tahoma, Arial, Helvetica, sans-serif");
styleObj.setProperty("font-size", DEFAULT_FONT_SIZE + "px");
// styleObj.setProperty("-moz-box-sizing", "content-box");
// default radio/check stuff
addDefaultCheckRadioStuff(css, "radioCheckField");
addDefaultCheckRadioStuff(css, "check");
addDefaultCheckRadioStuff(css, "radio");
// default table stuff (used by portal/listview)
styleObj = css.addStyle("th.nosort");
styleObj.setProperty("padding", "2px 0px 2px 2px");
styleObj.setProperty("text-align", "center");
styleObj.setProperty("vertical-align", "top");
styleObj.setProperty("font-weight", "normal");
styleObj = css.addStyle("th.sortable");
styleObj.setProperty("padding", SORTABLE_HEADER_PADDING + "px 0px " + SORTABLE_HEADER_PADDING + "px " + SORTABLE_HEADER_PADDING + "px");
// styleObj.setProperty("text-align","center");
styleObj.setProperty("vertical-align", "top");
styleObj = css.addStyle("td");
styleObj.setProperty("vertical-align", "top");
styleObj = css.addStyle("tr.headerbuttons");
styleObj.setProperty("background-image", "url(/servoy-webclient/templates/lafs/kunststoff/images/button/secondary-enabled.gif)", false);
styleObj.setProperty("background-color", "#DBE3EB", false);
styleObj.setProperty("background-repeat", "repeat-x", false);
styleObj.setProperty("background-position", "center center", false);
styleObj = css.addStyle("th.sortable a:visited, th.nosort a:visited");
styleObj.setProperty("text-decoration", "none");
styleObj.setProperty("color", "black");
styleObj = css.addStyle("th.sortable a:hover, th.nosort a:hover");
styleObj.setProperty("text-decoration", "underline");
styleObj.setProperty("color", "black");
styleObj = css.addStyle("th.nosort a");
styleObj.setProperty("text-decoration", "none");
styleObj = css.addStyle("th.sortable a");
// underline
styleObj.setProperty("text-decoration", "none");
styleObj.setProperty("font-weight", "normal");
styleObj.setProperty("color", "black");
styleObj.setProperty("background-position", "right");
styleObj.setProperty("background-repeat", "no-repeat", false);
styleObj.setProperty("display", "block");
// styleObj = css.addStyle("th.sortable a.orderOff");
// styleObj.setProperty("background-image", "url(/servoy-webclient/templates/lafs/kunststoff/images/sortheader/arrow_off.png)");
// styleObj = css.addStyle("th.sortable a.orderAsc");
// styleObj.setProperty("background-image", "url(/servoy-webclient/templates/lafs/kunststoff/images/sortheader/arrow_down.png)");
// styleObj = css.addStyle("th.sortable a.orderDesc");
// styleObj.setProperty("background-image", "url(/servoy-webclient/templates/lafs/kunststoff/images/sortheader/arrow_up.png)");
// let users define this
// styleObj = css.addStyle("tr.odd");
// styleObj.add("background-color","#fff");
// styleObj = css.addStyle("tr.even");
// styleObj.add("background-color","#fea");
styleObj = css.addStyle(".tableviewcell");
styleObj.setProperty("width", "100%");
styleObj.setProperty("height", "100%");
// accordion link margin for image custom
styleObj = css.addStyle(".accordionlinkmargin");
styleObj.setProperty("margin", "5px");
// tooltip stuff
styleObj = css.addStyle("#mktipmsg");
styleObj.setProperty("padding", "2px");
styleObj.setProperty("background-color", "#FFFFE1");
styleObj.setProperty("border", "1px solid #000000");
styleObj.setProperty("font-family", "arial, helvetica, tahoma, sans-serif");
styleObj.setProperty("font-size", "11px");
styleObj.setProperty("color", "#000000");
styleObj.setProperty("display", "none");
styleObj.setProperty("position", "absolute;left:0px;top:0px");
// blocker body
styleObj = css.addStyle(".blocker");
styleObj.setProperty("cursor", "progress");
// disable outline on focused div's (makes scrollbars appear in FF when mouse is clicked inside some div's)
styleObj = css.addStyle("div:focus");
styleObj.setProperty("outline", "none");
// disable text area resizing
styleObj = css.addStyle("textarea");
styleObj.setProperty("resize", "none");
// dialog
styleObj = css.addStyle("div.wicket-modal div.w_content_2");
styleObj.setProperty("background-color", "transparent !important");
styleObj.setProperty("padding-top", "0 !important");
styleObj = css.addStyle("div.wicket-modal div.w_content");
styleObj.setProperty("background-color", "transparent !important");
// modal dialog
styleObj = css.addStyle("div.wicket-modal div.w_undecorated div.w_caption,div.wicket-modal div.w_undecorated div.w_top,div.wicket-modal div.w_undecorated div.w_bottom,div.wicket-modal div.w_undecorated div.w_topLeft,div.wicket-modal div.w_undecorated div.w_topRight,div.wicket-modal div.w_undecorated div.w_bottomRight,div.wicket-modal div.w_undecorated div.w_bottomLeft,div.wicket-modal div.w_undecorated a.w_close");
styleObj.setProperty("display", "none");
styleObj = css.addStyle("div.wicket-modal div.w_undecorated div.w_caption,div.wicket-modal div.w_undecorated div.w_content,div.wicket-modal div.w_undecorated div.w_content_container,div.wicket-modal div.w_undecorated div.w_content_1,div.wicket-modal div.w_undecorated div.w_content_2,div.wicket-modal div.w_undecorated div.w_content_3,div.wicket-modal div.w_undecorated div.w_top,div.wicket-modal div.w_undecorated div.w_top_1,div.wicket-modal div.w_undecorated div.w_bottom,div.wicket-modal div.w_undecorated div.w_bottom_1,div.wicket-modal div.w_undecorated div.w_topLeft,div.wicket-modal div.w_undecorated div.w_left,div.wicket-modal div.w_undecorated div.w_topRight,div.wicket-modal div.w_undecorated div.w_right,div.wicket-modal div.w_undecorated div.w_right_1,div.wicket-modal div.w_undecorated div.w_bottomRight,div.wicket-modal div.w_undecorated div.w_bottomLeft,div.wicket-modal div.w_undecorated a.w_close,div.wicket-modal div.w_undecorated span.w_captionText");
styleObj.setProperty("padding", "0px");
styleObj.setProperty("margin", "0px");
styleObj.setProperty("border-width", "0px");
// placeholder style
styleObj = css.addStyle(".placeholder");
styleObj.setProperty("color", "#aaaaaa");
styleObj = css.addStyle("::-webkit-input-placeholder");
styleObj.setProperty("color", "#aaaaaa");
styleObj = css.addStyle(":-moz-placeholder");
styleObj.setProperty("color", "#aaaaaa");
// IMAGE MEDIA action buttons style
styleObj = css.addStyle(".image-media-save");
styleObj.setProperty("position", "absolute");
styleObj.setProperty("top", "1px");
styleObj.setProperty("left", "1px");
styleObj.setProperty("width", "16px");
styleObj.setProperty("height", "16px");
styleObj.setProperty("cursor", "pointer");
styleObj.setProperty("background-color", "gray");
styleObj.setProperty("z-index", "1");
styleObj = css.addStyle(".image-media-upload");
styleObj.setProperty("position", "absolute");
styleObj.setProperty("top", "1px");
styleObj.setProperty("left", "17px");
styleObj.setProperty("width", "16px");
styleObj.setProperty("height", "16px");
styleObj.setProperty("cursor", "pointer");
styleObj.setProperty("background-color", "gray");
styleObj.setProperty("z-index", "1");
styleObj = css.addStyle(".image-media-remove");
styleObj.setProperty("position", "absolute");
styleObj.setProperty("top", "1px");
styleObj.setProperty("left", "33px");
styleObj.setProperty("width", "16px");
styleObj.setProperty("height", "16px");
styleObj.setProperty("cursor", "pointer");
styleObj.setProperty("background-color", "gray");
styleObj.setProperty("z-index", "1");
// div.wicket-modal div.w_undecorated div.w_caption
return css.toString();
}
use of com.servoy.j2db.persistence.Style in project servoy-client by Servoy.
the class FlattenedSolution method getStyleForForm.
public Style getStyleForForm(Form f, Map<String, String> overridenStyles) {
if (loginFlattenedSolution != null) {
return loginFlattenedSolution.getStyleForForm(f, overridenStyles);
}
synchronized (this) {
String style_name = f.getStyleName();
if (deletedStyles.contains(style_name)) {
return null;
}
Map<String, Style> allStyles = getAllStyles();
if (style_name != null) {
String overridden = null;
if (overridenStyles != null && (overridden = overridenStyles.get(style_name)) != null) {
style_name = overridden;
}
if (user_created_styles != null) {
Style style = user_created_styles.get(style_name);
if (style != null)
return style;
}
Style style = allStyles.get(style_name);
if (style != null) {
return style;
}
if (overridden != null) {
try {
style = (Style) f.getRootObject().getRepository().getActiveRootObject(overridden, IRepository.STYLES);
if (style != null) {
synchronized (allStyles) {
allStyles.put(style.getName(), style);
}
return style;
}
} catch (Exception e) {
// $NON-NLS-1$ //$NON-NLS-2$
Debug.error("Couldn't get the new style " + overridden + " for the overridden one:" + f.getStyleName());
Debug.error(e);
}
}
}
Style s = loadStyleForForm(this, f);
if (s != null) {
synchronized (allStyles) {
allStyles.put(s.getName(), s);
}
}
return s;
}
}
use of com.servoy.j2db.persistence.Style in project servoy-client by Servoy.
the class FlattenedSolution method getStyle.
public synchronized Style getStyle(String name) {
if (user_created_styles != null) {
Style style = user_created_styles.get(name);
if (style != null)
return style;
}
if (deletedStyles.contains(name)) {
return null;
}
if (loginFlattenedSolution != null) {
return loginFlattenedSolution.getStyle(name);
}
Map<String, Style> allStyles = getAllStyles();
Style style = allStyles.get(name);
if (style == null) {
try {
style = (Style) mainSolution.getRootObject().getRepository().getActiveRootObject(name, IRepository.STYLES);
if (style != null) {
synchronized (allStyles) {
allStyles.put(name, style);
}
}
} catch (Exception e) {
// $NON-NLS-1$ //$NON-NLS-2$
Debug.error("error loading style '" + name + "'", e);
}
}
return style;
}
use of com.servoy.j2db.persistence.Style in project servoy-client by Servoy.
the class FlattenedSolution method createStyleCopy.
public Style createStyleCopy(Style style) {
if (mainSolution == null && loginFlattenedSolution == null)
return null;
if (user_created_styles == null)
user_created_styles = new HashMap<String, Style>();
Style copy = user_created_styles.get(style.getName());
if (copy == null) {
copy = new Style(style.getRepository(), style.getRootObjectMetaData());
copy.setContent(style.getContent());
user_created_styles.put(copy.getName(), copy);
}
return copy;
}
use of com.servoy.j2db.persistence.Style 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