Search in sources :

Example 41 with StringTokenizer

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

the class MainTab method loadTagsAndPrioritiesFrom.

/**
 * @param tags
 * @param priorities
 */
private void loadTagsAndPrioritiesFrom(String tagString, String priorityString) {
    String[] tags = StringUtils.unpack(tagString);
    StringTokenizer toker = null;
    List list = new ArrayList();
    // $NON-NLS-1$
    toker = new StringTokenizer(priorityString, ",");
    while (toker.hasMoreTokens()) {
        Integer number = null;
        try {
            number = Integer.valueOf(toker.nextToken());
        } catch (NumberFormatException e) {
            number = new Integer(IMarker.PRIORITY_NORMAL);
        }
        list.add(number);
    }
    Integer[] priorities = (Integer[]) list.toArray(new Integer[0]);
    fTaskTags = new TaskTag[Math.min(tags.length, priorities.length)];
    for (int i = 0; i < fTaskTags.length; i++) {
        fTaskTags[i] = new TaskTag(tags[i], priorities[i].intValue());
    }
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) TaskTag(org.eclipse.wst.sse.core.internal.provisional.tasks.TaskTag) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Point(org.eclipse.swt.graphics.Point)

Example 42 with StringTokenizer

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

the class CMDocumentFactoryRegistryReader method readElement.

protected void readElement(IConfigurationElement element) {
    if (element.getName().equals(TAG_NAME)) {
        String factoryClass = element.getAttribute(ATT_CLASS);
        String filenameExtensions = element.getAttribute(ATT_TYPE);
        if (factoryClass != null && filenameExtensions != null) {
            try {
                CMDocumentFactoryDescriptor descriptor = new CMDocumentFactoryDescriptor(element);
                for (// $NON-NLS-1$
                StringTokenizer st = new StringTokenizer(filenameExtensions, ","); // $NON-NLS-1$
                st.hasMoreTokens(); ) {
                    String token = st.nextToken().trim();
                    registry.putFactory(token, descriptor);
                }
            } catch (Exception e) {
                Logger.logException(e);
            }
        }
    }
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer)

Example 43 with StringTokenizer

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

the class BreakpointProviderBuilder method findElements.

/*
	 * Returns a matching array of extension points matching this key. Doesn't
	 * cause instantiation of providers. @return IBreakpointProvider[]
	 */
