Search in sources :

Example 1 with ECSSProperty

use of com.helger.css.property.ECSSProperty in project ph-css by phax.

the class MainCreateSupportedCSSPropertiesFile method main.

public static void main(final String[] args) {
    final Locale aLocale = Locale.US;
    final IMicroElement html = new MicroElement("html");
    final IMicroElement head = html.appendElement("head");
    head.appendElement("title").appendText("Supported CSS properties in ph-css");
    head.appendElement("style").appendText("* {font-family:Arial,Helvetica;}" + " table{border-collapse:collapse;}" + " td,th {border:solid 1px black;padding:3px;vertical-align:top; }" + " .odd{background-color:#ddd;}" + " .center{text-align:center;}" + " .nowrap{white-space:nowrap;}" + " a, a:link, a:visited, a:hover, a:active{color:blue;}");
    final IMicroElement body = html.appendElement("body");
    body.appendElement("div").appendText("Automatically generated by " + ClassHelper.getClassLocalName(MainCreateSupportedCSSPropertiesFile.class) + " on " + new Date().toString());
    body.appendElement("div").appendElement("a").setAttribute("href", "#generic").appendText("Generic properties");
    body.appendElement("div").appendElement("a").setAttribute("href", "#vendor").appendText("Vendor specific properties");
    body.appendElement("a").setAttribute("name", "generic").appendText("");
    body.appendElement("h1").appendText("Generic properties");
    IMicroElement table = body.appendElement("table");
    IMicroElement thead = table.appendElement("thead");
    IMicroElement tr = thead.appendElement("tr");
    tr.appendElement("th").appendText("Name");
    tr.appendElement("th").appendText("CSS 1.0");
    tr.appendElement("th").appendText("CSS 2.1");
    tr.appendElement("th").appendText("CSS 3.0");
    tr.appendElement("th").appendText("Links");
    IMicroElement tbody = table.appendElement("tbody");
    int nIndex = 0;
    for (final ECSSProperty eProperty : CollectionHelper.getSorted(ECSSProperty.values(), IHasName.getComparatorName())) if (!eProperty.isVendorSpecific()) {
        final Version eMinVersion = eProperty.getMinimumCSSVersion().getVersion();
        final boolean bCSS10 = eMinVersion.isLE(ECSSVersion.CSS10.getVersion());
        final boolean bCSS21 = eMinVersion.isLE(ECSSVersion.CSS21.getVersion());
        final boolean bCSS30 = eMinVersion.isLE(ECSSVersion.CSS30.getVersion());
        tr = tbody.appendElement("tr");
        if ((nIndex & 1) == 1)
            tr.setAttribute("class", "odd");
        tr.appendElement("td").setAttribute("class", "nowrap").appendText(eProperty.getName());
        _boolean(tr.appendElement("td"), bCSS10, null);
        _boolean(tr.appendElement("td"), bCSS21, null);
        _boolean(tr.appendElement("td"), bCSS30, null);
        final IMicroElement td = tr.appendElement("td");
        for (final ECSSSpecification eSpecs : eProperty.getAllSpecifications()) if (eSpecs.hasHandledURL())
            td.appendElement("div").appendElement("a").setAttribute("href", eSpecs.getHandledURL()).setAttribute("target", "_blank").appendText(eSpecs.getID());
        else
            td.appendElement("div").appendText(eSpecs.getID());
        ++nIndex;
    }
    // Determine all used vendor prefixes
    final EnumSet<ECSSVendorPrefix> aRequiredPrefixes = EnumSet.noneOf(ECSSVendorPrefix.class);
    for (final ECSSVendorPrefix eVendorPrefix : ECSSVendorPrefix.values()) {
        for (final ECSSProperty eProperty : ECSSProperty.values()) if (eProperty.isVendorSpecific(eVendorPrefix)) {
            aRequiredPrefixes.add(eVendorPrefix);
            break;
        }
    }
    body.appendElement("a").setAttribute("name", "vendor").appendText("");
    body.appendElement("h1").appendText("Vendor specific properties");
    table = body.appendElement("table");
    thead = table.appendElement("thead");
    tr = thead.appendElement("tr");
    tr.appendElement("th").appendText("Name");
    for (final ECSSVendorPrefix e : aRequiredPrefixes) {
        final IMicroElement th = tr.appendElement("th");
        th.appendText(e.getDisplayName());
        th.appendElement("span").setAttribute("class", "nowrap").appendText(" (" + e.getPrefix() + ")");
    }
    tbody = table.appendElement("tbody");
    nIndex = 0;
    for (final ECSSProperty eProperty : CollectionHelper.getSorted(ECSSProperty.values(), IComparator.getComparatorCollating(ECSSProperty::getVendorIndependentName, aLocale))) if (eProperty.isVendorSpecific()) {
        tr = tbody.appendElement("tr");
        if ((nIndex & 1) == 1)
            tr.setAttribute("class", "odd");
        tr.appendElement("td").setAttribute("class", "nowrap").appendText(eProperty.getVendorIndependentName());
        for (final ECSSVendorPrefix e : aRequiredPrefixes) _boolean(tr.appendElement("td"), eProperty.isVendorSpecific(e), eProperty.getName());
        ++nIndex;
    }
    body.appendElement("div").setAttribute("style", "margin:2em 0").appendText("That's it.");
    String sHTML = "<!--\r\n" + "\r\n" + "    Copyright (C) 2014 Philip Helger (www.helger.com)\r\n" + "    philip[at]helger[dot]com\r\n" + "\r\n" + "    Licensed under the Apache License, Version 2.0 (the \"License\");\r\n" + "    you may not use this file except in compliance with the License.\r\n" + "    You may obtain a copy of the License at\r\n" + "\r\n" + "            http://www.apache.org/licenses/LICENSE-2.0\r\n" + "\r\n" + "    Unless required by applicable law or agreed to in writing, software\r\n" + "    distributed under the License is distributed on an \"AS IS\" BASIS,\r\n" + "    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n" + "    See the License for the specific language governing permissions and\r\n" + "    limitations under the License.\r\n" + "\r\n" + "-->\r\n";
    sHTML += MicroWriter.getNodeAsString(html, new XMLWriterSettings().setIndent(EXMLSerializeIndent.ALIGN_ONLY).setSerializeVersion(EXMLSerializeVersion.HTML));
    SimpleFileIO.writeFile(new File("src/main/resources/supported-css-properties.html"), sHTML, StandardCharsets.UTF_8);
    System.out.println("Done");
}
Also used : Locale(java.util.Locale) MicroElement(com.helger.xml.microdom.MicroElement) IMicroElement(com.helger.xml.microdom.IMicroElement) XMLWriterSettings(com.helger.xml.serialize.write.XMLWriterSettings) ECSSVendorPrefix(com.helger.css.ECSSVendorPrefix) Date(java.util.Date) ECSSSpecification(com.helger.css.ECSSSpecification) ECSSVersion(com.helger.css.ECSSVersion) EXMLSerializeVersion(com.helger.xml.serialize.write.EXMLSerializeVersion) Version(com.helger.commons.version.Version) IMicroElement(com.helger.xml.microdom.IMicroElement) ECSSProperty(com.helger.css.property.ECSSProperty) File(java.io.File)

