blob: 4c60d0bf35fe58c1cc33c290cc392f54f5f06dc9 (
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
|
/*****************************************************************************
* Copyright (c) 2011 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:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.infra.table.properties.provider;
import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.papyrus.infra.table.properties.modelelement.PapyrusTableModelElement;
/**
*
* LabelProvider for the MetamodelView
*
*/
public class CustomizationLabelProvider extends LabelProvider {
/** the table instance*/
private final TableInstance2 table;
/** the preference : allows to manage the text displayed to represent the MetamodelView*/
private final int preference;
/**
*
* Constructor.
*
* @param table
* the table instance
* @param pref
* the preference
*/
public CustomizationLabelProvider(final TableInstance2 table, final int pref) {
preference = pref;
this.table = table;
}
/**
*
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*
* @param element
* @return
*/
@Override
public String getText(final Object element) {
final MetamodelView metamodelView = (MetamodelView) element;
if(table.getLocalCustomizations().contains(metamodelView)){
switch(preference){
case PapyrusTableModelElement.NO_LOCALS :
//it is not possible
return ""; //$NON-NLS-1$
case PapyrusTableModelElement.ONLY_ONE_LOCALS :
return "localCustomizations"; //$NON-NLS-1$
case PapyrusTableModelElement.ALL_LOCALS :
return "localCustomization" + " " + metamodelView.getMetamodelURI(); //$NON-NLS-1$ //$NON-NLS-2$
default :
return metamodelView.getName();
}
}else{
return metamodelView.getName();
}
}
}
|