/**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (ViewsViewsRepository.ViewsRepository.Properties.repositoryKind
           == event.getAffectedEditor()) {
         BasicDiagnostic chain = new BasicDiagnostic();
         for (Iterator iterator = ((List) event.getNewValue()).iterator(); iterator.hasNext(); ) {
           chain.add(
               Diagnostician.INSTANCE.validate(
                   ViewsPackage.eINSTANCE.getViewsRepository_RepositoryKind().getEAttributeType(),
                   iterator.next()));
         }
         ret = chain;
       }
       if (ViewsViewsRepository.ViewsRepository.Properties.name == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   ViewsPackage.eINSTANCE.getViewsRepository_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 ViewsPackage.eINSTANCE.getViewsRepository_Name().getEAttributeType(), newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public Object createKeyTypeOpenEnumFromString(EDataType eDataType, String initialValue) {
    if (initialValue == null) return null;
    Object result = null;
    RuntimeException exception = null;
    try {
      result = createKeyTypeEnumFromString(_200512Package.Literals.KEY_TYPE_ENUM, initialValue);
      if (result != null && Diagnostician.INSTANCE.validate(eDataType, result, null, null)) {
        return result;
      }
    } catch (RuntimeException e) {
      exception = e;
    }
    try {
      result =
          XMLTypeFactory.eINSTANCE.createFromString(XMLTypePackage.Literals.ANY_URI, initialValue);
      if (result != null && Diagnostician.INSTANCE.validate(eDataType, result, null, null)) {
        return result;
      }
    } catch (RuntimeException e) {
      exception = e;
    }
    if (result != null || exception == null) return result;

    throw exception;
  }
	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
	 * 
	 */
	public Diagnostic validateValue(IPropertiesEditionEvent event) {
		Diagnostic ret = Diagnostic.OK_INSTANCE;
		if (event.getNewValue() != null) {
			try {
				if (ScoViewsRepository.ArtifactIdentifier.Properties.resourceName == event.getAffectedEditor()) {
					Object newValue = event.getNewValue();
					if (newValue instanceof String) {
						newValue = EEFConverterUtil.createFromString(ScoPackage.eINSTANCE.getArtifactIdentifier_ResourceName().getEAttributeType(), (String)newValue);
					}
					ret = Diagnostician.INSTANCE.validate(ScoPackage.eINSTANCE.getArtifactIdentifier_ResourceName().getEAttributeType(), newValue);
				}
				if (ScoViewsRepository.ArtifactIdentifier.Properties.baselinedLineCount == event.getAffectedEditor()) {
					Object newValue = event.getNewValue();
					if (newValue instanceof String) {
						newValue = EEFConverterUtil.createFromString(ScoPackage.eINSTANCE.getArtifactIdentifier_BaselinedLineCount().getEAttributeType(), (String)newValue);
					}
					ret = Diagnostician.INSTANCE.validate(ScoPackage.eINSTANCE.getArtifactIdentifier_BaselinedLineCount().getEAttributeType(), newValue);
				}
				if (ScoViewsRepository.ArtifactIdentifier.Properties.currentLineCount == event.getAffectedEditor()) {
					Object newValue = event.getNewValue();
					if (newValue instanceof String) {
						newValue = EEFConverterUtil.createFromString(ScoPackage.eINSTANCE.getArtifactIdentifier_CurrentLineCount().getEAttributeType(), (String)newValue);
					}
					ret = Diagnostician.INSTANCE.validate(ScoPackage.eINSTANCE.getArtifactIdentifier_CurrentLineCount().getEAttributeType(), newValue);
				}
			} catch (IllegalArgumentException iae) {
				ret = BasicDiagnostic.toDiagnostic(iae);
			} catch (WrappedException we) {
				ret = BasicDiagnostic.toDiagnostic(we);
			}
		}
		return ret;
	}
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public Object createPriorityTypeFromString(EDataType eDataType, String initialValue) {
    if (initialValue == null) return null;
    Object result = null;
    RuntimeException exception = null;
    try {
      result =
          createPriorityTypeMember0FromString(
              jpdl32Package.Literals.PRIORITY_TYPE_MEMBER0, initialValue);
      if (result != null && Diagnostician.INSTANCE.validate(eDataType, result, null, null)) {
        return result;
      }
    } catch (RuntimeException e) {
      exception = e;
    }
    try {
      result =
          createPriorityTypeMember1FromString(
              jpdl32Package.Literals.PRIORITY_TYPE_MEMBER1, initialValue);
      if (result != null && Diagnostician.INSTANCE.validate(eDataType, result, null, null)) {
        return result;
      }
    } catch (RuntimeException e) {
      exception = e;
    }
    if (result != null || exception == null) return result;

    throw exception;
  }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (SoaViewsRepository.Service.Properties.synchronization == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   SoaPackage.eINSTANCE.getService_Synchronization().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 SoaPackage.eINSTANCE.getService_Synchronization().getEAttributeType(), newValue);
       }
       if (SoaViewsRepository.Service.Properties.kind == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   SoaPackage.eINSTANCE.getService_Kind().getEAttributeType(), (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 SoaPackage.eINSTANCE.getService_Kind().getEAttributeType(), newValue);
       }
       if (SoaViewsRepository.Service.Properties.name == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   SoaPackage.eINSTANCE.getService_Name().getEAttributeType(), (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 SoaPackage.eINSTANCE.getService_Name().getEAttributeType(), newValue);
       }
       if (SoaViewsRepository.Service.Properties.description == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(),
                 newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 @Override
 public Diagnostic validateValue(final IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (DatabaseViewsRepository.ForeignKeyElement.Properties.comments
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getDatabaseElement_Comments().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getDatabaseElement_Comments().getEAttributeType(),
                 newValue);
       }
       if (DatabaseViewsRepository.ForeignKeyElement.Properties.sourceTable
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
       }
       if (DatabaseViewsRepository.ForeignKeyElement.Properties.targetTable
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
       }
     } catch (final IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (final WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (StatemachineViewsRepository.Transition.Properties.description
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(),
                 newValue);
       }
       if (StatemachineViewsRepository.Transition.Properties.keywords
           == event.getAffectedEditor()) {
         BasicDiagnostic chain = new BasicDiagnostic();
         for (Iterator iterator = ((List) event.getNewValue()).iterator(); iterator.hasNext(); ) {
           chain.add(
               Diagnostician.INSTANCE.validate(
                   EnvironmentPackage.eINSTANCE.getObeoDSMObject_Keywords().getEAttributeType(),
                   iterator.next()));
         }
         ret = chain;
       }
       if (StatemachineViewsRepository.Transition.Properties.guard == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   StateMachinePackage.eINSTANCE.getTransition_Guard().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 StateMachinePackage.eINSTANCE.getTransition_Guard().getEAttributeType(),
                 newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (EcoreViewsRepository.EPackage.Properties.name == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EcorePackage.eINSTANCE.getENamedElement_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EcorePackage.eINSTANCE.getENamedElement_Name().getEAttributeType(), newValue);
       }
       if (EcoreViewsRepository.EPackage.Properties.nsURI == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EcorePackage.eINSTANCE.getEPackage_NsURI().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EcorePackage.eINSTANCE.getEPackage_NsURI().getEAttributeType(), newValue);
       }
       if (EcoreViewsRepository.EPackage.Properties.nsPrefix == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EcorePackage.eINSTANCE.getEPackage_NsPrefix().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EcorePackage.eINSTANCE.getEPackage_NsPrefix().getEAttributeType(), newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (GsnViewsRepository.Solution.Properties.identifier == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   ArmPackage.eINSTANCE.getModelElement_Identifier().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 ArmPackage.eINSTANCE.getModelElement_Identifier().getEAttributeType(), newValue);
       }
       if (GsnViewsRepository.Solution.Properties.description == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   ArmPackage.eINSTANCE.getModelElement_Description().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 ArmPackage.eINSTANCE.getModelElement_Description().getEAttributeType(), newValue);
       }
       if (GsnViewsRepository.Solution.Properties.content == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   ArmPackage.eINSTANCE.getModelElement_Content().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 ArmPackage.eINSTANCE.getModelElement_Content().getEAttributeType(), newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (UmlViewsRepository.LinkEndDestructionData.Properties.isDestroyDuplicates
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   UMLPackage.eINSTANCE
                       .getLinkEndDestructionData_IsDestroyDuplicates()
                       .getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE
                     .getLinkEndDestructionData_IsDestroyDuplicates()
                     .getEAttributeType(),
                 newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (SpemViewsRepository.ProcessComponent.Properties.name == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   SpemPackage.eINSTANCE.getProcessPackageableElement_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 SpemPackage.eINSTANCE.getProcessPackageableElement_Name().getEAttributeType(),
                 newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
Пример #12
0
 public String isValid(Object object) {
   Object value;
   try {
     value =
         eDataType
             .getEPackage()
             .getEFactoryInstance()
             .createFromString(eDataType, (String) object);
   } catch (Exception exception) {
     String message = exception.getClass().getName();
     int index = message.lastIndexOf('.');
     if (index >= 0) {
       message = message.substring(index + 1);
     }
     if (exception.getLocalizedMessage() != null) {
       message = message + ": " + exception.getLocalizedMessage();
     }
     return message;
   }
   Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eDataType, value);
   if (diagnostic.getSeverity() == Diagnostic.OK) {
     return null;
   } else {
     return (diagnostic.getChildren().get(0))
         .getMessage()
         .replaceAll("'", "''")
         .replaceAll("\\{", "'{'"); // }}
   }
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 @Override
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (DocbookViewsRepository.ItemizedList.Properties.mark == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DocbookPackage.eINSTANCE.getItemizedList_Mark().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DocbookPackage.eINSTANCE.getItemizedList_Mark().getEAttributeType(), newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
Пример #14
0
  @Lock(LockType.WRITE)
  public void put(String id, EObject value) {
    if (store.get(id) == null) {
      EObject obj = getEObjectByID(id);
      store.put(id, obj);
    }

    EObject obj = store.get(id);
    EList<EAttribute> eAttributes = obj.eClass().getEAllAttributes();
    for (EAttribute eAttribute : eAttributes) {
      obj.eSet(eAttribute, value.eGet(eAttribute));
      store.remove(id);
    }
    if (validation.getFlag()) {
      Diagnostic d = Diagnostician.INSTANCE.validate(obj);
      if (d.getSeverity() == Diagnostic.ERROR)
        throw new WebApplicationException(Status.BAD_REQUEST);
    }
    try {
      resourceLoader.getResource().save(Collections.EMPTY_MAP);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (MappingViewsRepository.Documentation.Documentation_.documentation__
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   MappingPackage.eINSTANCE
                       .getDocumentedElement_Documentation()
                       .getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 MappingPackage.eINSTANCE.getDocumentedElement_Documentation().getEAttributeType(),
                 newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
Пример #16
0
  /**
   * Dynamically create an {@link EObject} with a collection called <code>children</code> which
   * contains the given elements.
   *
   * @param collection The initial filling of the collection.
   * @return An {@link EObject} which just has a containment list (named <code>children</code>) of
   *     type {@link EObject}.
   */
  @SuppressWarnings("unchecked")
  public static EObject wrapInGenericContainer(Collection<? extends EObject> collection) {

    // create the wrapper containment reference
    final EReference children = EcoreFactory.eINSTANCE.createEReference();
    children.setName("children");
    children.setLowerBound(0);
    children.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY);
    children.setContainment(true);
    children.setEType(EcorePackage.Literals.EOBJECT);

    // create the wrapper class
    final EClass containerClass = EcoreFactory.eINSTANCE.createEClass();
    containerClass.setName("GenericEContainer");
    containerClass.getEStructuralFeatures().add(children);

    // create a package for our wrapper class
    final EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
    ePackage.setName("dynamic");
    ePackage.setNsPrefix("dynamic");
    ePackage.setNsURI("http://www.example.org/dynamic");
    ePackage.getEClassifiers().add(containerClass);

    // validate what we just created
    if (Diagnostician.INSTANCE.validate(ePackage).getCode() == Diagnostic.OK) {

      // instantiate our class, fill the children and return it
      final EObject container = ePackage.getEFactoryInstance().create(containerClass);
      ((EList<EObject>) container.eGet(children)).addAll(collection);
      return container;
    } else {
      throw new UnknownError(
          "Dynamic EMF wrapper model creation failed for whatever reason. Developer, please debug better!");
    }
  }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (DroidViewsRepository.RotateAnimation.Properties.fromAlpha
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   DroidPackage.eINSTANCE
                       .getTerminalAnimationElements_FromAlpha()
                       .getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DroidPackage.eINSTANCE
                     .getTerminalAnimationElements_FromAlpha()
                     .getEAttributeType(),
                 newValue);
       }
       if (DroidViewsRepository.RotateAnimation.Properties.toAlpha == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   DroidPackage.eINSTANCE
                       .getTerminalAnimationElements_ToAlpha()
                       .getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DroidPackage.eINSTANCE.getTerminalAnimationElements_ToAlpha().getEAttributeType(),
                 newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (ComponentsViewsRepository.PropertiesEditionElement.Properties.name
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   MappingPackage.eINSTANCE.getAbstractPropertyBinding_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 MappingPackage.eINSTANCE.getAbstractPropertyBinding_Name().getEAttributeType(),
                 newValue);
       }
       if (ComponentsViewsRepository.PropertiesEditionElement.Properties.helpID
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   ComponentsPackage.eINSTANCE.getEEFElement_HelpID().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 ComponentsPackage.eINSTANCE.getEEFElement_HelpID().getEAttributeType(), newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (EvidenceViewsRepository.Consistency.Properties.id == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   SACMPackage.eINSTANCE.getModelElement_Id().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 SACMPackage.eINSTANCE.getModelElement_Id().getEAttributeType(), newValue);
       }
       if (EvidenceViewsRepository.Consistency.Properties.value == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EvidencePackage.eINSTANCE.getConsistency_Value().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EvidencePackage.eINSTANCE.getConsistency_Value().getEAttributeType(), newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
Пример #20
0
  public MavenMetadata(URI uri) throws CoreException {
    Resource resource = getResourceSet().getResource(uri, true);
    EList<EObject> content = resource.getContents();
    if (content.size() != 1)
      throw ExceptionUtils.fromMessage(
          "ECore Resource did not contain one resource. It had %d",
          Integer.valueOf(content.size()));

    documentRoot = (DocumentRoot) content.get(0);
    Diagnostic diag = Diagnostician.INSTANCE.validate(documentRoot);
    if (diag.getSeverity() == Diagnostic.ERROR) {
      for (Diagnostic childDiag : diag.getChildren()) LogUtils.error(childDiag.getMessage());
      throw ExceptionUtils.fromMessage(
          "Maven Metadata model validation failed: %s", diag.getMessage());
    }
  }
  private boolean validateDlimModel(UsageEvolutionAlternative alternative)
      throws ValidationException {
    List<Resource> resources = alternative.getModelResources(ToolchainUtils.KEY_FILE_LIMBO);
    alternative
        .getSelfStatus()
        .checkError(
            ERROR_DLIM_NOT_REGISTERED, !resources.isEmpty(), true, ERROR_DLIM_NOT_REGISTERED);

    Resource resource = resources.get(0);
    alternative
        .getSelfStatus()
        .checkError(ERROR_DLIM_EMPTY, resource != null, true, ERROR_DLIM_EMPTY);

    Diagnostic diagnostic = Diagnostician.INSTANCE.validate(resource.getContents().get(0));

    boolean modelValid = diagnostic.getSeverity() == Diagnostic.OK;

    return modelValid;
  }
Пример #22
0
  @Lock(LockType.WRITE)
  public Object remove(String id) {
    if (store.get(id) == null) {
      EObject obj = getEObjectByID(id);
      store.put(id, obj);
    }
    EObject obj = store.get(id);
    if (validation.getFlag()) {
      Diagnostic d = Diagnostician.INSTANCE.validate(obj);
      if (d.getSeverity() == Diagnostic.ERROR)
        throw new WebApplicationException(Status.BAD_REQUEST);
    }

    EcoreUtil.delete(obj);
    store.remove(id);
    try {
      resourceLoader.getResource().save(Collections.EMPTY_MAP);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return null;
  }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (UmlViewsRepository.InputPin.Properties.name == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   UMLPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
       }
       if (UmlViewsRepository.InputPin.Properties.visibility == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   UMLPackage.eINSTANCE.getNamedElement_Visibility().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getNamedElement_Visibility().getEAttributeType(), newValue);
       }
       if (UmlViewsRepository.InputPin.Properties.isLeaf == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   UMLPackage.eINSTANCE.getRedefinableElement_IsLeaf().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getRedefinableElement_IsLeaf().getEAttributeType(),
                 newValue);
       }
       if (UmlViewsRepository.InputPin.Properties.ordering == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   UMLPackage.eINSTANCE.getObjectNode_Ordering().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getObjectNode_Ordering().getEAttributeType(), newValue);
       }
       if (UmlViewsRepository.InputPin.Properties.isControlType == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   UMLPackage.eINSTANCE.getObjectNode_IsControlType().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getObjectNode_IsControlType().getEAttributeType(), newValue);
       }
       if (UmlViewsRepository.InputPin.Properties.isOrdered == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   UMLPackage.eINSTANCE.getMultiplicityElement_IsOrdered().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getMultiplicityElement_IsOrdered().getEAttributeType(),
                 newValue);
       }
       if (UmlViewsRepository.InputPin.Properties.isUnique == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   UMLPackage.eINSTANCE.getMultiplicityElement_IsUnique().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getMultiplicityElement_IsUnique().getEAttributeType(),
                 newValue);
       }
       if (UmlViewsRepository.InputPin.Properties.isControl == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EcoreUtil.createFromString(
                   UMLPackage.eINSTANCE.getPin_IsControl().getEAttributeType(), (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getPin_IsControl().getEAttributeType(), newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
  @Override
  public void launch(
      ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
      throws CoreException {
    try {
      this.launch = launch;
      cleanup();

      final MitraLaunchConfigurationAdapter configAdapter =
          new MitraLaunchConfigurationAdapter(configuration);

      String consoleName = "Mitra Interpreter [" + configAdapter.getName() + "] " + mode;
      console = findConsole(consoleName);
      console.activate();
      initConsoleStream();

      clearConsole();

      final StandaloneExecutor executor =
          MitraStandaloneLaunchFactory.createExecutor(configAdapter);
      executor.getProjectContext().setMessageAcceptor(new ConsoleMessageAcceptor(console));

      console.addPatternMatchListener(new MitraConsoleTracker(executor.getProjectContext()));

      executor.getProjectContext().out = new PrintStream(createMessageStream(SWT.COLOR_BLACK));

      PrintStream err = new PrintStream(createMessageStream(SWT.COLOR_RED));
      executor.getProjectContext().err = err;

      executor.getProjectContext().log = new PrintStream(createMessageStream(SWT.COLOR_BLUE));

      try {
        executor.prepareInterpreter();
      } catch (Exception ex) {
        throw new CoreException(
            new Status(
                IStatus.ERROR,
                MitraDebugPlugin.PLUGIN_ID,
                "Error preparing Mitra interpreter: " + ex.getMessage(),
                ex));
      }

      executor
          .getDebugable()
          .addInterpreterListener(
              new IDebugableListener() {

                @Override
                public void terminated() {

                  out("Mitra interpreter terminated.");
                  try {
                    for (String fileName : configAdapter.getOutputModelFilenames().values()) {
                      URI uri = URI.createFileURI(fileName);
                      refreshPath(uri);
                    }
                    for (String fileName : configAdapter.getInputModelFilenames().values()) {
                      URI uri = URI.createFileURI(fileName);
                      refreshPath(uri);
                    }
                    if (configAdapter.isSaveTraces()) {
                      URI uri = URI.createFileURI(configAdapter.getTraceModelFilename());
                      refreshPath(uri);
                    }
                  } catch (CoreException ex) {
                    out("Error refreshing project path: " + ex);
                  }
                }

                @Override
                public void processDebugableEvent(DebugEventType eventType) {
                  // not interested in
                }

                @Override
                public void suspended() {
                  // not interested in
                }
              });

      ResourceSet rs = executor.getProjectContext().getResourceSet();
      int errorCount = 0;
      int warningCount = 0;
      int moduleCount = 0;
      // iterate over copy, as new resources may be
      // added while resolving proxies
      List<Resource> resources = new ArrayList<Resource>(rs.getResources());
      for (Resource resource : resources) {
        errorCount += resource.getErrors().size();
        warningCount += resource.getWarnings().size();

        if (resource.getContents().size() > 0) {
          for (EObject model : resource.getContents()) {

            if (model instanceof Module) {
              moduleCount++;
            }
            Diagnostic diagnostic = Diagnostician.INSTANCE.validate(model);
            for (Diagnostic child : diagnostic.getChildren()) {
              switch (child.getSeverity()) {
                case Diagnostic.ERROR:
                  if (!(model instanceof Module)) {
                    err.println(model.eResource().getURI() + ": " + child.getMessage());
                  }
                  errorCount++;
                  break;
                case Diagnostic.WARNING:
                  warningCount++;
              }
            }
          }
        }
      }

      MessageFormat form = new MessageFormat("Loaded {0}{1}, {2}.");
      double[] limits = {0, 1, 2};
      String[] moduleparts = {"no module", "1 module", "{0,number} modules"};
      ChoiceFormat moduleform = new ChoiceFormat(limits, moduleparts);
      form.setFormatByArgumentIndex(0, moduleform);
      String[] errorparts = {" successfully: 0 errors", ": 1 error", ": {1,number} errors"};
      ChoiceFormat errorform = new ChoiceFormat(limits, errorparts);
      form.setFormatByArgumentIndex(1, errorform);
      String[] warningparts = {"0 warnings", "1 warning", "{2,number} warnings"};
      ChoiceFormat warningform = new ChoiceFormat(limits, warningparts);
      form.setFormatByArgumentIndex(2, warningform);

      String msg = form.format(new Object[] {moduleCount, errorCount, warningCount});
      if (errorCount > 0) {
        msg += " Cannot start Mitra intpreter.";
      }
      out(msg);
      if (errorCount > 0 || moduleCount == 0) {
        throw new CoreException(new Status(IStatus.ERROR, MitraDebugPlugin.PLUGIN_ID, msg));
      }

      IDebuggable debugable = executor.getDebugable(); // debugable
      // supports
      // listeners!

      if (debugable == null) {
        throw new CoreException(
            new Status(
                IStatus.ERROR, MitraDebugPlugin.PLUGIN_ID, "No debuggable interpreter prepared."));
      }

      RuleDeclaration decl = debugable.getCalledRule();

      if (decl == null) {
        throw new CoreException(
            new Status(IStatus.ERROR, MitraDebugPlugin.PLUGIN_ID, "No rule selected."));
      }
      IDebugTarget debugTarget =
          new MitraDebugTarget(
              launch, new MitraDebugProxy(debugable), decl.eResource().getURI().toFileString());

      Display display = Display.getCurrent();
      if (display == null) { // start in normal thread
        if (log.isLoggable(Level.INFO)) {
          log.info("Start mitra interpreter via new thread");
        }
        out("Start Mitra interpreter on new thread");

        Thread interpreterThread = new Thread(debugable);
        if (mode.equals(ILaunchManager.DEBUG_MODE)) {
          debugable.enableDebug(true);
          interpreterThread.setName("MitraInterpreter");
          interpreterThread.start();
          launch.addDebugTarget(debugTarget);
        } else {
          interpreterThread.start();
        }
      } else { // start via display
        if (log.isLoggable(Level.INFO)) {
          log.info("Start mitra interpreter via display.asyncExec");
        }
        out("Start Mitra interpreter on display thread");

        if (mode.equals(ILaunchManager.DEBUG_MODE)) {
          debugable.enableDebug(true);
          display.asyncExec(debugable);
          // interpreterThread.setName("MitraInterpreter");
          // interpreterThread.start();
          launch.addDebugTarget(debugTarget);
        } else {
          display.asyncExec(debugable);
        }
      }
      out("Interpreter running...");
    } finally {
      console = null;
    }
  }
Пример #25
0
 protected Diagnostic validate(EObject target) {
   Map<Object, Object> ctx = new java.util.HashMap<Object, Object>();
   ctx.put(Environment.class, ocl.getEnvironment());
   return Diagnostician.INSTANCE.validate(target, ctx);
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (EnvironmentViewsRepository.Reference.Properties.name == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EnvironmentPackage.eINSTANCE.getProperty_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EnvironmentPackage.eINSTANCE.getProperty_Name().getEAttributeType(), newValue);
       }
       if (EnvironmentViewsRepository.Reference.Properties.multiplicity
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EnvironmentPackage.eINSTANCE.getProperty_Multiplicity().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EnvironmentPackage.eINSTANCE.getProperty_Multiplicity().getEAttributeType(),
                 newValue);
       }
       if (EnvironmentViewsRepository.Reference.Properties.isComposite
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EnvironmentPackage.eINSTANCE.getReference_IsComposite().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EnvironmentPackage.eINSTANCE.getReference_IsComposite().getEAttributeType(),
                 newValue);
       }
       if (EnvironmentViewsRepository.Reference.Properties.navigable
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EnvironmentPackage.eINSTANCE.getReference_Navigable().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EnvironmentPackage.eINSTANCE.getReference_Navigable().getEAttributeType(),
                 newValue);
       }
       if (EnvironmentViewsRepository.Reference.Properties.identifier
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EnvironmentPackage.eINSTANCE.getProperty_IsIdentifier().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EnvironmentPackage.eINSTANCE.getProperty_IsIdentifier().getEAttributeType(),
                 newValue);
       }
       if (EnvironmentViewsRepository.Reference.Properties.description
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(),
                 newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  * @generated
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (UmlViewsRepository.General.name == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   UMLPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
       }
       if (UmlViewsRepository.General.visibility == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   UMLPackage.eINSTANCE.getNamedElement_Visibility().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getNamedElement_Visibility().getEAttributeType(), newValue);
       }
       if (UmlViewsRepository.General.Qualifiers.abstract_ == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   UMLPackage.eINSTANCE.getClassifier_IsAbstract().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getClassifier_IsAbstract().getEAttributeType(), newValue);
       }
       if (UmlViewsRepository.General.Qualifiers.leaf == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   UMLPackage.eINSTANCE.getRedefinableElement_IsLeaf().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getRedefinableElement_IsLeaf().getEAttributeType(),
                 newValue);
       }
       if (UmlViewsRepository.General.Qualifiers.active == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   UMLPackage.eINSTANCE.getClass_IsActive().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 UMLPackage.eINSTANCE.getClass_IsActive().getEAttributeType(), newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (DatabaseViewsRepository.Sequence.Properties.name == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
       }
       if (DatabaseViewsRepository.Sequence.Properties.StartIncrement.start
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getSequence_Start().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getSequence_Start().getEAttributeType(), newValue);
       }
       if (DatabaseViewsRepository.Sequence.Properties.StartIncrement.increment
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getSequence_Increment().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getSequence_Increment().getEAttributeType(), newValue);
       }
       if (DatabaseViewsRepository.Sequence.Properties.MinMax.minValue
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getSequence_MinValue().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getSequence_MinValue().getEAttributeType(), newValue);
       }
       if (DatabaseViewsRepository.Sequence.Properties.MinMax.maxValue
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getSequence_MaxValue().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getSequence_MaxValue().getEAttributeType(), newValue);
       }
       if (DatabaseViewsRepository.Sequence.Properties.CycleCacheSize.cycle
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getSequence_Cycle().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getSequence_Cycle().getEAttributeType(), newValue);
       }
       if (DatabaseViewsRepository.Sequence.Properties.CycleCacheSize.cacheSize
           == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getSequence_CacheSize().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getSequence_CacheSize().getEAttributeType(), newValue);
       }
       if (DatabaseViewsRepository.Sequence.Properties.comments == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   DatabasePackage.eINSTANCE.getDatabaseElement_Comments().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 DatabasePackage.eINSTANCE.getDatabaseElement_Comments().getEAttributeType(),
                 newValue);
       }
     } catch (IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
 /**
  * {@inheritDoc}
  *
  * @see
  *     org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#validateValue(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
  */
 public Diagnostic validateValue(final IPropertiesEditionEvent event) {
   Diagnostic ret = Diagnostic.OK_INSTANCE;
   if (event.getNewValue() != null) {
     try {
       if (GraalViewsRepository.Task.Properties.description == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description().getEAttributeType(),
                 newValue);
       }
       if (GraalViewsRepository.Task.Properties.id == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   GraalPackage.eINSTANCE.getAbstractTask_Id().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 GraalPackage.eINSTANCE.getAbstractTask_Id().getEAttributeType(), newValue);
       }
       if (GraalViewsRepository.Task.Properties.name == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   GraalPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 GraalPackage.eINSTANCE.getNamedElement_Name().getEAttributeType(), newValue);
       }
       if (GraalViewsRepository.Task.Properties.preconditions == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   GraalPackage.eINSTANCE.getTask_Preconditions().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 GraalPackage.eINSTANCE.getTask_Preconditions().getEAttributeType(), newValue);
       }
       if (GraalViewsRepository.Task.Properties.postconditions == event.getAffectedEditor()) {
         Object newValue = event.getNewValue();
         if (newValue instanceof String) {
           newValue =
               EEFConverterUtil.createFromString(
                   GraalPackage.eINSTANCE.getTask_Postconditions().getEAttributeType(),
                   (String) newValue);
         }
         ret =
             Diagnostician.INSTANCE.validate(
                 GraalPackage.eINSTANCE.getTask_Postconditions().getEAttributeType(), newValue);
       }
     } catch (final IllegalArgumentException iae) {
       ret = BasicDiagnostic.toDiagnostic(iae);
     } catch (final WrappedException we) {
       ret = BasicDiagnostic.toDiagnostic(we);
     }
   }
   return ret;
 }
