use of org.eclipse.swt.graphics.FontData in project translationstudio8 by heartsome.
the class WorkbenchLabelProvider method getFont.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
public Font getFont(Object element) {
IWorkbenchAdapter2 adapter = getAdapter2(element);
if (adapter == null) {
return null;
}
FontData descriptor = adapter.getFont(element);
if (descriptor == null) {
return null;
}
return (Font) getResourceManager().get(FontDescriptor.createFrom(descriptor));
}
use of org.eclipse.swt.graphics.FontData in project translationstudio8 by heartsome.
the class XLIFFEditorImplWithNatTable method addFlagLableToColumn.
/**
* 配置标签列的显示效果
* @param configRegistry
* 配置注册表
*/
private void addFlagLableToColumn(IConfigRegistry configRegistry) {
// Edit by Leakey 实现状态图片的动态显示
StatusPainter painter = new StatusPainter(bodyDataProvider);
// CellPainterDecorator flagPainter = new CellPainterDecorator(new BackgroundPainter(), CellEdgeEnum.RIGHT,
// painter);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, DisplayMode.NORMAL, FLAG_CELL_LABEL);
// Set the color of the cell. This is picked up by the button painter to style the button
Style style = new Style();
FontData fd = GUIHelper.DEFAULT_FONT.getFontData()[0];
fd.setStyle(SWT.BOLD);
style.setAttributeValue(CellStyleAttributes.FONT, GUIHelper.getFont(fd));
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, FLAG_CELL_LABEL);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.SELECT, FLAG_CELL_LABEL);
}
use of org.eclipse.swt.graphics.FontData in project translationstudio8 by heartsome.
the class ExcelExporter method getFontInCSSFormat.
private String getFontInCSSFormat(Font font) {
FontData fontData = font.getFontData()[0];
String fontName = fontData.getName();
int fontStyle = fontData.getStyle();
String[] HTML_STYLES = new String[] { "NORMAL", "BOLD", "ITALIC" };
return String.format("font: %s; font-family: %s", fontStyle <= 2 ? HTML_STYLES[fontStyle] : HTML_STYLES[0], fontName);
}
use of org.eclipse.swt.graphics.FontData in project translationstudio8 by heartsome.
the class GUIHelper method getFont.
public static Font getFont(FontData... fontDatas) {
StringBuilder keyBuilder = new StringBuilder();
for (FontData fontData : fontDatas) {
keyBuilder.append(fontData.toString());
}
String key = keyBuilder.toString();
if (JFaceResources.getFontRegistry().hasValueFor(key)) {
return JFaceResources.getFont(key);
} else {
JFaceResources.getFontRegistry().put(key, fontDatas);
return JFaceResources.getFont(key);
}
}
use of org.eclipse.swt.graphics.FontData in project cubrid-manager by CUBRID.
the class ResourceManager method getFont.
public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) {
String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
Font font = fontMap.get(fontName);
if (font == null) {
FontData fontData = new FontData(name, size, style);
if (strikeout || underline) {
try {
//$NON-NLS-1$
Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT");
//$NON-NLS-1$
Object logFont = FontData.class.getField("data").get(fontData);
if (logFont != null && logFontClass != null) {
if (strikeout) {
//$NON-NLS-1$
logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1));
}
if (underline) {
//$NON-NLS-1$
logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1));
}
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
font = new Font(Display.getCurrent(), fontData);
fontMap.put(fontName, font);
}
return font;
}
Aggregations