Commit 2a869e81 authored by Juergen Haug's avatar Juergen Haug Committed by Gerrit Code Review @ Eclipse.org
Browse files

Merge "Bug 576866 - readded custom font in LabelProvider"

parents cd318150 5e7f5e9a
......@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
* CONTRIBUTORS:
......@@ -20,8 +20,8 @@ import org.eclipse.jface.resource.JFaceResources
import org.eclipse.jface.viewers.StyledString
import org.eclipse.jface.viewers.StyledString.Styler
import org.eclipse.swt.graphics.RGB
import org.eclipse.swt.graphics.TextStyle
import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider
import org.eclipse.xtext.ui.label.StylerFactory
/**
* Provides labels for a EObjects.
......@@ -32,23 +32,37 @@ class BaseLabelProvider extends DefaultEObjectLabelProvider {
protected static final String KEYWORD_COLOR = "KEYWORD_COLOR";
@Inject
protected StylerFactory stylerFactory;
protected Styler keywordStyler = null;
protected Styler typeStyler = null;
protected val fontRegistry = JFaceResources.fontRegistry // Bug 576866
protected val colorRegistry = JFaceResources.getColorRegistry
val keyWordStyler = new Styler() {
override applyStyles(TextStyle textStyle) {
textStyle.font = fontRegistry.getBold(JFaceResources.TEXT_FONT)
textStyle.foreground = colorRegistry.get(KEYWORD_COLOR)
}
}
val typeStyler = new Styler() {
override applyStyles(TextStyle textStyle) {
textStyle.font = fontRegistry.getItalic(JFaceResources.TEXT_FONT)
}
}
@Inject
new(AdapterFactoryLabelProvider delegate) {
super(delegate);
JFaceResources.getColorRegistry().put(KEYWORD_COLOR, new RGB(50, 50, 50));
colorRegistry.put(KEYWORD_COLOR, new RGB(50, 50, 50));
}
def String image(Import mdl) {
return null;
}
def StyledString text(Import im) {
if (im.getImportedNamespace() === null) {
var txt = new StyledString("import model " + im.getImportURI())
......@@ -62,22 +76,11 @@ class BaseLabelProvider extends DefaultEObjectLabelProvider {
}
def protected Styler getKeywordStyler() {
// Bug 576866
// if (keywordStyler===null) {
// var font = JFaceResources.getFontDescriptor(JFaceResources.TEXT_FONT)
// var boldFont = font.setStyle(SWT.BOLD)
// keywordStyler = stylerFactory.createStyler(boldFont, KEYWORD_COLOR, null)
// }
// return keywordStyler
return keyWordStyler
}
def protected Styler getTypeStyler() {
// Bug 576866
// if (typeStyler===null) {
// var font = JFaceResources.getFontDescriptor(JFaceResources.TEXT_FONT)
// var italicFont = font.setStyle(SWT.ITALIC)
// typeStyler = stylerFactory.createStyler(italicFont, null, null)
// }
// return typeStyler
return typeStyler
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment