コード例 #1
0
  /**
   * Get mappings available for a semantic element and a given container view.
   *
   * @param semanticElement Semantic element
   * @param containerView Container view
   * @param session Session
   * @return List of mappings which could not be null
   */
  protected List<DiagramElementMapping> getMappings(
      final EObject semanticElement, final DSemanticDecorator containerView, Session session) {
    final ModelAccessor modelAccessor = session.getModelAccessor();
    final List<DiagramElementMapping> mappings = new ArrayList<DiagramElementMapping>();

    if (containerView instanceof DSemanticDiagram) {
      mappings.addAll(
          AddElementToDiagramServices.INSTANCE.getValidMappingsForDiagram(
              semanticElement, (DSemanticDiagram) containerView, session));
    } else if (containerView instanceof DNodeContainerSpec) {
      for (final DiagramElementMapping mapping :
          ((DNodeContainerSpec) containerView).getActualMapping().getAllContainerMappings()) {
        final String domainClass = ((AbstractNodeMapping) mapping).getDomainClass();
        if (modelAccessor.eInstanceOf(semanticElement, domainClass)
            && !mapping.isCreateElements()) {
          mappings.add(mapping);
        }
      }
      for (final DiagramElementMapping mapping :
          ((DNodeContainerSpec) containerView).getActualMapping().getAllNodeMappings()) {
        final String domainClass = ((AbstractNodeMapping) mapping).getDomainClass();
        if (modelAccessor.eInstanceOf(semanticElement, domainClass)
            && !mapping.isCreateElements()) {
          mappings.add(mapping);
        }
      }
    }
    return mappings;
  }
 private IPermissionAuthority getPermissionAuthority() {
   if (permissionAuthority == null && object instanceof EObject) {
     Session session = new EObjectQuery((EObject) object).getSession();
     if (session != null) {
       ModelAccessor modelAccessor = session.getModelAccessor();
       if (modelAccessor != null) {
         permissionAuthority = modelAccessor.getPermissionAuthority();
       }
     }
   }
   return permissionAuthority;
 }
コード例 #3
0
 private IPermissionAuthority getPermissionAuthority() {
   final ModelAccessor accessor =
       SiriusPlugin.getDefault().getModelAccessorRegistry().getModelAccessor(diagram);
   return accessor.getPermissionAuthority();
 }