protected IConfigurationElement[] findElements(String key) {
    initCache();
    if (cache == null || cache.size() == 0)
        return new IConfigurationElement[0];
    int num = cache.size();
    List elements = new ArrayList(1);
    for (int i = 0; i < num; i++) {
        Object obj = cache.get(i);
        if (!(obj instanceof IConfigurationElement))
            continue;
        IConfigurationElement element = (IConfigurationElement) obj;
        if (!TAG_PROVIDER.equals(element.getName()))
            continue;
        boolean add = false;
        String types = element.getAttribute(ATT_CONTENT_TYPES);
        String exts = element.getAttribute(ATT_EXTENSIONS);
        if (types == null && exts == null) {
            add = true;
        }
        if (!add && types != null && types.length() > 0) {
            IContentType testType = Platform.getContentTypeManager().getContentType(key);
            // $NON-NLS-1$
            StringTokenizer tokenizer = new StringTokenizer(types, ",");
            while (tokenizer.hasMoreTokens()) {
                String type = tokenizer.nextToken();
                IContentType contentType = Platform.getContentTypeManager().getContentType(type);
                if (contentType != null && testType != null && testType.isKindOf(contentType)) {
                    add = true;
                    break;
                }
            }
        }
        if (!add && exts != null) {
            // $NON-NLS-1$
            StringTokenizer tokenizer = new StringTokenizer(exts, ",");
            while (tokenizer.hasMoreTokens()) {
                String ext = tokenizer.nextToken();
                if (ext.trim().equals(key.trim())) {
                    add = true;
                    break;
                }
            }
        }
        if (add) {
            elements.add(element);
        }
    }
    return (IConfigurationElement[]) elements.toArray(new IConfigurationElement[0]);
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IContentType(org.eclipse.core.runtime.content.IContentType) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 44 with StringTokenizer

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

the class BreakpointProviderBuilder method createBreakpointProviders.

/*
	 * Creates an array of breakpoint providers matching the given key to the
	 * value of the IConfigurationElement attribute "attrName" @return
	 * IBreakpointProvider[]
	 */
protected IBreakpointProvider[] createBreakpointProviders(String attrName, String key) {
    if (cache == null)
        return new IBreakpointProvider[0];
    final int num = cache.size();
    if (num == 0)
        return new IBreakpointProvider[0];
    IBreakpointProvider[] bp = new IBreakpointProvider[num];
    int j = 0;
    for (int i = 0; i < num; i++) {
        Object obj = cache.get(i);
        if (!(obj instanceof IConfigurationElement))
            continue;
        IConfigurationElement element = (IConfigurationElement) obj;
        if (!TAG_PROVIDER.equals(element.getName()))
            continue;
        boolean doCreate = false;
        String attrValues = element.getAttribute(attrName);
        if (attrValues != null) {
            // $NON-NLS-1$
            StringTokenizer tokenizer = new StringTokenizer(attrValues, ",");
            while (tokenizer.hasMoreTokens()) {
                String type = tokenizer.nextToken();
                if (type.trim().equalsIgnoreCase(key.trim())) {
                    doCreate = true;
                    break;
                }
            }
        }
        if (doCreate) {
            IBreakpointProvider b = createBreakpointProvider(element);
            if (b != null) {
                bp[j] = b;
                j++;
            }
        }
    }
    IBreakpointProvider[] bp2 = new IBreakpointProvider[j];
    for (int i = 0; i < j; i++) {
        bp2[i] = bp[i];
    }
    return bp2;
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) IBreakpointProvider(org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.IBreakpointProvider) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 45 with StringTokenizer

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

the class ColorHelper method unpackStylePreferences.

/**
 * Extracts the foreground (RGB String), background (RGB String), bold
 * (boolean String) from the given preference string.
 *
 * @param preference
 *            should be in the form of Foreground RGB String | Background
 *            RGB String | Bold true/false | Italic true/false | Strikethrough true/false | Underline true/false
 * @return String[] where String[0] = Foreground RGB String, String[1] =
 *         Background RGB String, String[2] = Bold true/false, 3 = Italic
 *         true/false, 4 = Strikethrough true/false, 5 = Underline
 *         true/false; indexes 2-4 may be null if we ran into problems
 *         extracting
 */
public static String[] unpackStylePreferences(String preference) {
    String[] stylePrefs = new String[6];
    if (preference != null) {
        StringTokenizer st = new StringTokenizer(preference, STYLE_SEPARATOR);
        if (st.hasMoreTokens()) {
            String foreground = st.nextToken().trim();
            stylePrefs[0] = foreground;
        } else {
            stylePrefs[0] = NULL;
        }
        if (st.hasMoreTokens()) {
            String background = st.nextToken().trim();
            stylePrefs[1] = background;
        } else {
            stylePrefs[1] = NULL;
        }
        if (st.hasMoreTokens()) {
            String bold = st.nextToken().trim();
            stylePrefs[2] = Boolean.valueOf(bold).toString();
        } else {
            stylePrefs[2] = Boolean.FALSE.toString();
        }
        if (st.hasMoreTokens()) {
            String italic = st.nextToken().trim();
            stylePrefs[3] = Boolean.valueOf(italic).toString();
        } else {
            stylePrefs[3] = Boolean.FALSE.toString();
        }
        if (st.hasMoreTokens()) {
            String strikethrough = st.nextToken().trim();
            stylePrefs[4] = Boolean.valueOf(strikethrough).toString();
        } else {
            stylePrefs[4] = Boolean.FALSE.toString();
        }
        if (st.hasMoreTokens()) {
            String underline = st.nextToken().trim();
            stylePrefs[5] = Boolean.valueOf(underline).toString();
        } else {
            stylePrefs[5] = Boolean.FALSE.toString();
        }
    }
    return stylePrefs;
}
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