org.eclipse.emf.ecore.EClass Java Examples

The following examples show how to use org.eclipse.emf.ecore.EClass. 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: ModelDefinitionItemProviderTests.java    From M2Doc with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void getChoiceOfValuesEClass() {
    final IItemPropertyDescriptor descriptor = provider.getPropertyDescriptor(definition,
            GenconfPackage.Literals.MODEL_DEFINITION__VALUE);

    properties.getVariables().put(SELF, "ecore::EClass");
    properties.save();
    saveDocument();

    @SuppressWarnings("unchecked")
    final List<EClass> values = (List<EClass>) descriptor.getChoiceOfValues(definition);

    assertNotNull(values);
    assertEquals(4, values.size());
    assertEquals("Class1", values.get(0).getName());
    assertEquals("Class2", values.get(1).getName());
    assertEquals("Class3", values.get(2).getName());
    assertEquals(null, values.get(3));
}
 
Example #2
Source File: EObjectContentProviderTest.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Mocks XtextEditor and XtextElementSelectionListener to return an element selection that has:
 * - given EAttribute with a specific value (AttributeValuePair)
 * - given EStructuralFeature
 * - given EOperation.
 *
 * @param attributeValuePair
 *          EAttribute with a specific value
 * @param feature
 *          the EStructuralFeature
 * @param operation
 *          the EOperation
 * @return the EClass of the "selected" element
 */
@SuppressWarnings("unchecked")
private EClass mockSelectedElement(final AttributeValuePair attributeValuePair, final EStructuralFeature feature, final EOperation operation) {
  EClass mockSelectionEClass = mock(EClass.class);
  when(mockSelectionListener.getSelectedElementType()).thenReturn(mockSelectionEClass);
  // Mockups for returning AttributeValuePair
  URI elementUri = URI.createURI("");
  when(mockSelectionListener.getSelectedElementUri()).thenReturn(elementUri);
  XtextEditor mockEditor = mock(XtextEditor.class);
  when(mockSelectionListener.getEditor()).thenReturn(mockEditor);
  IXtextDocument mockDocument = mock(IXtextDocument.class);
  when(mockEditor.getDocument()).thenReturn(mockDocument);
  when(mockDocument.<ArrayList<AttributeValuePair>> readOnly(any(IUnitOfWork.class))).thenReturn(newArrayList(attributeValuePair));
  // Mockups for returning EOperation
  BasicEList<EOperation> mockEOperationsList = new BasicEList<EOperation>();
  mockEOperationsList.add(operation);
  when(mockSelectionEClass.getEAllOperations()).thenReturn(mockEOperationsList);
  // Mockups for returning EStructuralFeature
  BasicEList<EStructuralFeature> mockEStructuralFeatureList = new BasicEList<EStructuralFeature>();
  mockEStructuralFeatureList.add(feature);
  mockEStructuralFeatureList.add(attributeValuePair.getAttribute());
  when(mockSelectionEClass.getEAllStructuralFeatures()).thenReturn(mockEStructuralFeatureList);
  return mockSelectionEClass;
}
 
Example #3
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 6 votes vote down vote up
protected Result<EClass> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final EObject obj) throws RuleFailedException {
  try {
  	final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
  	final Result<EClass> _result_ = applyRuleEObjectEClass(G, _subtrace_, obj);
  	addToTrace(_trace_, new Provider<Object>() {
  		public Object get() {
  			return ruleName("EObjectEClass") + stringRepForEnv(G) + " |- " + stringRep(obj) + " : " + stringRep(_result_.getFirst());
  		}
  	});
  	addAsSubtrace(_trace_, _subtrace_);
  	return _result_;
  } catch (Exception e_applyRuleEObjectEClass) {
  	typeThrowException(ruleName("EObjectEClass") + stringRepForEnv(G) + " |- " + stringRep(obj) + " : " + "EClass",
  		EOBJECTECLASS,
  		e_applyRuleEObjectEClass, obj, new ErrorInformation[] {new ErrorInformation(obj)});
  	return null;
  }
}
 
Example #4
Source File: ExtensionsFactoryImpl.java    From ifml-editor with MIT License 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EObject create(EClass eClass) {
	switch (eClass.getClassifierID()) {
		case ExtensionsPackage.ON_SUBMIT_EVENT: return createOnSubmitEvent();
		case ExtensionsPackage.VALIDATION_RULE: return createValidationRule();
		case ExtensionsPackage.LIST: return createList();
		case ExtensionsPackage.POSITION: return createPosition();
		case ExtensionsPackage.USER_ROLE: return createUserRole();
		case ExtensionsPackage.IFML_SLOT: return createIFMLSlot();
		case ExtensionsPackage.ON_SELECT_EVENT: return createOnSelectEvent();
		case ExtensionsPackage.FORM: return createForm();
		case ExtensionsPackage.DEVICE: return createDevice();
		case ExtensionsPackage.SELECTION_FIELD: return createSelectionField();
		case ExtensionsPackage.SIMPLE_FIELD: return createSimpleField();
		case ExtensionsPackage.DETAILS: return createDetails();
		case ExtensionsPackage.IFML_WINDOW: return createIFMLWindow();
		case ExtensionsPackage.ON_LOAD_EVENT: return createOnLoadEvent();
		case ExtensionsPackage.IFML_MENU: return createIFMLMenu();
		case ExtensionsPackage.JUMP_EVENT: return createJumpEvent();
		case ExtensionsPackage.LANDING_EVENT: return createLandingEvent();
		case ExtensionsPackage.SET_CONTEXT_EVENT: return createSetContextEvent();
		default:
			throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
	}
}
 
