blob: 59ba33844a297a7543a82464e2f5758fe69c93f4 (
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*****************************************************************************
* 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:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.views.search.results;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.openelement.service.OpenElementService;
import org.eclipse.papyrus.views.search.scope.ScopeEntry;
import org.eclipse.ui.PartInitException;
/**
*
* A match raised by a viewer (i.e. something that is a view of a real match) in a model
*
*/
public class ViewerMatch extends AbstractResultEntry {
/**
* The model element that is represented by the viewer
*/
protected URI URIsemanticElement;
public ViewerMatch(Object source, ScopeEntry scopeEntry, Object semanticElement) {
super(UNSPECIFIED, UNSPECIFIED, source, scopeEntry);
if (semanticElement instanceof EObject) {
this.URIsemanticElement = EcoreUtil.getURI((EObject) semanticElement);
}
this.parent = getLastParent(this, scopeEntry);
// this.parent = new ResultEntry(scopeEntry.getResource(), scopeEntry);
}
public Object getSemanticElement() {
if (this.URIsemanticElement != null) {
ResourceSet resSet = ((ScopeEntry) this.getElement()).getModelSet();
return resSet.getEObject(this.URIsemanticElement, true);
}
return null;
}
public void setSemanticElement(Object semanticElement) {
if (semanticElement instanceof EObject) {
this.URIsemanticElement = EcoreUtil.getURI((EObject) semanticElement);
}
}
/**
*
* @see org.eclipse.papyrus.views.search.results.AbstractResultEntry#elementToDisplay()
*
* @return
*/
@Override
public Object elementToDisplay() {
return this.getSource();
}
/**
*
* @see org.eclipse.papyrus.views.search.results.AbstractResultEntry#elementToCheckFilterFor()
*
* @return
*/
@Override
public Object elementToCheckFilterFor() {
if (this.URIsemanticElement != null) {
ResourceSet resSet = ((ScopeEntry) this.getElement()).getModelSet();
return resSet.getEObject(this.URIsemanticElement, true);
}
return null;
}
/**
*
* @see org.eclipse.papyrus.views.search.results.AbstractResultEntry#openElement()
*
* @return
*/
@Override
public Object openElement(OpenElementService service) throws ServiceException, PartInitException {
if (this.getSource() instanceof EObject) {
return service.openElement((EObject) this.getSource());
}
return null;
}
}
|