Package org.eclipse.emf.common.util

Examples of org.eclipse.emf.common.util.BasicDiagnostic$StatusWrapper


    this.resolvedIUs = Lists.newArrayList();
    this.options = options;
  }
 
  public Diagnostic resolve(IMetadataRepositoryManager metadataRepositoryManager, IProgressMonitor monitor) {
    BasicDiagnostic diag = new BasicDiagnostic();
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
   
    IMetadataRepository metadataRepository;
    try {
      metadataRepository = metadataRepositoryManager.loadRepository(uri, subMonitor.newChild(80));
      SubMonitor loopMonitor = subMonitor.newChild(20).setWorkRemaining(unresolvedIUs.size());
      for (UnresolvedIU iu : unresolvedIUs) {
        if (monitor.isCanceled()) {
          break;
        }
        Set<IInstallableUnit> results = metadataRepository.query(iu.getQuery(), loopMonitor.newChild(1)).toUnmodifiableSet();
        if (!results.isEmpty()) {
          IInstallableUnit unit =  results.iterator().next();
          if (iu.isLazyRange() && unit instanceof InstallableUnit) {
            ((InstallableUnit)unit).setVersion(Version.create("0.0.0"));
          }
          resolvedIUs.add(unit);
        } else {
          String msg = "Error occured during resolution of '" + uri.toString() + "'. The IU '" + iu.getID() + "' with range constraint '" + iu.getVersionRange() + "' can not be found.";
          diag.merge(new BasicDiagnostic(Diagnostic.ERROR, TargetPlatformBundleActivator.PLUGIN_ID, -1, msg, new Object[]{this, iu,}));
        }
      }
    } catch (ProvisionException e) {
      diag.merge(BasicDiagnostic.toDiagnostic(e));
    }
   
    return diag;
  }
View Full Code Here


  public Environment getEnvironment() {
    return environment;
  }
 
  public Diagnostic resolve(IMetadataRepositoryManager metadataRepositoryManager, IProgressMonitor monitor) {
    BasicDiagnostic ret = new BasicDiagnostic();
    SubMonitor subMonitor = SubMonitor.convert(monitor, getLocations().size());
    for (ResolvedLocation location : getLocations()) {
      if(subMonitor.isCanceled()) {
        ret.merge(BasicDiagnostic.CANCEL_INSTANCE);
        break;
      }
      Diagnostic diagnostic = location.resolve(metadataRepositoryManager, subMonitor);
      if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
        ret.merge(diagnostic);
      }
      subMonitor.worked(1);
    }
    return ret;
  }
View Full Code Here

 
  @Inject
  private IProvisioningAgent agent;
 
  public Diagnostic generateTargetDefinitionFile(URI uri, IProgressMonitor monitor) {
    BasicDiagnostic ret = new BasicDiagnostic(TargetPlatformBundleActivator.PLUGIN_ID, 0, "Diagnostic of the generation of the target platform.", null);
    if (!"targetplatform".equals(uri.fileExtension()) && !"tpd".equals(uri.fileExtension())) {
      ret.merge(new BasicDiagnostic(Diagnostic.ERROR, TargetPlatformBundleActivator.PLUGIN_ID, -1, "The target platform file '" + uri + "' must ends with '.tpd' or '.targetplatform' extensions.", null));
    } else {
      Diagnostic diagnostic = doGenerateTargetDefinitionFile(uri, monitor);
      if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
        ret.merge(diagnostic);
      }
    }
    return ret;
  }
View Full Code Here

    }
    return ret;
  }

  private Diagnostic doGenerateTargetDefinitionFile(URI uri, IProgressMonitor monitor) {
    BasicDiagnostic ret = new BasicDiagnostic();
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
   
    try {
      Resource resource = loadTargetPlatform(uri);
      subMonitor.worked(2);
     
      Diagnostic resourceDiagnostic = EcoreUtil.computeDiagnostic(resource, true);
      if (resourceDiagnostic.getSeverity() >= Diagnostic.WARNING) {
        ret.merge(resourceDiagnostic);
      }

      if (resourceDiagnostic.getSeverity() < Diagnostic.ERROR) {
        TargetPlatform targetPlatform = null;
        if (resource != null && !resource.getContents().isEmpty()) {
          targetPlatform = (TargetPlatform) resource.getContents().get(0);
        }
        if (targetPlatform == null) {
          ret.merge(new BasicDiagnostic(Diagnostic.ERROR, TargetPlatformBundleActivator.PLUGIN_ID, -1, "Error occured while loading the file " + uri + ".", null));
        } else if (subMonitor.isCanceled()) {
          ret.merge(Diagnostic.CANCEL_INSTANCE);
        } else {
          SubMonitor diagnosticianMonitor = subMonitor.newChild(90).setWorkRemaining(targetPlatform.getLocations().size());
          Diagnostic validation = new CustomDiagnostician(diagnosticianMonitor).validate(targetPlatform);
          if (validation.getSeverity() >= Diagnostic.WARNING) {
            ret.merge(validation);
          } else if (subMonitor.isCanceled()) {
            ret.merge(Diagnostic.CANCEL_INSTANCE);
          }
         
          if (validation.getSeverity() < Diagnostic.ERROR) {
            Diagnostic diagnostic = doGenerateTargetDefinitionFile(uri, targetPlatform, subMonitor.newChild(8));
            if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
              ret.merge(diagnostic);
            }
          }
          subMonitor.setWorkRemaining(0);
        }
      }
    } catch (Exception e) {
      ret.merge(BasicDiagnostic.toDiagnostic(e));
    }
    return ret;
  }
