Example usage for org.eclipse.jface.resource StringConverter asInt

List of usage examples for org.eclipse.jface.resource StringConverter asInt

Introduction

In this page you can find the example usage for org.eclipse.jface.resource StringConverter asInt.

Prototype

public static int asInt(String value, int dflt) 

Source Link

Document

Converts the given value into an int.

Usage

From source file:com.google.dart.tools.search.internal.ui.SearchPageDescriptor.java

License:Open Source License

private void readExtensionScorePairs() {
    fExtensionScorePairs = new ArrayList<ExtensionScorePair>(3);
    String content = fElement.getAttribute(EXTENSIONS_ATTRIBUTE);
    if (content == null) {
        return;//from   ww  w.  j  ava2  s .co m
    }
    StringTokenizer tokenizer = new StringTokenizer(content, ","); //$NON-NLS-1$
    while (tokenizer.hasMoreElements()) {
        String token = tokenizer.nextToken().trim();
        int pos = token.indexOf(':');
        if (pos != -1) {
            String extension = token.substring(0, pos);
            int score = StringConverter.asInt(token.substring(pos + 1).trim(),
                    ISearchPageScoreComputer.UNKNOWN);
            if (extension.equals("*")) { //$NON-NLS-1$
                fWildcardScore = score;
            } else {
                fExtensionScorePairs.add(new ExtensionScorePair(extension, score));
            }
        }
    }
}

From source file:com.google.dart.tools.ui.internal.dialogs.SourceActionDialog.java

License:Open Source License

protected int asInt(String string, int defaultValue) {
    if (string != null) {
        return StringConverter.asInt(string, defaultValue);
    }//  w ww. j a  v  a 2  s. c  o  m
    return defaultValue;
}

From source file:com.nokia.carbide.search.system.internal.ui.SearchPageDescriptor.java

License:Open Source License

private void readExtensionScorePairs() {
    fExtensionScorePairs = new ArrayList(3);
    String content = fElement.getAttribute(EXTENSIONS_ATTRIBUTE);
    if (content == null)
        return;// ww w  .j a  v a2  s.co m
    StringTokenizer tokenizer = new StringTokenizer(content, ","); //$NON-NLS-1$
    while (tokenizer.hasMoreElements()) {
        String token = tokenizer.nextToken().trim();
        int pos = token.indexOf(':');
        if (pos != -1) {
            String extension = token.substring(0, pos);
            int score = StringConverter.asInt(token.substring(pos + 1).trim(),
                    ISearchPageScoreComputer.UNKNOWN);
            if (extension.equals("*")) { //$NON-NLS-1$
                fWildcardScore = score;
            } else {
                fExtensionScorePairs.add(new ExtensionScorePair(extension, score));
            }
        }
    }
}

From source file:ext.org.eclipse.jdt.internal.corext.codemanipulation.tostringgeneration.ToStringGenerationSettings.java

License:Open Source License

private static int asInt(String string, int defaultValue) {
    if (string != null) {
        return StringConverter.asInt(string, defaultValue);
    }/*  www.  jav  a  2  s  .c om*/
    return defaultValue;
}

From source file:org.eclipse.ui.texteditor.AnnotationTypeLookup.java

License:Open Source License

/**
 * Creates an annotation type mapping from the given configuration element.
 *
 * @param element the configuration element
 * @param typeAttributeName the name of the attribute specifying the
 *            annotation type//from www .j a v  a  2s.  c  o m
 * @return the annotation type mapping or <code>null</code>
 */
