Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 37801c148efe464efa11171356fb7a0d91ae3112 (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
/**
 *  Copyright (c) 2012 Mia-Software.
 *  
 *  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:
 *  	Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
 */
package org.eclipse.papyrus.emf.facet.custom.ui.internal.dialog;

import org.eclipse.papyrus.emf.facet.custom.ui.internal.ImageProvider;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

public class ColorLabelProvider extends LabelProvider implements IColorProvider {

	private final LoadCustomizationsDialog loadCustomDialog;

	public ColorLabelProvider(final LoadCustomizationsDialog loadCustomDialog) {
		super();
		this.loadCustomDialog = loadCustomDialog;
	}

	@Override
	public String getText(final Object element) {
		final Customization customization = (Customization) element;
		return customization.getName();
	}

	@Override
	public Image getImage(final Object element) {
		Image result;
		if (this.loadCustomDialog.getLockedCustoms().contains(element)) {
			result = ImageProvider.getInstance().getGrayedUiCustomIcon();
		} else {
			result = ImageProvider.getInstance().getUiCustomIcon();
		}
		return result;
	}

	public Color getForeground(final Object element) {
		Color result = null;
		if (this.loadCustomDialog.getLockedCustoms().contains(element)) {
				result = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
		}
		return result;
	}

	public Color getBackground(final Object element) {
		return null;
	}

}

Back to the top