XWT.open string [message #554641] |
Mon, 23 August 2010 15:41  |
FD Messages: 15 Registered: August 2010 |
Junior Member |
|
|
Is there a function to open an 'xwt string'?
In the following example I've to create a temporary file to be able to open the 'xwt string'.
package test;
import java.io.*;
import java.net.URL;
import org.eclipse.e4.xwt.XWT;
public class Test {
public static void main(String[] args) throws IOException {
String xwtstr = "<Composite xmlns=\"http://www.eclipse.org/xwt/presentation\" xmlns:x=\"http://www.eclipse.org/xwt\"><Composite.layout> <GridLayout numColumns=\"1\"/> </Composite.layout> <Text text=\"test text\" x:style=\"SWT.NONE\"></Text></Composite>";
File xwtTemp = File.createTempFile("Test", ".xwt");
xwtTemp.deleteOnExit();
BufferedWriter out = new BufferedWriter(new FileWriter(xwtTemp));
out.write(xwtstr);
out.close();
@SuppressWarnings("deprecation")
URL url = xwtTemp.toURL();
try {
XWT.open(url);
} catch (Exception e) {
e.printStackTrace();
}
}
}
[Updated on: Mon, 23 August 2010 15:41] Report message to a moderator
|
|
|
|
|
| Re: XWT.open string [message #555506 is a reply to message #555078] |
Thu, 26 August 2010 16:44  |
Yves YANG Messages: 686 Registered: July 2009 |
Senior Member |
|
|
yes, exactly.
Best regards
Yves YANG
"FD" <dubfa@hotmail.com> wrote in message
news:i530d5$b47$1@build.eclipse.org...
> XWT.open(InputStream input, URL referenceLocation) ?
>
> I see only XWT.load(InputStream input, URL referenceLocation)
>
> Can I do this?
>
> Control root = XWT.load(inputStream, xwturl );
> Shell shell = root.getShell();
> shell.open();
>
|
|
|
| Re: XWT.open string [message #581197 is a reply to message #554641] |
Mon, 23 August 2010 17:53  |
Yves YANG Messages: 686 Registered: July 2009 |
Senior Member |
|
|
You can create directly InputStream with the content in string and then call
XWT.open(InputStream input, URL referenceLocation). This feature is used by
XWT Visual Design Editor to display in memory code.
Best regards
Yves YANG
"FD" <dubfa@hotmail.com> wrote in message
news:i4uit5$c6q$1@build.eclipse.org...
> Is there a function to open an 'xwt string'?
> In the folowing example I've to create a temporary file to be able to open
> the 'xwt string'.
>
> package test;
>
> import java.io.*;
> import java.net.URL;
> import org.eclipse.e4.xwt.XWT;
>
> public class Test {
>
> public static void main(String[] args) throws IOException {
> String xwtstr = "<Composite
> xmlns=\"http://www.eclipse.org/xwt/presentation\"
> xmlns:x=\"http://www.eclipse.org/xwt\"><Composite.layout> <GridLayout
> numColumns=\"1\"/> </Composite.layout> <Text text=\"test text\"
> x:style=\"SWT.NONE\"></Text></Composite>";
> File xwtTemp = File.createTempFile("Test", ".xwt");
> xwtTemp.deleteOnExit();
> BufferedWriter out = new BufferedWriter(new FileWriter(xwtTemp));
> out.write(xwtstr);
> out.close(); @SuppressWarnings("deprecation")
> URL url = xwtTemp.toURL();
> try {
> XWT.open(url);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
> }
|
|
|
| Re: XWT.open string [message #581304 is a reply to message #554658] |
Wed, 25 August 2010 07:56  |
FD Messages: 15 Registered: August 2010 |
Junior Member |
|
|
XWT.open(InputStream input, URL referenceLocation) ?
I see only XWT.load(InputStream input, URL referenceLocation)
Can I do this?
Control root = XWT.load(inputStream, xwturl );
Shell shell = root.getShell();
shell.open();
|
|
|
| Re: XWT.open string [message #581319 is a reply to message #555078] |
Thu, 26 August 2010 16:44  |
Yves YANG Messages: 686 Registered: July 2009 |
Senior Member |
|
|
yes, exactly.
Best regards
Yves YANG
"FD" <dubfa@hotmail.com> wrote in message
news:i530d5$b47$1@build.eclipse.org...
> XWT.open(InputStream input, URL referenceLocation) ?
>
> I see only XWT.load(InputStream input, URL referenceLocation)
>
> Can I do this?
>
> Control root = XWT.load(inputStream, xwturl );
> Shell shell = root.getShell();
> shell.open();
>
|
|
|
Powered by
FUDForum. Page generated in 0.02667 seconds