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("\\_\\_", ".");
}
return ""; //$NON-NLS-1$
}
});
modulesViewer.addSelectionChangedListener(new ISelectionChangedListener(){
public void selectionChanged( SelectionChangedEvent event ) {
if (!(event.getSelection() instanceof IStructuredSelection)) {
return;
}
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
Object selectedItem = sel.getFirstElement();
if (selectedItem == null) {
// unselected, show empty panel
putUnselected();
return;
}
if (selectedItem instanceof ViewerModule) {
ModuleDescription currentSelectedModule = ((ViewerModule) selectedItem).getModuleDescription();
currentSelectedModuleGui = new ModuleGui(currentSelectedModule);
Control control = currentSelectedModuleGui.makeGui(modulesGuiComposite, false);
// Label dummyLabel = new Label(modulesGuiComposite, SWT.NONE);