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
104
105
106
107
108
|
/*******************************************************************************
* Copyright (c) 2011 Formal Mind GmbH and University of Dusseldorf.
* 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:
* Michael Jastram - initial API and implementation
******************************************************************************/
package org.eclipse.rmf.pror.reqif10.provider;
import java.util.Collection;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.rmf.pror.reqif10.util.ProrUtil;
import org.eclipse.rmf.reqif10.ReqIfContent;
import org.eclipse.rmf.reqif10.Reqif10Factory;
import org.eclipse.rmf.reqif10.Reqif10Package;
import org.eclipse.rmf.reqif10.SpecType;
import org.eclipse.rmf.reqif10.Specification;
import org.eclipse.rmf.reqif10.SpecificationType;
/**
* Virtual node for grouping {@link Specification}s together.
* <p>
*
* TODO We explicitly register a Listener for the Outline (in ReqIFEditor), but
* it would be better if the model would magically refresh itself. It doesn't do
* this, because this provider isn't a {@link Notifier}.
*/
public class VirtualSpecificationsItemProvider extends
TransientReqIFItemProvider {
public VirtualSpecificationsItemProvider(AdapterFactory adapterFactory,
ReqIfContent content) {
super(adapterFactory, content);
}
@Override
protected Collection<? extends EStructuralFeature> getChildrenFeatures(
Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures
.add(Reqif10Package.Literals.REQ_IF_CONTENT__SPECIFICATIONS);
}
return childrenFeatures;
}
@Override
public String getText(Object object) {
return "Specifications";
}
@Override
public Object getImage(Object object) {
return overlayImage(object, getResourceLocator().getImage(
"full/obj16/VirtualSpecifications.png"));
}
@Override
protected void collectNewChildDescriptors(
Collection<Object> newChildDescriptors, Object object) {
super.collectNewChildDescriptors(newChildDescriptors, target);
// Allow creation of new untyped Specifications
newChildDescriptors.add(createChildParameter(
Reqif10Package.Literals.REQ_IF_CONTENT__SPECIFICATIONS,
Reqif10Factory.eINSTANCE.createSpecification()));
// Allow creation of typed Specifications
ProrUtil.collectNewChildDescriptorsForTypeCreators(newChildDescriptors,
target,
Reqif10Package.Literals.REQ_IF_CONTENT__SPECIFICATIONS, SpecificationType.class);
}
@Override
protected Command createCreateChildCommand(EditingDomain domain,
EObject owner, EStructuralFeature feature, Object value, int index,
Collection<?> collection) {
if (value instanceof SpecType) {
return ProrUtil.createAddTypedElementCommand(owner,
Reqif10Package.Literals.REQ_IF_CONTENT__SPECIFICATIONS,
Reqif10Factory.eINSTANCE.createSpecification(),
Reqif10Package.Literals.SPECIFICATION__TYPE,
(SpecType) value, index, 0, domain,
adapterFactory);
}
return super.createCreateChildCommand(domain, owner, feature, value,
index, collection);
}
@Override
public Collection<?> getChildren(Object object) {
Collection<?> children = super.getChildren(object);
return children;
}
}
|