Search in sources :

Example 6 with IModelProvideAdapter

use of org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter in project webtools.sourceediting by eclipse.

the class CSSImportRuleImpl method releaseRule.

/**
 */
void releaseRule() {
    if (fStyleSheet != null) {
        ICSSStyleSheet sheet = fStyleSheet;
        // to prevent loop, we must reset fStyleSheet
        fStyleSheet = null;
        // before all closing action
        sheet.getModel().removeStyleListener(getOwnerDocument().getModel());
        // get ModelProvideAdapter
        IModelProvideAdapter adapter = (IModelProvideAdapter) getAdapterFor(IModelProvideAdapter.class);
        // }
        if (adapter != null)
            adapter.modelReleased(sheet.getModel());
        sheet.getModel().releaseFromRead();
    }
}
Also used : IModelProvideAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter) ICSSStyleSheet(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)

Example 7 with IModelProvideAdapter

use of org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter in project webtools.sourceediting by eclipse.

the class CSSImportRuleImpl method closeStyleSheet.

/**
 */
void closeStyleSheet() {
    if (fStyleSheet != null) {
        ICSSStyleSheet sheet = fStyleSheet;
        // to prevent loop, we must reset fStyleSheet
        fStyleSheet = null;
        // before all closing action
        sheet.getModel().removeStyleListener(getOwnerDocument().getModel());
        // get ModelProvideAdapter
        IModelProvideAdapter adapter = (IModelProvideAdapter) getAdapterFor(IModelProvideAdapter.class);
        // }
        if (adapter != null)
            adapter.modelRemoved(sheet.getModel());
        sheet.getModel().releaseFromRead();
    }
}
Also used : IModelProvideAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter) ICSSStyleSheet(org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)

Example 8 with IModelProvideAdapter

use of org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter in project webtools.sourceediting by eclipse.

the class StyleElementAdapter method getModel.

/**
 */
public ICSSModel getModel() {
    ICSSModel model = getExistingModel();
    if (this.replaceModel) {
        ICSSModel oldModel = model;
        model = createModel(false);
        // need to set before contentChanged()
        setModel(model, false);
        contentChanged();
        // from super.createModel()
        // get ModelProvideAdapter
        IModelProvideAdapter modelProvideAdapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
        // notify adapter
        if (modelProvideAdapter != null)
            modelProvideAdapter.modelProvided(model);
        // from createModel()
        IStructuredDocument structuredDocument = null;
        if (model != null)
            structuredDocument = model.getStructuredDocument();
        if (structuredDocument == null)
            return null;
        structuredDocument.addDocumentChangedListener(this);
        // from setModel()
        if (oldModel != null)
            oldModel.removeStyleListener(this);
        if (model != null)
            model.addStyleListener(this);
        if (oldModel != null) {
            // get ModelProvideAdapter
            IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
            if (adapter != null) {
                adapter.modelRemoved(oldModel);
            }
        }
        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) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 9 with IModelProvideAdapter

use of org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter in project webtools.sourceediting by eclipse.

the class AbstractStyleSheetAdapter method released.

/**
 */
public void released() {
    ICSSModel currentModel = getModel();
    // get ModelProvideAdapter
    IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
    setElement(null);
    setModel(null);
    if (adapter != null)
        adapter.modelReleased(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 10 with IModelProvideAdapter

use of org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter 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)

Aggregations

IModelProvideAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IModelProvideAdapter)10 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)8 ICSSStyleSheet (org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleSheet)2 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URLModelProviderCSS (org.eclipse.wst.css.core.internal.util.URLModelProviderCSS)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)1 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)1 Element (org.w3c.dom.Element)1