/**
* Shows the tab associated with the selection.
*/
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
IFeaturePanel tab = null;
FeaturePanelTabDescriptor descriptor = (FeaturePanelTabDescriptor) selection
.getFirstElement();
if (descriptor == null) {
// pretend the tab is empty.
hideTab(currentTab);
} else {
// create tab if necessary
// can not cache based on the id - tabs may have the same id,
// but different section depending on the selection
//
tab = descriptorToTab.get(descriptor);
if (tab != currentTab) {
hideTab(currentTab);
}
Composite tabComposite = (Composite) tabToComposite.get(tab);
if (tabComposite == null) {
tabComposite = createTabComposite();
tab.createPartControl(tabComposite);
try {
tab.init(site, null);
} catch (PartInitException e) {
IStatus status = new Status(IStatus.ERROR, descriptor.getEntry().getId(),
"Problem initializing feature panel", e);
FeatureEditorPlugin.getDefault().getLog().log(status);
}
tabToComposite.put(tab, tabComposite);
}
// force widgets to be resized
// tab.setInput(tabbedPropertyViewer.getWorkbenchPart(),(ISelection)
// tabbedPropertyViewer.getInput());
// store tab selection
storeCurrentTabSelection(descriptor.getLabel());
if (tab != currentTab) {
showTab(tab);
}
tab.refresh();
}
tabbedPropertyComposite.getTabComposite().layout(true);
currentTab = tab;
resizeScrolledComposite();