Java 类org.eclipse.jface.resource.DataFormatException 实例源码

项目:bts    文件:EditorUtils.java   
public static Color colorFromString(String rgbString) {
    if (rgbString != null && rgbString.trim().length() > 0) {
        Color col = JFaceResources.getColorRegistry().get(rgbString);
        try {
            if (col == null) {
                RGB rgb = StringConverter.asRGB(rgbString);
                JFaceResources.getColorRegistry().put(rgbString, rgb);
                col = JFaceResources.getColorRegistry().get(rgbString);
            }
        }
        catch (DataFormatException e) {
            log.error("Corrupt color value: " + rgbString, e);
        }
        return col;
    }
    return null;
}
项目:PDFReporter-Studio    文件:UITheme.java   
public void createColorProperty(Composite cmp, final String prop, String name, final IPreferenceStore store) {
    new Label(cmp, SWT.NONE).setText(name);

    final ColorSelector colorSelector = new ColorSelector(cmp);
    colorSelector.addListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            properties.put(prop, StringConverter.asString(colorSelector.getColorValue()));
            save(store);
        }
    });
    try {
        colorSelector.setColorValue(StringConverter.asRGB(properties.get(prop)));
    } catch (DataFormatException e) {
        e.printStackTrace();
    }
}
项目:termsuite-ui    文件:StringToIntegerConverter.java   
@Override
  public Object convert(Object fromObject) {
    if (fromObject instanceof String) {
        try {
            return StringConverter.asInt(fromObject.toString());
        } catch(DataFormatException e) {

        }
    } else if (fromObject instanceof Integer) {
        return StringConverter.asString((Integer)fromObject);
    } else if(fromObject == null)
        return null;
    throw new IllegalArgumentException(fromObject.getClass() + " type cannot be converted by " + getClass());
}
项目:OpenSPIFe    文件:PlotRgbRegistry.java   
private RGB parseRgb(String rgbString) {
    RGB rgb = null;
    if (rgbString != null) {
        if (rgbString.equalsIgnoreCase("null")) {
            rgb = NULL;
        } else {
            try {
                rgb = ColorUtils.parseRGB(rgbString);
            } catch (DataFormatException x) {
                LogUtil.error(x);
            }
        }
    }
    return rgb;
}
项目:translationstudio8    文件:ColorPersistor.java   
/**
 * Create a Color instance using the String created by {@link ColorPersistor#asColor(String)}
 */
public static Color asColor(String colorAsString) {
    try {
        return GUIHelper.getColor(StringConverter.asRGB(colorAsString));
    } catch (DataFormatException e) {
        return DEFAULT_COLOR;
    }
}
项目:tmxeditor8    文件:ColorPersistor.java   
/**
 * Create a Color instance using the String created by {@link ColorPersistor#asColor(String)}
 */
public static Color asColor(String colorAsString) {
    try {
        return GUIHelper.getColor(StringConverter.asRGB(colorAsString));
    } catch (DataFormatException e) {
        return DEFAULT_COLOR;
    }
}
项目:Pydev    文件:ColorCache.java   
protected Color getNamedColor(String name) {
    Color color = fNamedColorTable.get(name);
    if (color == null || color.isDisposed()) {
        String colorCode = preferences != null ? preferences.getString(name) : "";
        if (colorCode.length() == 0) {
            if (name.equals("RED")) {
                color = getColor(new RGB(255, 0, 0));

            } else if (name.equals("BLACK")) {
                color = getColor(new RGB(0, 0, 0));

            } else if (name.equals("WHITE")) {
                color = getColor(new RGB(255, 255, 255));

            } else {
                Log.log("Unknown color:" + name);
                color = getColor(new RGB(255, 0, 0));
            }
        } else {
            try {
                RGB rgb = StringConverter.asRGB(colorCode);
                color = new Color(Display.getCurrent(), rgb);
                fNamedColorTable.put(name, color);
            } catch (DataFormatException e) {
                // Data conversion failure, maybe someone edited our prefs by hand
                Log.log(e);
                color = getColor(new RGB(255, 50, 0));
            }
        }
    }
    return color;
}