Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » XWT. Using TableViewer.columns. Why?
XWT. Using TableViewer.columns. Why? [message #527747] Fri, 16 April 2010 11:08 Go to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
As I understand, "Class.property" should be used when you want to set value of "property". However TableViewer has no property "columns" or method "setColumns()", etc. It seems that it works without wrapping TableViewerColumn-s into "TableViewer.columns", so is there reason to use it in code generation?

Here is code from xwt tests.

<TableViewer xmlns="http://www.eclipse.org/xwt/presentation"
    xmlns:x="http://www.eclipse.org/xwt"
    xmlns:j="clr-namespace:java.lang"
    Name="TableViewer">
	<TableViewer.columns>
		<TableViewerColumn width="80" text="column0"/>
		<TableViewerColumn width="80" text="column1"/>
	</TableViewer.columns>
</TableViewer>


But this also works

<Shell xmlns="http://www.eclipse.org/xwt/presentation" xmlns:x="http://www.eclipse.org/xwt">
	<Shell.layout>
		<FillLayout type="VERTICAL"/>
	</Shell.layout>
	<TableViewer x:Style="BORDER | FULL_SELECTION">
		<TableViewer.table headerVisible="true" linesVisible="true"/>
		<TableViewerColumn width="150" text="Name"/>
		<TableViewerColumn width="150" text="Age"/>
		<TableViewerColumn width="150" text="Image"/>
	</TableViewer>
</Shell>


Konstantin Scheglov,
Google, Inc.
Re: XWT. Using TableViewer.columns. Why? [message #527748 is a reply to message #527747] Fri, 16 April 2010 11:15 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
What I think is strange too here is that this looks like
TableViewerColumn has the properties (name, width) which is doesn't have
in JFace.

I would have expected the attribute is column.width, ... (not sure this
is valid XML) because in Java-Code you write
viewerCol.getColumn().setWidth().

Tom

Am 16.04.10 13:08, schrieb Konstantin Scheglov:
> As I understand, "Class.property" should be used when you want to set
> value of "property". However TableViewer has no property "columns" or
> method "setColumns()", etc. It seems that it works without wrapping
> TableViewerColumn-s into "TableViewer.columns", so is there reason to
> use it in code generation?
>
> Here is code from xwt tests.
>
> <TableViewer xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt"
> xmlns:j="clr-namespace:java.lang"
> Name="TableViewer">
> <TableViewer.columns>
> <TableViewerColumn width="80" text="column0"/>
> <TableViewerColumn width="80" text="column1"/>
> </TableViewer.columns>
> </TableViewer>
>
> But this also works
>
> <Shell xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt">
> <Shell.layout>
> <FillLayout type="VERTICAL"/>
> </Shell.layout>
> <TableViewer x:Style="BORDER | FULL_SELECTION">
> <TableViewer.table headerVisible="true" linesVisible="true"/>
> <TableViewerColumn width="150" text="Name"/>
> <TableViewerColumn width="150" text="Age"/>
> <TableViewerColumn width="150" text="Image"/>
> </TableViewer>
> </Shell>
Re: XWT. Using TableViewer.columns. Why? [message #527841 is a reply to message #527748] Fri, 16 April 2010 15:22 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
XWT's UI Model aligns as much as possible with SWT/JFace "model".
Unfortuately, the API of SWT/JFace is not model-driven. The Java Bean
specification is not totally respected. However, XWT is a 100% model-based
UI solution. We need to connect the SWT/Jface APIs to UI model via an
intermediate model services, which is our UI metamodel. XWT provides a
possibility to extend and overwrite the default UI metamodel.

As for the TableViewerColumn, we have added two additional attributes in the
metaclass of TableViewerColumn to make the declarative simple and
strainghtforward..

"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:hq9gs4$lo$1@build.eclipse.org...
> What I think is strange too here is that this looks like
> TableViewerColumn has the properties (name, width) which is doesn't have
> in JFace.
>
> I would have expected the attribute is column.width, ... (not sure this
> is valid XML) because in Java-Code you write
> viewerCol.getColumn().setWidth().
>
> Tom
>
> Am 16.04.10 13:08, schrieb Konstantin Scheglov:
>> As I understand, "Class.property" should be used when you want to set
>> value of "property". However TableViewer has no property "columns" or
>> method "setColumns()", etc. It seems that it works without wrapping
>> TableViewerColumn-s into "TableViewer.columns", so is there reason to
>> use it in code generation?
>>
>> Here is code from xwt tests.
>>
>> <TableViewer xmlns="http://www.eclipse.org/xwt/presentation"
>> xmlns:x="http://www.eclipse.org/xwt"
>> xmlns:j="clr-namespace:java.lang"
>> Name="TableViewer">
>> <TableViewer.columns>
>> <TableViewerColumn width="80" text="column0"/>
>> <TableViewerColumn width="80" text="column1"/>
>> </TableViewer.columns>
>> </TableViewer>

This is the model-based declaration with a virtual attribute "columns".

>>
>> But this also works
>>
>> <Shell xmlns="http://www.eclipse.org/xwt/presentation"
>> xmlns:x="http://www.eclipse.org/xwt">
>> <Shell.layout>
>> <FillLayout type="VERTICAL"/>
>> </Shell.layout>
>> <TableViewer x:Style="BORDER | FULL_SELECTION">
>> <TableViewer.table headerVisible="true" linesVisible="true"/>
>> <TableViewerColumn width="150" text="Name"/>
>> <TableViewerColumn width="150" text="Age"/>
>> <TableViewerColumn width="150" text="Image"/>
>> </TableViewer>
>> </Shell>

This is the default mechanism of XWT loader, which takes TableViewerColumn
as child of TableViewer. When XWT loads the resource, JFace API creates the
column in table. But from modeling standpoint, I think it isn't appropriate:
column should not be a child of table.

Regards
Yves
Re: XWT. Using TableViewer.columns. Why? [message #527887 is a reply to message #527841] Fri, 16 April 2010 19:09 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Yves YANG wrote on Fri, 16 April 2010 19:22
>> But this also works
>>
>> <Shell xmlns="http://www.eclipse.org/xwt/presentation"
>> xmlns:x="http://www.eclipse.org/xwt">
>> <Shell.layout>
>> <FillLayout type="VERTICAL"/>
>> </Shell.layout>
>> <TableViewer x:Style="BORDER | FULL_SELECTION">
>> <TableViewer.table headerVisible="true" linesVisible="true"/>
>> <TableViewerColumn width="150" text="Name"/>
>> <TableViewerColumn width="150" text="Age"/>
>> <TableViewerColumn width="150" text="Image"/>
>> </TableViewer>
>> </Shell>

This is the default mechanism of XWT loader, which takes TableViewerColumn
as child of TableViewer. When XWT loads the resource, JFace API creates the
column in table. But from modeling standpoint, I think it isn't appropriate:
column should not be a child of table.



To be honest, I don't understand what you mean.
In both case we create TableViewerColumn-s, which in both cases children of TableViewer (not Table).

I just wonder why special "TableViewer.columns" element is used. For example when we create Composite with children Control-s, we don't wrap children into "Composite.controls" element...




Konstantin Scheglov,
Google, Inc.
Re: XWT. Using TableViewer.columns. Why? [message #527941 is a reply to message #527887] Sat, 17 April 2010 04:29 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
The reason is very simple: I didn't expect the second case works.

> To be honest, I don't understand what you mean.
> In both case we create TableViewerColumn-s, which in both cases children
> of TableViewer (not Table).
>
> I just wonder why special "TableViewer.columns" element is used. For
> example when we create Composite with children Control-s, we don't wrap
> children into "Composite.controls" element...

I think "TableViewerColumn" is not a contained child of TableViewer. They
are used to define the header and structure of TableViewer. TableViewer
should have a collection or array of TableViewerColumn in order and same
type.

Let's compare the following case in two ways:

Grouped
======
<TableViewer>
<TableViewer.filters>
<ViewerFilter>
<ViewerFilter.conditions>
<Condition property="age" value="30" operator="GT"/>
</ViewerFilter.conditions>
</ViewerFilter>
<ViewerFilter>
<ViewerFilter.conditions>
<Condition property="salary" value="50" operator="LT"/>
</ViewerFilter.conditions>
</ViewerFilter>
</TableViewer.filters>

<TableViewer.columns>
<TableViewerColumn width="150" text="Name" bindingPath="name"/>
<TableViewerColumn width="150" text="Age" bindingPath="age"/>
</TableViewer.columns>
</TableViewer>


Flat
===
<TableViewer>
<TableViewerColumn width="150" text="Name" bindingPath="name"/>
<ViewerFilter>
<ViewerFilter.conditions>
<Condition property="age" value="30" operator="GT"/>
</ViewerFilter.conditions>
</ViewerFilter>

<TableViewerColumn width="150" text="Age" bindingPath="age"/>
<ViewerFilter>
<ViewerFilter.conditions>
<Condition property="salary" value="50" operator="LT"/>
</ViewerFilter.conditions>
</ViewerFilter>
</TableViewer>

Which do you prefer?

By writting this, I have checked on the Table. I just noticed Table column
is defined in flat way. It'd better to keep the syntax (or model)
consistance between Table and TableViewer.

Regards
Yves
>
>
>
> --
> Konstantin Scheglov,
> Instantiations, Inc.
Re: XWT. Using TableViewer.columns. Why? [message #527946 is a reply to message #527941] Sat, 17 April 2010 08:21 Go to previous message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Yves YANG wrote on Sat, 17 April 2010 08:29

Which do you prefer?



Hm...
Example with logical grouping columns and filters into container elements looks better.


Konstantin Scheglov,
Google, Inc.
Re: XWT. Using TableViewer.columns. Why? [message #574402 is a reply to message #527747] Fri, 16 April 2010 11:15 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
What I think is strange too here is that this looks like
TableViewerColumn has the properties (name, width) which is doesn't have
in JFace.

I would have expected the attribute is column.width, ... (not sure this
is valid XML) because in Java-Code you write
viewerCol.getColumn().setWidth().

Tom

Am 16.04.10 13:08, schrieb Konstantin Scheglov:
> As I understand, "Class.property" should be used when you want to set
> value of "property". However TableViewer has no property "columns" or
> method "setColumns()", etc. It seems that it works without wrapping
> TableViewerColumn-s into "TableViewer.columns", so is there reason to
> use it in code generation?
>
> Here is code from xwt tests.
>
> <TableViewer xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt"
> xmlns:j="clr-namespace:java.lang"
> Name="TableViewer">
> <TableViewer.columns>
> <TableViewerColumn width="80" text="column0"/>
> <TableViewerColumn width="80" text="column1"/>
> </TableViewer.columns>
> </TableViewer>
>
> But this also works
>
> <Shell xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt">
> <Shell.layout>
> <FillLayout type="VERTICAL"/>
> </Shell.layout>
> <TableViewer x:Style="BORDER | FULL_SELECTION">
> <TableViewer.table headerVisible="true" linesVisible="true"/>
> <TableViewerColumn width="150" text="Name"/>
> <TableViewerColumn width="150" text="Age"/>
> <TableViewerColumn width="150" text="Image"/>
> </TableViewer>
> </Shell>
Re: XWT. Using TableViewer.columns. Why? [message #574474 is a reply to message #527748] Fri, 16 April 2010 15:22 Go to previous message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
XWT's UI Model aligns as much as possible with SWT/JFace "model".
Unfortuately, the API of SWT/JFace is not model-driven. The Java Bean
specification is not totally respected. However, XWT is a 100% model-based
UI solution. We need to connect the SWT/Jface APIs to UI model via an
intermediate model services, which is our UI metamodel. XWT provides a
possibility to extend and overwrite the default UI metamodel.

As for the TableViewerColumn, we have added two additional attributes in the
metaclass of TableViewerColumn to make the declarative simple and
strainghtforward..

"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:hq9gs4$lo$1@build.eclipse.org...
> What I think is strange too here is that this looks like
> TableViewerColumn has the properties (name, width) which is doesn't have
> in JFace.
>
> I would have expected the attribute is column.width, ... (not sure this
> is valid XML) because in Java-Code you write
> viewerCol.getColumn().setWidth().
>
> Tom
>
> Am 16.04.10 13:08, schrieb Konstantin Scheglov:
>> As I understand, "Class.property" should be used when you want to set
>> value of "property". However TableViewer has no property "columns" or
>> method "setColumns()", etc. It seems that it works without wrapping
>> TableViewerColumn-s into "TableViewer.columns", so is there reason to
>> use it in code generation?
>>
>> Here is code from xwt tests.
>>
>> <TableViewer xmlns="http://www.eclipse.org/xwt/presentation"
>> xmlns:x="http://www.eclipse.org/xwt"
>> xmlns:j="clr-namespace:java.lang"
>> Name="TableViewer">
>> <TableViewer.columns>
>> <TableViewerColumn width="80" text="column0"/>
>> <TableViewerColumn width="80" text="column1"/>
>> </TableViewer.columns>
>> </TableViewer>

This is the model-based declaration with a virtual attribute "columns".

>>
>> But this also works
>>
>> <Shell xmlns="http://www.eclipse.org/xwt/presentation"
>> xmlns:x="http://www.eclipse.org/xwt">
>> <Shell.layout>
>> <FillLayout type="VERTICAL"/>
>> </Shell.layout>
>> <TableViewer x:Style="BORDER | FULL_SELECTION">
>> <TableViewer.table headerVisible="true" linesVisible="true"/>
>> <TableViewerColumn width="150" text="Name"/>
>> <TableViewerColumn width="150" text="Age"/>
>> <TableViewerColumn width="150" text="Image"/>
>> </TableViewer>
>> </Shell>

This is the default mechanism of XWT loader, which takes TableViewerColumn
as child of TableViewer. When XWT loads the resource, JFace API creates the
column in table. But from modeling standpoint, I think it isn't appropriate:
column should not be a child of table.

Regards
Yves
Re: XWT. Using TableViewer.columns. Why? [message #574504 is a reply to message #527841] Fri, 16 April 2010 19:09 Go to previous message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Yves YANG wrote on Fri, 16 April 2010 19:22
> >> But this also works
> >>
> >> <Shell xmlns="http://www.eclipse.org/xwt/presentation"
> >> xmlns:x="http://www.eclipse.org/xwt">
> >> <Shell.layout>
> >> <FillLayout type="VERTICAL"/>
> >> </Shell.layout>
> >> <TableViewer x:Style="BORDER | FULL_SELECTION">
> >> <TableViewer.table headerVisible="true" linesVisible="true"/>
> >> <TableViewerColumn width="150" text="Name"/>
> >> <TableViewerColumn width="150" text="Age"/>
> >> <TableViewerColumn width="150" text="Image"/>
> >> </TableViewer>
> >> </Shell>
>
> This is the default mechanism of XWT loader, which takes TableViewerColumn
> as child of TableViewer. When XWT loads the resource, JFace API creates the
> column in table. But from modeling standpoint, I think it isn't appropriate:
> column should not be a child of table.


To be honest, I don't understand what you mean.
In both case we create TableViewerColumn-s, which in both cases children of TableViewer (not Table).

I just wonder why special "TableViewer.columns" element is used. For example when we create Composite with children Control-s, we don't wrap children into "Composite.controls" element...



--
Konstantin Scheglov,
Instantiations, Inc.


Konstantin Scheglov,
Google, Inc.
Re: XWT. Using TableViewer.columns. Why? [message #574578 is a reply to message #574504] Sat, 17 April 2010 04:29 Go to previous message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
The reason is very simple: I didn't expect the second case works.

> To be honest, I don't understand what you mean.
> In both case we create TableViewerColumn-s, which in both cases children
> of TableViewer (not Table).
>
> I just wonder why special "TableViewer.columns" element is used. For
> example when we create Composite with children Control-s, we don't wrap
> children into "Composite.controls" element...

I think "TableViewerColumn" is not a contained child of TableViewer. They
are used to define the header and structure of TableViewer. TableViewer
should have a collection or array of TableViewerColumn in order and same
type.

Let's compare the following case in two ways:

Grouped
======
<TableViewer>
<TableViewer.filters>
<ViewerFilter>
<ViewerFilter.conditions>
<Condition property="age" value="30" operator="GT"/>
</ViewerFilter.conditions>
</ViewerFilter>
<ViewerFilter>
<ViewerFilter.conditions>
<Condition property="salary" value="50" operator="LT"/>
</ViewerFilter.conditions>
</ViewerFilter>
</TableViewer.filters>

<TableViewer.columns>
<TableViewerColumn width="150" text="Name" bindingPath="name"/>
<TableViewerColumn width="150" text="Age" bindingPath="age"/>
</TableViewer.columns>
</TableViewer>


Flat
===
<TableViewer>
<TableViewerColumn width="150" text="Name" bindingPath="name"/>
<ViewerFilter>
<ViewerFilter.conditions>
<Condition property="age" value="30" operator="GT"/>
</ViewerFilter.conditions>
</ViewerFilter>

<TableViewerColumn width="150" text="Age" bindingPath="age"/>
<ViewerFilter>
<ViewerFilter.conditions>
<Condition property="salary" value="50" operator="LT"/>
</ViewerFilter.conditions>
</ViewerFilter>
</TableViewer>

Which do you prefer?

By writting this, I have checked on the Table. I just noticed Table column
is defined in flat way. It'd better to keep the syntax (or model)
consistance between Table and TableViewer.

Regards
Yves
>
>
>
> --
> Konstantin Scheglov,
> Instantiations, Inc.
Re: XWT. Using TableViewer.columns. Why? [message #574626 is a reply to message #527941] Sat, 17 April 2010 08:21 Go to previous message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Yves YANG wrote on Sat, 17 April 2010 08:29
> Which do you prefer?


Hm...
Example with logical grouping columns and filters into container elements looks better.

--
Konstantin Scheglov,
Instantiations, Inc.


Konstantin Scheglov,
Google, Inc.
Previous Topic:XWT + RCP
Next Topic:Starting an RCP application
Goto Forum:
  


Current Time: Sat Apr 20 00:56:31 GMT 2024

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

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

Back to the top