View Full Code Here

    }
    return ret;
  }

  private Diagnostic doGenerateTargetDefinitionFile(URI uri, TargetPlatform targetPlatform, IProgressMonitor monitor)  {
    final BasicDiagnostic ret = new BasicDiagnostic();
    SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
   
    try {
      IMetadataRepositoryManager repositoryManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
      ResolvedTargetPlatform resolvedTargetPlatform = ResolvedTargetPlatform.create(targetPlatform, indexBuilder);
      subMonitor.worked(5);
     
      if (subMonitor.isCanceled()) {
        ret.merge(Diagnostic.CANCEL_INSTANCE);
      } else {
        Diagnostic diagnostic = resolvedTargetPlatform.resolve(repositoryManager, subMonitor.newChild(90));
        if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
          ret.merge(diagnostic);
        }
        if (subMonitor.isCanceled()) {
          ret.merge(Diagnostic.CANCEL_INSTANCE);
        } else if (ret.getSeverity() < Diagnostic.ERROR) {
          diagnostic = doGenerateTargetDefinitionFile(uri, resolvedTargetPlatform);
          if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
            ret.merge(diagnostic);
          }
          subMonitor.worked(5);
        }
      }
    } catch (Exception e) {
      ret.merge(BasicDiagnostic.toDiagnostic(e));
    }
   
   
    return ret;
  }
View Full Code Here

   
    return ret;
  }

  private Diagnostic doGenerateTargetDefinitionFile(URI uri, ResolvedTargetPlatform resolvedTargetPlatform) {
    BasicDiagnostic ret = new BasicDiagnostic();
    TargetDefinitionGenerator generator = new TargetDefinitionGenerator();
    String xml = generator.generate(resolvedTargetPlatform, (int)TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()));
    final URI targetDefinitionLocation = uri.trimFileExtension().appendFileExtension("target");
   
    Diagnostic diagnostic = serialize(targetDefinitionLocation, xml);
    if (diagnostic.getSeverity() >= Diagnostic.WARNING) {
      ret.merge(diagnostic);
    }
   
    return ret;
  }
View Full Code Here

   
    return ret;
  }

  private Diagnostic serialize(URI targetPlatformLocation, String xml) {
    BasicDiagnostic ret = new BasicDiagnostic();
    URI targetDefinitionLocation = targetPlatformLocation.trimFileExtension().appendFileExtension("target");
   
    if (hasContentDifferencesOtherThanSequenceNumber(targetDefinitionLocation, xml)) {
      OutputStream outputStream = null;
      try {
        outputStream = new BufferedOutputStream(new FileOutputStream(new File(targetDefinitionLocation.toFileString())));
        outputStream.write(xml.getBytes());
      } catch (Exception e) {
        ret.merge(BasicDiagnostic.toDiagnostic(e));
      } finally {
        try {
          Closeables.close(outputStream, true);
        } catch (IOException e) {
          // swallowed
        }
      }
    } else {
      ret.merge(new BasicDiagnostic(Diagnostic.INFO, TargetPlatformBundleActivator.PLUGIN_ID, -1, "The target definition '"+targetDefinitionLocation+"' did not changed since previous generation, we did not overwrote it.", null));
    }
   
    return ret;
  }
View Full Code Here

    }

    private static BasicDiagnostic create(final int diagnosticId, final String message)
    {
        final int severity = IMessage.NORMAL_SEVERITY;//ELValidationPreferences.getDefaultSeverity(diagnosticId);
        return new BasicDiagnostic(severity, SOURCE_ID
                , diagnosticId
                , message
                , null);
    }
View Full Code Here

   * <!-- end-user-doc -->
   * @generated
   */
  protected void updateProblemIndication() {
    if (updateProblemIndication) {
      BasicDiagnostic diagnostic =
        new BasicDiagnostic
          (Diagnostic.OK,
           "OntoUML.editor",
           0,
           null,
           new Object [] { editingDomain.getResourceSet() });
      for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) {
        if (childDiagnostic.getSeverity() != Diagnostic.OK) {
          diagnostic.add(childDiagnostic);
        }
      }

      int lastEditorPage = getPageCount() - 1;
      if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) {
        ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic);
        if (diagnostic.getSeverity() != Diagnostic.OK) {
          setActivePage(lastEditorPage);
        }
      }
      else if (diagnostic.getSeverity() != Diagnostic.OK) {
        ProblemEditorPart problemEditorPart = new ProblemEditorPart();
        problemEditorPart.setDiagnostic(diagnostic);
        try {
          addPage(++lastEditorPage, problemEditorPart, getEditorInput());
          setPageText(lastEditorPage, problemEditorPart.getPartName());
View Full Code Here

   * <!-- end-user-doc -->
   * @generated
   */
  public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
    if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) {
      BasicDiagnostic basicDiagnostic =
        new BasicDiagnostic
          (Diagnostic.ERROR,
           "OntoUML.editor",
           0,
           getString("_UI_CreateModelError_message", resource.getURI()),
           new Object [] { exception == null ? (Object)resource : exception });
      basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
      return basicDiagnostic;
    }
    else if (exception != null) {
      return
        new BasicDiagnostic
          (Diagnostic.ERROR,
           "OntoUML.editor",
           0,
           getString("_UI_CreateModelError_message", resource.getURI()),
           new Object[] { exception });
View Full Code Here

TOP

Related Classes of org.eclipse.emf.common.util.BasicDiagnostic$StatusWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.