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

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

Introduction

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

Prototype

public static boolean asBoolean(String value, boolean dflt) 

Source Link

Document

Converts the given value into a boolean.

Usage

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

License:Open Source License

protected boolean asBoolean(String string, boolean defaultValue) {
    if (string != null) {
        return StringConverter.asBoolean(string, defaultValue);
    }/*from   w  w  w  . j  a va2 s.c o m*/
    return defaultValue;
}

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

License:Open Source License

private boolean asBoolean(String string, boolean defaultValue) {
    if (string != null) {
        return StringConverter.asBoolean(string, defaultValue);
    }// ww  w  .  ja va  2s  .c  o  m
    return defaultValue;
}

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
 *//*from   w  w  w  .j a v  a 2s  .co m*/
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;
}