blob: 9a2a5ef5ac3b56843c881c850ec4d0a454a050ea (
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
|
/*******************************************************************************
* Copyright (c) 2008, 2012 Angelo Zerr and others.
* 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:
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
* IBM Corporation
*******************************************************************************/
package org.eclipse.e4.ui.css.swt.engine;
import org.eclipse.e4.ui.css.core.impl.engine.CSSEngineImpl;
import org.eclipse.e4.ui.css.core.resources.IResourcesRegistry;
import org.eclipse.e4.ui.css.swt.properties.converters.CSSValueSWTColorConverterImpl;
import org.eclipse.e4.ui.css.swt.properties.converters.CSSValueSWTCursorConverterImpl;
import org.eclipse.e4.ui.css.swt.properties.converters.CSSValueSWTFontConverterImpl;
import org.eclipse.e4.ui.css.swt.properties.converters.CSSValueSWTFontDataConverterImpl;
import org.eclipse.e4.ui.css.swt.properties.converters.CSSValueSWTGradientConverterImpl;
import org.eclipse.e4.ui.css.swt.properties.converters.CSSValueSWTImageConverterImpl;
import org.eclipse.e4.ui.css.swt.properties.converters.CSSValueSWTRGBConverterImpl;
import org.eclipse.e4.ui.css.swt.resources.SWTResourceRegistryKeyFactory;
import org.eclipse.e4.ui.css.swt.resources.SWTResourcesRegistry;
import org.eclipse.swt.widgets.Display;
/**
* CSS SWT Engine implementation which configure CSSEngineImpl to apply styles
* to SWT widgets.
*/
public abstract class AbstractCSSSWTEngineImpl extends CSSEngineImpl {
protected Display display;
public AbstractCSSSWTEngineImpl(Display display) {
this(display, false);
}
public AbstractCSSSWTEngineImpl(Display display, boolean lazyApplyingStyles) {
this.display = display;
/** Initialize SWT CSSValue converter * */
// Register SWT RGB CSSValue Converter
super.registerCSSValueConverter(CSSValueSWTRGBConverterImpl.INSTANCE);
// Register SWT Color CSSValue Converter
super.registerCSSValueConverter(CSSValueSWTColorConverterImpl.INSTANCE);
// Register SWT Gradient CSSValue Converter
super
.registerCSSValueConverter(CSSValueSWTGradientConverterImpl.INSTANCE);
// Register SWT Cursor CSSValue Converter
super
.registerCSSValueConverter(CSSValueSWTCursorConverterImpl.INSTANCE);
// Register SWT Font CSSValue Converter
super.registerCSSValueConverter(CSSValueSWTFontConverterImpl.INSTANCE);
// Register SWT FontData CSSValue Converter
super
.registerCSSValueConverter(CSSValueSWTFontDataConverterImpl.INSTANCE);
// Register SWT Image CSSValue Converter
super.registerCSSValueConverter(CSSValueSWTImageConverterImpl.INSTANCE);
if (lazyApplyingStyles) {
new CSSSWTApplyStylesListener(display, this);
}
initializeCSSPropertyHandlers();
// SWTElement.setEngine(display, this);
setResourceRegistryKeyFactory(new SWTResourceRegistryKeyFactory());
}
protected abstract void initializeCSSPropertyHandlers();
@Override
public IResourcesRegistry getResourcesRegistry() {
IResourcesRegistry resourcesRegistry = super.getResourcesRegistry();
if (resourcesRegistry == null) {
super.setResourcesRegistry(new SWTResourcesRegistry(display));
}
return super.getResourcesRegistry();
}
}
|