Example #5
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected Result<Boolean> closuresInternal(final RuleEnvironment _environment_, final RuleApplicationTrace _trace_, final EClass eClass) {
  try {
  	checkParamsNotNull(eClass);
  	return closuresDispatcher.invoke(_environment_, _trace_, eClass);
  } catch (Exception _e_closures) {
  	sneakyThrowRuleFailedException(_e_closures);
  	return null;
  }
}
 
Example #6
Source File: PartialContentAssistTestLanguageFactoryImpl.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EObject create(EClass eClass)
{
  switch (eClass.getClassifierID())
  {
    case PartialContentAssistTestLanguagePackage.TYPE_DECLARATION: return createTypeDeclaration();
    case PartialContentAssistTestLanguagePackage.PROPERTY: return createProperty();
    default:
      throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
  }
}
 
Example #7
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
public Result<EObject> type2(final RuleEnvironment _environment_, final RuleApplicationTrace _trace_, final EClass c) {
  try {
  	return type2Internal(_environment_, _trace_, c);
  } catch (Exception _e_type2) {
  	return resultForFailure(_e_type2);
  }
}
 
Example #8
Source File: Xtext2EcoreTransformerTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAssignedKeyword() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test with org.eclipse.xtext.common.Terminals generate test \'http://test\' RuleA: featureA?=(\'+\'|\'-\') featureB=(\'*\'|\'/\');");
  final String grammar = _builder.toString();
  EPackage ePackage = this.getEPackageFromGrammar(grammar);
  Assert.assertEquals(1, ePackage.getEClassifiers().size());
  EClassifier _type = this.<EClassifier>type(ePackage, "RuleA");
  EClass ruleA = ((EClass) _type);
  Assert.assertEquals(2, ruleA.getEAttributes().size());
  this.assertAttributeConfiguration(ruleA, 0, "featureA", "EBoolean", 0, 1);
  this.assertAttributeConfiguration(ruleA, 1, "featureB", "EString", 0, 
    1);
}
 
Example #9
Source File: ModelImpl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EList<Instance> getAllInstances(EClass eClass) {
	final EList<Instance> instances = new UniqueEList<Instance>();

	for (final Type type : getTypes()) {
		if (eClass.isSuperTypeOf(type.getEClass())) {
			instances.addAll(type.getInstances());
		}
	}

	return instances;
}
 
Example #10
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
public Result<Boolean> type(final RuleEnvironment _environment_, final RuleApplicationTrace _trace_, final EClass c1, final EObject o1) {
  try {
  	return typeInternal(_environment_, _trace_, c1, o1);
  } catch (Exception _e_type) {
  	return resultForFailure(_e_type);
  }
}
 
Example #11
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 5 votes vote down vote up
protected Result<Boolean> applyRuleEClassSubtyping(final RuleEnvironment G, final RuleApplicationTrace _trace_, final EClass candidate, final EClass superClass) throws RuleFailedException {
  /* superClass.isSuperTypeOf(candidate) */
  if (!superClass.isSuperTypeOf(candidate)) {
    sneakyThrowRuleFailedException("superClass.isSuperTypeOf(candidate)");
  }
  return new Result<Boolean>(true);
}
 
Example #12
Source File: LocalUniqueNameContext.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public final boolean isCaseSensitive(EObject candidate, EClass clusterType) {
	return true;
}
 
Example #13
Source File: EGaml.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Gets the key of an eObject in a given eClass
 *
 * @param object
 *            the object
 * @param clazz
 *            the clazz
 * @return the key of
 */