Пример #30
0
  /**
   *
   * <!-- begin-user-doc -->
   * Load all the argument file paths or URIs as instances of the model.
   * <!-- end-user-doc -->
   *
   * @param args the file paths or URIs.
   * @generated
   */
  public static void main(String[] args) {
    // Create a resource set to hold the resources.
    //
    ResourceSet resourceSet = new ResourceSetImpl();

    // Register the appropriate resource factory to handle all file extensions.
    //
    resourceSet
        .getResourceFactoryRegistry()
        .getExtensionToFactoryMap()
        .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());

    // Register the package to ensure it is available during loading.
    //
    resourceSet.getPackageRegistry().put(Mu2consolPackage.eNS_URI, Mu2consolPackage.eINSTANCE);

    // If there are no arguments, emit an appropriate usage message.
    //
    if (args.length == 0) {
      System.out.println("Enter a list of file paths or URIs that have content like this:");
      try {
        Resource resource = resourceSet.createResource(URI.createURI("http:///My.mu2consol"));
        GeneralHeaderConstraints root = Mu2consolFactory.eINSTANCE.createGeneralHeaderConstraints();
        resource.getContents().add(root);
        resource.save(System.out, null);
      } catch (IOException exception) {
        exception.printStackTrace();
      }
    } else {
      // Iterate over all the arguments.
      //
      for (int i = 0; i < args.length; ++i) {
        // Construct the URI for the instance file.
        // The argument is treated as a file path only if it denotes an existing file.
        // Otherwise, it's directly treated as a URL.
        //
        File file = new File(args[i]);
        URI uri =
            file.isFile() ? URI.createFileURI(file.getAbsolutePath()) : URI.createURI(args[i]);

        try {
          // Demand load resource for this file.
          //
          Resource resource = resourceSet.getResource(uri, true);
          System.out.println("Loaded " + uri);

          // Validate the contents of the loaded resource.
          //
          for (EObject eObject : resource.getContents()) {
            Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eObject);
            if (diagnostic.getSeverity() != Diagnostic.OK) {
              printDiagnostic(diagnostic, "");
            }
          }
        } catch (RuntimeException exception) {
          System.out.println("Problem loading " + uri);
          exception.printStackTrace();
        }
      }
    }
  }