private boolean isValidModelResource(Object oSelection) {
    boolean bResult = false;
    if (oSelection instanceof IResource) {
      try {

        IResource resource = (IResource) oSelection;

        if (ModelUtilities.isModelFile(resource)) {
          ModelResource mr = ModelUtil.getModelResource((IFile) resource, true);
          if (mr.getModelType() != null) {
            if (mr.getModelType().equals(newModelInfo.getModelType())) {
              if (mr.getPrimaryMetamodelDescriptor() != null) {
                if (mr.getPrimaryMetamodelDescriptor()
                    .getNamespaceURI()
                    .equals(newModelInfo.getModelURI())) {
                  bResult = true;
                }
              }
            }
          }
        }
      } catch (ModelWorkspaceException mwe) {
        ModelerCore.Util.log(IStatus.ERROR, mwe, mwe.getMessage());
      }
    }
    return bResult;
  }
  /**
   * Create a Model with the supplied name, in the desired project
   *
   * @param targetProj the project resource under which to create the model
   * @param modelName the model name to create
   * @return the newly-created ModelResource
   */
  public ModelResource constructModel(IResource targetRes, String sModelName) {

    String sFileName = getFileName(sModelName);
    IPath relativeModelPath = targetRes.getProjectRelativePath().append(sFileName);
    final IFile modelFile = targetRes.getProject().getFile(relativeModelPath);
    final ModelResource resrc = ModelerCore.create(modelFile);
    try {
      resrc.getModelAnnotation().setPrimaryMetamodelUri(newModelInfo.getModelURI());
      resrc.getModelAnnotation().setModelType(newModelInfo.getModelType());
    } catch (ModelWorkspaceException mwe) {
      mwe.printStackTrace();
    }
    return resrc;
  }