blob: cf15643ebe7775355d292dd9d4ba57c1b4adbfb6 (
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
|
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* 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:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.css.properties.provider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.papyrus.infra.gmfdiag.css.stylesheets.Theme;
import org.eclipse.papyrus.infra.gmfdiag.css.theme.ThemeManager;
import org.eclipse.swt.graphics.Image;
public class CSSThemeLabelProvider extends LabelProvider {
@Override
public String getText(Object value) {
Theme theme = getTheme(value);
if (theme != null) {
return theme.getLabel();
}
return super.getText(value);
}
@Override
public Image getImage(Object value) {
Theme theme = getTheme(value);
if (theme != null) {
Image icon = ThemeManager.instance.getThemeIcon(theme);
return icon;
}
return super.getImage(value);
}
protected Theme getTheme(Object value) {
if (value instanceof String) {
String themeId = (String) value;
Theme theme = ThemeManager.instance.getTheme(themeId);
return theme;
}
return null;
}
}
|