blob: bd680ce4e8a844f7f46aa7a3b8a60a27b92f49bf (
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
|
/*******************************************************************************
* Copyright (c) 2013 Atos
* 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:
* Arthur Daussy - initial implementation
*******************************************************************************/
package org.eclipse.papyrus.team.collaborative.integration.papyrus;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
import org.eclipse.papyrus.team.collaborative.IExtendedURI;
import org.eclipse.papyrus.team.collaborative.utils.ExtendedURIUtil;
import org.eclipse.uml2.uml.Element;
import com.google.common.base.Predicate;
/**
* The Class MatchingURIObject.
* Predicate that will return true if the EObject belong to the set of {@link IExtendedURI}
*/
public class MatchingURIObject implements Predicate<EObject> {
private Set<IExtendedURI> uris;
public MatchingURIObject(Set<IExtendedURI> uris) {
super();
this.uris = uris;
}
public boolean apply(EObject input) {
List<EObject> objectToTEObjects = new ArrayList<EObject>();
objectToTEObjects.add(input);
objectToTEObjects.addAll(NotationUtils.getLoadedAssociatedDiagrams(input));
for(IExtendedURI extendedURI : uris) {
for(EObject o : objectToTEObjects) {
boolean contained = ExtendedURIUtil.isIncluded(o, extendedURI);
if(contained) {
return contained;
}
}
}
return false;
}
protected EObject getSemanticObject(EObject eObject) {
EObject result = null;
if(eObject instanceof Element) {
result = eObject;
} else if(eObject instanceof View) {
//Handle view
result = ((View)eObject).getElement();
} else {
//Handle setereotype
Element baseElement = org.eclipse.uml2.uml.util.UMLUtil.getBaseElement(eObject);
if(baseElement != null) {
result = baseElement;
}
//TODO handle tab
}
return result;
}
}
|