Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a212c0c30aa9f2f6a92a6770b6e7a2cce8760f3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * CONTRIBUTORS:
 * 		Juergen Haug (initial contribution)
 * 
 *******************************************************************************/

package org.eclipse.etrice.ui.behavior.actioneditor.modelaware

import java.util.Map
import org.eclipse.etrice.expressions.ui.highlight.AbstractHighlightStyles
import org.eclipse.jface.text.TextAttribute
import org.eclipse.swt.SWT
import org.eclipse.swt.graphics.Color
import org.eclipse.swt.graphics.RGB
import org.eclipse.swt.widgets.Display

class JFaceHighlightStyles extends AbstractHighlightStyles {

	override getDefault() {
		new TextAttribute(getColor(DEFAULT_RGB))
	}
	
	override getTargetKeyword() {
		new TextAttribute(getColor(TARGET_KEYWORD_RGB), null, SWT.BOLD)
	}
	
	override getComment() {
		new TextAttribute(getColor(COMMENT_RGB))
	}
	
	override getString() {
		new TextAttribute(getColor(STRING_RGB))
	}
	
	override getNumber() {
		new TextAttribute(getColor(NUMBER_RGB))
	}
	
	override getSpecialFeature() {
		new TextAttribute(getColor(SPECIAL_FEATURE_RGB))
	}
	
	override getOperation() {
		new TextAttribute(getColor(OPERATION_RGB))
	}
	
	override getAttribute() {
		new TextAttribute(getColor(ATTRIBUTE_RGB))
	}
	
	override getInterfaceItem() {
		new TextAttribute(getColor(INTERFACE_ITEM_RGB))
	}
	
	override getEnum() {
		new TextAttribute(getColor(ENUM_RGB))
	}
	
	override getDataClass() {
		new TextAttribute(getColor(DATA_CLASS_RGB))
	}
	
	override getPrimitiveType() {
		new TextAttribute(getColor(PRIMITIVE_TYPE_RGB))
	}
	
	override getExternalType() {
		new TextAttribute(getColor(EXTERNAL_TYPE_RGB))
	}
	
	protected Map<RGB, Color> fColorTable = newHashMap
	
	def private Color getColor(RGB rgb) {
		var color = fColorTable.get(rgb)
		if (color === null) {
			color = new Color(Display.getCurrent(), rgb)
			fColorTable.put(rgb, color)
		}
		
		return color
	}
	
}

Back to the top