Search in sources :

Example 16 with StringTokenizer

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

the class TextHoverManager method generateTextHoverDescriptors.

/**
 * Generate a list of text hover descriptors from the given delimited
 * string
 *
 * @param textHoverStrings
 * @return
 */
public TextHoverDescriptor[] generateTextHoverDescriptors(String textHoverStrings) {
    StringTokenizer st = new StringTokenizer(textHoverStrings, HOVER_SEPARATOR);
    // read from preference and load id-descriptor mapping to a hash table
    HashMap idToModifier = new HashMap(st.countTokens());
    while (st.hasMoreTokens()) {
        String textHoverString = st.nextToken();
        StringTokenizer st2 = new StringTokenizer(textHoverString, HOVER_ATTRIBUTE_SEPARATOR);
        if (st2.countTokens() == 3) {
            String id = st2.nextToken();
            boolean enabled = Boolean.valueOf(st2.nextToken()).booleanValue();
            String modifierString = st2.nextToken();
            if (modifierString.equals(NO_MODIFIER))
                // $NON-NLS-1$
                modifierString = "";
            String label = null;
            String description = null;
            try {
                label = SSEUIMessages.getResourceBundle().getString(id + LABEL_KEY);
                description = SSEUIMessages.getResourceBundle().getString(id + DESCRIPTION_KEY);
            } catch (Exception e) {
                Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
            }
            TextHoverDescriptor descriptor = new TextHoverDescriptor(id, label, description, enabled, modifierString);
            // should check to see if ids appear more than once
            idToModifier.put(id, descriptor);
        }
    }
    // go through all defined text hovers and match with their preference
    TextHoverDescriptor[] descriptors = new TextHoverDescriptor[TEXT_HOVER_IDS.length];
    for (int i = 0; i < TEXT_HOVER_IDS.length; i++) {
        TextHoverDescriptor desc = (TextHoverDescriptor) idToModifier.get(TEXT_HOVER_IDS[i]);
        if (desc != null) {
            descriptors[i] = desc;
        } else {
            String label = null;
            String description = null;
            try {
                label = SSEUIMessages.getResourceBundle().getString(TEXT_HOVER_IDS[i] + LABEL_KEY);
                description = SSEUIMessages.getResourceBundle().getString(TEXT_HOVER_IDS[i] + DESCRIPTION_KEY);
            } catch (Exception e) {
                Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
            }
            descriptors[i] = new TextHoverDescriptor(TEXT_HOVER_IDS[i], label, description);
        }
    }
    return descriptors;
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) HashMap(java.util.HashMap)

Example 17 with StringTokenizer

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

the class EditorUtility method computeStateMask.

/**
 * Computes the state mask for the given modifier string.
 *
 * @param modifiers
 *            the string with the modifiers, separated by '+', '-', ';',
 *            ',' or '.'
 * @return the state mask or -1 if the input is invalid
 */
public static int computeStateMask(String modifiers) {
    if (modifiers == null)
        return -1;
    if (modifiers.length() == 0)
        return SWT.NONE;
    int stateMask = 0;
    // $NON-NLS-1$
    StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* ");
    while (modifierTokenizer.hasMoreTokens()) {
        int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
        if (modifier == 0 || (stateMask & modifier) == modifier)
            return -1;
        stateMask = stateMask | modifier;
    }
    return stateMask;
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer)

Example 18 with StringTokenizer

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

the class AbstractCompletionProposalCategoriesConfiguration method loadShouldNotDisplayOnOwnPage.

/**
 * <p>Loads the user preferences for which categories should not be displayed on their own
 * content assist page</p>
 *
 * @param useDefaults if <code>true</code> then use the {@link IPreferenceStore} defaults,
 * otherwise use the user specified preferences
 */
private void loadShouldNotDisplayOnOwnPage(boolean useDefaults) {
    // clear the current sort order
    this.fShouldNotDisplayOnOwnPage.clear();
    // parse either the default or user configuration preference
    String preference;
    if (useDefaults) {
        preference = getPreferenceStore().getDefaultString(getShouldNotDisplayOnOwnPagePrefKey());
    } else {
        preference = getPreferenceStore().getString(getShouldNotDisplayOnOwnPagePrefKey());
    }
    StringTokenizer tokenizer = new StringTokenizer(preference, PREFERENCE_CATEGORY_SEPERATOR);
    while (tokenizer.hasMoreTokens()) {
        String categoryID = tokenizer.nextToken();
        this.fShouldNotDisplayOnOwnPage.add(categoryID);
    }
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer)

Example 19 with StringTokenizer

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

the class BreakpointProvidersTest method testMultipleProviders.

/**
 * Tests the case of multiple providers for a content type
 */
public void testMultipleProviders() {
    final String pattern = ClassPatternRegistry.getInstance().getClassPattern("org.eclipse.jst.jsp.ui.tests.multitype");
    assertNotNull("Class pattern for 'type' shouldn't be null", pattern);
    final String[] expected = new String[] { "*foo", "*bar", "*baz" };
    final StringTokenizer tokenizer = new StringTokenizer(pattern, ",");
    final Set tokens = new HashSet(expected.length);
    while (tokenizer.hasMoreTokens()) {
        tokens.add(tokenizer.nextElement());
    }
    for (int i = 0; i < expected.length; i++) {
        tokens.remove(expected[i]);
    }
    assertTrue("Class patterns are not equal", tokens.isEmpty());
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) HashSet(java.util.HashSet) Set(java.util.Set) HashSet(java.util.HashSet)

Example 20 with StringTokenizer

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

the class SimpleWebFacetInstallDataModelProvider method validateContextRoot.

protected IStatus validateContextRoot(String contextRoot) {
    if (contextRoot == null || contextRoot.length() == 0) {
        return new ResourceStatus(IResourceStatus.INVALID_VALUE, null, ResourceHandler.Context_Root_cannot_be_empty_2);
    } else if (contextRoot.trim().equals(contextRoot)) {
        // $NON-NLS-1$
        StringTokenizer stok = new StringTokenizer(contextRoot, ".");
        while (stok.hasMoreTokens()) {
            String token = stok.nextToken();
            int cp;
            for (int i = 0; i < token.length(); i += UTF16.getCharCount(cp)) {
                cp = UTF16.charAt(token, i);
                if (token.charAt(i) == ' ') {
                    return new ResourceStatus(IResourceStatus.INVALID_VALUE, null, ResourceHandler.Names_cannot_contain_whitespace);
                } else if (!(token.charAt(i) == '_') && !(token.charAt(i) == '-') && !(token.charAt(i) == '/') && Character.isLetterOrDigit(token.charAt(i)) == false) {
                    String invalidCharString = null;
                    if (UTF16.getCharCount(cp) > 1) {
                        invalidCharString = UTF16.valueOf(cp);
                    } else {
                        invalidCharString = (new Character(token.charAt(i))).toString();
                    }
                    Object[] invalidChar = new Object[] { invalidCharString };
                    String errorStatus = ResourceHandler.getString(ResourceHandler.The_character_is_invalid_in_a_context_root, invalidChar);
                    return new ResourceStatus(IResourceStatus.INVALID_VALUE, null, errorStatus);
                }
            }
        }
    } else {
        return new ResourceStatus(IResourceStatus.INVALID_VALUE, null, ResourceHandler.Names_cannot_contain_whitespace);
    }
    return OK_STATUS;
}
Also used : StringTokenizer(com.ibm.icu.util.StringTokenizer) ResourceStatus(org.eclipse.core.internal.resources.ResourceStatus) IResourceStatus(org.eclipse.core.resources.IResourceStatus)

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