Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » StructuredModelManager
StructuredModelManager [message #202898] Tue, 23 October 2007 12:48 Go to next message
Klaus Schaefers is currently offline Klaus SchaefersFriend
Messages: 24
Registered: July 2009
Junior Member
Hello guys,

I have a question concerning the StructuredTextViewer. I'm using it to
display some piece of HTML. Since I only have the html in form of a
String, I put it into an ByteArrayStream and use this stream to load the
structured model. But I have to big problem.

1) Caching. The ModelManager seens to have some cache. How can I force it
to reload the model?

I have used teh fllowing approach:

structuredModel = modelManager.getModelForEdit("xxx.xxx.xxx.xxx",
inputStream, null);
modelManager.reinitialize(structuredModel);

But this does not solve the problem.


2) Internationalization. No matter how I convert the Stream (UTF-8, ...)
chinse characters are broken every time. Does anybody know how to solve
this issue?

Kind Regards,

Klaus
Re: StructuredModelManager [message #202928 is a reply to message #202898] Tue, 23 October 2007 17:59 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Klausing wrote:
> I have a question concerning the StructuredTextViewer. I'm using it to
> display some piece of HTML. Since I only have the html in form of a
> String, I put it into an ByteArrayStream and use this stream to load the
> structured model. But I have to big problem.
>
> 1) Caching. The ModelManager seens to have some cache. How can I force
> it to reload the model?
>
> I have used teh fllowing approach:
>
> structuredModel = modelManager.getModelForEdit("xxx.xxx.xxx.xxx",
> inputStream, null);
> modelManager.reinitialize(structuredModel);
>
> But this does not solve the problem.
>
> 2) Internationalization. No matter how I convert the Stream (UTF-8, ...)
> chinse characters are broken every time. Does anybody know how to solve
> this issue?

For your usage you're better off calling
IModelManager.createUnManagedStructuredModelFor(String) where the
String is the HTML Content Type ID. From there you can just set
your HTML into the document. It should help to avoid any encoding
pitfalls. You can find a similar usage in the
HTMLTemplatePreferencePage.

--
Nitin Dahyabhai
Structured Source Editing


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: StructuredModelManager [message #202963 is a reply to message #202928] Wed, 24 October 2007 15:51 Go to previous messageGo to next message
Klaus Schaefers is currently offline Klaus SchaefersFriend
Messages: 24
Registered: July 2009
Junior Member
Hi, this works great. But until now I release the model from reading. if I
call the release methods now, the following exception will be thrown:


java.lang.IllegalArgumentException: can not release a model without a
document reference
at
org.eclipse.wst.sse.core.internal.FileBufferModelManager.rel easeModel(FileBufferModelManager.java:668)
at
org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.cle anupDiscardedModel(ModelManagerImpl.java:1449)
at
org.eclipse.wst.sse.core.internal.model.ModelManagerImpl.rel easeFromRead(ModelManagerImpl.java:1353)

My code looks like this..

// create moel form string...
structuredModel = modelManager.createUnManagedStructuredModelFor
(ContentTypeIdForHTML.ContentTypeID_HTML); structuredModel.getStructuredDocument().set(mailContent);

// show dialog, let user edit, after save is clicked read the content then
currentModel.releaseFromEdit();
currentModel.releaseFromRead();


Do I have to stop calling this methods?

Klaus
Re: StructuredModelManager [message #203022 is a reply to message #202963] Wed, 24 October 2007 22:08 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Yes, unmanaged models don't need to be released. You do, however,
need to take care to not otherwise leak them somehow.

--
Nitin Dahyabhai
Structured Source Editing


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: StructuredModelManager [message #203346 is a reply to message #203022] Tue, 30 October 2007 08:54 Go to previous messageGo to next message
Klaus Schaefers is currently offline Klaus SchaefersFriend
Messages: 24
Registered: July 2009
Junior Member
Hi, I have changed to way the model is handled now in the way you
suggested. This works fine, but now the html content assitant fails Here
is the stacktrace. What have I done wrong.


java.lang.IllegalStateException: problem getting model
at
org.eclipse.wst.xml.ui.internal.contentassist.AbstractConten tAssistProcessor.computeCompletionProposals(AbstractContentA ssistProcessor.java:1283)
at
org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAs sistProcessor.computeCompletionProposals(HTMLContentAssistPr ocessor.java:302)
at
org.eclipse.wst.sse.ui.internal.contentassist.CompoundConten tAssistProcessor.computeCompletionProposals(CompoundContentA ssistProcessor.java:233)
at
org.eclipse.jface.text.contentassist.ContentAssistant.comput eCompletionProposals(ContentAssistant.java:1612)
at
org.eclipse.jface.text.contentassist.CompletionProposalPopup .computeProposals(CompletionProposalPopup.java:473)
at
org.eclipse.jface.text.contentassist.CompletionProposalPopup .access$16(CompletionProposalPopup.java:470)
at
org.eclipse.jface.text.contentassist.CompletionProposalPopup $2.run(CompletionProposalPopup.java:405)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:67)
at
org.eclipse.jface.text.contentassist.CompletionProposalPopup .showProposals(CompletionProposalPopup.java:399)
at
org.eclipse.jface.text.contentassist.ContentAssistant$2.run( ContentAssistant.java:347)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:123)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3325)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2971)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:820 )
at org.eclipse.jface.window.Window.open(Window.java:796)
Re: StructuredModelManager [message #203378 is a reply to message #203346] Tue, 30 October 2007 17:01 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Klaus Schaefers wrote:
> Hi, I have changed to way the model is handled now in the way you
> suggested. This works fine, but now the html content assitant fails Here
> is the stacktrace. What have I done wrong.
>
>
> java.lang.IllegalStateException: problem getting model
> at
> org.eclipse.wst.xml.ui.internal.contentassist.AbstractConten tAssistProcessor.computeCompletionProposals(AbstractContentA ssistProcessor.java:1283)

Nothing, content assist requires a managed model so it can go from
the source viewer's document to that model.

--
Nitin Dahyabhai
Structured Source Editing


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: StructuredModelManager [message #203418 is a reply to message #203378] Thu, 01 November 2007 05:56 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Nitin Dahyabhai wrote:
> Klaus Schaefers wrote:
>> Hi, I have changed to way the model is handled now in the way you
>> suggested. This works fine, but now the html content assitant fails
>> Here is the stacktrace. What have I done wrong.
>>
>>
>> java.lang.IllegalStateException: problem getting model
>> at
>> org.eclipse.wst.xml.ui.internal.contentassist.AbstractConten tAssistProcessor.computeCompletionProposals(AbstractContentA ssistProcessor.java:1283)
>
>
> Nothing, content assist requires a managed model so it can go from the
> source viewer's document to that model.

Just to followup on this, you'd want to go back to the original
method you posted about since the model is shared in that case.
You can try using IStructuredModel.reload(InputStream), or just set
the text into the document as indicated previously.

--
Nitin Dahyabhai
Structured Source Editing


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Re: source code for org.eclipse.wst.wsdl.validation
Next Topic:Deploy WAR with WTP
Goto Forum:
  


Current Time: Thu Apr 25 02:31:55 GMT 2024

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

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

Back to the top