/**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case DslFilterPackage.ALL_FILTERS:
       return createAllFilters();
     case DslFilterPackage.FILTER_GROUP:
       return createFilterGroup();
     case DslFilterPackage.FILTER:
       return createFilter();
     case DslFilterPackage.CNUMBER_OPERATION:
       return createCNumberOperation();
     case DslFilterPackage.CSTRING_OPERATION:
       return createCStringOperation();
     case DslFilterPackage.CSTRUCTURAL_EOBJECT:
       return createCStructuralEObject();
     case DslFilterPackage.CLOGIC_OPERATION:
       return createCLogicOperation();
     case DslFilterPackage.INT_TO_EOBJECT_MAP:
       return (EObject) createIntToEObjectMap();
     case DslFilterPackage.BASIC_CSTRING_OPERATION:
       return createBasicCStringOperation();
     case DslFilterPackage.BASIC_CNUMBER_OPERATION:
       return createBasicCNumberOperation();
     case DslFilterPackage.BASIC_CLOGIC_OPERATION:
       return createBasicCLogicOperation();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
 @Override
 public @Nullable Object evaluate(
     @NonNull Executor executor, @NonNull TypeId returnTypeId, @Nullable Object sourceValue) {
   IdResolver idResolver = executor.getIdResolver();
   Property oppositeProperty = idResolver.getProperty(oppositePropertyId);
   ModelManager.ModelManagerExtension modelManager =
       (ModelManager.ModelManagerExtension) executor.getModelManager();
   Type thatType = ClassUtil.nonNullModel(oppositeProperty.getType());
   if (thatType instanceof CollectionType) {
     thatType = ((CollectionType) thatType).getElementType();
   }
   List<Object> results = new ArrayList<Object>();
   if (thatType instanceof org.eclipse.ocl.pivot.Class) {
     for (@NonNull
     Object eObject :
         modelManager.get((org.eclipse.ocl.pivot.Class) thatType)) { // FIXME Use a cache
       EClass eClass = modelManager.eClass(eObject);
       EStructuralFeature eFeature = eClass.getEStructuralFeature(oppositeProperty.getName());
       assert eFeature != null;
       Object eGet = modelManager.eGet(eObject, eFeature);
       if (eGet == sourceValue) {
         results.add(eObject);
       }
     }
   }
   return results;
 }
Beispiel #3
0
 /**
  * Converts this Object to a dynamic object with a new type that is a subtype of the current type,
  * preserving any existing property values.
  *
  * @param newEClass the new type for this Object
  * @throws IllegalArgumentException if newEClass is not a subtype of this Object's current type
  * @see org.eclipse.emf.ecore.InternalEObject#eSetClass(org.eclipse.emf.ecore.EClass)
  */
 public void narrow(EClass newEClass) throws IllegalArgumentException {
   if (!eClass().equals(EcorePackage.eINSTANCE.getEObject())
       && !eClass().isSuperTypeOf(newEClass)) {
     throw new IllegalArgumentException(
         "The class "
             + newEClass.getName()
             + " is not a subtype of the Object's current type "
             + eClass().getName());
   }
   EPropertiesHolder props = eProperties();
   if (props.getEClass() != null && props.hasSettings()) {
     int staticSize = eStaticFeatureCount();
     int oldSize = eClass().getEAllStructuralFeatures().size() - staticSize;
     if (oldSize > 0) {
       int newSize = newEClass.getEAllStructuralFeatures().size() - staticSize;
       if (newSize > oldSize) {
         List oldValues = new ArrayList(oldSize);
         for (int i = 0; i < oldSize; i++) {
           oldValues.add(props.dynamicGet(i));
         }
         props.allocateSettings(newSize);
         for (int i = 0; i < oldSize; i++) {
           props.dynamicSet(i, oldValues.get(i));
         }
       }
     }
   }
   eSetClass(newEClass);
 }
  /**
   * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children that
   * can be created under this object.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generatedNOT
   */
  @Override
  protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
    super.collectNewChildDescriptors(newChildDescriptors, object);

    // newChildDescriptors.add(createChildParameter(
    // AnnotationsmodelPackage.Literals.ANNOTATED_EENUM_LITERAL__EENUM_LITERAL_ANNOTATIONS,
    // AnnotationsmodelFactory.eINSTANCE.createEEnumLiteralAnnotation()));

    final AnnotatedEEnumLiteral aEnum = (AnnotatedEEnumLiteral) object;
    for (EClass eClass :
        AnnotationsModelRegistry.getInstance()
            .getSubEClasses(AnnotationsmodelPackage.Literals.EENUM_LITERAL_ANNOTATION)) {
      if (eClass.isAbstract()) {
        continue;
      }
      boolean isUsed = false;
      for (EEnumLiteralAnnotation annotation : aEnum.getEEnumLiteralAnnotations()) {
        if (annotation.eClass() == eClass) {
          isUsed = true;
          break;
        }
      }
      if (!isUsed && !eClass.isAbstract()) {
        newChildDescriptors.add(
            createChildParameter(
                AnnotationsmodelPackage.Literals.ANNOTATED_EENUM_LITERAL__EENUM_LITERAL_ANNOTATIONS,
                EcoreUtil.create(eClass)));
      }
    }
  }
  @Override
  public EClass eClass() {
    if (eClass == null) {
      ePackage = EcoreFactory.eINSTANCE.createEPackage();
      eClass = EcoreFactory.eINSTANCE.createEClass();
      ePackage.getEClassifiers().add(eClass);

      eClass.setName("StringWrapper"); // $NON-NLS-1$
      eClass.getESuperTypes().add(XMLTypePackage.eINSTANCE.getAnyType());
      ExtendedMetaData.INSTANCE.setName(eClass, ""); // $NON-NLS-1$
      eClass.setInstanceClass(AnyType.class);

      EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute();
      eAttribute.setName("value"); // $NON-NLS-1$
      eAttribute.setChangeable(true);
      eAttribute.setUnsettable(true);
      eAttribute.setEType(EcorePackage.eINSTANCE.getEClassifier("EString")); // $NON-NLS-1$
      eClass.getEStructuralFeatures().add(eAttribute);

      //			ExtendedMetaData.INSTANCE.setNamespace(eAttribute, ePackage.getNsURI());
      ExtendedMetaData.INSTANCE.setFeatureKind(eAttribute, ExtendedMetaData.ATTRIBUTE_FEATURE);
      ExtendedMetaData.INSTANCE.setName(eAttribute, "value"); // $NON-NLS-1$
    }
    return eClass;
  }
 @Test
 public void test_cg_derived_property() throws ParserException, IOException {
   TestOCL ocl = createOCL();
   if (!EMFPlugin.IS_ECLIPSE_RUNNING) {
     OCLinEcoreStandaloneSetup.doSetup();
     //			OCLDelegateDomain.initialize(null);
   }
   MetamodelManager metamodelManager = ocl.getMetamodelManager();
   String metamodelText =
       "import ecore : 'http://www.eclipse.org/emf/2002/Ecore#/';\n"
           + "package pkg : pkg = 'pkg' {\n"
           + "  class A {\n"
           + "    property derivedInteger : Integer { derivation: 99; }\n"
           + "    property derivedDerivedInteger : Integer { derivation: 2 * derivedInteger;}\n"
           + "  }\n"
           + "}\n";
   Resource metamodel = cs2as(ocl, metamodelText);
   Model pivotModel = (Model) metamodel.getContents().get(0);
   org.eclipse.ocl.pivot.Package pivotPackage = pivotModel.getOwnedPackages().get(0);
   org.eclipse.ocl.pivot.Class pivotType = pivotPackage.getOwnedClasses().get(0);
   EClass eClass = metamodelManager.getEcoreOfPivot(EClass.class, pivotType);
   Object testObject = eClass.getEPackage().getEFactoryInstance().create(eClass);
   String textQuery = "self.derivedDerivedInteger";
   ocl.assertQueryEquals(testObject, 198, textQuery);
   ocl.dispose();
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case EXTLibraryPackage.BOOK:
       return createBook();
     case EXTLibraryPackage.LIBRARY:
       return createLibrary();
     case EXTLibraryPackage.WRITER:
       return createWriter();
     case EXTLibraryPackage.PERIODICAL:
       return createPeriodical();
     case EXTLibraryPackage.BOOK_ON_TAPE:
       return createBookOnTape();
     case EXTLibraryPackage.VIDEO_CASSETTE:
       return createVideoCassette();
     case EXTLibraryPackage.BORROWER:
       return createBorrower();
     case EXTLibraryPackage.PERSON:
       return createPerson();
     case EXTLibraryPackage.EMPLOYEE:
       return createEmployee();
     default:
       throw new IllegalArgumentException(
           "The class '"
               + eClass.getName()
               + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
   }
 }
