Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » How to get hold of appropriate Document object for XML Content Assist ?
How to get hold of appropriate Document object for XML Content Assist ? [message #532138] Fri, 07 May 2010 10:06 Go to next message
Ankit Goel is currently offline Ankit GoelFriend
Messages: 9
Registered: May 2010
Junior Member
Hi:

I am trying to embed StructuredTextViewer in a dialog for editing XML code. I am facing problems with getting content assist to work in a particular scenario - when the XML code in the dialog does not correspond to any external file. Getting hold of a proper document and model has been a problem in such a scenario.

Content assist would work fine only if a proper document is provided to StructuredTextViewer.

If I intend to edit a existing XML file in my dialog I can get hold of the appropriate document this way:

IStructuredModel scratchModel = StructuredModelManager.getModelManager() .getModelForEdit(ContentTypeIdForXML.ContentTypeID_XML,new FileInputStream(new File(<FILE PATH>)), null);

IDocument document = scratchModel.getStructuredDocument();

StructuredTextViewer structuredViewer = new StructuredTextViewer(composite, null, null, false, SWT.NONE);

StructuredTextViewerConfigurationXML sourceViewerConfiguration = new StructuredTextViewerConfigurationXML();

structuredViewer.configure(sourceViewerConfiguration);
structuredViewer.setDocument(document);

But the idea is to open up the dialog, take users input in form of XML and do further processing on the input XML - nowhere the input XML code is written to a file. How do I create a Document/Model for such a case so that contents assist works fine ?

Will appreciate any help on this!

Cheers,
Ankit
Re: How to get hold of appropriate Document object for XML Content Assist ? [message #532501 is a reply to message #532138] Mon, 10 May 2010 09:58 Go to previous messageGo to next message
Sarika Sinha is currently offline Sarika SinhaFriend
Messages: 131
Registered: February 2010
Location: Bangalore, India
Senior Member
Hi,
You can use this signature:
org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.get ModelForEdit(IFile)

This method does not check for physical file's existance. You can pass any path and create IPath - Ifile. Later you can set the text to the socument.


Sarika Sinha
JDT Programmer
Re: How to get hold of appropriate Document object for XML Content Assist ? [message #536108 is a reply to message #532501] Thu, 27 May 2010 06:20 Go to previous messageGo to next message
Ankit Goel is currently offline Ankit GoelFriend
Messages: 9
Registered: May 2010
Junior Member
Hi:

org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.get ModelForEdit(IFile) returns null if the IFile does not exist.

IFile physical existence is checked in the following method

org.eclipse.wst.sse.core.internal.model.ModelManagerImpl >> private IStructuredModel _commonGetModel(IFile file, String id, IModelHandler handler, URIResolver resolver, ReadEditType rwType, String encoding, String lineDelimiter) throws IOException, CoreException

Hence this does not solve my problem!!!

Any other way to get this working without physically creating a file.

Regards,
Ankit
Re: How to get hold of appropriate Document object for XML Content Assist ? [message #536149 is a reply to message #536108] Thu, 27 May 2010 09:26 Go to previous messageGo to next message
Sarika Sinha is currently offline Sarika SinhaFriend
Messages: 131
Registered: February 2010
Location: Bangalore, India
Senior Member
Hi,
Did you try this:
org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.get ModelForEdit(String, InputStream, URIResolver)

by passing null for URIResolver.


Sarika Sinha
JDT Programmer
Re: How to get hold of appropriate Document object for XML Content Assist ? [message #536188 is a reply to message #536149] Thu, 27 May 2010 10:54 Go to previous message
Ankit Goel is currently offline Ankit GoelFriend
Messages: 9
Registered: May 2010
Junior Member
Yeah gr8 this works fine...

Thanks,
Ankit
Previous Topic:Tomcat Server Startup Configuration
Next Topic:How to get a schema parent?
Goto Forum:
  


Current Time: Tue Apr 23 09:37:31 GMT 2024

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

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

Back to the top