Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/labeling/BaseLabelProvider.xtend')
-rw-r--r--plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/labeling/BaseLabelProvider.xtend53
1 files changed, 28 insertions, 25 deletions
diff --git a/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/labeling/BaseLabelProvider.xtend b/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/labeling/BaseLabelProvider.xtend
index d9e486e8b..ef34fef58 100644
--- a/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/labeling/BaseLabelProvider.xtend
+++ b/plugins/org.eclipse.etrice.core.common.ui/src/org/eclipse/etrice/core/common/ui/labeling/BaseLabelProvider.xtend
@@ -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
}
+
}

Back to the top