Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-ui-dev] How to call Javadoc view?

Hi Jan.  

I use the same mechanism in one of my tools (Ferret) and the Javadoc view correctly reacts to selections.

One thing you haven't shown is how you pump out your view's selections (i.e., calling your setSelection()).  If your viewers (say a JFace TreeViewer) is manipulating IJavaElements, you can actually just do:

	getSite().setSelectionProvider(myTreeViewer);

Brian.

On 11-Nov-2011, at 3:45 AM, Jan-Christian Krause wrote:

> Hello everybody,
> 
> I wrote a new editor to document my APIs. It also supports Java and Javadoc. I would like to show the Javadoc of the current selected method by my editor in the Javadoc view (like the Project Explorer does with Java-Files). But I didn't get it working yet.
> 
> In my editor I implemented the interface ISelectionProvider:
> 
> <code>
> private Set<ISelectionChangedListener> listeners = new HashSet<ISelectionChangedListener>();
> 
> @Override
> public void setSelection(ISelection arg0)
> {
>        // Get the selected method from my editor...
> 	IJavaElement selection = (IJavaElement) ...;
> 
>        if (selection != null)
> 	{
> 	  Object[] elements = new Object[1];
> 	  elements[0] = selection;
> 
> 	StructuredSelection sel = new StructuredSelection(elements);
> 	SelectionChangedEvent event = new SelectionChangedEvent(this, sel);
> 
> 	for (ISelectionChangedListener listener : listeners)
> 	{
> 		listener.selectionChanged(event);
> 	}
> }
> 
> @Override
> public void removeSelectionChangedListener(ISelectionChangedListener arg0)
> {
> listeners.remove(arg0);
> }
> 
> @Override
> public ISelection getSelection()
> {
>  // Get the method from my editor ...	
>  IJavaElement selection = (IJavaElement)...;
> 
>  if (selection != null)
>  {
> 	Object[] elements = new Object[1];
> 	elements[0] = selection;
> 
> 	StructuredSelection sel = new StructuredSelection(elements);
> 							
> 	return sel;
>  }
> 				
>  return null;
> }
> 
> @Override
> public void addSelectionChangedListener(ISelectionChangedListener arg0)
> {
> 	listeners.add(arg0);
> }
> </code>
> 
> In the init-method I register my selection provider
> 
> <code>
> getSite().setSelectionProvider(this);
> </code>
> 
> 
> But when changing my selected method, the Javadoc View does not react. By using the debugger I could see that the changed selection is set to the listeners. But there is no Javadoc view in there. Is my approach correct? Could anybody give me a hint or an example?
> 
> Greetings
> 
> Jan Chistian
> _______________________________________________
> jdt-ui-dev mailing list
> jdt-ui-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jdt-ui-dev



Back to the top