private AnnotationTypeMapping createMapping(IConfigurationElement element, String typeAttributeName) {

    AnnotationTypeMapping mapping = new AnnotationTypeMapping();

    String s = element.getAttribute(typeAttributeName);
    if (s == null || s.trim().length() == 0)
        return null;
    mapping.fAnnotationType = s;

    s = element.getAttribute("markerType"); //$NON-NLS-1$
    if (s == null || s.trim().length() == 0)
        return null;
    mapping.fMarkerType = s;

    s = element.getAttribute("markerSeverity"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        mapping.fMarkerSeverity = StringConverter.asInt(s, AnnotationTypeMapping.UNDEFINED);

    return mapping;
}

From source file:org.eclipse.ui.texteditor.MarkerAnnotationPreferences.java

License:Open Source License

/**
 * Creates a <code>AnnotationPreference</code> the given configuration element.
 *
 * @param element the configuration element
 * @return the created annotation preference
 */// w  ww . j  a  va  2s.  c  om
private AnnotationPreference createSpec(IConfigurationElement element) {

    String s;
    int i;
    boolean b;

    ReadOnlyAnnotationPreference info = new ReadOnlyAnnotationPreference();

    s = element.getAttribute("annotationType"); //$NON-NLS-1$
    if (s == null || s.trim().length() == 0)
        return null;
    info.setAnnotationType(s);

    s = element.getAttribute("label"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setPreferenceLabel(s);

    s = element.getAttribute("markerType"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setMarkerType(s);

    s = element.getAttribute("markerSeverity"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        i = StringConverter.asInt(s, IMarker.SEVERITY_INFO);
        info.setSeverity(i);
    }

    s = element.getAttribute("textPreferenceKey"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setTextPreferenceKey(s);

    s = element.getAttribute("textPreferenceValue"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        b = StringConverter.asBoolean(s, false);
        info.setTextPreferenceValue(b);
    }

    s = element.getAttribute("highlightPreferenceKey"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setHighlightPreferenceKey(s);

    s = element.getAttribute("highlightPreferenceValue"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        b = StringConverter.asBoolean(s, false);
        info.setHighlightPreferenceValue(b);
    }

    s = element.getAttribute("overviewRulerPreferenceKey"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setOverviewRulerPreferenceKey(s);

    s = element.getAttribute("overviewRulerPreferenceValue"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        b = StringConverter.asBoolean(s, false);
        info.setOverviewRulerPreferenceValue(b);
    }

    s = element.getAttribute("verticalRulerPreferenceKey"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setVerticalRulerPreferenceKey(s);

    s = element.getAttribute("verticalRulerPreferenceValue"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        b = StringConverter.asBoolean(s, true);
        info.setVerticalRulerPreferenceValue(b);
    }

    s = element.getAttribute("colorPreferenceKey"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setColorPreferenceKey(s);

    s = element.getAttribute("colorPreferenceValue"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        RGB rgb = StringConverter.asRGB(s);
        info.setColorPreferenceValue(rgb == null ? new RGB(0, 0, 0) : rgb);
    }

    s = element.getAttribute("presentationLayer"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        i = StringConverter.asInt(s, 0);
        info.setPresentationLayer(i);
    }

    s = element.getAttribute("contributesToHeader"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        b = StringConverter.asBoolean(s, false);
        info.setContributesToHeader(b);
    }

    s = element.getAttribute("showInNextPrevDropdownToolbarActionKey"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setShowInNextPrevDropdownToolbarActionKey(s);

    s = element.getAttribute("showInNextPrevDropdownToolbarAction"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        b = StringConverter.asBoolean(s, false);
        info.setShowInNextPrevDropdownToolbarAction(b);
    }

    s = element.getAttribute("isGoToNextNavigationTargetKey"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setIsGoToNextNavigationTargetKey(s);

    s = element.getAttribute("isGoToNextNavigationTarget"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        b = StringConverter.asBoolean(s, false);
        info.setIsGoToNextNavigationTarget(b);
    }

    s = element.getAttribute("isGoToPreviousNavigationTargetKey"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setIsGoToPreviousNavigationTargetKey(s);

    s = element.getAttribute("isGoToPreviousNavigationTarget"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {
        b = StringConverter.asBoolean(s, false);
        info.setIsGoToPreviousNavigationTarget(b);
    }

    s = element.getAttribute("symbolicIcon"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setSymbolicImageName(s);

    s = element.getAttribute("icon"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setImageDescriptor(getImageDescriptor(s, element));

    s = element.getAttribute("quickFixIcon"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setQuickFixImageDescriptor(getImageDescriptor(s, element));

    s = element.getAttribute("annotationImageProvider"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setAnnotationImageProviderData(element, "annotationImageProvider"); //$NON-NLS-1$

    s = element.getAttribute("textStylePreferenceKey"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0)
        info.setTextStylePreferenceKey(s);

    s = element.getAttribute("textStylePreferenceValue"); //$NON-NLS-1$
    if (s != null && s.trim().length() > 0) {

        if (AnnotationPreference.STYLE_BOX.equals(s) || AnnotationPreference.STYLE_DASHED_BOX.equals(s)
                || AnnotationPreference.STYLE_IBEAM.equals(s) || AnnotationPreference.STYLE_SQUIGGLES.equals(s)
                || AnnotationPreference.STYLE_PROBLEM_UNDERLINE.equals(s)
                || AnnotationPreference.STYLE_UNDERLINE.equals(s))
            info.setTextStyleValue(s);
        else
            info.setTextStyleValue(AnnotationPreference.STYLE_NONE);

    }

    s = element.getAttribute("includeOnPreferencePage"); //$NON-NLS-1$
    info.setIncludeOnPreferencePage(s == null || StringConverter.asBoolean(s, true));

    info.markReadOnly();

    return info;
}