Search in sources :

Example 1 with StyleSheet

use of org.w3c.dom.stylesheets.StyleSheet in project dbeaver by serge-rider.

the class ApplicationCSSManager method updateApplicationCSS.

static void updateApplicationCSS(Display display) {
    CSSEngine engine = WidgetElement.getEngine(display);
    if (engine == null) {
        log.error("No CSSEngine");
        return;
    }
    ExtendedDocumentCSS doc = (ExtendedDocumentCSS) engine.getDocumentCSS();
    List<StyleSheet> sheets = new ArrayList<>();
    StyleSheetList list = doc.getStyleSheets();
    for (int i = 0; i < list.getLength(); i++) {
        sheets.add(list.item(i));
    }
    try {
        Reader reader = new StringReader(EXTRA_CSS);
        sheets.add(engine.parseStyleSheet(reader));
        doc.removeAllStyleSheets();
        for (StyleSheet sheet : sheets) {
            doc.addStyleSheet(sheet);
        }
        engine.reapply();
    } catch (Exception e) {
        log.error(e);
    }
}
Also used : StyleSheet(org.w3c.dom.stylesheets.StyleSheet) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) CSSEngine(org.eclipse.e4.ui.css.core.engine.CSSEngine) StringReader(java.io.StringReader) Reader(java.io.Reader) ExtendedDocumentCSS(org.eclipse.e4.ui.css.core.dom.ExtendedDocumentCSS) StyleSheetList(org.w3c.dom.stylesheets.StyleSheetList)

Example 2 with StyleSheet

use of org.w3c.dom.stylesheets.StyleSheet in project webtools.sourceediting by eclipse.

the class HTMLDocumentAdapter method item.

/**
 */
public StyleSheet item(int index) {
    if (this.styleAdapters == null)
        return null;
    List validAdapters = getValidAdapters();
    if (index < 0 || index >= validAdapters.size())
        return null;
    StyleSheet sheet = ((IStyleSheetAdapter) validAdapters.get(index)).getSheet();
    if (sheet == null) {
        // for LINK element whose link is broken
        ICSSModel model = ((AbstractStyleSheetAdapter) validAdapters.get(index)).createModel();
        sheet = ((model != null) ? (StyleSheet) model.getDocument() : null);
    }
    return sheet;
}
Also used : StyleSheet(org.w3c.dom.stylesheets.StyleSheet) ICSSModel(org.eclipse.wst.css.core.internal.provisional.document.ICSSModel) StyleSheetList(org.w3c.dom.stylesheets.StyleSheetList) ArrayList(java.util.ArrayList) List(java.util.List) IStyleSheetAdapter(org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter)

Example 3 with StyleSheet

use of org.w3c.dom.stylesheets.StyleSheet in project dbeaver by dbeaver.

the class ApplicationCSSManager method updateApplicationCSS.

static void updateApplicationCSS(Display display) {
    CSSEngine engine = WidgetElement.getEngine(display);
    if (engine == null) {
        log.error("No CSSEngine");
        return;
    }
    ExtendedDocumentCSS doc = (ExtendedDocumentCSS) engine.getDocumentCSS();
    List<StyleSheet> sheets = new ArrayList<>();
    StyleSheetList list = doc.getStyleSheets();
    for (int i = 0; i < list.getLength(); i++) {
        sheets.add(list.item(i));
    }
    try {
        Reader reader = new StringReader(EXTRA_CSS);
        sheets.add(engine.parseStyleSheet(reader));
        doc.removeAllStyleSheets();
        for (StyleSheet sheet : sheets) {
            doc.addStyleSheet(sheet);
        }
        engine.reapply();
    } catch (Exception e) {
        log.error(e);
    }
}
Also used : StyleSheet(org.w3c.dom.stylesheets.StyleSheet) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) CSSEngine(org.eclipse.e4.ui.css.core.engine.CSSEngine) StringReader(java.io.StringReader) Reader(java.io.Reader) ExtendedDocumentCSS(org.eclipse.e4.ui.css.core.dom.ExtendedDocumentCSS) StyleSheetList(org.w3c.dom.stylesheets.StyleSheetList)

Aggregations

ArrayList (java.util.ArrayList)3 StyleSheet (org.w3c.dom.stylesheets.StyleSheet)3 StyleSheetList (org.w3c.dom.stylesheets.StyleSheetList)3 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 ExtendedDocumentCSS (org.eclipse.e4.ui.css.core.dom.ExtendedDocumentCSS)2 CSSEngine (org.eclipse.e4.ui.css.core.engine.CSSEngine)2 List (java.util.List)1 IStyleSheetAdapter (org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter)1 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)1