List< ? > list = (List< ? >) parentElement;
Object[] array = list.toArray();
return array;
}
if (parentElement instanceof ViewerFolder) {
ViewerFolder folder = (ViewerFolder) parentElement;
List<ViewerFolder> subFolders = folder.getSubFolders();
List<ViewerModule> modules = folder.getModules();
List<Object> allObjs = new ArrayList<Object>();
allObjs.addAll(subFolders);
allObjs.addAll(modules);
return allObjs.toArray();
}
return new Object[0];
}
public Object getParent( Object element ) {
if (element instanceof ViewerFolder) {
ViewerFolder folder = (ViewerFolder) element;
return folder.getParentFolder();
}
if (element instanceof ViewerModule) {
ViewerModule module = (ViewerModule) element;
return module.getParentFolder();
}
return null;
}
public boolean hasChildren( Object element ) {
return getChildren(element).length > 0;
}
public void dispose() {
}
public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
}
});
modulesViewer.setLabelProvider(new LabelProvider(){
public Image getImage( Object element ) {
if (element instanceof ViewerFolder) {
return ImageCache.getInstance().getImage(ImageCache.CATEGORY);
}
if (element instanceof ViewerModule) {
ModuleDescription md = ((ViewerModule) element).getModuleDescription();
Status status = md.getStatus();
if (status == Status.experimental) {
return ImageCache.getInstance().getImage(ImageCache.MODULEEXP);
} else {
return ImageCache.getInstance().getImage(ImageCache.MODULE);
}
}
return null;
}
public String getText( Object element ) {
if (element instanceof ViewerFolder) {
ViewerFolder categoryFolder = (ViewerFolder) element;
return categoryFolder.getName();
}
if (element instanceof ViewerModule) {
ModuleDescription module = ((ViewerModule) element).getModuleDescription();
return module.getName().replaceAll("\\_\\_", ".");
}