コード例 #1
0
 private EClassifier resolveFeatureType(
     EStructuralFeature feature,
     Collection<EClassifierMapping> eClassifierMappings,
     Collection<EPackage> ePackages) {
   EAnnotation eAnnotation = feature.getEAnnotation(TypesPackage.eNS_URI);
   if (eAnnotation != null) {
     JvmTypeReference type = getEObject(eAnnotation.getReferences(), JvmTypeReference.class, null);
     if (type == null) {
       return null;
     }
     EClassifier eClassifier = null;
     for (EClassifierMapping eClassifierMapping : eClassifierMappings) {
       if (eClassifierMapping.getDeclaredType() == type) {
         eClassifier = eClassifierMapping.getEClassifier();
         break;
       }
     }
     String typeName = getTypeName(type);
     if (eClassifier == null) {
       for (EPackage ePackage : ePackages) {
         eClassifier = findEClassifier(typeName, ePackage);
         if (eClassifier != null) {
           break;
         }
       }
     }
     if (eClassifier == null) {
       eClassifier = findEClassifier(typeName, EcorePackage.eINSTANCE);
     }
     feature.setEType(eClassifier);
     return eClassifier;
   }
   return null;
 }
コード例 #2
0
ファイル: ValidityModel.java プロジェクト: ewillink/ocl
 //
 // 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);
         }
       }
     }
   }
 }
コード例 #3
0
  /** @generated NOT */
  protected void decorateView(
      View containerView,
      View view,
      IAdaptable semanticAdapter,
      String semanticHint,
      int index,
      boolean persisted) {
    if (semanticHint == null) {
      semanticHint = OepcVisualIDRegistry.getType(XORConnectorEditPart.VISUAL_ID);
      view.setType(semanticHint);
    }
    super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
    if (!OEPCEditPart.MODEL_ID.equals(OepcVisualIDRegistry.getModelID(containerView))) {
      EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
      shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
      shortcutAnnotation.getDetails().put("modelID", OEPCEditPart.MODEL_ID); // $NON-NLS-1$
      view.getEAnnotations().add(shortcutAnnotation);
    }

    // setting up default color background to view style
    NotationPackage NOTATION = NotationPackage.eINSTANCE;
    EClass shapeStyle = NOTATION.getShapeStyle();
    ShapeStyle style = (ShapeStyle) view.getStyle(shapeStyle);
    if (style == null) {
      style = (ShapeStyle) view.createStyle(shapeStyle);
    }
    BflowDiagramEditPart.apply(XORConnectorEditPart.class, style);
  }
コード例 #4
0
ファイル: Ecore2AS.java プロジェクト: eclipse/ocl
 protected void installImports() {
   URI baseURI = getBaseURI(ecoreResource);
   List<Import> allImports = pivotModel.getOwnedImports();
   for (EObject eContent : ecoreResource.getContents()) {
     if (eContent instanceof EModelElement) {
       EAnnotation importAnnotation =
           ((EModelElement) eContent).getEAnnotation(PivotConstants.IMPORT_ANNOTATION_SOURCE);
       if (importAnnotation != null) {
         EMap<String, String> details = importAnnotation.getDetails();
         for (String key : details.keySet()) {
           URI uri = URI.createURI(details.get(key));
           if (baseURI != null) {
             uri = uri.resolve(baseURI);
           }
           try {
             assert uri != null;
             Element importedObject =
                 metamodelManager.loadResource(uri, null, ecoreResource.getResourceSet());
             if (importedObject instanceof Namespace) {
               Import anImport = PivotFactory.eINSTANCE.createImport();
               anImport.setName(key);
               anImport.setImportedNamespace((Namespace) importedObject);
               allImports.add(anImport);
             }
           } catch (ParserException e) {
             error(e.getMessage());
           }
         }
       }
     }
   }
 }
