Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 180d101b7edc634f32e3f354ba7ec5e6c11357fb (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) 2013 CEA LIST.
 *
 * 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:
 *  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.uml.profile.providers;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
import org.eclipse.papyrus.infra.ui.emf.providers.EMFLabelProvider;
import org.eclipse.papyrus.uml.profile.utils.Util;
import org.eclipse.uml2.uml.util.UMLUtil;


/**
 * A LabelProvider for a single Profile Definition (EPackage)
 *
 * @author Camille Letavernier
 *
 */
public class ProfileDefinitionLabelProvider extends EMFLabelProvider implements IFilteredLabelProvider {

	@Override
	protected String getText(EObject element) {
		if (element instanceof EPackage) {
			EPackage definition = (EPackage) element;
			String label = String.format("%s (%s)", definition.getName(), Util.getDefinitionVersion(definition).toString());
			return label;

		}

		return super.getText(element);
	}

	public boolean accept(Object element) {
		EObject eObject = EMFHelper.getEObject(element);
		if (eObject instanceof EPackage) {
			EPackage ePackage = (EPackage) eObject;
			return UMLUtil.getProfile(ePackage) != null;
		}

		return false;
	}

}

Back to the top