/** * The style sheet. */ public StyleSheet getSheet() { if (sheet == null) { sheet = factory.createStyleSheet(this, getPseudoAttributes()); } return sheet; }
/** * Merges all StyleSheets in this list into one. * * @return the new (merged) StyleSheet */ public StyleSheet merge() { final CSSStyleSheetImpl merged = new CSSStyleSheetImpl(); final CSSRuleListImpl cssRuleList = new CSSRuleListImpl(); final Iterator<CSSStyleSheet> it = getCSSStyleSheets().iterator(); while (it.hasNext()) { final CSSStyleSheetImpl cssStyleSheet = (CSSStyleSheetImpl) it.next(); final CSSMediaRuleImpl cssMediaRule = new CSSMediaRuleImpl(merged, null, cssStyleSheet.getMedia()); cssMediaRule.setRuleList((CSSRuleListImpl) cssStyleSheet.getCssRules()); cssRuleList.add(cssMediaRule); } merged.setCssRules(cssRuleList); merged.setMediaText("all"); return merged; }
private boolean equalsStyleSheets(final StyleSheetList ssl) { if ((ssl == null) || (getLength() != ssl.getLength())) { return false; } for (int i = 0; i < getLength(); i++) { final StyleSheet styleSheet1 = item(i); final StyleSheet styleSheet2 = ssl.item(i); if (!LangUtils.equals(styleSheet1, styleSheet2)) { return false; } } return true; }
JStyleSheetWrapper(final cz.vutbr.web.css.StyleSheet jStyleSheet, final String mediaStr, final String href, final Node ownerNode, final CSSStyleSheet parentStyleSheet, final String type, final String title, final StyleSheetBridge bridge) { this.jStyleSheet = jStyleSheet; this.mediaStr = mediaStr; this.href = href; this.bridge = bridge; this.ownerNode = ownerNode; this.type = type; this.title = title; this.parentStyleSheet = parentStyleSheet; }
/** * Creates a stylesheet from the data of an xml-stylesheet * processing instruction or return null. */ public StyleSheet createStyleSheet(Node n, HashTable attrs) { throw new UnsupportedOperationException ("StyleSheetFactory.createStyleSheet is not implemented"); // XXX }
@Override public StyleSheet getParentStyleSheet() { return parentStyleSheet_; }
public void setParentStyleSheet(final StyleSheet parentStyleSheet) { parentStyleSheet_ = parentStyleSheet; }
@Override public StyleSheet item(final int index) { return getCSSStyleSheets().get(index); }
public cz.vutbr.web.css.StyleSheet getJStyleSheet() { return this.jStyleSheet; }
public void setJStyleSheet(final cz.vutbr.web.css.StyleSheet jStyleSheet) { this.jStyleSheet = jStyleSheet; }
/** * Used to insert a new rule into the style sheet. The new rule now becomes * part of the cascade. * * @param rule * The parsable text representing the rule. For rule sets this * contains both the selector and the style declaration. For * at-rules, this specifies both the at-identifier and the rule * content. * @param index * The index within the style sheet's rule list of the rule before * which to insert the specified rule. If the specified index is * equal to the length of the style sheet's rule collection, the rule * will be added to the end of the style sheet. * @return The index within the style sheet's rule collection of the newly * inserted rule. * @exception DOMException * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted * at the specified index e.g. if an <code>@import</code> rule is * inserted after a standard rule set or other at-rule. <br> * INDEX_SIZE_ERR: Raised if the specified index is not a valid * insertion point. <br> * NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is * readonly. <br> * SYNTAX_ERR: Raised if the specified rule has a syntax error * and is unparsable. */ //TODO handle all the different types of exceptions as mentioned above public int insertRule(final String rule, final int index) throws DOMException { final cz.vutbr.web.css.StyleSheet jSheet = CSSUtils.parse(rule); if (jSheet.size() > 0) { this.jStyleSheet.add(index, jSheet.get(0)); bridge.notifyStyleSheetChanged(this); return index; } return -1; }
/** * Creates a stylesheet from the data of the xml-stylesheet * processing instruction or return null when it is not possible * to create the given stylesheet. */ StyleSheet createStyleSheet(Node node, HashTable pseudoAttrs);
/** * @param jStyleSheet * parsed style sheet from jStyleParser * @param mediaStr * The intended destination media for style information. The media is * often specified in the <code>ownerNode</code>. If no media has * been specified, the <code>MediaList</code> will be empty. See the * media attribute definition for the <code>LINK</code> element in * HTML 4.0, and the media pseudo-attribute for the XML style sheet * processing instruction . Modifying the media list may cause a * change to the attribute <code>disabled</code>. * @param href * If the style sheet is a linked style sheet, the value of its * attribute is its location. For inline style sheets, the value of * this attribute is <code>null</code>. See the href attribute * definition for the <code>LINK</code> element in HTML 4.0, and the * href pseudo-attribute for the XML style sheet processing * instruction. * @param parentStyleSheet * For style sheet languages that support the concept of style sheet * inclusion, this attribute represents the including style sheet, if * one exists. If the style sheet is a top-level style sheet, or the * style sheet language does not support inclusion, the value of this * attribute is <code>null</code>. * @param bridge * callback to notify any changes in the style sheet or to * dynamically get data from the caller. */ public JStyleSheetWrapper(final cz.vutbr.web.css.StyleSheet jStyleSheet, final String mediaStr, final String href, final CSSStyleSheet parentStyleSheet, final StyleSheetBridge bridge) { this(jStyleSheet, mediaStr, href, null, parentStyleSheet, null, null, bridge); }
/** * @param jStyleSheet * parsed style sheet from jStyleParser * @param mediaStr * The intended destination media for style information. The media is * often specified in the <code>ownerNode</code>. If no media has * been specified, the <code>MediaList</code> will be empty. See the * media attribute definition for the <code>LINK</code> element in * HTML 4.0, and the media pseudo-attribute for the XML style sheet * processing instruction . Modifying the media list may cause a * change to the attribute <code>disabled</code>. * @param href * If the style sheet is a linked style sheet, the value of its * attribute is its location. For inline style sheets, the value of * this attribute is <code>null</code>. See the href attribute * definition for the <code>LINK</code> element in HTML 4.0, and the * href pseudo-attribute for the XML style sheet processing * instruction. * @param type * the type of the style sheet. e.g. "text/css" * @param title * The advisory title. The title is often specified in the * <code>ownerNode</code>. See the title attribute definition for the * <code>LINK</code> element in HTML 4.0, and the title * pseudo-attribute for the XML style sheet processing instruction. * @param ownerNode * The node that associates this style sheet with the document. For * HTML, this may be the corresponding <code>LINK</code> or * <code>STYLE</code> element. For XML, it may be the linking * processing instruction. For style sheets that are included by * other style sheets, the value of this attribute is * <code>null</code>. * @param bridge * callback to notify any changes in the style sheet or to * dynamically get data from the caller. */ public JStyleSheetWrapper(final cz.vutbr.web.css.StyleSheet jStyleSheet, final String mediaStr, final String href, final String type, final String title, final Node ownerNode, final StyleSheetBridge bridge) { this(jStyleSheet, mediaStr, href, ownerNode, null, type, title, bridge); }
/** * @return The containing <code>Style Sheet</code>, applicable only for * <code>@import</code> rules. <code>null</code> for nodes as the * style sheet is a top-level style sheet, either from * <code>LINK</code> or <code>STYLE</code> element. */ public StyleSheet getParentStyleSheet() { return this.parentStyleSheet; }