blob: 1ab8c233723bd7cb6d71bf27b25c8815f1cef50f (
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
75
76
77
78
79
80
|
/*****************************************************************************
* 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:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.sysml.nattable.provider;
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
import org.eclipse.papyrus.infra.nattable.utils.AxisUtils;
import org.eclipse.papyrus.infra.nattable.utils.Constants;
import org.eclipse.papyrus.infra.nattable.utils.LabelProviderCellContextElementWrapper;
import org.eclipse.papyrus.sysml.service.types.matcher.FlowPortNAMatcher;
import org.eclipse.papyrus.uml.nattable.provider.AbstractUMLNattableCellLabelProvider;
import org.eclipse.uml2.uml.Port;
/**
* This label provider allows to display N/A for the direction of the FlowPort when its requred!
*
* @author Vincent Lorenzo
*
*/
public class SysMLFlowPortDirectionLabelProvider extends AbstractUMLNattableCellLabelProvider {
/**
* N/A FlowPort matcher
*/
private static final FlowPortNAMatcher matcher = new FlowPortNAMatcher();
/**
*
* @see org.eclipse.papyrus.infra.nattable.provider.GenericCellLabelProvider#accept(java.lang.Object)
*
* @param element
* @return
*/
@Override
public boolean accept(final Object element) {
if(element instanceof LabelProviderCellContextElementWrapper) {
final ILayerCell cell = ((LabelProviderCellContextElementWrapper)element);
final IConfigRegistry registry = ((LabelProviderCellContextElementWrapper)element).getConfigRegistry();
final Object columnObject = getColumnObject(cell, registry);
String str = AxisUtils.getPropertyId(columnObject);
if(str == null) {
final Object rowObject = getRowObject(cell, registry);
str = AxisUtils.getPropertyId(rowObject);
}
if(str != null) {
return str.endsWith(org.eclipse.papyrus.sysml.nattable.utils.Constants.STEREOTYPE_FLOWPORT_DIRECTION);
}
}
return false;
}
@Override
public String getText(Object element) {
final ILayerCell cell = ((LabelProviderCellContextElementWrapper)element);
final IConfigRegistry configRegistry = ((LabelProviderCellContextElementWrapper)element).getConfigRegistry();
final Object rowObject = getRowObject(cell, configRegistry);
final Object columObject = getColumnObject(cell, configRegistry);
Port port = null;
if(rowObject instanceof Port) {
port = (Port)rowObject;
} else if(columObject instanceof Port) {
port = (Port)columObject;
}
if(port != null && matcher.matches(port)) {
return Constants.NOT_AVALAIBLE;
}
return super.getText(element);
}
}
|