Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » XWT.open string
icon5.gif  XWT.open string [message #554641] Mon, 23 August 2010 19:41 Go to next message
FD  is currently offline 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 19:41]

Report message to a moderator

Re: XWT.open string [message #554658 is a reply to message #554641] Mon, 23 August 2010 21:53 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
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 #555078 is a reply to message #554658] Wed, 25 August 2010 11:56 Go to previous messageGo to next message
FD  is currently offline 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 #555506 is a reply to message #555078] Thu, 26 August 2010 20:44 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
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 21:53 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
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 11:56 Go to previous message
FD  is currently offline 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 20:44 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
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();
>
Previous Topic:Using XWT Views with Riena
Next Topic:e4 and JFace Wizards
Goto Forum:
  


Current Time: Tue Sep 23 16:33:47 GMT 2014

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

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