Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » XWT: Preview & Run-time views are different
XWT: Preview & Run-time views are different [message #523100] Thu, 25 March 2010 05:25 Go to next message
can kayacan is currently offline can kayacan
Messages: 16
Registered: March 2010
Junior Member
Hi,

I have simple UI element, which has two button and a text widgets. The XWT designer and the Preview shows the button and text size as I expected. But the run-time widget sizes are not shown as I defined. The default widget size is being shown instead.

Anyone has any idea, what is the correct way to define the widget width and height?


Demo.xwt
<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt" xmlns:c="clr-namespace:demo.xwt"
xmlns:j="clr-namespace:java.lang" x:Class="demo.xwt.Demo">

<Composite.layout>
<GridLayout numColumns="1" />
</Composite.layout>

<Text x:style="SWT.NONE" weight="400" height="150" />

<Button x:style="SWT.PUSH" x:Name="NotifyButton1" text="Notify" width="200" Height="50" />

<Button x:style="SWT.PUSH" x:Name="NotifyButton2" text="Notify" width="200" Height="50" />

</Composite>


Demo.java
public class Demo extends Composite {

public Demo(Composite parent, int style) {
super(parent, style);
}

}


Simple main method:
public static void main(String[] args) {
URL content = Demo.class.getResource("Demo.xwt");
try {
XWT.open(content);
} catch (Exception e) {
e.printStackTrace();
}
}

[Updated on: Thu, 25 March 2010 05:28]

Report message to a moderator

Re: XWT: Preview & Run-time views are different [message #523158 is a reply to message #523100] Thu, 25 March 2010 11:56 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin Scheglov
Messages: 554
Registered: July 2009
Senior Member
You should use GridData for GridLayout instead of specifying size directly.
In general Layout manages location and size, so your width/height are overridden.

You want something like this
<Composite xmlns="http://www.eclipse.org/xwt/presentation" xmlns:x="http://www.eclipse.org/xwt">
	<Composite.layout>
		<GridLayout numColumns="1"/>
	</Composite.layout>
	<Text x:Style="BORDER">
		<Text.layoutData>
			<GridData grabExcessHorizontalSpace="true" horizontalAlignment="FILL" heightHint="150"/>
		</Text.layoutData>
	</Text>
	<Button x:Name="NotifyButton1" text="Notify">
		<Button.layoutData>
			<GridData widthHint="200" heightHint="50"/>
		</Button.layoutData>
	</Button>
	<Button x:Name="NotifyButton2" text="Notify">
		<Button.layoutData>
			<GridData heightHint="50" widthHint="200"/>
		</Button.layoutData>
	</Button>
</Composite>


http://dl.dropbox.com/u/76691/Eclipse/images/Screenshot%20-%2025.03.2010%20%2C%2014_53_21.png


Konstantin Scheglov,
Google, Inc.
Re: XWT: Preview & Run-time views are different [message #523301 is a reply to message #523158] Thu, 25 March 2010 20:21 Go to previous messageGo to next message
can kayacan is currently offline can kayacan
Messages: 16
Registered: March 2010
Junior Member
Thank you so much again, Konstantin. This was very helpful.
Re: Preview & Run-time views are different [message #525879 is a reply to message #523100] Thu, 08 April 2010 07:16 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
How do you set the width and height, via XWT Visual Designer? If so, it
could be a bug of the tool and please report a bug.

Regards
Yves
"can kayacan" <kayacanc@hotmail.com> wrote in message
news:hoes53$hh2$1@build.eclipse.org...
> Hi,
>
> I have simple UI element, which has two button and a text widgets. The XWT
> designer and the Preview shows the button and text size (width and
> height) as I expected. But the run-time widget sizes are not shown as I
> defined. The default widget size is being shown.
>
> Anyone has any idea, what is the correct way to define the widget width
> and height?
>
> Demo.xwt
> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt" xmlns:c="clr-namespace:demo.xwt"
> xmlns:j="clr-namespace:java.lang" x:Class="demo.xwt.Demo">
>
> <Composite.layout>
> <GridLayout numColumns="2" />
> </Composite.layout>
>
> <Text x:style="SWT.NONE" weight="400" height="150" />
>
> <Button x:style="SWT.PUSH" x:Name="NotifyButton1" text="Notify"
> width="200" Height="50" />
>
> <Button x:style="SWT.PUSH" x:Name="NotifyButton2" text="Notify"
> width="200" Height="50" />
>
> </Composite>
>
>
> Demo.java
> public class Demo extends Composite {
> public Demo(Composite parent, int style) {
> super(parent, style);
> }
>
> }
>
>
>
> Simple main method: public static void main(String[] args) {
> URL content = Demo.class.getResource("Demo.xwt");
> try {
> XWT.open(content);
> } catch (Exception e) {
> e.printStackTrace();
> }
> }
Re: Preview & Run-time views are different [message #526125 is a reply to message #525879] Thu, 08 April 2010 19:09 Go to previous messageGo to next message
can kayacan is currently offline can kayacan
Messages: 16
Registered: March 2010
Junior Member
Hi Yang,

I did not use Visual Designer, intellisense shows the "width" and "height".

I checked the designer, the width and height is available under Size & Location tab.

Normally, SWT button has setSize method which takes width and height as parameters. If these are what the intellisense shows?

Should I still report?
Re: Preview & Run-time views are different [message #573550 is a reply to message #525879] Thu, 08 April 2010 19:09 Go to previous message
can kayacan is currently offline can kayacan
Messages: 16
Registered: March 2010
Junior Member
Hi Yang,

I did not use Visual Designer, intellisense shows the "width" and "height".

I checked the designer, the width and height is available under Size & Location tab.

Normally, SWT button has setSize method which takes width and height as parameters. If these are what the intellisense shows?

Should I still report?
Previous Topic:XWT: Preview & Run-time views are different
Next Topic:open Application.e4xmi and the window keeps flashing
Goto Forum:
  


Current Time: Mon Sep 22 06:20:43 GMT 2014

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

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