コード例 #5
0
 /** @generated */
 protected void decorateView(
     View containerView,
     View view,
     IAdaptable semanticAdapter,
     String semanticHint,
     int index,
     boolean persisted) {
   if (semanticHint == null) {
     semanticHint =
         BusinessVisualIDRegistry.getType(
             org.talend.designer.business.model.business.diagram.edit.parts
                 .DataBusinessItemEditPart.VISUAL_ID);
     view.setType(semanticHint);
   }
   super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
   if (!BusinessProcessEditPart.MODEL_ID.equals(
       BusinessVisualIDRegistry.getModelID(containerView))) {
     EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
     shortcutAnnotation
         .getDetails()
         .put("modelID", BusinessProcessEditPart.MODEL_ID); // $NON-NLS-1$
     view.getEAnnotations().add(shortcutAnnotation);
   }
   getViewService()
       .createNode(
           semanticAdapter,
           view,
           BusinessVisualIDRegistry.getType(DataBusinessItemNameEditPart.VISUAL_ID),
           ViewUtil.APPEND,
           true,
           getPreferencesHint());
 }
コード例 #6
0
 /** @generated */
 private void stampShortcut(View containerView, Node target) {
   if (!SchemaEditPart.MODEL_ID.equals(SqlmodelVisualIDRegistry.getModelID(containerView))) {
     EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
     shortcutAnnotation.getDetails().put("modelID", SchemaEditPart.MODEL_ID); // $NON-NLS-1$
     target.getEAnnotations().add(shortcutAnnotation);
   }
 }
コード例 #7
0
 /**
  * Find all hints in the given package.
  *
  * @param ePackage The package to search.
  * @return List of all extension hints found in all the factories in the map.
  */
 public static List<IXArchADTSubstitutionHint> parseExtensionHints(EPackage ePackage) {
   EAnnotation eAnnotation = ePackage.getEAnnotation(EXTENSION_HINT_URI);
   if (eAnnotation != null) {
     String extensionHintsText = eAnnotation.getDetails().get("appinfo");
     return parseExtensionHints(extensionHintsText);
   }
   return Collections.emptyList();
 }
コード例 #8
0
  /**
   * Adds any arguments from annotations.
   *
   * @param <ArgumentType> the argument type
   * @param context the argument context
   */
  protected <ArgumentType> void addEAnnotationArguments(IArgumentContext<ArgumentType> context) {
    final EAnnotation annotation = getEAnnotation();
    if (annotation == null) return;
    final String value = annotation.getDetails().get(context.getName());
    if (value == null) return;

    IManager.Factory.getManager().addArgumentValue(context, this, null, null, value);
  }
コード例 #9
0
ファイル: Ecore2AS.java プロジェクト: eclipse/ocl
 public static boolean isNullFree(@NonNull ETypedElement eObject) {
   boolean isNullFree = false;
   EAnnotation eAnnotation = eObject.getEAnnotation(PivotConstants.COLLECTION_ANNOTATION_SOURCE);
   if (eAnnotation != null) {
     isNullFree =
         Boolean.valueOf(eAnnotation.getDetails().get(PivotConstants.COLLECTION_IS_NULL_FREE));
   }
   return isNullFree;
 }
