Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9f04a3dab6c7acc73aabcef110f51c5816887461 (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
/*****************************************************************************
 * Copyright (c) 2015 CEA LIST and others.
 * 
 * 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:
 *   Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Initial API and implementation
 *   
 *****************************************************************************/

package org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.preferences.provider;

import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.papyrus.infra.gmfdiag.extensionpoints.editors.configuration.IDirectEditorConstraint;
import org.eclipse.swt.graphics.Image;

/**
 * Label provider for preferences tree of Direct Editor and Constraint.
 * 
 * @author Gabriel Pascual
 *
 */
public class DirectEditorLabelProvider extends LabelProvider implements ILabelProvider {

	/** The Constant UNKNOWN_LABEL. */
	private static final String UNKNOWN_LABEL = "<Unknown>";

	/**
	 * Default constructor.
	 *
	 */
	public DirectEditorLabelProvider() {
		super();
	}

	@Override
	public Image getImage(Object element) {
		return null;
	}

	/**
	 * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
	 *
	 * @param element
	 * @return
	 */
	@Override
	public String getText(Object element) {
		String text = UNKNOWN_LABEL;
		if (element instanceof DirectEditorTreeItem) {
			// For a Direct Editor, the meta class to edit is displayed
			text = ((DirectEditorTreeItem) element).getMetaClassToEdit();
		} else if (element instanceof IDirectEditorConstraint) {
			// For a Constraint, the label of the constraint is displayed
			text = ((IDirectEditorConstraint) element).getLabel();
		}
		return text;
	}

}

Back to the top