/** * @return org.w3c.dom.css.CSSRule * @param rule * java.lang.String */ public CSSRule createCSSRule(String rule) { CSSDocumentLoader loader = new CSSDocumentLoader(); IStructuredDocument structuredDocument = (IStructuredDocument) loader.createNewStructuredDocument(); structuredDocument.set(rule); //CSSModelParser modelParser = new CSSModelParser((CSSDocumentImpl) getOwnerDocument()); CSSModelParser modelParser = new CSSModelParser(getOwnerDocument()); return modelParser.createCSSRule(structuredDocument.getRegionList()); }
public boolean parse(String filePath) { getLocalParser().removeStructuredDocumentRegionHandler(this); // from outer class List blockMarkers = this.fTranslator.getBlockMarkers(); IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(getLocalParser()); String contents = getContents(filePath); if (contents == null) return false; // this adds the current markers from the outer class list // to this parser so parsing works correctly for (int i = 0; i < blockMarkers.size(); i++) { addBlockMarker((BlockMarker) blockMarkers.get(i)); } reset(contents); // forceParse(); document.set(contents); IStructuredDocumentRegion cursor = document.getFirstStructuredDocumentRegion(); while (cursor != null) { nodeParsed(cursor); cursor = cursor.getNext(); } getLocalParser().addStructuredDocumentRegionHandler(this); return true; }
setAccessible(fText, SSEUIMessages.Sample_text__UI_); fDocument = StructuredModelManager.getModelManager().createStructuredDocumentFor(ContentTypeIdForXML.ContentTypeID_XML); fDocument.set(getExampleText()); viewer.setDocument(fDocument);
private void setCssValueTextCore(String value) throws DOMException { // use temporary document synchronized (CSSStyleDeclarationImpl.class) { if (sharedStructuredDocument == null) { IDocumentLoader loader = new CSSDocumentLoader(); sharedStructuredDocument = (IStructuredDocument) loader.createNewStructuredDocument(); ((CSSSourceParser) sharedStructuredDocument.getParser()).setParserMode(CSSSourceParser.MODE_DECLARATION_VALUE); } sharedStructuredDocument.set(value); IStructuredDocumentRegion node = sharedStructuredDocument.getFirstStructuredDocumentRegion(); if (node == null) { return; } if (node.getNext() != null) { throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, "");//$NON-NLS-1$ } CSSDeclarationItemParser itemParser = new CSSDeclarationItemParser(getOwnerDocument()); itemParser.setStructuredDocumentTemporary(true); // make a copy of nodelist because setupValues will destroy list ITextRegionList nodeList = new TextRegionListImpl(node.getRegions()); itemParser.setupValues(this, node, nodeList); } }