Home » Eclipse Projects » Eclipse 4 » Load XWT from a string in memory(Loading XWT from a string in memory)
| | | | | | | | | | |
Re: Load XWT from a string in memory [message #520972 is a reply to message #520960] |
Tue, 16 March 2010 01:45 |
No real name Messages: 17 Registered: March 2010 |
Junior Member |
|
|
In the ElementManager method below,
public Element load(InputStream stream, URL url) throws Exception {
reset();
// Initialize document root
PushbackInputStream pis = null;
if (stream != null) {
if (stream instanceof PushbackInputStream) {
pis = (PushbackInputStream) stream;
} else {
pis = new PushbackInputStream(stream, 4);
}
}
documentRoot.init(pis, url.toString());
InputStream input = pis;
if (pis == null) {
input = documentRoot.openStream();
}
doLoad(input);
input = documentRoot.openStream();
loadXData(input);
input.close();
return rootElement;
}
The url argument can't be null because of
documentRoot.init(pis, url.toString());.
So even if you pass in a valid stream like
ByteArrayInputStream bs = new ByteArrayInputStream(myXwt.getBytes());
to
Control c = XWT.load(aShell, bs, myUrl, contextObject);
the documentRoot.openStream() call requires a valid URL to
keep "new URL(...).openStream();" happy.
So if you have a stream with your XWT spec, I am not sure
how this combination of arguments makes sense to use.
The above post states,
"The second argument indicates the location to find the Java class event
handler. It shouldn't be null."
But I am not sure what an example of a "Java class event handler"
would be especially when you are trying to debug things.
Maybe Yves YANG can elaborate???
WRT the question of where one can get a "context" for the statement,
"You can call XWT.findElementByName(context, "<my name>")"
see the post within
http://www.eclipse.org/forums/index.php?t=msg&goto=50515 3&
|
|
|
Re: Load XWT from a string in memory [message #521019 is a reply to message #520972] |
Tue, 16 March 2010 08:42 |
Yves YANG Messages: 688 Registered: July 2009 |
Senior Member |
|
|
<allygirl@mailinator.com> wrote in message
news:hnmnse$e4m$1@build.eclipse.org...
> In the ElementManager method below,
>
> public Element load(InputStream stream, URL url) throws Exception {
> reset();
> // Initialize document root
> PushbackInputStream pis = null;
> if (stream != null) {
> if (stream instanceof PushbackInputStream) {
> pis = (PushbackInputStream) stream;
> } else {
> pis = new PushbackInputStream(stream, 4);
> }
> }
> documentRoot.init(pis, url.toString());
> InputStream input = pis;
> if (pis == null) {
> input = documentRoot.openStream();
> }
> doLoad(input);
> input = documentRoot.openStream();
> loadXData(input);
> input.close();
> return rootElement;
> }
>
> The url argument can't be null because of
> documentRoot.init(pis, url.toString());.
>
> So even if you pass in a valid stream like
> ByteArrayInputStream bs = new ByteArrayInputStream(myXwt.getBytes());
> to
> Control c = XWT.load(aShell, bs, myUrl, contextObject);
> the documentRoot.openStream() call requires a valid URL to
> keep "new URL(...).openStream();" happy.
> So if you have a stream with your XWT spec, I am not sure how this
> combination of arguments makes sense to use.
>
> The above post states, "The second argument indicates the location to find
> the Java class event
> handler. It shouldn't be null."
>
> But I am not sure what an example of a "Java class event handler"
> would be especially when you are trying to debug things.
we need to develop a snippet. Unfortunately, I'm busy for eclipsecon for
now. I can do it after. Please fill a bug and CC to me.
This feature is used by our XML editor for instant preview of the code in
memory. The class is XWTView in the plugin org.eclipse.e4.xwt.tools.ui.
best regards
Yves YANG
>
> Maybe Yves YANG can elaborate???
>
> WRT the question of where one can get a "context" for the statement,
> "You can call XWT.findElementByName(context, "<my name>")"
> see the post within
> http://www.eclipse.org/forums/index.php?t=msg&goto=50515 3&
|
|
| | |
Re: Load XWT from a string in memory [message #570569 is a reply to message #570559] |
Mon, 15 March 2010 11:58 |
Konstantin Scheglov Messages: 555 Registered: July 2009 |
Senior Member |
|
|
I use following code to render XWT document.
String content = m_context.getContent();
Map<String, Object> options = Maps.newHashMap();
XWT.loadWithOptions(IOUtils.toInputStream(content), url, options);
Where IOUtils is org.apache.commons.io.IOUtils is from Jakarta Commons.
--
Konstantin Scheglov,
Instantiations, Inc.
Konstantin Scheglov,
Google, Inc.
|
|
| | | | | | |
Re: Load XWT from a string in memory [message #570715 is a reply to message #570703] |
Tue, 16 March 2010 01:45 |
No real name Messages: 17 Registered: March 2010 |
Junior Member |
|
|
In the ElementManager method below,
public Element load(InputStream stream, URL url) throws Exception {
reset();
// Initialize document root
PushbackInputStream pis = null;
if (stream != null) {
if (stream instanceof PushbackInputStream) {
pis = (PushbackInputStream) stream;
} else {
pis = new PushbackInputStream(stream, 4);
}
}
documentRoot.init(pis, url.toString());
InputStream input = pis;
if (pis == null) {
input = documentRoot.openStream();
}
doLoad(input);
input = documentRoot.openStream();
loadXData(input);
input.close();
return rootElement;
}
The url argument can't be null because of
documentRoot.init(pis, url.toString());.
So even if you pass in a valid stream like
ByteArrayInputStream bs = new ByteArrayInputStream(myXwt.getBytes());
to
Control c = XWT.load(aShell, bs, myUrl, contextObject);
the documentRoot.openStream() call requires a valid URL to
keep "new URL(...).openStream();" happy.
So if you have a stream with your XWT spec, I am not sure
how this combination of arguments makes sense to use.
The above post states,
"The second argument indicates the location to find the Java class event
handler. It shouldn't be null."
But I am not sure what an example of a "Java class event handler"
would be especially when you are trying to debug things.
Maybe Yves YANG can elaborate???
WRT the question of where one can get a "context" for the statement,
"You can call XWT.findElementByName(context, "<my name>")"
see the post within
http://www.eclipse.org/forums/index.php?t=msg&goto=50515 3&
|
|
|
Re: Load XWT from a string in memory [message #570764 is a reply to message #570715] |
Tue, 16 March 2010 08:42 |
Yves YANG Messages: 688 Registered: July 2009 |
Senior Member |
|
|
<allygirl@mailinator.com> wrote in message
news:hnmnse$e4m$1@build.eclipse.org...
> In the ElementManager method below,
>
> public Element load(InputStream stream, URL url) throws Exception {
> reset();
> // Initialize document root
> PushbackInputStream pis = null;
> if (stream != null) {
> if (stream instanceof PushbackInputStream) {
> pis = (PushbackInputStream) stream;
> } else {
> pis = new PushbackInputStream(stream, 4);
> }
> }
> documentRoot.init(pis, url.toString());
> InputStream input = pis;
> if (pis == null) {
> input = documentRoot.openStream();
> }
> doLoad(input);
> input = documentRoot.openStream();
> loadXData(input);
> input.close();
> return rootElement;
> }
>
> The url argument can't be null because of
> documentRoot.init(pis, url.toString());.
>
> So even if you pass in a valid stream like
> ByteArrayInputStream bs = new ByteArrayInputStream(myXwt.getBytes());
> to
> Control c = XWT.load(aShell, bs, myUrl, contextObject);
> the documentRoot.openStream() call requires a valid URL to
> keep "new URL(...).openStream();" happy.
> So if you have a stream with your XWT spec, I am not sure how this
> combination of arguments makes sense to use.
>
> The above post states, "The second argument indicates the location to find
> the Java class event
> handler. It shouldn't be null."
>
> But I am not sure what an example of a "Java class event handler"
> would be especially when you are trying to debug things.
we need to develop a snippet. Unfortunately, I'm busy for eclipsecon for
now. I can do it after. Please fill a bug and CC to me.
This feature is used by our XML editor for instant preview of the code in
memory. The class is XWTView in the plugin org.eclipse.e4.xwt.tools.ui.
best regards
Yves YANG
>
> Maybe Yves YANG can elaborate???
>
> WRT the question of where one can get a "context" for the statement,
> "You can call XWT.findElementByName(context, "<my name>")"
> see the post within
> http://www.eclipse.org/forums/index.php?t=msg&goto=50515 3&
|
|
|
Goto Forum:
Current Time: Tue Sep 24 12:06:54 GMT 2024
Powered by FUDForum. Page generated in 0.06643 seconds
|