コード例 #10
0
 /** @generated */
 protected void decorateView(
     View containerView,
     View view,
     IAdaptable semanticAdapter,
     String semanticHint,
     int index,
     boolean persisted) {
   if (semanticHint == null) {
     semanticHint =
         OntoUML.diagram.part.OntoUMLVisualIDRegistry.getType(
             OntoUML.diagram.edit.parts.RoleEditPart.VISUAL_ID);
     view.setType(semanticHint);
   }
   super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
   if (!OntoUML.diagram.edit.parts.ContainerEditPart.MODEL_ID.equals(
       OntoUML.diagram.part.OntoUMLVisualIDRegistry.getModelID(containerView))) {
     EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
     shortcutAnnotation
         .getDetails()
         .put("modelID", OntoUML.diagram.edit.parts.ContainerEditPart.MODEL_ID); // $NON-NLS-1$
     view.getEAnnotations().add(shortcutAnnotation);
   }
   IAdaptable eObjectAdapter = null;
   EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
   if (eObject != null) {
     eObjectAdapter = new EObjectAdapter(eObject);
   }
   getViewService()
       .createNode(
           eObjectAdapter,
           view,
           OntoUML.diagram.part.OntoUMLVisualIDRegistry.getType(
               OntoUML.diagram.edit.parts.WrappingLabel9EditPart.VISUAL_ID),
           ViewUtil.APPEND,
           true,
           getPreferencesHint());
   getViewService()
       .createNode(
           eObjectAdapter,
           view,
           OntoUML.diagram.part.OntoUMLVisualIDRegistry.getType(
               OntoUML.diagram.edit.parts.RoleNameEditPart.VISUAL_ID),
           ViewUtil.APPEND,
           true,
           getPreferencesHint());
   getViewService()
       .createNode(
           eObjectAdapter,
           view,
           OntoUML.diagram.part.OntoUMLVisualIDRegistry.getType(
               OntoUML.diagram.edit.parts.RoleAttributeCompartmentEditPart.VISUAL_ID),
           ViewUtil.APPEND,
           true,
           getPreferencesHint());
 }
コード例 #11
0
 private void setOrRemoveTransient(EClass eClass) {
   if (eClass.getEAnnotation("teneo.jpa") != null) {
     eClass.getEAnnotations().remove(eClass.getEAnnotation("teneo.jpa"));
   } else {
     final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     eAnnotation.setSource("teneo.jpa");
     eAnnotation.getDetails().put("value", "@Transient");
     eClass.getEAnnotations().add(eAnnotation);
   }
 }
コード例 #12
0
 /** @generated */
 public static String getModelID(View view) {
   View diagram = view.getDiagram();
   while (view != diagram) {
     EAnnotation annotation = view.getEAnnotation("Shortcut"); // $NON-NLS-1$
     if (annotation != null) {
       return (String) annotation.getDetails().get("modelID"); // $NON-NLS-1$
     }
     view = (View) view.eContainer();
   }
   return diagram != null ? diagram.getType() : null;
 }
コード例 #13
0
  protected String getPivotModelAnnotation(GenClass genClass) {

    // find out the pivot model type this class should be mapped to
    for (EAnnotation annotation : genClass.getEcoreClass().getEAnnotations()) {
      if (annotation
          .getSource()
          .equalsIgnoreCase("http://www.tu-dresden.de/ocl20/pivot/2007/pivotmodel")) {
        return PivotAdapterGeneratorUtil.getAnnotationDetails(annotation);
      }
    }
    return null;
  }
 public String getArrowDirection() {
   View view = this.getNotationView();
   if (view == null) return "";
   EAnnotation ea = view.getEAnnotation(ARROW);
   if (ea != null) {
     String pos = ea.getDetails().get(DIRECTION);
     if (pos != null) {
       return pos;
     }
   }
   return VERTICAL;
 }
コード例 #15
0
 private boolean removeAnnotation(EOperation existingOperation) {
   List<EAnnotation> annotations = existingOperation.getEAnnotations();
   EAnnotation annotationToRemove = null;
   for (EAnnotation annotation : annotations) {
     if (annotation.getSource().equals(EcoreModelRefactorer.class.getName())) {
       annotationToRemove = annotation;
     }
   }
   if (annotationToRemove != null) {
     return annotations.remove(annotationToRemove);
   }
   return false;
 }
