1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
class FolderNode extends TreeNode
{
private File fFolder; /* actual data object */
public FolderNode(File folder) {
this(null, folder);
}
public FolderNode(ITreeNode parent, File folder) {
super(parent);
fFolder = folder;
}
public String getName() {
return "FOLDER: " + fFolder.getName();
}
public Image getImage() {
ImageDescriptor descriptor=null;
if(getName.equals("ABSTRACT")){
descriptor=(AbstractUIPlugin.imageDescriptorFromPlugin (Activator.PLUGIN_ID, ABSTRACT_CLASS.gif));}
else{
descriptor=(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, CONCRET_CLASS.gif));}
Image image = descriptor.createImage();
return image;
}
}
protected void createChildren(List children)
{
File[] childFiles = fFolder.listFiles();
for(int i=0; i<childFiles.length; i++)
{
File childFile = childFiles[i];
if( childFile.isDirectory() )
children.add(new FolderNode(this, childFile));
else
children.add(new FileNode(this, childFile));
}
}
}
il s'agit d'une modification du code http://www.eclipsezone.com/eclipse/forums/t53983.html
pour y rajouter des images particulieres |
Partager