Beispiel #8
0
  /** @since 4.0 */
  protected void writeSystemValues(CDODataOutput out) throws IOException {
    EClass eClass = getEClass();
    CDOClassifierRef classRef = new CDOClassifierRef(eClass);

    if (TRACER.isEnabled()) {
      TRACER.format(
          "Writing revision: ID={0}, className={1}, version={2}, branchPoint={3}, revised={4}, resource={5}, container={6}, featureID={7}", //$NON-NLS-1$
          id,
          eClass.getName(),
          getVersion(),
          branchPoint,
          revised,
          resourceID,
          containerID,
          containingFeatureID);
    }

    out.writeCDOClassifierRef(classRef);
    out.writeCDOID(id);
    out.writeCDOBranchPoint(branchPoint);
    out.writeInt(getVersion());
    if (!id.isTemporary()) {
      out.writeLong(revised);
    }

    out.writeCDOID(resourceID);
    out.writeCDOID(out.getIDProvider().provideCDOID(containerID));
    out.writeInt(containingFeatureID);
  }
Beispiel #9
0
 /**
  * Collecting all properties from a EMF object, if contansReferences is TRUE, all features should
  * be contained, otherwise, only EAttrubutes will be returned.
  */
 public static List<EStructuralFeature> collectProperties(
     EClass eClass,
     boolean containsSupers,
     boolean containsReferences,
     boolean containsUnsettables) {
   if (eClass == null) {
     return Collections.emptyList();
   }
   List<EStructuralFeature> properties = new ArrayList<EStructuralFeature>();
   List<EStructuralFeature> features = null;
   if (containsReferences) {
     features = eClass.getEStructuralFeatures();
   } else {
     features = new ArrayList<EStructuralFeature>(eClass.getEAttributes());
   }
   for (EStructuralFeature sf : features) {
     try {
       if (containsUnsettables || eClass.eIsSet(sf)) {
         properties.add(sf);
       }
     } catch (Exception e) {
     }
   }
   if (containsSupers) {
     EList<EClass> eSuperTypes = eClass.getESuperTypes();
     for (EClass eSuperClass : eSuperTypes) {
       properties.addAll(
           collectProperties(
               eSuperClass, containsSupers, containsReferences, containsUnsettables));
     }
   }
   return properties;
 }
 public void testMetamodel() throws Exception {
   AbstractRule rule =
       GrammarUtil.findRuleForName(getGrammarAccess().getGrammar(), "OverridableParserRule2");
   assertNotNull("rule", rule);
   TypeRef ref = rule.getType();
   assertNotNull("ref", ref);
   final EClass clazz = (EClass) ref.getClassifier();
   assertNotNull("class", clazz);
   assertEquals("AType2", clazz.getName());
   assertEquals(2, clazz.getESuperTypes().size());
   Set<String> expectedNames =
       new HashSet<String>(Arrays.asList(new String[] {"AType", "RootRule"}));
   Iterator<String> iter =
       Iterables.transform(
               clazz.getESuperTypes(),
               new Function<EClass, String>() {
                 public String apply(EClass param) {
                   return param.getName();
                 }
               })
           .iterator();
   while (iter.hasNext()) {
     String name = iter.next();
     assertTrue("name = '" + name + "'", expectedNames.remove(name));
   }
   assertTrue(expectedNames.toString(), expectedNames.isEmpty());
 }
