org.eclipse.jface.resource.DataFormatException Java Examples

The following examples show how to use org.eclipse.jface.resource.DataFormatException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EditorUtils.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: ColorPersistor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
	}
}
 
Example #3
Source File: ColorPersistor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
	}
}