Example 2 with ECSSProperty

use of com.helger.css.property.ECSSProperty in project ph-css by phax.

the class CSSShortHandRegistry method registerShortHandDescriptor.

public static void registerShortHandDescriptor(@Nonnull final CSSShortHandDescriptor aDescriptor) {
    ValueEnforcer.notNull(aDescriptor, "Descriptor");
    final ECSSProperty eProperty = aDescriptor.getProperty();
    s_aRWLock.writeLocked(() -> {
        if (s_aMap.containsKey(eProperty))
            throw new IllegalStateException("A short hand for property '" + eProperty.getName() + "' is already registered!");
        s_aMap.put(eProperty, aDescriptor);
    });
}
Also used : ECSSProperty(com.helger.css.property.ECSSProperty)

Example 3 with ECSSProperty

use of com.helger.css.property.ECSSProperty in project ph-css by phax.

the class MainAddMissingProperties method main.

public static void main(final String[] args) throws Exception {
    boolean bFieldEmitted = false;
    final Class<?> aCClass = CCSSProperties.class;
    for (final ECSSProperty e : ECSSProperty.values()) if (!e.isVendorSpecific()) {
        boolean bHasField = false;
        try {
            bHasField = aCClass.getField(e.name()) != null;
        } catch (final Exception ex) {
        }
        if (!bHasField) {
            if (e.getClass().getField(e.name()).getAnnotation(Deprecated.class) != null)
                System.out.println("@Deprecated");
            System.out.println("public static final ICSSProperty " + e.name() + " = new CSSPropertyFree (ECSSProperty." + e.name() + ");");
            bFieldEmitted = true;
        }
    }
    if (!bFieldEmitted)
        System.out.println("All fields present");
}
Also used : CCSSProperties(com.helger.css.property.CCSSProperties) ECSSProperty(com.helger.css.property.ECSSProperty)

Aggregations

ECSSProperty (com.helger.css.property.ECSSProperty)3 Version (com.helger.commons.version.Version)1 ECSSSpecification (com.helger.css.ECSSSpecification)1 ECSSVendorPrefix (com.helger.css.ECSSVendorPrefix)1 ECSSVersion (com.helger.css.ECSSVersion)1 CCSSProperties (com.helger.css.property.CCSSProperties)1 IMicroElement (com.helger.xml.microdom.IMicroElement)1 MicroElement (com.helger.xml.microdom.MicroElement)1 EXMLSerializeVersion (com.helger.xml.serialize.write.EXMLSerializeVersion)1 XMLWriterSettings (com.helger.xml.serialize.write.XMLWriterSettings)1 File (java.io.File)1 Date (java.util.Date)1 Locale (java.util.Locale)1