在Eclipse中,如何以编程方式在Classpath条目中设置JavaDoc URL? [英] In Eclipse, how to set JavaDoc URL on a classpath entry programmatically?

查看:107
本文介绍了在Eclipse中,如何以编程方式在Classpath条目中设置JavaDoc URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Eclipse插件,除其他外,可以创建一个项目并给它几个类路径条目。这本身就可以正常工作。



这些jar没有包含源代码,但是有一个可以用于Javadoc的URL。我想通过插件创建的这些类路径条目以编程方式设置。这是我在做的:

  IClasspathEntry cpEntry; 

文件[] jarFile = installFilePath.listFiles();

IPath jarFilePath;
(int fileCount = 0; fileCount< jarFile.length; fileCount ++)
{
jarFilePath = new Path(jarFile [fileCount] .getAbsolutePath());
cpEntry = JavaCore.newLibraryEntry(jarFilePath,null,null);
entries.add(cpEntry);
}

我无法弄清楚如何在claspath条目中设置JavaDoc URL位置。这可以在Eclipse UI中完成 - 例如,如果右键单击项目,请转到属性 - >Java构建路径,然后展开其中一个JAR条目并编辑Javadoc位置,您可以指定一个URL。如何从插件中执行此操作?

解决方案

我使用以下内容:

 路径pth =新路径(MY_JARFILE_LOCATION); 
路径pthd =新路径(MY_JAVADOC_LOCATION);
ClasspathAttribute att = new ClasspathAttribute(javadoc_location,file:+ pthd.toOSString());
IClasspathAttribute [] atts = new IClasspathAttribute [] {att};
IClasspathEntry cpISDI = JavaCore.newLibraryEntry(pth,null,null,null,atts,false);
cpEntries.add(1,cpISDI);

(编辑格式)


I have an Eclipse plugin, that among other things, can create a project and give it several classpath entries. This in and of itself works fine.

These jars do not have source included in the, however there is a URL that can be used for Javadoc. I want to set this up programmatically for these classpath entries that the plug-in creates. This is what I'm doing:

  IClasspathEntry cpEntry;

  File[] jarFile = installFilePath.listFiles();

  IPath jarFilePath;
  for (int fileCount = 0; fileCount < jarFile.length; fileCount++)
  {
      jarFilePath = new Path(jarFile[fileCount].getAbsolutePath());
      cpEntry = JavaCore.newLibraryEntry(jarFilePath, null, null);
      entries.add(cpEntry);
  }

I could not figure out how to set the JavaDoc URL location on a claspath entry. This can be done in the Eclipse UI - for instance, if you right-click the project, go to Properties... -> Java Build Path, and expand one of the JAR entries and edit the "Javadoc Location", you can specify a URL. How do I do this from within a plug-in?

解决方案

I use the following:

        Path   pth = new Path( MY_JARFILE_LOCATION );
        Path   pthd = new Path( MY_JAVADOC_LOCATION );
        ClasspathAttribute att = new ClasspathAttribute("javadoc_location", "file:" + pthd.toOSString());
        IClasspathAttribute[] atts = new IClasspathAttribute[] { att };
        IClasspathEntry cpISDI = JavaCore.newLibraryEntry(pth, null, null, null, atts, false);
        cpEntries.add(1, cpISDI);

(edited formatting)

这篇关于在Eclipse中,如何以编程方式在Classpath条目中设置JavaDoc URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