Beispiel #11
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case RuntimePackage.WORKFLOW_CONTEXT:
       return createWorkflowContext();
     case RuntimePackage.WORKFLOW_ENGINE:
       return createWorkflowEngine();
     case RuntimePackage.WORKFLOW_STATE_MAP:
       return (EObject) createWorkflowStateMap();
     case RuntimePackage.WORKFLOW_PARAMETER_MAP:
       return (EObject) createWorkflowParameterMap();
     case RuntimePackage.WORKFLOW_PARAMETER_VALUE_PROXY:
       return createWorkflowParameterValueProxy();
     case RuntimePackage.WORKFLOW_STATE_RESOLUTION_STRATEGY:
       return createWorkflowStateResolutionStrategy();
     case RuntimePackage.WORKFLOW_RUNNABLE:
       return (EObject) createWorkflowRunnable();
     case RuntimePackage.WORKFLOW_RUNNER:
       return createWorkflowRunner();
     case RuntimePackage.WORKFLOW_LOG:
       return createWorkflowLog();
     case RuntimePackage.WORKFLOW_LOG_ENTRY:
       return createWorkflowLogEntry();
     case RuntimePackage.WORKFLOW_LOG_MAP:
       return (EObject) createWorkflowLogMap();
     case RuntimePackage.WORKFLOW_COMPONENT_EXECUTION_INFO:
       return createWorkflowComponentExecutionInfo();
     case RuntimePackage.WORKFLOW_COMPONENT_EXECUTION_INFO_MAP:
       return (EObject) createWorkflowComponentExecutionInfoMap();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case NplPackage.DECLARATION:
       return createDeclaration();
     case NplPackage.IMAGES_COUNT:
       return createImagesCount();
     case NplPackage.FONT_SIZE:
       return createFontSize();
     case NplPackage.FORMAT:
       return createFormat();
     case NplPackage.DATE:
       return createDate();
     case NplPackage.LANGUAGE:
       return createLanguage();
     case NplPackage.PRICE:
       return createPrice();
     case NplPackage.CURRENCY:
       return createCurrency();
     case NplPackage.TOPIC:
       return createTopic();
     case NplPackage.PAIR:
       return createPair();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case RuntimePackage.EXTENDET_DATA:
       return createExtendetData();
     case RuntimePackage.ENVIORMENT:
       return createEnviorment();
     case RuntimePackage.RUNTIME_CHARACTER:
       return createRuntimeCharacter();
     case RuntimePackage.TEAM:
       return createTeam();
     case RuntimePackage.GRUNT_TEAM:
       return createGruntTeam();
     case RuntimePackage.GRUNT_RUNTIME_CHARACTER:
       return createGruntRuntimeCharacter();
     case RuntimePackage.DRONE:
       return createDrone();
     case RuntimePackage.MATRIX_DEVICE:
       return createMatrixDevice();
     case RuntimePackage.RIGGER_CONSOLE:
       return createRiggerConsole();
     case RuntimePackage.CYBERDECK:
       return createCyberdeck();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case DocumentationPackage.BOOK:
       return createBook();
     case DocumentationPackage.PARAGRAPH:
       return createParagraph();
     case DocumentationPackage.SECTION:
       return createSection();
     case DocumentationPackage.TEXTUAL_VALUE:
       return createTextualValue();
     case DocumentationPackage.ITEMIZED_LIST_VALUE:
       return createItemizedListValue();
     case DocumentationPackage.ITEMIZED_LIST_VALUE_ITEM:
       return createItemizedListValueItem();
     case DocumentationPackage.EMPHASIS_VALUE:
       return createEmphasisValue();
     case DocumentationPackage.XREF_VALUE:
       return createXRefValue();
     case DocumentationPackage.INFORMAL_TABLE_VALUE:
       return createInformalTableValue();
     case DocumentationPackage.INFORMAL_TABLE_VALUE_ROW:
       return createInformalTableValueRow();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
 private void writeEmbedded(PrintWriter out, EObject eObject) throws SerializerException {
   EClass class1 = eObject.eClass();
   out.print(upperCases.get(class1));
   out.print(OPEN_PAREN);
   EStructuralFeature structuralFeature = class1.getEStructuralFeature(WRAPPED_VALUE);
   if (structuralFeature != null) {
     Object realVal = eObject.eGet(structuralFeature);
     if (structuralFeature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
       Object stringVal =
           eObject.eGet(class1.getEStructuralFeature(structuralFeature.getName() + "AsString"));
       if (stringVal != null && model.isUseDoubleStrings()) {
         out.print(stringVal);
       } else {
         if (((Double) realVal).isInfinite() || (((Double) realVal).isNaN())) {
           LOGGER.info("Serializing infinite or NaN double as 0.0");
           out.print("0.0");
         } else {
           out.print(realVal);
         }
       }
     } else {
       writePrimitive(out, realVal);
     }
   }
   out.print(CLOSE_PAREN);
 }
