Search in sources :

Example 51 with StringTokenizer

use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.

the class HTMLFormattingUtil method getInlineSet.

private static Set getInlineSet() {
    String inline = HTMLCorePlugin.getDefault().getPluginPreferences().getString(HTMLCorePreferenceNames.INLINE_ELEMENTS);
    Set elements = new HashSet();
    StringTokenizer tokenizer = new StringTokenizer(inline, ",");
    while (tokenizer.hasMoreTokens()) {
        elements.add(tokenizer.nextToken());
    }
    return elements;
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) HashSet(java.util.HashSet) Set(java.util.Set) HashSet(java.util.HashSet)

Example 52 with StringTokenizer

use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.

the class HTMLFormattingUtil method getDefaultInlineElements.

/**
 * Returns an array of the default element names considered as "inline" for the purposes of formatting.
 *
 * @return An array of the default element names considered to be "inline"
 */
public static Object[] getDefaultInlineElements() {
    String inline = HTMLCorePlugin.getDefault().getPluginPreferences().getDefaultString(HTMLCorePreferenceNames.INLINE_ELEMENTS);
    Set defaults = new HashSet();
    StringTokenizer tokenizer = new StringTokenizer(inline, ",");
    while (tokenizer.hasMoreTokens()) {
        defaults.add(tokenizer.nextToken());
    }
    return defaults.toArray();
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) HashSet(java.util.HashSet) Set(java.util.Set) HashSet(java.util.HashSet)

Example 53 with StringTokenizer

use of com.ibm.icu.util.StringTokenizer in project webtools.sourceediting by eclipse.

the class HTMLStyleSelectorAdapter method match.

public boolean match(ICSSSimpleSelector selector, Element element, String pseudoName) {
    if (element == null)
        return false;
    int i;
    String key;
    // PseudoName
    i = selector.getNumOfPseudoNames();
    if (i > 0) {
        if (pseudoName == null || pseudoName.length() == 0)
            return false;
        for (i = i - 1; i >= 0; i--) {
            if (pseudoName.equalsIgnoreCase(selector.getPseudoName(i))) {
                break;
            }
        }
        if (i < 0)
            return false;
    }
    // check tag name
    if (!selector.isUniversal() && !element.getNodeName().equalsIgnoreCase(selector.getName()))
        return false;
    // check id
    i = selector.getNumOfIDs();
    if (i > 0) {
        if (i > 1)
            return false;
        if (// $NON-NLS-1$ //$NON-NLS-2$
        !element.hasAttribute("id") || (key = element.getAttribute("id")).length() == 0)
            return false;
        if (!selector.getID(0).equals(key))
            return false;
    }
    // check class
    i = selector.getNumOfClasses();
    if (i > 0) {
        if (// $NON-NLS-1$  //$NON-NLS-2$
        !element.hasAttribute("class") || (key = element.getAttribute("class")).length() == 0)
            return false;
        StringTokenizer tokenizer = new StringTokenizer(key);
        for (i = i - 1; i >= 0; i--) {
            boolean ok = false;
            while (tokenizer.hasMoreTokens()) {
                if (selector.getClass(i).equals(tokenizer.nextToken())) {
                    ok = true;
                    break;
                }
            }
            if (!ok)
                return false;
        }
    }
    // check attributes
    for (i = selector.getNumOfAttributes() - 1; i >= 0; i--) {
        // $NON-NLS-1$
        StringTokenizer tokenizer = new StringTokenizer(selector.getAttribute(i), "=~| \t\r\n\f");
        int countTokens = tokenizer.countTokens();
        if (countTokens > 0) {
            String attrName = tokenizer.nextToken();
            String attrValue = null;
            if (!element.hasAttribute(attrName) || (attrValue = element.getAttribute(attrName)).length() == 0)
                return false;
            if (countTokens > 1) {
                // $NON-NLS-1$
                String token = tokenizer.nextToken("= \t\r\n\f");
                StringTokenizer attrValueTokenizer = null;
                if (token.equals("~")) {
                    // $NON-NLS-1$
                    attrValueTokenizer = new StringTokenizer(attrValue);
                } else if (token.equals("|")) {
                    // $NON-NLS-1$
                    // $NON-NLS-1$
                    attrValueTokenizer = new StringTokenizer(attrValue, "-");
                }
                if (attrValueTokenizer != null) {
                    if (tokenizer.hasMoreTokens()) {
                        token = tokenizer.nextToken();
                        boolean ok = false;
                        while (attrValueTokenizer.hasMoreTokens()) {
                            if (token.equals(attrValueTokenizer.nextToken())) {
                                ok = true;
                                break;
                            }
                        }
                        if (!ok)
                            return false;
                    }
                } else {
                    if (!attrValue.equals(token))
                        return false;
                }
            }
        }
    }
    return true;
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer)

Aggregations

StringTokenizer (com.ibm.icu.util.StringTokenizer)53 ArrayList (java.util.ArrayList)9 List (java.util.List)6 HashSet (java.util.HashSet)4 IDOMAttr (org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)4 Attr (org.w3c.dom.Attr)4 Set (java.util.Set)3 Point (org.eclipse.swt.graphics.Point)3 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)3 InputStream (java.io.InputStream)2 Iterator (java.util.Iterator)2 Pattern (java.util.regex.Pattern)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)2 IDocument (org.eclipse.jface.text.IDocument)2