SourceViewer with StructuredTextViewerConfigurationXML - Exception [message #170025] |
Wed, 24 May 2006 12:04 |
Eclipse User |
|
|
|
Originally posted by: sparky.flo.com
hy!
currently, i am developing my first application with the eclipse-api. so
far, everything worked fine, but now i have a problem, i could not solve on
my own:
i have a SourceViewer and i want to show xml-content. i would like the
content to be syntax highlighted, so i searched the web and found the
StructuredTextViewerConfigurationXml
i tried to do something like that:
this.view_xml = new SourceViewer(this.shell, null, SWT.BORDER);
this.view_xml.setEditable(false);
this.view_xml.setDocument(new Document(xml_content));
StructuredTextViewerConfigurationXML conf = new
StructuredTextViewerConfigurationXML();
this.view_xml.configure(conf);
i tried it in two ways:
--- application as an applet ---
whenever i create an instance of StructuredTextViewerConfigurationXML,
it throws a null-pointer exception (in the constructor).
Exception in thread "main" java.lang.NullPointerException
at
org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration.cre ateCombinedPreferenceStore(StructuredTextViewerConfiguration .java:96)
at
org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration.<init >(StructuredTextViewerConfiguration.java:86)
at
org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML. <init>(StructuredTextViewerConfigurationXML.java:78)
--- application as an eclipse plugin ---
I am able to create an instance, but if i try to configure my source-viewer,
it throws an exception
java.lang.ClassCastException: org.eclipse.jface.text.source.SourceViewer
at
org.eclipse.wst.sse.ui.StructuredTextViewerUndoManager.conne ct(StructuredTextViewerUndoManager.java:73)
at org.eclipse.jface.text.TextViewer.activatePlugins(TextViewer .java:1525)
at
org.eclipse.jface.text.source.SourceViewer.activatePlugins(S ourceViewer.java:414)
at
org.eclipse.jface.text.source.SourceViewer.configure(SourceV iewer.java:385)
i should work both ways: as plugin as well as an applet ...
can anybody help me with that?
thanks in advance!
florian
|
|
|
Re: SourceViewer with StructuredTextViewerConfigurationXML - Exception [message #171280 is a reply to message #170025] |
Thu, 15 June 2006 07:49 |
|
The StructuredTextViewerConfiguration* classes expect only to be
used with the SSE StructuredTextViewer, and that in turn with an
IStructuredDocument. Without all 3 in place, you're likely to
continue running into odd exceptions along the way. We haven't
placed much focus in allowing what you seem to be attempting (hence
the viewer class remaining internal), so your mileage may vary.
--
- Nitin
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
Powered by
FUDForum. Page generated in 0.02881 seconds