Search in sources :

Example 6 with ICSSModel

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

the class AbstractStyleSheetAdapter method removed.

/**
 */
public void removed() {
    ICSSModel currentModel = getModel();
    setModel(null);
    // get ModelProvideAdapter
    IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
    if (adapter != null)
        adapter.modelRemoved(currentModel);
    if (currentModel != null)
        currentModel.releaseFromRead();
}
Also used : IModelProvideAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)

Example 7 with ICSSModel

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

the class LinkElementAdapter method getModel.

/**
 */
public ICSSModel getModel() {
    ICSSModel model = getExistingModel();
    if (this.replaceModel) {
        ICSSModel oldModel = model;
        try {
            model = retrieveModel();
            setModel(model);
            // release old model
            if (oldModel != null) {
                // get ModelProvideAdapter
                IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
                if (adapter != null)
                    adapter.modelRemoved(oldModel);
            }
        } finally {
            if (oldModel != null)
                oldModel.releaseFromRead();
        }
        this.replaceModel = false;
    }
    return model;
}
Also used : IModelProvideAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)

Example 8 with ICSSModel

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

the class LinkElementAdapter method setModel.

/**
 */
protected void setModel(ICSSModel model) {
    ICSSModel oldModel = getExistingModel();
    if (model == oldModel)
        return;
    super.setModel(model);
    if (this.replaceModel)
        this.replaceModel = false;
    if (oldModel != null)
        oldModel.removeStyleListener(this);
    if (model != null)
        model.addStyleListener(this);
}
Also used : ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)

Example 9 with ICSSModel

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

the class LinkElementAdapter method removed.

/**
 */
public void removed() {
    ICSSModel model = getExistingModel();
    if (model != null) {
        try {
            setModel(null);
            // get ModelProvideAdapter
            IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
            if (adapter != null)
                adapter.modelRemoved(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 10 with ICSSModel

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

the class LinkElementAdapter method retrieveModel.

/**
 */
private ICSSModel retrieveModel() {
    if (!isValidAttribute()) {
        return null;
    }
    // null,attr check is done in isValidAttribute()
    Element element = getElement();
    // $NON-NLS-1$
    String href = element.getAttribute("href");
    IDOMModel baseModel = ((IDOMNode) element).getModel();
    if (baseModel == null)
        return null;
    Object id = baseModel.getId();
    if (!(id instanceof String))
        return null;
    // String base = (String)id;
    // get ModelProvideAdapter
    IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(ModelProvideAdapterClass);
    URLModelProvider provider = new URLModelProvider();
    try {
        IStructuredModel newModel = provider.getModelForRead(baseModel, href);
        if (newModel == null)
            return null;
        if (!(newModel instanceof ICSSModel)) {
            newModel.releaseFromRead();
            return null;
        }
        // notify adapter
        if (adapter != null)
            adapter.modelProvided(newModel);
        return (ICSSModel) newModel;
    } catch (UnsupportedEncodingException e) {
    } catch (IOException e) {
    }
    return null;
}
Also used : IModelProvideAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) Element(org.w3c.dom.Element) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) IOException(java.io.IOException)

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