org.eclipse.emf.ecore.EStructuralFeature Java Examples

The following examples show how to use org.eclipse.emf.ecore.EStructuralFeature. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetamodelTest.java    From xtext-core with Eclipse Public License 2.0 7 votes vote down vote up
@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());
}
 
Example #2
Source File: AssignableConstraint.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example #3
Source File: AbstractOutlineTest.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #4
Source File: ExclusiveGroupValidator.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@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;
    }

}
 
Example #5
Source File: MasterServerItemProvider.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: AbstractEObjectRegion.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
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]++;
		}
	}
}
 
Example #8
Source File: DocumentRootImpl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <!-- 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);
}
 
Example #9
Source File: EMFResourceUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #10
Source File: ConnectionTypeItemProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 );
}
 
Example #11
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected Result<Boolean> collectionsInternal(final RuleEnvironment _environment_, final RuleApplicationTrace _trace_, final EClass c2, final List<EStructuralFeature> l2) {
  try {
  	checkParamsNotNull(c2, l2);
  	return collectionsDispatcher.invoke(_environment_, _trace_, c2, l2);
  } catch (Exception _e_collections) {
  	sneakyThrowRuleFailedException(_e_collections);
  	return null;
  }
}
 
Example #12
Source File: EventItemProvider.java    From ifml-editor with MIT License 5 votes vote down vote up
/**
 * 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(CorePackage.Literals.EVENT__INTERACTION_FLOW_EXPRESSION);
	}
	return childrenFeatures;
}
 
Example #13
Source File: EClassifierInfo.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public boolean isFeatureSemanticallyEqualTo(EStructuralFeature f1, EStructuralFeature f2) {
	boolean result = isFeatureSemanticallyEqualApartFromType(f1, f2);
	if (f1 instanceof EReference && f2 instanceof EReference) {
		EClass f1Type = (EClass) f1.getEType();
		EClass f2Type = (EClass) f2.getEType();
		result &= f1Type.isSuperTypeOf(f2Type);
		result &= ((EReference) f1).isContainment() == ((EReference) f2).isContainment();
		result &= ((EReference) f1).isContainer() == ((EReference) f2).isContainer();
	} else {
		result &= f1.getEType().equals(EcoreUtil2.getCompatibleType(f1.getEType(), f2.getEType()));
	}
	return result;
}
 
Example #14
Source File: DataTypeItemProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
    * <!-- 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);
   }
 
Example #15
Source File: ExpressionsSemantics.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected void vartypeThrowException(final String _error, final String _issue, final Exception _ex, final Variable variable, final ErrorInformation[] _errorInformations) throws RuleFailedException {
  String _stringRep = this.stringRep(variable);
  String _plus = ("cannot type " + _stringRep);
  String error = _plus;
  EObject source = variable;
  EReference _variable_Expression = ExpressionsPackage.eINSTANCE.getVariable_Expression();
  EStructuralFeature feature = _variable_Expression;
  throwRuleFailedException(error,
  	_issue, _ex, new ErrorInformation(source, feature));
}
 
Example #16
Source File: EmfJsonSerializer.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private void writeEmbedded(IdEObject object) throws IOException {
	print("{");
	print("\"_t\":\"" + object.eClass().getName() + "\",");
	for (EStructuralFeature eStructuralFeature : object.eClass().getEAllStructuralFeatures()) {
		print("\"" + eStructuralFeature.getName() + "\":");
		writePrimitive(eStructuralFeature, object.eGet(eStructuralFeature));
		if (object.eClass().getEAllStructuralFeatures().get(object.eClass().getEAllStructuralFeatures().size()-1) != eStructuralFeature) {
			print(",");
		}
	}
	print("}");
}
 
Example #17
Source File: SequenceFeeder.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public void accept(RuleCall rc, Object value) {
	EStructuralFeature feature = getFeature(rc);
	assertIndex(feature);
	assertValue(feature, value);
	INode node = getNode(feature, value);
	String token = getToken(rc, value, node);
	acceptRuleCall(rc, value, token, ISemanticSequenceAcceptor.NO_INDEX, node);
}
 
Example #18
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected Result<Boolean> applyRuleForEach(final RuleEnvironment G, final RuleApplicationTrace _trace_, final EObject obj) throws RuleFailedException {
  final Consumer<EStructuralFeature> _function = new Consumer<EStructuralFeature>() {
    public void accept(final EStructuralFeature it) {
      /* G |- it */
      type1Internal(G, _trace_, it);
    }
  };
  obj.eClass().getEStructuralFeatures().forEach(_function);
  return new Result<Boolean>(true);
}
 
Example #19
Source File: ProfileConfigurationItemProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 );
}
 
Example #20
Source File: ExecutionScopeItemProvider.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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);
}
 
Example #21
Source File: EndpointItemProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 ( WorldPackage.Literals.ENDPOINT__BOUND_SERVICE );
    }
    return childrenFeatures;
}
 
Example #22
Source File: FormMappingItemProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
    * <!-- 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);
   }
 
Example #23
Source File: PackageMetaData.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
public EReference getEReference(String className, String referenceName) {
	EClassifier eClassifier = ePackage.getEClassifier(className);
	if (eClassifier instanceof EClass) {
		EClass eClass = (EClass)eClassifier;
		EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(referenceName);
		if (eStructuralFeature instanceof EReference) {
			return (EReference) eStructuralFeature;
		}
	}
	return null;
}
 
Example #24
Source File: ModbusDeviceItemProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 );
}
 
Example #25
Source File: AbstractInputItemProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- 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 );
}
 
Example #26
Source File: ScriptSeriesItemProvider.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 ( ChartPackage.Literals.SCRIPT_SERIES__LINE_PROPERTIES );
    }
    return childrenFeatures;
}
 
Example #27
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
public Result<Boolean> collections(final RuleEnvironment _environment_, final RuleApplicationTrace _trace_, final EClass c2, final List<EStructuralFeature> l2) {
  try {
  	return collectionsInternal(_environment_, _trace_, c2, l2);
  } catch (Exception _e_collections) {
  	return resultForFailure(_e_collections);
  }
}
 
Example #28
Source File: TypeItemProvider.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <!-- 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);
}
 
Example #29
Source File: EnumerationTypeItemProvider.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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.ENUMERATION_TYPE__ENUMERATOR);
	}
	return childrenFeatures;
}
 
Example #30
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected void subtypeThrowException(final String _error, final String _issue, final Exception _ex, final EClass left, final EClass right, final ErrorInformation[] _errorInformations) throws RuleFailedException {
  String _name = left.getName();
  String _plus = (_name + " is not a subtype of ");
  String _name_1 = right.getName();
  String _plus_1 = (_plus + _name_1);
  String error = _plus_1;
  EObject source = left;
  EStructuralFeature _eStructuralFeature = left.getEStructuralFeature("name");
  EStructuralFeature feature = _eStructuralFeature;
  throwRuleFailedException(error,
  	_issue, _ex, new ErrorInformation(source, feature));
}