コード例 #16
0
  @Override
  public String eURIFragmentSegment(EStructuralFeature eStructuralFeature, EObject eObject) {
    if (eObject instanceof ENamedElement) {
      ENamedElement eNamedElement = (ENamedElement) eObject;
      String name = eNamedElement.getName();
      if (name != null) {
        int count = 0;
        for (Object otherEObject : eContents()) {
          if (otherEObject == eObject) {
            break;
          }
          if (otherEObject instanceof ENamedElement) {
            ENamedElement otherENamedElement = (ENamedElement) otherEObject;
            if (name.equals(otherENamedElement.getName())) {
              ++count;
            }
          }
        }
        name = eEncodeValue(name);
        return count > 0 ? name + "." + count : name;
      }
    } else if (eObject instanceof EAnnotation) {
      EAnnotation eAnnotation = (EAnnotation) eObject;
      String source = eAnnotation.getSource();
      if (source != null) {
        int count = 0;
        for (Object otherEObject : eContents()) {
          if (otherEObject == eObject) {
            break;
          }
          if (otherEObject instanceof EAnnotation) {
            EAnnotation otherEAnnotation = (EAnnotation) otherEObject;
            if (source.equals(otherEAnnotation.getSource())) {
              ++count;
            }
          }
        }

        StringBuffer result = new StringBuffer(source.length() + 5);
        result.append('%');
        result.append(URI.encodeSegment(source, false));
        result.append('%');
        if (count > 0) {
          result.append('.');
          result.append(count);
        }
        return result.toString();
      }
    }
    return super.eURIFragmentSegment(eStructuralFeature, eObject);
  }
  public void setArrowDirection(String dir) {
    View view = this.getNotationView();
    if (view == null) return;

    EAnnotation ea = view.getEAnnotation(ARROW);
    if (ea == null) {
      ea = EcoreFactory.eINSTANCE.createEAnnotation();
      ea.setSource(ARROW);
      ea.getDetails().put(DIRECTION, dir);
      view.getEAnnotations().add(ea);
    } else {
      ea.getDetails().clear();
      ea.getDetails().put(DIRECTION, dir);
    }
  }
コード例 #18
0
 /** @generated */
 protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
     throws ExecutionException {
   for (Iterator it = myDescriptors.iterator(); it.hasNext(); ) {
     CreateViewRequest.ViewDescriptor nextDescriptor =
         (CreateViewRequest.ViewDescriptor) it.next();
     View view = (View) nextDescriptor.getAdapter(View.class);
     if (view != null && view.getEAnnotation("Shortcut") == null) { // $NON-NLS-1$
       EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
       shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
       shortcutAnnotation.getDetails().put("modelID", IStarEditPart.MODEL_ID); // $NON-NLS-1$
       view.getEAnnotations().add(shortcutAnnotation);
     }
   }
   return CommandResult.newOKCommandResult();
 }
コード例 #19
0
 /** @generated */
 private void stampShortcut(View containerView, Node target) {
   if (!edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.ClassDiagramEditPart
       .MODEL_ID.equals(
       edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
           .NECSIS14_ClassDiagramVisualIDRegistry.getModelID(containerView))) {
     EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
     shortcutAnnotation
         .getDetails()
         .put(
             "modelID",
             edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
                 .ClassDiagramEditPart.MODEL_ID); //$NON-NLS-1$
     target.getEAnnotations().add(shortcutAnnotation);
   }
 }
