[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] switching between views
|
Hi,
I have a TreeViewer with a few items. As I scroll through the items, I
want a corresponding view to be shown. Views are automaticly shown in
the perspective.
I tried it like this:
**TreeViewer class**
[...]
// Sends the message that something has changed
getSite().setSelectionProvider(treeViewer);
**
** Listener: FileView class**
public void createPartControl(Composite parent) {
[...]
// listen to the treeViewer
getViewSite().getPage().addSelectionListener(this);
public void selectionChanged(IWorkbenchPart part, ISelection selection)
{
if (selection instanceof IStructuredSelection) {
Object first = ((IStructuredSelection)Selection).getFirstElement();
// make 'first' an Item
Item fitem = new Item();
IWorkbenchPage page =
part.getSite().getWorkbenchWindow().getActivePage();
if (first instanceof Item) {
fitem = (Item) first;
if (fitem.getName() == "File") {
lblfName.setText(fitem.getName());
// Put the focus
try {
LabelView lview = (LabelView) page.showView(FILEVIEW_ID);
} catch (PartInitException e) {
} } } }
**
Other listenerView classes have similar code.
First time I select an item on the tree, the focus is correctly set on
the wanted View. But allready there something goes wrong, the
selectionprovider doesn't seem to send the next events anymore. It gives
a "Unhandled exception caught in event loop.
java.lang.NullPointerException" when it's in Workbench.runEventLoop().
Do you have a solution for my problem ?
Many thanks,
Sebastiaan Wauters
sebastiaan.wauters@xxxxxxxxxx