Beispiel #16
0
 public static String getFullName(EClass eClass) {
   EPackage ePackage = eClass.getEPackage();
   if (ePackage == null) {
     return eClass.getName();
   }
   return getFullName(ePackage) + "." + eClass.getName();
 }
Beispiel #17
0
  public void handleRevisions(
      EClass eClass,
      CDOBranch branch,
      long timeStamp,
      boolean exactTime,
      CDORevisionHandler handler) {
    Query query = getObjectContainer().query();
    query.constrain(DB4ORevision.class);
    if (eClass != null) {
      query
          .descend(DB4ORevision.ATTRIBUTE_PACKAGE_NS_URI)
          .constrain(eClass.getEPackage().getNsURI());
      query.descend(DB4ORevision.ATTRIBUTE_CLASS_NAME).constrain(eClass.getName());
    }

    ObjectSet<?> revisions = query.execute();
    if (revisions.isEmpty()) {
      return;
    }

    for (Object revision : revisions.toArray()) {
      CDORevision cdoRevision = DB4ORevision.getCDORevision(getStore(), (DB4ORevision) revision);
      handler.handleRevision(cdoRevision);
    }
  }
  public IReason updateNeeded(IUpdateContext context) {
    // retrieve name from pictogram model
    String pictogramName = null;
    PictogramElement pictogramElement = context.getPictogramElement();
    if (pictogramElement instanceof ContainerShape) {
      ContainerShape cs = (ContainerShape) pictogramElement;
      for (Shape shape : cs.getChildren()) {
        if (shape.getGraphicsAlgorithm() instanceof Text) {
          Text text = (Text) shape.getGraphicsAlgorithm();
          pictogramName = text.getValue();
        }
      }
    }

    // retrieve name from business model
    String businessName = null;
    Object bo = getBusinessObjectForPictogramElement(pictogramElement);
    if (bo instanceof EClass) {
      EClass eClass = (EClass) bo;
      businessName = eClass.getName();
    }

    // update needed, if names are different
    boolean updateNameNeeded =
        ((pictogramName == null && businessName != null)
            || (pictogramName != null && !pictogramName.equals(businessName)));
    if (updateNameNeeded) {
      return Reason.createTrueReason("Name is out of date");
    } else {
      return Reason.createFalseReason();
    }
  }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case UiextensionmodelPackage.ACTIVITY_EXTENSION:
       return createActivityExtension();
     case UiextensionmodelPackage.CASE_EXTENSION:
       return createCaseExtension();
     case UiextensionmodelPackage.COPY_EXTENSION:
       return createCopyExtension();
     case UiextensionmodelPackage.END_NODE:
       return createEndNode();
     case UiextensionmodelPackage.LINK_EXTENSION:
       return createLinkExtension();
     case UiextensionmodelPackage.ON_ALARM_EXTENSION:
       return createOnAlarmExtension();
     case UiextensionmodelPackage.ON_EVENT_EXTENSION:
       return createOnEventExtension();
     case UiextensionmodelPackage.ON_MESSAGE_EXTENSION:
       return createOnMessageExtension();
     case UiextensionmodelPackage.PARTNER_LINK_EXTENSION:
       return createPartnerLinkExtension();
     case UiextensionmodelPackage.PROCESS_EXTENSION:
       return createProcessExtension();
     case UiextensionmodelPackage.REFERENCE_PARTNER_LINKS:
       return createReferencePartnerLinks();
     case UiextensionmodelPackage.START_NODE:
       return createStartNode();
     case UiextensionmodelPackage.VARIABLE_EXTENSION:
       return createVariableExtension();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case ComponentsPackage.COMPONENT:
       return createComponent();
     case ComponentsPackage.PORT:
       return createPort();
     case ComponentsPackage.CAPABILITY:
       return createCapability();
     case ComponentsPackage.REQUIREMENT:
       return createRequirement();
     case ComponentsPackage.PROPERTY:
       return createProperty();
     case ComponentsPackage.COMPONENT_ASSEMBLY:
       return createComponentAssembly();
     case ComponentsPackage.PROPERTY_CONNECTOR:
       return createPropertyConnector();
     case ComponentsPackage.PORT_CONNECTOR:
       return createPortConnector();
     case ComponentsPackage.EXTERNAL_REFERENCE:
       return createExternalReference();
     case ComponentsPackage.MONOLITHIC_IMPLEMENTATION:
       return createMonolithicImplementation();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
  @Override
  protected boolean isCompatibleMetaclass(Object containerElement, Object metaclass) {
    Element semanticElement = UMLUtil.resolveUMLElement(containerElement);

    if (semanticElement == null) {
      return false;
    }

    if (metaclass instanceof Stereotype) {
      Stereotype stereotype = (Stereotype) metaclass;
      boolean res = semanticElement.getAppliedStereotype(stereotype.getQualifiedName()) != null;
      if (!res) {
        EClass definition = stereotype.getDefinition();
        for (EObject e : semanticElement.getStereotypeApplications()) {
          EClass c = e.eClass();
          if (definition != null && definition.isSuperTypeOf(c)) {
            res = true;
            break;
          }
        }
      }
      return res;
    }

    // TODO : We should use super.isCompatibleMetaclass(), but the super-implementation
    // may not be compatible with our implementation of getAdaptedValue()
    if (metaclass instanceof EClassifier) {
      return ((EClassifier) metaclass).isInstance(semanticElement);
    }

    return false;
  }
