Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Call Javadoc View from own editor
Call Javadoc View from own editor [message #756075] Thu, 10 November 2011 19:13 Go to next message
Jan Christian Krause is currently offline Jan Christian KrauseFriend
Messages: 1
Registered: November 2011
Junior Member
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:
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);
}


In the init-method I register my selection provider

		getSite().setSelectionProvider(this);


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
Re: Call Javadoc View from own editor [message #756535 is a reply to message #756075] Mon, 14 November 2011 09:01 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 10.11.2011 20:13, 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.
Make sure the Javadoc view is already open and that 'Link with
Selection' is enabled. If that's the case and it's still not working,
then start debugging in
org.eclipse.jdt.internal.ui.infoviews.AbstractInfoView.selectionChanged(IWorkbenchPart,
ISelection).

Dani
>
> In my editor I implemented the interface ISelectionProvider:
>
> 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);
> }
>
>
> In the init-method I register my selection provider
>
>
> getSite().setSelectionProvider(this);
>
>
> 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
Previous Topic:"Comparison method violates its general contract!" Error
Next Topic:no grammar constraints dtd or xml schema detected for the document
Goto Forum:
  


Current Time: Fri Mar 29 08:17:57 GMT 2024

Powered by FUDForum. Page generated in 0.03572 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top