Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » SourceViewer with StructuredTextViewerConfigurationXSL not editable
SourceViewer with StructuredTextViewerConfigurationXSL not editable [message #1277792] Wed, 26 March 2014 13:26 Go to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 530
Registered: June 2011
Senior Member
Hi,

I have a small test RCP application with one view containing one source viewer. On application load source viewer is shown on the view but it is not editable even though i have used the method setEditable(true) and when i close the rcp application i get folling messages on the console.

!ENTRY org.eclipse.ui 4 4 2014-03-26 14:20:02.081
!MESSAGE Invalid preference page path: XML Syntax

!ENTRY org.eclipse.ui 4 4 2014-03-26 14:20:02.088
!MESSAGE Invalid preference page path: XSLT Validation


Folling is the code used to create source viewer.

CompositeRuler ruler = new CompositeRuler();
LineNumberRulerColumn lnrc = new LineNumberRulerColumn(); lnrc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
lnrc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
ruler.addDecorator(0,lnrc);
SourceViewer viewer = new StructuredTextViewer(parent, ruler, null, true, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
((StructuredTextViewer) viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
viewer.configure(new StructuredTextViewerConfigurationXSL());
viewer.setEditable(true);

Do you have any idea why source viewer is not editable?

Cheers

Re: SourceViewer with StructuredTextViewerConfigurationXSL not editable [message #1277895 is a reply to message #1277792] Wed, 26 March 2014 15:57 Go to previous messageGo to next message
ModelGeek Mising name is currently offline ModelGeek Mising nameFriend
Messages: 530
Registered: June 2011
Senior Member
Hi,

I have fixed the problem. Actually viewer requires a document to work with, so i created a IDocument object.

IStructuredModel scratchModel = StructuredModelManager.getModelManager().getModelForEdit(file);
IDocument document = scratchModel.getStructuredDocument();
viewer.setDocument(document);

cheers,
Re: SourceViewer with StructuredTextViewerConfigurationXSL not editable [message #1282732 is a reply to message #1277895] Wed, 02 April 2014 18:21 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2341
Registered: July 2009
Senior Member
Ha, you beat me to it. You can find an example of this being done for the templates preference pages in WTP, e.g. org.eclipse.wst.xml.ui.internal.preferences.XMLTemplatePreferencePage.doCreateViewer(Composite, SourceViewerConfiguration) for the XML editor templates.

Also, be sure to call IStructuredModel.releaseFromEdit() when you're done--it's like a reference counted resource.


---
Nitin Dahyabhai
Eclipse WTP, IBM
Previous Topic:After Kepler Upgrade: javax.servlet.jsp.tagext.SimpleTagSupport not found
Next Topic:SSE ITextHover Extension
Goto Forum:
  


Current Time: Sat Dec 20 03:08:13 GMT 2014

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

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