コード例 #20
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public Relator relator() {
    if (relatorBodyOCL == null) {
      EOperation eOperation = RefOntoUMLPackage.eINSTANCE.getRoleMixin().getEOperations().get(1);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getRoleMixin(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        relatorBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(relatorBodyOCL);

    return (Relator) query.evaluate(this);
  }
コード例 #21
0
 /** @generated */
 protected void decorateView(
     View containerView,
     View view,
     IAdaptable semanticAdapter,
     String semanticHint,
     int index,
     boolean persisted) {
   if (semanticHint == null) {
     semanticHint = MolicVisualIDRegistry.getType(UbiquitousAccessEditPart.VISUAL_ID);
     view.setType(semanticHint);
   }
   super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
   if (!DiagramEditPart.MODEL_ID.equals(MolicVisualIDRegistry.getModelID(containerView))) {
     EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
     shortcutAnnotation.getDetails().put("modelID", DiagramEditPart.MODEL_ID); // $NON-NLS-1$
     view.getEAnnotations().add(shortcutAnnotation);
   }
 }
コード例 #22
0
ファイル: Ecore2AS.java プロジェクト: eclipse/ocl
 protected void loadImports(@NonNull EPackage ePackage, @Nullable URI baseURI) {
   if (ClassUtil.basicGetMetamodelAnnotation(ePackage) != null) {
     if (asMetamodels == null) {
       asMetamodels = new HashSet<EPackage>();
     }
     asMetamodels.add(ePackage);
   }
   EAnnotation importAnnotation = ePackage.getEAnnotation(PivotConstants.IMPORT_ANNOTATION_SOURCE);
   if (importAnnotation != null) {
     EMap<String, String> details = importAnnotation.getDetails();
     for (String key : details.keySet()) {
       URI uri = URI.createURI(details.get(key));
       uri = resolveImportURI(uri, ePackage, baseURI);
       assert uri != null;
       ResourceSet resourceSet = environmentFactory.getResourceSet();
       EObject importedEObject = null;
       String fragment = uri.fragment();
       if (fragment == null) {
         importedEObject = resourceSet.getPackageRegistry().getEPackage(uri.toString());
       } else {
         importedEObject = resourceSet.getEObject(uri, true);
       }
       if (importedEObject != null) {
         if (importedEObjects == null) {
           importedEObjects = new HashSet<EObject>();
         }
         if (importedEObjects.add(importedEObject) && (importedEObject instanceof EPackage)) {
           Resource importedResource = importedEObject.eResource();
           if (importedResource != null) {
             URI baseURI2 = getBaseURI(importedResource);
             loadImports((EPackage) importedEObject, baseURI2);
           }
         }
       }
     }
   }
   for (EPackage eSubPackage : ePackage.getESubpackages()) {
     if (eSubPackage != null) {
       loadImports(eSubPackage, baseURI);
     }
   }
 }
コード例 #23
0
 public static String getDocumentationText(Element umlElement) {
   if (!umlElement.getOwnedComments().isEmpty()) {
     return umlElement.getOwnedComments().get(0).getBody();
   }
   EAnnotation topcasedDocAnnotation =
       umlElement.getEAnnotation("http://www.topcased.org/documentation");
   if (topcasedDocAnnotation != null) {
     return topcasedDocAnnotation.getDetails().get("documentation");
   }
   for (EObject obj :
       EcoreUtil2.findAllByType(umlElement.getModel().eAllContents(), Comment.class)) {
     Comment c = (Comment) obj;
     for (EObject annotatedObject : c.getAnnotatedElements()) {
       if (annotatedObject == umlElement) {
         return c.getBody();
       }
     }
   }
   return null;
 }
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public boolean isCircular() {
    if (isCircularBodyOCL == null) {
      EOperation eOperation =
          RefOntoUMLPackage.eINSTANCE.getMeasurementDimension().getEOperations().get(2);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getMeasurementDimension(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        isCircularBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(isCircularBodyOCL);

    return ((Boolean) query.evaluate(this)).booleanValue();
  }
コード例 #25
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public EList<RigidSortalClass> rigidSortals() {
    if (rigidSortalsBodyOCL == null) {
      EOperation eOperation = RefOntoUMLPackage.eINSTANCE.getRoleMixin().getEOperations().get(3);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getRoleMixin(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        rigidSortalsBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(rigidSortalsBodyOCL);

    @SuppressWarnings("unchecked")
    Collection<RigidSortalClass> result = (Collection<RigidSortalClass>) query.evaluate(this);
    return new BasicEList.UnmodifiableEList<RigidSortalClass>(result.size(), result.toArray());
  }
 /** @generated */
 protected void decorateView(
     View containerView,
     View view,
     IAdaptable semanticAdapter,
     String semanticHint,
     int index,
     boolean persisted) {
   if (semanticHint == null) {
     semanticHint =
         GMFMapVisualIDRegistry.getType(
             org.eclipse.gmf.map.editor.edit.parts.ChildReferenceOwnedChildEditPart.VISUAL_ID);
     view.setType(semanticHint);
   }
   super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
   if (!MappingEditPart.MODEL_ID.equals(GMFMapVisualIDRegistry.getModelID(containerView))) {
     EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
     shortcutAnnotation.getDetails().put("modelID", MappingEditPart.MODEL_ID); // $NON-NLS-1$
     view.getEAnnotations().add(shortcutAnnotation);
   }
 }
コード例 #27
0
 @Override
 public HyperLinkEditor getHyperLinkObjectForEAnnotation(EAnnotation eAnnotation) {
   if (eAnnotation.getSource().equals(HyperLinkDiagramConstants.HYPERLINK_DIAGRAM)) {
     HyperLinkDiagram hyperLinkDiagram = new HyperLinkDiagram();
     EList<EObject> list = eAnnotation.getReferences();
     if (list.size() > 0) {
       if (eAnnotation.getReferences().get(0).eResource() != null) {
         hyperLinkDiagram.setDiagram((Diagram) eAnnotation.getReferences().get(0));
         hyperLinkDiagram.setTooltipText(
             eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_TOOLTYPE_TEXT));
         if (eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_IS_DEFAULT_NAVIGATION)
             != null) {
           String stringboolean =
               eAnnotation.getDetails().get(HyperLinkConstants.HYPERLINK_IS_DEFAULT_NAVIGATION);
           boolean isDefaultNaviagation = Boolean.parseBoolean(stringboolean);
           hyperLinkDiagram.setIsDefault(isDefaultNaviagation);
         } else {
           hyperLinkDiagram.setIsDefault(false);
         }
         return hyperLinkDiagram;
       }
     }
   }
   return null;
 }
コード例 #28
0
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated NOT
   */
  public EAnnotation getEAnnotation(String source) {
    if (eAnnotations != null) {
      if (eAnnotations instanceof BasicEList) {
        int size = eAnnotations.size();
        if (size > 0) {
          EAnnotation[] eAnnotationArray = (EAnnotation[]) ((BasicEList<?>) eAnnotations).data();
          if (source == null) {
            for (int i = 0; i < size; ++i) {
              EAnnotation eAnnotation = eAnnotationArray[i];
              if (eAnnotation.getSource() == null) {
                return eAnnotation;
              }
            }
          } else {
            for (int i = 0; i < size; ++i) {
              EAnnotation eAnnotation = eAnnotationArray[i];
              if (source.equals(eAnnotation.getSource())) {
                return eAnnotation;
              }
            }
          }
        }
      } else {
        if (source == null) {
          for (EAnnotation eAnnotation : eAnnotations) {
            if (eAnnotation.getSource() == null) {
              return eAnnotation;
            }
          }
        } else {
          for (EAnnotation eAnnotation : eAnnotations) {
            if (source.equals(eAnnotation.getSource())) {
              return eAnnotation;
            }
          }
        }
      }
    }

    return null;
  }
コード例 #29
0
 public String getLatexDocAnnotation(EModelElement eModelElement, String key) {
   EAnnotation annotation =
       eModelElement.getEAnnotation(prefs.getPreferenceString(PreferenceConstants.P_NAMESPACE));
   return (annotation != null) ? annotation.getDetails().get(key) : null;
 }
コード例 #30
0
  public Object execute(ExecutionEvent event) throws ExecutionException {
    String tag = null;
    boolean copyLibraries = false;
    try {
      copyLibraries =
          (event.getParameter("emf-rest.copyLibraries") == null
              ? false
              : Boolean.valueOf(event.getParameter("emf-rest.copyLibraries")));
      tag = event.getParameter("emf-rest.tagParameter");
    } catch (Exception e) {
      e.printStackTrace();
    }
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    IStructuredSelection selection =
        (IStructuredSelection) window.getSelectionService().getSelection();
    IResource ecoreResource = (IResource) selection.getFirstElement();

    if (tag != null && tag.equals("None")) {
      GenerationListener genlistener =
          new GenerationListener(ecoreResource.getProject(), Platform.getBundle("emf-rest"), true);
      genlistener.afterFinishExecution(null, null, null);
      return null;
    }

    HashMap<String, Object> variables = new HashMap<String, Object>();
    variables.put("ecore_file", ecoreResource.getLocation().toOSString());
    variables.put(
        "genModel_file",
        ecoreResource.getLocation().toOSString().replaceFirst(".ecore", ".genmodel"));
    variables.put(
        "output", ecoreResource.getProject().findMember("src").getLocation().toOSString());
    try {
      variables.put(
          "modelDirectory",
          ecoreResource.getProject().findMember("WebContent/models").getLocation().toOSString());
    } catch (Exception ex) {
      variables.put("modelDirectory", "");
    }
    File scriptDir =
        new File(ecoreResource.getProject().getLocation().toOSString() + "/WebContent/scripts");
    if (tag == null || tag.equals("javascript")) {
      scriptDir.mkdirs();
    }
    variables.put(
        "output_js", ecoreResource.getProject().getLocation().toOSString() + "/WebContent/scripts");
    HashMap<String, GenPackage> usedGenPackages = new HashMap<String, GenPackage>();

    try {
      ResourceSet eCoreResourceSet = new ResourceSetImpl();
      Resource eCoreResource =
          eCoreResourceSet.createResource(
              URI.createFileURI(ecoreResource.getLocation().toOSString()));
      eCoreResource.load(null);
      EPackage ePackage = (EPackage) eCoreResource.getContents().get(0);
      for (EAnnotation eAnnotation : ePackage.getEAnnotations()) {
        if (eAnnotation.getSource().equalsIgnoreCase("emf.gen.usedGenPackage")) {
          ResourceSet genModelResourceSet = new ResourceSetImpl();
          Resource genModelResource =
              genModelResourceSet.createResource(
                  URI.createURI(eAnnotation.getDetails().get("genModel"), false));
          genModelResource.load(null);
          GenModel genModel = (GenModel) genModelResource.getContents().get(0);
          for (GenPackage genPackage : genModel.getGenPackages()) {
            String usedGenPackageName = eAnnotation.getDetails().get("name");
            if (genPackage.getEcorePackage().getName().equals(usedGenPackageName)) {
              usedGenPackages.put(usedGenPackageName, genPackage);
            }
          }
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    variables.put("usedGenPackages", usedGenPackages);
    variables.put("pluginName", ecoreResource.getProject().getName());
    variables.put("foreignModel", ecoreResource.getName());

    File webContentModelsPath =
        new File(
            ecoreResource.getProject().findMember("WebContent/models").getLocation().toOSString());
    String modelName = "";
    for (File file : webContentModelsPath.listFiles()) {
      if (file.getName().endsWith(".xmi")) {
        modelName = file.getName().substring(0, file.getName().lastIndexOf("."));
      }
    }
    variables.put("modelName", modelName);

    MTCChoreographer choreographer =
        MTCStandaloneUtils.startMTC(
            ecoreResource.getProject(),
            "emf-rest",
            "default.mtc",
            variables,
            (tag == null ? null : Collections.singletonList(tag)));
    ArrayList<IResource> resourceToRefresh = new ArrayList<IResource>();
    resourceToRefresh.add(ecoreResource.getProject());
    choreographer.addExecutionListener(
        new GenerationListener(
            ecoreResource.getProject(), Platform.getBundle("emf-rest"), copyLibraries));
    choreographer.start();
    choreographer.modelReady("Ecore Fully Annotated", null);
    return null;
  }