/** * Used to retrieve the object representation of the value of a CSS * property if it has been explicitly set within this declaration block. * This method returns <code>null</code> if the property is a shorthand * property. Shorthand property values can only be accessed and modified * as strings, using the <code>getPropertyValue</code> and * <code>setProperty</code> methods. * * @param propertyName * The name of the CSS property. See the CSS property index. * @return Returns the value of the property if it has been explicitly set * for this declaration block. Returns <code>null</code> if the * property has not been set. */ public CSSValue getPropertyCSSValue(String propertyName) { ICSSStyleDeclItem item = getDeclItemNode(propertyName); if (item != null) return item.getCSSValue(); return null; }
/** */ public String toString() { if (value == null && declItem != null) { value = declItem.getCSSValueText(); } return value; }
/** * Used to retrieve the priority of a CSS property (e.g. the * <code>"important"</code> qualifier) if the property has been * explicitly set in this declaration block. * * @param propertyName * The name of the CSS property. See the CSS property index. * @return A string representing the priority (e.g. * <code>"important"</code>) if one exists. The empty string if * none exists. */ public String getPropertyPriority(String propertyName) { ICSSStyleDeclItem item = getDeclItemNode(propertyName); if (item != null) return item.getPriority(); return null; }
ICSSStyleDeclItem declItem = (ICSSStyleDeclItem) decl.getDeclItemNode(propName).cloneNode(true); int nValues = declItem.getLength(); for (int j = 0; j < nValues; j++) { conv.toAbsolute(declItem.item(j)); declItem.setPriority(null); fProperties.put(propN, new CSSQueryDeclarationData(declItem, important, specificity));
public ICSSStyleDeclItem getDeclItemNode(String propertyName) { ICSSNode node = getLastChild(); propertyName = propertyName.trim(); while (node != null) { if (node instanceof CSSStyleDeclItemImpl) { ICSSStyleDeclItem item = (ICSSStyleDeclItem) node; if (propertyName.compareToIgnoreCase(item.getPropertyName().trim()) == 0) return item; } node = node.getPreviousSibling(); } return null; }
ITextRegionList regionBuf = new TextRegionListImpl(); String propertyName = item.getPropertyName().toLowerCase(); boolean bFont = (propertyName.equals(PropCMProperty.P_FONT)); if (value != null) { if (fUpdateContext == null || !fUpdateContext.isActive()) { item.appendValue(value); item.appendValue(value); value = createPrimitiveValue(regionBuf); if (fUpdateContext == null || !fUpdateContext.isActive()) { item.appendValue(value);
/** * @param item * org.eclipse.wst.css.core.model.interfaces.ICSSStyleDeclItem * @param nodeRegions * java.util.Vector */ private void setupImportantAttribute(ICSSStyleDeclItem item, ITextRegionList nodeRegions) { if (item == null || nodeRegions == null || nodeRegions.isEmpty()) { return; } ITextRegion region = nodeRegions.get(nodeRegions.size() - 1); if (region != null && region.getType() == CSSRegionContexts.CSS_DECLARATION_VALUE_IMPORTANT) { item.setPriority(getText(region)); CSSAttrImpl attr = ((CSSStyleDeclItemImpl) item).getAttributeNode(ICSSStyleDeclItem.IMPORTANT); attr.setRangeRegion(fParentRegion, region, region); nodeRegions.remove(region); } }
/** * Used to remove a CSS property if it has been explicitly set within this * declaration block. * * @param propertyName * The name of the CSS property. See the CSS property index. * @return Returns the value of the property if it has been explicitly set * for this declaration block. Returns the empty string if the * property has not been set or the property name does not * correspond to a known CSS property. * @exception DOMException * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration * is readonly or the property is readonly. */ public String removeProperty(String propertyName) throws DOMException { ICSSStyleDeclItem item = getDeclItemNode(propertyName); if (item != null) { removeChild((CSSNodeImpl) item); return item.getCssText(); } return null; }
if (declItem.getLength() <= 0) { ICSSStyleDeclItem itemToRemove = decl.getDeclItemNode(key.toString()); if (itemToRemove != null) {
public ICSSStyleDeclItem setDeclItemNode(ICSSStyleDeclItem newDecl) throws DOMException { if (newDecl == null) return null; ICSSStyleDeclItem item = getDeclItemNode(newDecl.getPropertyName()); if (item != null) return (ICSSStyleDeclItem) replaceChild((CSSNodeImpl) newDecl, (CSSNodeImpl) item); else return (ICSSStyleDeclItem) appendChild((CSSNodeImpl) newDecl); }
return getProperty(((ICSSStyleDeclItem) node).getPropertyName()); return getDescriptor(((ICSSStyleDeclItem) node).getPropertyName());
/** * */ protected void formatPost(ICSSNode node, StringBuffer source) { CSSCleanupStrategy stgy = getCleanupStrategy(node); int end = ((IndexedRegion) node).getEndOffset(); int start = (node.getLastChild() != null && ((IndexedRegion) node.getLastChild()).getEndOffset() > 0) ? ((IndexedRegion) node.getLastChild()).getEndOffset() : getChildInsertPos(node); if (end > 0 && start < end) { // format source IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument(); CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy); for (int i = 0; i < regions.length; i++) { appendSpaceBefore(node, regions[i], source); source.append(decoratedIdentRegion(regions[i], stgy)); } } else { // generate source // append "!important" String priority = ((ICSSStyleDeclItem) node).getPriority(); if (priority != null && priority.length() > 0) { appendSpaceBefore(node, priority, source); source.append(priority); } } }
IStructuredDocument structuredDocument = node.getOwnerDocument().getModel().getStructuredDocument(); CompoundRegion[] regions = getRegionsWithoutWhiteSpaces(structuredDocument, new FormatRegion(start, end - start), stgy); boolean appendQuote = regions.length > 1 && node.getParentNode() instanceof ICSSStyleDeclItem && isCleanup() && getCleanupStrategy(node).isQuoteValues() && (((ICSSStyleDeclItem) node.getParentNode()).getPropertyName().equals(PropCMProperty.P_FONT) || ((ICSSStyleDeclItem) node.getParentNode()).getPropertyName().equals(PropCMProperty.P_FONT_FAMILY) || ((ICSSStyleDeclItem) node.getParentNode()).getPropertyName().equals(PropCMProperty.P_VOICE_FAMILY)); String quote = preferences.getString(CSSCorePreferenceNames.FORMAT_QUOTE);
String important = ((ICSSStyleDeclItem) node).getPriority(); if (important != null && important.length() > 0) {
ICSSStyleDeclItem item = (ICSSStyleDeclItem) node; if (preferences.getInt(CSSCorePreferenceNames.CASE_PROPERTY_NAME) == CSSCorePreferenceNames.UPPER) source.append(item.getPropertyName().toUpperCase()); else source.append(item.getPropertyName());