Home » Eclipse Projects » Rich Client Platform (RCP) » How to view the outline and property sheet views in an RCP application?
| | | | |
Re: How to view the outline and property sheet views in an RCP application? [message #466870 is a reply to message #466441] |
Wed, 25 April 2007 20:24   |
Eclipse User |
|
|
|
Originally posted by: jweeks.neuraldk.org
valere fedronic wrote:
> Take a look at this article:
>
http://wiki.eclipse.org/index.php/FAQ_How_do_I_create_an_Out line_view_for_my_own_language_editor%3F
I believe there might be some problems with this article... perhaps someone
can explain to me how I should be doing this, as I used this article as a
template (and also its associated source at
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.exam ples.javaeditor/Eclipse
Java Editor
Example/org/eclipse/ui/examples/javaeditor/JavaContentOutlin ePage.java?view=markup)
and I'm still having issues.
The problem in question is that the TreeViewer is never created, because
createControl(Composite parent) is never called.
In the tutorial, createControl() is overridden, but never explicitly
executed. Even inside getAdapter(Class required) the outline page is
simply constructed, and createControl() is never called. From this, I
assumed that the requester of getAdapter() would implicitly call
createControl() but this doesn't appear to be the case.
So, long story short; who should be calling createControl()? And, if *I*
should be doing so, what should I be passing in as 'parent'?
Thanks,
Jeff
|
|
|
Re: How to view the outline and property sheet views in an RCP application? [message #466872 is a reply to message #466870] |
Wed, 25 April 2007 21:41   |
Eclipse User |
|
|
|
Originally posted by: jweeks.neuraldk.org
--nextPart1207067.kPSuJC0pKQ
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8Bit
It turns out that this was a red herring. The problem below wasn't that
createControl() wasn't being called, it was that update() was being called
before the control was created.
I've fixed this, however, and I'm still receiving a default Outline window
(contains only the text "An outline is not available").
I get no errors, exceptions, or any indication that something has gone
wrong. Could someone please suggest what might be wrong, or some method of
debugging this issue? So far everything looks good... I see it iterate
through all my Segment elements, but none are displayed (I've attached the
trace, if anyone's interested).
Thanks,
Jeff
Jeff Weeks [ neuraldk ] wrote:
> valere fedronic wrote:
>
>> Take a look at this article:
>>
>
http://wiki.eclipse.org/index.php/FAQ_How_do_I_create_an_Out line_view_for_my_own_language_editor%3F
>
> I believe there might be some problems with this article... perhaps
> someone can explain to me how I should be doing this, as I used this
> article as a template (and also its associated source at
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.exam ples.javaeditor/Eclipse
> Java Editor
>
Example/org/eclipse/ui/examples/javaeditor/JavaContentOutlin ePage.java?view=markup)
> and I'm still having issues.
>
> The problem in question is that the TreeViewer is never created, because
> createControl(Composite parent) is never called.
>
> In the tutorial, createControl() is overridden, but never explicitly
> executed. Even inside getAdapter(Class required) the outline page is
> simply constructed, and createControl() is never called. From this, I
> assumed that the requester of getAdapter() would implicitly call
> createControl() but this doesn't appear to be the case.
>
> So, long story short; who should be calling createControl()? And, if *I*
> should be doing so, what should I be passing in as 'parent'?
>
> Thanks,
> Jeff
--nextPart1207067.kPSuJC0pKQ
Content-Type: text/x-java; name="LogOutlinePage.java"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="LogOutlinePage.java"
package tvnavtraceviewer.editors;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.part.IPage;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import java.util.List;
import java.util.ArrayList;
import java.text.MessageFormat;
import org.eclipse.jface.text.IPositionUpdater;
import org.eclipse.jface.text.DefaultPositionUpdater;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.IStructuredSelection;
public class LogOutlinePage extends ContentOutlinePage
{
protected Object input;
protected IDocumentProvider provider;
protected ITextEditor editor;
protected static class Segment
{
public String name;
public Position position;
public Segment(String name, Position position)
{
this.name = name;
this.position = position;
}
public String toString()
{
return name;
}
}
protected class ContentProvider implements ITreeContentProvider
{
protected final static String SEGMENTS= IDocument.DEFAULT_CATEGORY; //"__java_segments"; //$NON-NLS-1$
protected IPositionUpdater fPositionUpdater= new DefaultPositionUpdater(SEGMENTS);
protected List fContent= new ArrayList(10);
protected void parse(IDocument document)
{
int lines = document.getNumberOfLines();
int increment = Math.max(Math.round(lines / 10), 10);
for (int line = 0; line < lines; line += increment)
{
int length = increment;
if (line + increment > lines)
{
length = lines - line;
}
try
{
int offset = document.getLineOffset(line);
int end = document.getLineOffset(line + length);
length = end - offset;
Position p = new Position(offset, length);
document.addPosition(SEGMENTS, p);
fContent.add(
new Segment(
/*
MessageFormat.format(
"linenum " + line,
new Object[] { new Integer(offset) }
),
p
*/
"linenum" + line, p
)
); //$NON-NLS-1$
} catch (BadPositionCategoryException x)
{
}
catch (BadLocationException x)
{
}
}
}
/*
* @see IContentProvider#inputChanged(Viewer, Object, Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
{
if (oldInput != null)
{
IDocument document= provider.getDocument(oldInput);
if (document != null)
{
try
{
document.removePositionCategory(SEGMENTS);
} catch (BadPositionCategoryException x)
{
}
document.removePositionUpdater(fPositionUpdater);
}
}
fContent.clear();
if (newInput != null)
{
IDocument document= provider.getDocument(newInput);
if (document != null)
{
document.addPositionCategory(SEGMENTS);
document.addPositionUpdater(fPositionUpdater);
parse(document);
}
}
}
/*
* @see IContentProvider#dispose
*/
public void dispose()
{
if (fContent != null)
{
fContent.clear();
fContent= null;
}
}
/*
* @see IContentProvider#isDeleted(Object)
*/
public boolean isDeleted(Object element)
{
return false;
}
/*
* @see IStructuredContentProvider#getElements(Object)
*/
public Object[] getElements(Object element)
{
return fContent.toArray();
}
/*
* @see ITreeContentProvider#hasChildren(Object)
*/
public boolean hasChildren(Object element)
{
boolean children = (element == input);
return children;
}
/*
* @see ITreeContentProvider#getParent(Object)
*/
public Object getParent(Object element)
{
if (element instanceof Segment)
{
return input;
}
else
{
return null;
}
}
/*
* @see ITreeContentProvider#getChildren(Object)
*/
public Object[] getChildren(Object element)
{
if (element == input)
{
return fContent.toArray();
}
else
{
return new Object[0];
}
}
}
public LogOutlinePage(IDocumentProvider provider, ITextEditor editor)
{
super();
this.provider= provider;
this.editor= editor;
}
/* override */
public void createControl(Composite parent)
{
super.createControl(parent);
System.out.println("LogOutlinePage::createControl()");
TreeViewer viewer= getTreeViewer();
viewer.setContentProvider(new ContentProvider());
viewer.setLabelProvider(new LabelProvider());
viewer.addSelectionChangedListener(this);
if (input != null)
{
System.out.println("Calling viewer.setInput");
viewer.setInput(input);
}
update();
}
/* override */
public void selectionChanged(SelectionChangedEvent event)
{
super.selectionChanged(event);
ISelection selection= event.getSelection();
if (selection.isEmpty())
{
editor.resetHighlightRange();
}
else
{
Segment segment= (Segment) ((IStructuredSelection) selection).getFirstElement();
int start= segment.position.getOffset();
int length= segment.position.getLength();
try
{
editor.setHighlightRange(start, length, true);
} catch (IllegalArgumentException x)
{
editor.resetHighlightRange();
}
}
}
/* new */
public void setInput(Object input)
{
this.input = input;
update();
}
/* new */
public void update()
{
TreeViewer viewer= getTreeViewer();
System.out.println("LogOutlinePage::update()");
if (viewer != null)
{
Control control= viewer.getControl();
if (control != null && !control.isDisposed())
{
control.setRedraw(false);
viewer.setInput(input);
viewer.expandAll();
control.setRedraw(true);
}
}
else
{
System.out.println("tree viewer is null in LogOutlinePage::update()");
}
}
public void dispose()
{
// TODO Auto-generated method stub
}
public Control getControl()
{
// TODO Auto-generated method stub
return null;
}
public void setActionBars(IActionBars actionBars)
{
// TODO Auto-generated method stub
}
public void setFocus()
{
// TODO Auto-generated method stub
}
public void addSelectionChangedListener(ISelectionChangedListener listener)
{
// TODO Auto-generated method stub
}
public ISelection getSelection()
{
// TODO Auto-generated method stub
return null;
}
public void removeSelectionChangedListener(ISelectionChangedListener listener)
{
// TODO Auto-generated method stub
}
public void setSelection(ISelection selection)
{
// TODO Auto-generated method stub
}
}
--nextPart1207067.kPSuJC0pKQ--
|
|
|
Re: How to view the outline and property sheet views in an RCP application? [message #466900 is a reply to message #466872] |
Thu, 26 April 2007 08:00   |
Eclipse User |
|
|
|
Originally posted by: valere.fedronic.ext.streamezzo.com
It is because you have overridden getControl() to return null.
Do not override the following methods:
public void dispose()
public Control getControl()
public void setActionBars(IActionBars actionBars)
public void setFocus()
public void addSelectionChangedListener(ISelectionChangedListener listener)
public ISelection getSelection()
public void removeSelectionChangedListener(ISelectionChangedListener
listener)
public void setSelection(ISelection selection)
valere.
Jeff Weeks [ neuraldk ] a écrit :
> It turns out that this was a red herring. The problem below wasn't that
> createControl() wasn't being called, it was that update() was being called
> before the control was created.
>
> I've fixed this, however, and I'm still receiving a default Outline window
> (contains only the text "An outline is not available").
>
> I get no errors, exceptions, or any indication that something has gone
> wrong. Could someone please suggest what might be wrong, or some method of
> debugging this issue? So far everything looks good... I see it iterate
> through all my Segment elements, but none are displayed (I've attached the
> trace, if anyone's interested).
>
> Thanks,
> Jeff
>
> Jeff Weeks [ neuraldk ] wrote:
>
>> valere fedronic wrote:
>>
>>> Take a look at this article:
>>>
> http://wiki.eclipse.org/index.php/FAQ_How_do_I_create_an_Out line_view_for_my_own_language_editor%3F
>> I believe there might be some problems with this article... perhaps
>> someone can explain to me how I should be doing this, as I used this
>> article as a template (and also its associated source at
>>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.exam ples.javaeditor/Eclipse
>> Java Editor
>>
> Example/org/eclipse/ui/examples/javaeditor/JavaContentOutlin ePage.java?view=markup)
>> and I'm still having issues.
>>
>> The problem in question is that the TreeViewer is never created, because
>> createControl(Composite parent) is never called.
>>
>> In the tutorial, createControl() is overridden, but never explicitly
>> executed. Even inside getAdapter(Class required) the outline page is
>> simply constructed, and createControl() is never called. From this, I
>> assumed that the requester of getAdapter() would implicitly call
>> createControl() but this doesn't appear to be the case.
>>
>> So, long story short; who should be calling createControl()? And, if *I*
>> should be doing so, what should I be passing in as 'parent'?
>>
>> Thanks,
>> Jeff
|
|
|
Re: How to view the outline and property sheet views in an RCP application? [message #466985 is a reply to message #466900] |
Thu, 26 April 2007 20:49  |
Eclipse User |
|
|
|
Originally posted by: jweeks.neuraldk.org
D'oh! I totally neglected to take into account those!
Thanks!
--Jeff
> It is because you have overridden getControl() to return null.
>
> Do not override the following methods:
>
> public void dispose()
> public Control getControl()
> public void setActionBars(IActionBars actionBars)
> public void setFocus()
> public void addSelectionChangedListener(ISelectionChangedListener
> listener) public ISelection getSelection()
>
> public void removeSelectionChangedListener(ISelectionChangedListener
> listener)
> public void setSelection(ISelection selection)
>
> valere.
>
> Jeff Weeks [ neuraldk ] a écrit :
>> It turns out that this was a red herring. The problem below wasn't that
>> createControl() wasn't being called, it was that update() was being
>> called before the control was created.
>>
>> I've fixed this, however, and I'm still receiving a default Outline
>> window (contains only the text "An outline is not available").
>>
>> I get no errors, exceptions, or any indication that something has gone
>> wrong. Could someone please suggest what might be wrong, or some method
>> of
>> debugging this issue? So far everything looks good... I see it iterate
>> through all my Segment elements, but none are displayed (I've attached
>> the trace, if anyone's interested).
>>
>> Thanks,
>> Jeff
>>
>> Jeff Weeks [ neuraldk ] wrote:
>>
>>> valere fedronic wrote:
>>>
>>>> Take a look at this article:
>>>>
>>
http://wiki.eclipse.org/index.php/FAQ_How_do_I_create_an_Out line_view_for_my_own_language_editor%3F
>>> I believe there might be some problems with this article... perhaps
>>> someone can explain to me how I should be doing this, as I used this
>>> article as a template (and also its associated source at
>>>
>>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ui.exam ples.javaeditor/Eclipse
>>> Java Editor
>>>
>>
Example/org/eclipse/ui/examples/javaeditor/JavaContentOutlin ePage.java?view=markup)
>>> and I'm still having issues.
>>>
>>> The problem in question is that the TreeViewer is never created, because
>>> createControl(Composite parent) is never called.
>>>
>>> In the tutorial, createControl() is overridden, but never explicitly
>>> executed. Even inside getAdapter(Class required) the outline page is
>>> simply constructed, and createControl() is never called. From this, I
>>> assumed that the requester of getAdapter() would implicitly call
>>> createControl() but this doesn't appear to be the case.
>>>
>>> So, long story short; who should be calling createControl()? And, if
>>> *I* should be doing so, what should I be passing in as 'parent'?
>>>
>>> Thanks,
>>> Jeff
|
|
|
Goto Forum:
Current Time: Sun May 18 22:21:17 EDT 2025
Powered by FUDForum. Page generated in 0.03721 seconds
|