@Override
public String getKeyOf(final EObject object, final EClass clazz) {
	String s;
	final int id = clazz.getClassifierID();
	switch (id) {
		case GamlPackage.UNARY:
			return ((Unary) object).getOp();
		case GamlPackage.BINARY_OPERATOR:
			return ((BinaryOperator) object).getOp();
		case GamlPackage.ARGUMENT_PAIR:
			s = ((ArgumentPair) object).getOp();
			return s.endsWith(":") ? s.substring(0, s.length() - 1) : s;
		case GamlPackage.PARAMETER:
			final Parameter p = (Parameter) object;
			s = getKeyOf(p.getLeft());
			if (s == null) {
				s = p.getBuiltInFacetKey();
			}
			return s.endsWith(":") ? s.substring(0, s.length() - 1) : s;
		case GamlPackage.MODEL:
			return IKeyword.MODEL;
		case GamlPackage.STATEMENT:
			s = ((Statement) object).getKey();
			if (s == null && object instanceof S_Definition) {
				final TypeRef type = (TypeRef) ((S_Definition) object).getTkey();
				if (type != null) { return getKeyOf(type); }
			}
			return s;
		case GamlPackage.FACET:
			s = ((Facet) object).getKey();
			return s.endsWith(":") ? s.substring(0, s.length() - 1) : s;
		case GamlPackage.FUNCTION:
			final Function ff = (Function) object;
			return getKeyOf(ff.getLeft());
		case GamlPackage.TYPE_REF:
			s = getNameOfRef(object);
			if (s.contains("<")) {
				s = s.split("<")[0];
				// Special case for the 'species<xxx>' case
				if (s.equals("species")) {
					s = SyntacticFactory.SPECIES_VAR;
				}
			}
			return s;
		case GamlPackage.IF:
			return "?";
		case GamlPackage.VARIABLE_REF:
		case GamlPackage.UNIT_NAME:
		case GamlPackage.ACTION_REF:
		case GamlPackage.SKILL_REF:
		case GamlPackage.EQUATION_REF:
			return getNameOfRef(object);
		case GamlPackage.INT_LITERAL:
		case GamlPackage.STRING_LITERAL:
		case GamlPackage.DOUBLE_LITERAL:
			// case GamlPackage.COLOR_LITERAL:
		case GamlPackage.RESERVED_LITERAL:
		case GamlPackage.BOOLEAN_LITERAL:
		case GamlPackage.TERMINAL_EXPRESSION:
			return ((TerminalExpression) object).getOp();
		default:
			final List<EClass> eSuperTypes = clazz.getESuperTypes();
			return eSuperTypes.isEmpty() ? null : getKeyOf(object, eSuperTypes.get(0));
	}
}
 
Example #14
Source File: TwoOptionsImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass()
{
  return SerializationerrorPackage.Literals.TWO_OPTIONS;
}
 
Example #15
Source File: CommandImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass()
{
  return FowlerdslPackage.Literals.COMMAND;
}
 
Example #16
Source File: ChoiceStatementImpl.java    From yang-design-studio with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass()
{
  return YangPackage.eINSTANCE.getChoiceStatement();
}
 
Example #17
Source File: TypeSystem.java    From xsemantics with Eclipse Public License 1.0 4 votes vote down vote up
public Result<Boolean> type(final RuleEnvironment _environment_, final EClass c, final EObject o) {
  return type(_environment_, null, c, o);
}
 
Example #18
Source File: CurrentTimeControllerImpl.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass ()
{
    return ChartPackage.Literals.CURRENT_TIME_CONTROLLER;
}
 
Example #19
Source File: ComplexrewritetestPackageImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EClass getC3()
{
  return c3EClass;
}
 
Example #20
Source File: MatchDataExpressionImpl.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass()
{
  return ScopePackage.Literals.MATCH_DATA_EXPRESSION;
}
 
Example #21
Source File: DomainmodelPackageImpl.java    From xtext-web with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EClass getFeature()
{
  return featureEClass;
}
 
Example #22
Source File: StaticExternalEventFilterImpl.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass ()
{
    return OsgiPackage.Literals.STATIC_EXTERNAL_EVENT_FILTER;
}
 
Example #23
Source File: InfrastructurePackageImpl.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EClass getMasterImport ()
{
    return masterImportEClass;
}
 
Example #24
Source File: SimpleMultiplicitiesImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass()
{
  return CsvalidationtestPackage.Literals.SIMPLE_MULTIPLICITIES;
}
 
Example #25
Source File: PartialSerializationTestLanguagePackageImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public EClass getTwoChilds()
{
  return twoChildsEClass;
}
 
Example #26
Source File: ElementImpl.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass()
{
  return BuilderTestLanguagePackage.Literals.ELEMENT;
}
 
Example #27
Source File: NamespaceImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass()
{
  return IndexTestLanguagePackage.Literals.NAMESPACE;
}
 
Example #28
Source File: Step0049.java    From BIMserver with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void migrate(Schema schema, DatabaseSession databaseSession) {
	EClass pluginDescriptor = schema.getEClass("store", "PluginDescriptor");
	EClass objectType = schema.getEClass("store", "ObjectType");
	schema.createEReference(pluginDescriptor, "settings", objectType);
}
 
Example #29
Source File: EnumValImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass()
{
  return AssignmentFinderTestPackage.Literals.ENUM_VAL;
}
 
Example #30
Source File: GuardExpressionImpl.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected EClass eStaticClass()
{
  return BeeLangTestLanguagePackage.Literals.GUARD_EXPRESSION;
}