Beispiel #22
0
 /**
  * Returns the invocation of an element or rule accessor, including the .getType() call. Example1:
  * getFooRule().getType() Example2: getBarRule().getFooAction().getType()
  */
 public String gaTypeAccessor(final TypeRef ele) {
   String _switchResult = null;
   EObject _eContainer = ele.eContainer();
   final EObject cnt = _eContainer;
   boolean _matched = false;
   if (!_matched) {
     if (cnt instanceof AbstractElement) {
       _matched = true;
       String _gaRuleElementAccessor = this.gaRuleElementAccessor(((AbstractElement) cnt));
       _switchResult = (_gaRuleElementAccessor + ".getType()");
     }
   }
   if (!_matched) {
     if (cnt instanceof AbstractRule) {
       _matched = true;
       String _gaRuleAccessor = this.gaRuleAccessor(((AbstractRule) cnt));
       _switchResult = (_gaRuleAccessor + ".getType()");
     }
   }
   if (!_matched) {
     EObject _eContainer_1 = ele.eContainer();
     EClass _eClass = _eContainer_1.eClass();
     String _name = _eClass.getName();
     String _plus = ("<error: unknown type " + _name);
     _switchResult = (_plus + ">");
   }
   return _switchResult;
 }
Beispiel #23
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case WikimPackage.CATEGORY:
       return createCategory();
     case WikimPackage.WIKI_CONTENT:
       return createWikiContent();
     case WikimPackage.SECTION:
       return createSection();
     case WikimPackage.WIKI_DATABASE:
       return createWikiDatabase();
     case WikimPackage.ARTICLE:
       return createArticle();
     case WikimPackage.IMAGE:
       return createImage();
     case WikimPackage.PARAGRAPH:
       return createParagraph();
     case WikimPackage.ITEM_LIST:
       return createItemList();
     case WikimPackage.ITEM:
       return createItem();
     case WikimPackage.FILE:
       return createFile();
     case WikimPackage.USER:
       return createUser();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
 @Override
 public void run() {
   InputDialog inputDialog =
       new InputDialog(
           null,
           Messages.RenameActionProvider_ProvideNameTitle,
           Messages.RenameActionProvider_ProvideNameDescription,
           eclass.getName(),
           null);
   int open = inputDialog.open();
   if (open == Dialog.OK) {
     String newName = inputDialog.getValue();
     Resource resource = eclass.eResource();
     ResourceSet resourceSet = resource.getResourceSet();
     TransactionalEditingDomain domain =
         TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
     try {
       if (domain != null) {
         Command setCommand =
             domain.createCommand(
                 SetCommand.class,
                 new CommandParameter(
                     eclass, EcorePackage.Literals.ENAMED_ELEMENT__NAME, newName));
         domain.getCommandStack().execute(setCommand);
         try {
           resource.save(Collections.emptyMap());
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
     } finally {
       domain.dispose();
     }
   }
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case CommandsPackageImpl.BINDING_CONTEXT:
       return (EObject) createBindingContext();
     case CommandsPackageImpl.BINDING_TABLE:
       return (EObject) createBindingTable();
     case CommandsPackageImpl.COMMAND:
       return (EObject) createCommand();
     case CommandsPackageImpl.COMMAND_PARAMETER:
       return (EObject) createCommandParameter();
     case CommandsPackageImpl.HANDLER:
       return (EObject) createHandler();
     case CommandsPackageImpl.KEY_BINDING:
       return (EObject) createKeyBinding();
     case CommandsPackageImpl.PARAMETER:
       return (EObject) createParameter();
     case CommandsPackageImpl.CATEGORY:
       return (EObject) createCategory();
     default:
       throw new IllegalArgumentException(
           "The class '"
               + eClass.getName()
               + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$
   }
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case DpdPackage.AUTHOR:
       return createAuthor();
     case DpdPackage.CHILD_HW_DEVICE:
       return createChildHwDevice();
     case DpdPackage.DEVICE_CLASS:
       return createDeviceClass();
     case DpdPackage.DEVICE_PKG:
       return createDevicePkg();
     case DpdPackage.DEVICE_PKG_REF:
       return createDevicePkgRef();
     case DpdPackage.DOCUMENT_ROOT:
       return createDocumentRoot();
     case DpdPackage.HW_DEVICE_REGISTRATION:
       return createHwDeviceRegistration();
     case DpdPackage.LOCAL_FILE:
       return createLocalFile();
     case DpdPackage.PROPERTY_FILE:
       return createPropertyFile();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case ConceptualPackage.CONCEPTUAL_MODEL:
       return createConceptualModel();
     case ConceptualPackage.TERM_UNIT:
       return createTermUnit();
     case ConceptualPackage.CONCEPTUAL_CONTAINER:
       return createConceptualContainer();
     case ConceptualPackage.FACT_UNIT:
       return createFactUnit();
     case ConceptualPackage.CONCEPTUAL_RELATIONSHIP:
       return createConceptualRelationship();
     case ConceptualPackage.BEHAVIOR_UNIT:
       return createBehaviorUnit();
     case ConceptualPackage.RULE_UNIT:
       return createRuleUnit();
     case ConceptualPackage.SCENARIO_UNIT:
       return createScenarioUnit();
     case ConceptualPackage.CONCEPTUAL_FLOW:
       return createConceptualFlow();
     case ConceptualPackage.CONCEPTUAL_ELEMENT:
       return createConceptualElement();
     case ConceptualPackage.CONCEPTUAL_ROLE:
       return createConceptualRole();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
Beispiel #28
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public EObject create(EClass eClass) {
   switch (eClass.getClassifierID()) {
     case XsdPackage.SEQUENCE:
       return createSequence();
     case XsdPackage.CHOICE:
       return createChoice();
     case XsdPackage.COMPLEX_TYPE:
       return createComplexType();
     case XsdPackage.ELEMENT_DEFINITION:
       return createElementDefinition();
     case XsdPackage.ATTRIBUTE:
       return createAttribute();
     case XsdPackage.ANY:
       return createAny();
     case XsdPackage.GROUP:
       return createGroup();
     case XsdPackage.ANNOTATION:
       return createAnnotation();
     case XsdPackage.NOTATION:
       return createNotation();
     case XsdPackage.SIMPLE_TYPE:
       return createSimpleType();
     case XsdPackage.ELEMENT_REFERENCE:
       return createElementReference();
     case XsdPackage.SIMPLE_CONTENT:
       return createSimpleContent();
     case XsdPackage.COMPLEX_CONTENT:
       return createComplexContent();
     default:
       throw new IllegalArgumentException(
           "The class '" + eClass.getName() + "' is not a valid classifier");
   }
 }
Beispiel #29
0
 //
 // Create the ResultValidatableNode,ResultConstrainingNode cross-linkage for all
 // validateableObject,constraint pairs.
 //
 protected void createResults(@NonNull Set<Resource> resources) {
   for (Resource resource : resources) {
     System.out.println("createResults " + resource.getURI());
     System.out.println(resource);
     for (TreeIterator<EObject> tit = resource.getAllContents(); tit.hasNext(); ) {
       @SuppressWarnings("null")
       @NonNull
       EObject eObject = tit.next();
       EClass eClass = eObject.eClass();
       EAnnotation eAnnotation = eClass.getEAnnotation("http://www.eclipse.org/uml2/2.0.0/UML");
       if ((eAnnotation != null)
           && (eAnnotation.getReferences().size() > 0)) { // Stereotype application
         EObject umlClass = eAnnotation.getReferences().get(0);
         if (umlClass != null) {
           createResultNodes(eObject, getURI(umlClass));
           //						eClass = null;
         }
       } else if (eClass != null) {
         for (@SuppressWarnings("null") @NonNull URI aType : getTypeClosure(eClass)) {
           //				System.out.println("  ... " + getLabel(eObject) + " " + getLabel(aType));
           createResultNodes(eObject, aType);
         }
       }
     }
   }
 }
Beispiel #30
0
 private IScope scope_MetaClass_Type(EObject context, EReference reference) {
   Diagram diagram = EcoreUtil2.getContainerOfType(context, Diagram.class);
   // all eClasses that are direct containments of context's diagram model type
   final EClass diagramModelType = diagram.getModelType();
   if (diagramModelType == null || diagramModelType.getEPackage() == null) {
     return IScope.NULLSCOPE;
   }
   final Predicate<EClassifier> filter =
       new Predicate<EClassifier>() {
         @Override
         public boolean apply(EClassifier input) {
           return input instanceof EClass
               && input != diagramModelType
               && !((EClass) input).isAbstract();
         }
       };
   final Function<EClassifier, IEObjectDescription> toObjDesc =
       new Function<EClassifier, IEObjectDescription>() {
         @Override
         public IEObjectDescription apply(EClassifier input) {
           return EObjectDescription.create(qnProvider.apply(input), input);
         }
       };
   // Implicit import of the EPackage of the Diagram Model type
   final List<ImportNormalizer> normalizer =
       Collections.singletonList(
           new ImportNormalizer(qnProvider.apply(diagramModelType.getEPackage()), true, false));
   final ImportScope importDiagramTypePackage =
       new ImportScope(normalizer, delegateGetScope(context, reference), null, null, false);
   final Iterable<IEObjectDescription> descriptions =
       Iterables.transform(
           Iterables.filter(diagramModelType.getEPackage().getEClassifiers(), filter), toObjDesc);
   // the delegate scope will provide import scopes
   return MapBasedScope.createScope(importDiagramTypePackage, descriptions);
 }