Package org.osmorc.obrimport.springsource

Examples of org.osmorc.obrimport.springsource.ObrMavenResult


      return "Find OSGi-ready version";
    }

    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {
      final MavenDomDependency dependency = getDependency((XmlTag)problemDescriptor.getPsiElement());
      final ObrMavenResult mavenResult =
        ObrSearchDialog.queryForMavenArtifact(project, dependency.getArtifactId().toString());
      if (mavenResult != null) {

        final PsiFile psiFile = problemDescriptor.getPsiElement().getContainingFile();
        new WriteCommandAction(project, psiFile) {
          protected void run(Result result) throws Throwable

          {
            MavenDomProjectModel model =
              MavenDomUtil.getMavenDomProjectModel(getProject(), psiFile.getVirtualFile());
            // adds a new dependency to the end of the list
            MavenDomDependency dummy = model.getDependencies().addDependency();
            dummy.getArtifactId().setStringValue(mavenResult.getArtifactId());
            dummy.getVersion().setStringValue(mavenResult.getVersion());
            dummy.getGroupId().setStringValue(mavenResult.getGroupId());
            // copy over scope from old item
            if (!"".equals(dependency.getScope().getStringValue())) {
              dummy.getScope().setStringValue(dependency.getScope().getStringValue());
            }

            PsiElement newDep = dummy.getXmlElement();
            PsiElement oldDep = dependency.getXmlElement();
            // add after the old element a copy of our dummy element (which is at the end of the list so far)
            oldDep.getParent().addAfter(newDep.copy(), oldDep);
            // kill old dependency and the dummy
            oldDep.delete();
            newDep.delete();

            // finally check the repo urls, if we need to add a new one.
            MavenRepository[] repos = mavenResult.getBundleRepository().getMavenRepositories();
            List<MavenDomRepository> repositories = model.getRepositories().getRepositories();

            List<MavenRepository> knownRepositories = new ArrayList<MavenRepository>();
            for (MavenDomRepository repository : repositories) {
              String knownRepoUrl = repository.getUrl().getStringValue();
View Full Code Here

TOP

Related Classes of org.osmorc.obrimport.springsource.ObrMavenResult

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.