使用以下方法获得Java性质:
IExtensionPoint ex= Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.core.resources.natures");
并使用以下方法获取自然图像:
IExtensionPoint ex2= Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.ui.ide.projectNatureImages");
所以,我有一个包含IExtension元素和Image元素的对象:
public class NatureInformationWrapper {
private IExtension extension;
private Image image;
public IExtension getExtension() {
return extension;
}
public void setExtension(IExtension extension) {
this.extension = extension;
}
public Image getImage() {
return image;
}
public void setImage(Image image) {
this.image = image;
}
}
我为此设置了IExtensions:
ArrayList<String> identifiers=new ArrayList<String>();
ArrayList<NatureInformationWrapper> extensionsList= new
ArrayList<NatureInformationWrapper>();
for(int index=0; index< extensions.length; index++) {
extensionsList.add(niw);
}
我将图像设置为此:
for(int index2=0; index2<imageExtensionsList.size(); index2++) {
IConfigurationElement[] configurationElements=imageExtensionsList.get(index2).getConfigurationElements();
for(int index3=0; index3<configurationElements.length; index3++) {
String natureId=imageExtensionsList.get(index2).getConfigurationElements()[index3].getAttribute("natureId");
for(int listInputIndex=0; listInputIndex<extensionsList.size(); listInputIndex++) {
String currentNatureId=extensionsList.get(listInputIndex).getExtension().getUniqueIdentifier();
if(natureId.equals(currentNatureId)) {
Image img=null;
String icon = configurationElements[index3].getAttribute("icon");
icon = icon.replace("$nl$", "");
if (icon !=null) {
final String cont = configurationElements[index3].getContributor().getName();
final Bundle bundle= Platform.getBundle(cont);
final URL entry = bundle.getEntry(icon);
final ImageDescriptor des = ImageDescriptor.createFromURL(entry);
img= des.createImage();
}
extensionsList.get(listInputIndex).setImage(img);
}
}
}
}
但是ex2.getExtensions();
总是返回一个元素,它是org.eclipse.jdt.core.javanature的IExtension。
我的问题是,如何从ex2.getExtensions();
获得更多IExtensions?
我需要安装一些东西吗?