Search in sources :

Example 81 with ICSSModel

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.

the class LinkElementAdapter method released.

/**
 */
public void released() {
    ICSSModel model = getExistingModel();
    if (model != null) {
        try {
            // get ModelProvideAdapter
            IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
            // set element to null first, so that no document wide updates
            setElement(null);
            setModel(null);
            if (adapter != null)
                adapter.modelReleased(model);
        } finally {
            model.releaseFromRead();
        }
    }
    this.replaceModel = false;
}
Also used : IModelProvideAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)

Example 82 with ICSSModel

use of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel in project webtools.sourceediting by eclipse.

the class StyleAttrAdapter method getModel.

/**
 */
public ICSSModel getModel() {
    ICSSModel model = getExistingModel();
    if (model == null && isModelNecessary()) {
        model = createModel();
        if (model == null)
            return null;
        IStructuredDocument structuredDocument = model.getStructuredDocument();
        if (structuredDocument == null)
            return null;
        RegionParser parser = structuredDocument.getParser();
        if (parser instanceof CSSSourceParser) {
            ((CSSSourceParser) parser).setParserMode(CSSSourceParser.MODE_DECLARATION);
        } else {
            return null;
        }
        structuredDocument.addDocumentChangedListener(this);
        // need to set before valueChanged()
        setModel(model);
        valueChanged();
    }
    if (model != null && !isModelNecessary()) {
        model = null;
        valueChanged();
    }
    return model;
}
Also used : ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) CSSSourceParser(org.eclipse.wst.css.core.internal.parser.CSSSourceParser) RegionParser(org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser)

Aggregations

ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)82 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)41 CSSRule (org.w3c.dom.css.CSSRule)21 CSSRuleList (org.w3c.dom.css.CSSRuleList)20 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)15 CSSStyleDeclaration (org.w3c.dom.css.CSSStyleDeclaration)14 CSSStyleSheet (org.w3c.dom.css.CSSStyleSheet)14 CSSValue (org.w3c.dom.css.CSSValue)14 ICSSDocument (org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument)12 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)12 ICSSNode (org.eclipse.wst.css.core.internal.provisional.document.ICSSNode)11 IModelProvideAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter)8 CSSSourceParser (org.eclipse.wst.css.core.internal.parser.CSSSourceParser)7 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)7 CSSStyleRule (org.w3c.dom.css.CSSStyleRule)7 IFile (org.eclipse.core.resources.IFile)6 Path (org.eclipse.core.runtime.Path)6 CSSSourceFormatter (org.eclipse.wst.css.core.internal.formatter.CSSSourceFormatter)6 IndexedRegion (org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)6 Element (org.w3c.dom.Element)6