下面列出了org.eclipse.ui.views.properties.IPropertySourceProvider#org.eclipse.emf.ecore.EStructuralFeature 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test public void testDerivedModel() {
EPackage pack = DatatypeRulesTestLanguagePackage.eINSTANCE;
EClass model = (EClass) pack.getEClassifier("Model");
assertNotNull(model);
EStructuralFeature feature = model.getEStructuralFeature("id");
assertNotNull(feature);
assertEquals(EcorePackage.Literals.ESTRING, feature.getEType());
feature = model.getEStructuralFeature("value");
assertNotNull(feature);
assertEquals(EcorePackage.Literals.EBIG_DECIMAL, feature.getEType());
feature = model.getEStructuralFeature("vector");
assertNotNull(feature);
assertEquals(EcorePackage.Literals.ESTRING, feature.getEType());
feature = model.getEStructuralFeature("dots");
assertNotNull(feature);
assertEquals(EcorePackage.Literals.ESTRING, feature.getEType());
}
@Override
public void validate ( final ValidationContext context )
{
final Object o = context.getTarget ();
if ( ! ( o instanceof EObject ) )
{
return;
}
final EObject eo = (EObject)o;
final EStructuralFeature f = eo.eClass ().getEStructuralFeature ( this.featureName );
if ( f == null )
{
return;
}
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures ( Object object )
{
if ( childrenFeatures == null )
{
super.getChildrenFeatures ( object );
childrenFeatures.add ( OsgiPackage.Literals.EQUINOX_APPLICATION__CONNECTIONS );
childrenFeatures.add ( OsgiPackage.Literals.EQUINOX_APPLICATION__EXPORTER );
childrenFeatures.add ( OsgiPackage.Literals.EQUINOX_APPLICATION__CUSTOMIZATION_PROFILE );
childrenFeatures.add ( OsgiPackage.Literals.EQUINOX_APPLICATION__MODULES );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__SUMMARY_GROUPS );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__ITEMS );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__MARKERS );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__MONITOR_POOLS );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__EVENT_POOLS );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__DATA_MAPPER );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__EXTERNAL_EVENT_MONITORS );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__EXTERNAL_EVENT_FILTERS );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__AVERAGES );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__MOVING_AVERAGES );
childrenFeatures.add ( OsgiPackage.Literals.MASTER_SERVER__BUFFERED_VALUES );
}
return childrenFeatures;
}
protected Result<EClass> applyRuleWithFail(final RuleEnvironment G, final RuleApplicationTrace _trace_, final EObject o2) throws RuleFailedException {
EClass eClass = null; // output parameter
/* fail or fail error "this is an error" source o2.eClass feature o2.eClass.eContainingFeature */
{
RuleFailedException previousFailure = null;
try {
/* fail */
throwForExplicitFail();
} catch (Exception e) {
previousFailure = extractRuleFailedException(e);
/* fail error "this is an error" source o2.eClass feature o2.eClass.eContainingFeature */
String error = "this is an error";
EClass _eClass = o2.eClass();
EObject source = _eClass;
EStructuralFeature _eContainingFeature = o2.eClass().eContainingFeature();
EStructuralFeature feature = _eContainingFeature;
throwForExplicitFail(error, new ErrorInformation(source, feature));
}
}
return new Result<EClass>(eClass);
}
/**
* Add the given outline node to the outline map.
*
* @param node
* IOutlineNode to add.
*/
private void addToOutlineMap(final IOutlineNode node) {
EStructuralFeature eFeature = null;
if (node instanceof EObjectNode) {
eFeature = ((EObjectNode) node).getEObject(getTestSource().getXtextResource()).eContainingFeature();
// TODO : remove the following part once all tests have been refactored
Class<?> nodeClazz = ((EObjectNode) node).getEClass().getInstanceClass();
if (!getOutlineMap().containsKey(nodeClazz)) {
getOutlineMap().put(nodeClazz, new ArrayList<IOutlineNode>());
}
getOutlineMap().get(nodeClazz).add(node);
} else if (node instanceof EStructuralFeatureNode) {
eFeature = ((EStructuralFeatureNode) node).getEStructuralFeature();
}
if (eFeature == null) {
return;
}
if (!getOutlineMap().containsKey(eFeature)) {
getOutlineMap().put(eFeature, new ArrayList<IOutlineNode>());
}
getOutlineMap().get(eFeature).add(node);
}
protected void initChildrenFeatureIndexes() {
EClass clazz = semanticElement.eClass();
int[] indices = new int[clazz.getFeatureCount()];
Arrays.fill(indices, 0);
for (IAstRegion ele : children) {
EStructuralFeature feat = ele.getContainingFeature();
if (feat != null && feat.isMany()) {
int id = clazz.getFeatureID(feat);
if (ele instanceof AbstractEObjectRegion) {
((AbstractEObjectRegion) ele).indexInFeature = indices[id];
} else if (ele instanceof NodeSemanticRegion) {
((NodeSemanticRegion) ele).indexInFeature = indices[id];
} else if (ele instanceof StringSemanticRegion) {
((StringSemanticRegion) ele).indexInFeature = indices[id];
}
indices[id]++;
}
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case ConnectorImplementationPackage.DOCUMENT_ROOT__MIXED:
((FeatureMap.Internal)getMixed()).set(newValue);
return;
case ConnectorImplementationPackage.DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
((EStructuralFeature.Setting)getXMLNSPrefixMap()).set(newValue);
return;
case ConnectorImplementationPackage.DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
((EStructuralFeature.Setting)getXSISchemaLocation()).set(newValue);
return;
case ConnectorImplementationPackage.DOCUMENT_ROOT__CONNECTOR_IMPLEMENTATION:
setConnectorImplementation((ConnectorImplementation)newValue);
return;
}
super.eSet(featureID, newValue);
}
public String[] getFeatureValuesFromEObjectId(String xmiId, EStructuralFeature... features) {
try (Scanner scanner = new Scanner(eResourceFile, UTF_8)) {
List<String> values = new ArrayList<>();
String xmiIdPattern = toXMIIdPattern(xmiId);
while(scanner.hasNextLine()) {
String line = scanner.nextLine();
if(line.contains(xmiIdPattern)){
for(EStructuralFeature feature : features){
values.add(getFeatureValue(line,feature));
}
return values.toArray(new String[values.size()]);
}
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
return null;
}
@Override
protected IStatus performLiveValidation(IValidationContext ctx) {
final EStructuralFeature featureTriggered = ctx.getFeature();
if (featureTriggered.equals(ProcessPackage.Literals.ASSIGNABLE__ACTOR)) {
final Assignable assignable = (Assignable) ctx.getTarget();
if (!hasActorsDefined(assignable)) {
return ctx.createFailureStatus(new Object[] { ((Element) assignable).getName() });
}
} else if (featureTriggered.equals(NotationPackage.Literals.VIEW__ELEMENT)) {
final EObject eobject = (EObject) ctx.getFeatureNewValue();
if (eobject instanceof Assignable) {
if (!hasActorsDefined((Assignable) eobject)) {
return ctx.createFailureStatus(new Object[] { ((Element) eobject).getName() });
}
}
} else if (featureTriggered.equals(ProcessPackage.Literals.TASK__OVERRIDE_ACTORS_OF_THE_LANE)) {
final Task task = (Task) ctx.getTarget();
final Boolean overrideGroupsOfLane = (Boolean) ctx.getFeatureNewValue();
if (overrideGroupsOfLane) {
if (!hasActorsDefined(task)) {
return ctx.createFailureStatus(new Object[] { task.getName() });
}
}
}
return ctx.createSuccessStatus();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature ( Object object, Object child )
{
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature ( object, child );
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures ( Object object )
{
if ( childrenFeatures == null )
{
super.getChildrenFeatures ( object );
childrenFeatures.add ( ConfigurationPackage.Literals.DOCUMENT_ROOT__ROOT );
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature ( Object object, Object child )
{
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature ( object, child );
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature ( Object object, Object child )
{
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature ( object, child );
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures ( Object object )
{
if ( childrenFeatures == null )
{
super.getChildrenFeatures ( object );
childrenFeatures.add ( DetailViewPackage.Literals.VIEW__HEADER_COMPONENT );
childrenFeatures.add ( DetailViewPackage.Literals.VIEW__GROUPS );
childrenFeatures.add ( DetailViewPackage.Literals.VIEW__HIDDEN_COMPONENT );
childrenFeatures.add ( DetailViewPackage.Literals.VIEW__SCRIPT_MODULE );
}
return childrenFeatures;
}
public void accept(RuleCall rc, Object value, String token, int indexInFeature, int indexInNonTransient) {
EStructuralFeature feature = getFeature(rc);
assertIndex(feature, indexInFeature);
assertValue(feature, value);
INode node = getNode(feature, indexInFeature, indexInNonTransient, value);
acceptRuleCall(rc, value, token, indexInFeature, node);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
@Override
public <V> V get(EStructuralFeature feature) {
if (feature instanceof EAttribute) {
return this.getAttributeValue((EAttribute) feature);
} else if (feature instanceof EReference) {
return this.getReferenceValue((EReference) feature);
}
return null;
}
/**
* @generated
*/
public static List<CrossflowLinkDescriptor> getSource_2005IncomingLinks(View view) {
Source modelElement = (Source) view.getElement();
Map<EObject, Collection<EStructuralFeature.Setting>> crossReferences = EcoreUtil.CrossReferencer
.find(view.eResource().getResourceSet().getResources());
LinkedList<CrossflowLinkDescriptor> result = new LinkedList<CrossflowLinkDescriptor>();
result.addAll(getIncomingFeatureModelFacetLinks_Stream_InputOf_4005(modelElement, crossReferences));
return result;
}
/**
* @return the location data for the given diagnostic.
*/
protected IssueLocation getLocationData(EObject obj, EStructuralFeature structuralFeature, int index) {
INode parserNode = NodeModelUtils.getNode(obj);
if (parserNode != null) {
if (structuralFeature != null) {
List<INode> nodes = NodeModelUtils.findNodesForFeature(obj, structuralFeature);
if (index < 0) // insignificant index
index = 0;
if (nodes.size()>index)
parserNode = nodes.get(index);
}
return getLocationForNode(parserNode);
} else if (obj.eContainer() != null) {
EObject container = obj.eContainer();
EStructuralFeature containingFeature = obj.eContainingFeature();
return getLocationData(container, containingFeature,
containingFeature.isMany() ? ((EList<?>) container.eGet(containingFeature)).indexOf(obj)
: ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
}
// place issue at start of document since we lack location information
IssueLocation startOfDocumentLocation = new IssueLocation();
startOfDocumentLocation.offset = 0;
startOfDocumentLocation.length = 0;
startOfDocumentLocation.lineNumber = 1;
startOfDocumentLocation.column = 1;
startOfDocumentLocation.lineNumberEnd = 1;
startOfDocumentLocation.columnEnd = 1;
return new IssueLocation();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures ( Object object )
{
if ( childrenFeatures == null )
{
super.getChildrenFeatures ( object );
childrenFeatures.add ( MemoryPackage.Literals.TYPE_SYSTEM__TYPES );
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EStructuralFeature getChildFeature(Object object, Object child) {
// Check the type of the specified child object and return the proper feature to use for
// adding (see {@link AddCommand}) it as a child.
return super.getChildFeature(object, child);
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(TypesPackage.Literals.TYPE__SUPER_TYPES);
}
return childrenFeatures;
}
protected List<IAstRegion> findRegions(IEObjectRegion owner, FeatureChange change) {
EStructuralFeature feature = change.getFeature();
if (feature instanceof EReference && ((EReference) feature).isContainment()) {
ITextRegionAccess access = owner.getTextRegionAccess();
Set<EObject> children = Sets.newHashSet();
for (ListChange lc : change.getListChanges()) {
children.addAll(lc.getReferenceValues());
}
List<IEObjectRegion> result = Lists.newArrayList();
for (EObject obj : children) {
IEObjectRegion region = access.regionForEObject(obj);
if (region != null) {
result.add(region);
}
}
for (IAstRegion astRegion : owner.getAstRegions()) {
if (astRegion instanceof IEObjectRegion) {
if (feature.equals(astRegion.getContainingFeature())) {
result.add((IEObjectRegion) astRegion);
}
}
}
Collections.sort(result, (a, b) -> a.getOffset() - b.getOffset());
return ImmutableList.copyOf(result);
} else {
return ImmutableList.copyOf(owner.getRegionFor().features(feature));
}
}
@Override
public ValueTransient isValueTransient(EObject semanticObject, EStructuralFeature feature) {
final String n = feature.getName();
if ("required1".equals(n) || "required2".equals(n))
return ValueTransient.PREFERABLY;
if ("opt1".equals(n) || "opt2".equals(n))
return ValueTransient.YES;
return super.isValueTransient(semanticObject, feature);
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS);
}
return childrenFeatures;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case CheckPackage.XISSUE_EXPRESSION__CHECK:
setCheck((Check)null);
return;
case CheckPackage.XISSUE_EXPRESSION__MARKER_FEATURE:
setMarkerFeature((EStructuralFeature)null);
return;
case CheckPackage.XISSUE_EXPRESSION__MARKER_OBJECT:
setMarkerObject((XExpression)null);
return;
case CheckPackage.XISSUE_EXPRESSION__MARKER_INDEX:
setMarkerIndex((XExpression)null);
return;
case CheckPackage.XISSUE_EXPRESSION__MESSAGE:
setMessage((XExpression)null);
return;
case CheckPackage.XISSUE_EXPRESSION__MESSAGE_PARAMETERS:
getMessageParameters().clear();
return;
case CheckPackage.XISSUE_EXPRESSION__ISSUE_CODE:
setIssueCode(ISSUE_CODE_EDEFAULT);
return;
case CheckPackage.XISSUE_EXPRESSION__ISSUE_DATA:
getIssueData().clear();
return;
}
super.eUnset(featureID);
}
/**
* This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an
* {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or
* {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Collection<? extends EStructuralFeature> getChildrenFeatures(Object object) {
if (childrenFeatures == null) {
super.getChildrenFeatures(object);
childrenFeatures.add(ConnectorDefinitionPackage.Literals.DOCUMENT_ROOT__CONNECTOR_DEFINITION);
}
return childrenFeatures;
}