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;
}
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;
}
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);
}
}
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());
}
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;
}
Aggregations