Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Riena » Two questions about Treetable
Two questions about Treetable [message #547578] Mon, 19 July 2010 02:45 Go to next message
lushiwei lushiwei is currently offline lushiwei lushiweiFriend
Messages: 12
Registered: June 2010
Junior Member
I am a newbie for Riena, I have two questions about treetable.

1.The method of setColumnWidths does not work, Why getUIControl() always return null?
My View:
public void basicCreatePartControl(Composite parent) {
ergebnis = new Tree(container, SWT.BORDER | SWT.FULL_SELECTION);
new TreeColumn(ergebnis, SWT.NONE);
addUIControl(ergebnis, "result");
}

My Controller:
final ITreeTableRidget kunden = ((ITreeTableRidget) getRidget("result"));
// set the widths
ColumnLayoutData[] widths = new ColumnLayoutData[] { new ColumnWeightData(2), new ColumnWeightData(1) };
treeTableRidget.setColumnWidths(widths);

String[] columnValues = new String[] { "word", "upperCase" };
String[] columnHeaders = new String[] { "Word", "Uppercase" };
treeTableRidget.bindToModel(createTreeInput(), WordNode.class, "children", "parent",
columnValues, columnHeaders);
treeTableRidget.expandAll();

2. Is it posible to control the showing folder or file icon by a property in the model?
e.g. Show a folder icon for a node which doesn't have a child, but it's property is a category?

Thanks.
Re: Two questions about Treetable [message #547645 is a reply to message #547578] Mon, 19 July 2010 08:56 Go to previous messageGo to next message
Christian Campo is currently offline Christian CampoFriend
Messages: 597
Registered: July 2009
Senior Member
Am 19.07.10 04:45, schrieb lushiwei:
> I am a newbie for Riena, I have two questions about treetable.
>
> 1.The method of setColumnWidths does not work, Why getUIControl() always
> return null?
> My View:
> public void basicCreatePartControl(Composite parent) {
> ergebnis = new Tree(container, SWT.BORDER | SWT.FULL_SELECTION);
> new TreeColumn(ergebnis, SWT.NONE);
> addUIControl(ergebnis, "result");
> }
>
> My Controller:
> final ITreeTableRidget kunden = ((ITreeTableRidget) getRidget("result"));
> // set the widths
> ColumnLayoutData[] widths = new ColumnLayoutData[] { new
> ColumnWeightData(2), new ColumnWeightData(1) };
> treeTableRidget.setColumnWidths(widths);
>
> String[] columnValues = new String[] { "word", "upperCase" };
> String[] columnHeaders = new String[] { "Word", "Uppercase" };
> treeTableRidget.bindToModel(createTreeInput(), WordNode.class,
> "children", "parent",
> columnValues, columnHeaders);
> treeTableRidget.expandAll();
>
> 2. Is it posible to control the showing folder or file icon by a
> property in the model?
> e.g. Show a folder icon for a node which doesn't have a child, but it's
> property is a category?
>
> Thanks.
getUIControl() returns null in method configureRidgets since controller and view are not "bound" yet.

Overwrite afterBind() in the controller and getUIControl() will return a result.

not sure about the others.....maybe Elias has an answer...

- christian
Re: Two questions about Treetable [message #547875 is a reply to message #547645] Tue, 20 July 2010 02:07 Go to previous messageGo to next message
lushiwei lushiwei is currently offline lushiwei lushiweiFriend
Messages: 12
Registered: June 2010
Junior Member
Hi Christian,

Thanks for you reply.
But the getUIControl() still returns null when I overwrite the afterBind() in the controller. I can't add custom listener to the tree.
---------------------------------------
@Override
public void afterBind() {
}
---------------------------------------

To make setColumnWidths work, please setting the layout of tree container to null

I still have no any idea for the question 2.

Thanks,
lushiwei
Re: Two questions about Treetable [message #547925 is a reply to message #547875] Tue, 20 July 2010 07:51 Go to previous messageGo to next message
Christian Campo is currently offline Christian CampoFriend
Messages: 597
Registered: July 2009
Senior Member
Am 20.07.10 04:07, schrieb lushiwei:
> Hi Christian,
>
> Thanks for you reply. But the getUIControl() still returns null when I
> overwrite the afterBind() in the controller. I can't add custom listener
> to the tree.
> ---------------------------------------
> @Override
> public void afterBind() {
> }
> ---------------------------------------
>
> To make setColumnWidths work, please setting the layout of tree
> container to null
>
> I still have no any idea for the question 2.
>
> Thanks,
> lushiwei


You need to do this

public void afterBind() {
ITreeTableRidget kunden = ((ITreeTableRidget) getRidget("result"));
Tree tree = kunden.getUIControl();
}

- christian
Re: Two questions about Treetable [message #547941 is a reply to message #547925] Tue, 20 July 2010 08:53 Go to previous messageGo to next message
lushiwei lushiwei is currently offline lushiwei lushiweiFriend
Messages: 12
Registered: June 2010
Junior Member
Hi christian,

OK, I got the tree control.

Thanks


Re: Two questions about Treetable [message #548012 is a reply to message #547578] Tue, 20 July 2010 11:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stephan.mann.compeople.de

In article <i20e8l$1qd$1@build.eclipse.org>, lushiwei@gmail.com says...
> 1.The method of setColumnWidths does not work, [..]
> My View:
> public void basicCreatePartControl(Composite parent) {
> ergebnis = new Tree(container, SWT.BORDER | SWT.FULL_SELECTION);
> new TreeColumn(ergebnis, SWT.NONE);
> addUIControl(ergebnis, "result");
> } [..]

We had the same problem just today with a Table. However, this seems to
be a SWT issue. Try putting the Tree into its own Composite like this:

@Override
protected void basicCreatePartControl(final Composite parent) {
GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(parent);

Composite tblCmp = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(tblCmp);
Table table = UIControlsFactory.createTable(tblCmp,
SWT.NONE, "table");
}

It also seems to be important to *not* set any GridData to the Table.
Hope it's the same with the Tree.

If this doesn't work, try ColumnPixelData(..) or ColumnWeightData(int
weight, int minWidth).

stephan
Re: Two questions about Treetable [message #548182 is a reply to message #548012] Wed, 21 July 2010 01:41 Go to previous messageGo to next message
lushiwei lushiwei is currently offline lushiwei lushiweiFriend
Messages: 12
Registered: June 2010
Junior Member
Hi Stephan,

Yes, it's the same with the Tree.

The method setColumnWidths works well when I put the Tree into its own Composite and set layout of composite to null.

You can get more information from the codes. ColumnUtils.applyColumnWidths(...) in line 132.

lushiwei
Re: Two questions about Treetable [message #549788 is a reply to message #547578] Tue, 27 July 2010 23:26 Go to previous message
Elias Volanakis is currently offline Elias VolanakisFriend
Messages: 43
Registered: July 2009
Member
On 7/18/2010 19:45, lushiwei wrote:

> 2. Is it posible to control the showing folder or file icon by a
> property in the model?
> e.g. Show a folder icon for a node which doesn't have a child, but it's
> property is a category?
>
> Thanks.

Yes, there are two ways to do this:

(a) use one of the treeRidget.bindToModel(...) methods that have
....imageAccessor arguments. One of the bind methods accepts a
leafImageAccessor property. Another variant accepts an imageAccessor and
openNodeImageAccessor property. Refer to the javadoc for a detailed
description.

These properties point to methods that return a String with the filename
of an image. The image is found by searching the known imagePaths. Use
the imagePaths extension point to register the directory containing your
images:

<extension
point="org.eclipse.riena.ui.swt.imagePaths">
<path path="icons"/>
</extension>

Example: see SonarController#setRootNodes and plugin.xml in
org.eclipse.riena.example.ping.client.

(b) if you use an ITreeTableRidget you can use a ColumnFormatter and
override the getImage() method.

treeTableRidget.setColumnFormatter(columnNumber, new ColumnFormatter() {
public Image getImage(final Object element) { ... }
});

At the moment you will run into Bug 316103 if you use this on the 1st
column. This will be fixed with the next milestone.

Hope this helps,
Elias.
Re: Two questions about Treetable [message #586516 is a reply to message #547645] Tue, 20 July 2010 02:07 Go to previous message
lushiwei lushiwei is currently offline lushiwei lushiweiFriend
Messages: 12
Registered: June 2010
Junior Member
Hi Christian,

Thanks for you reply.
But the getUIControl() still returns null when I overwrite the afterBind() in the controller. I can't add custom listener to the tree.
---------------------------------------
@Override
public void afterBind() {
}
---------------------------------------

To make setColumnWidths work, please setting the layout of tree container to null

I still have no any idea for the question 2.

Thanks,
lushiwei
Re: Two questions about Treetable [message #586529 is a reply to message #586516] Tue, 20 July 2010 07:51 Go to previous message
Christian Campo is currently offline Christian CampoFriend
Messages: 597
Registered: July 2009
Senior Member
Am 20.07.10 04:07, schrieb lushiwei:
> Hi Christian,
>
> Thanks for you reply. But the getUIControl() still returns null when I
> overwrite the afterBind() in the controller. I can't add custom listener
> to the tree.
> ---------------------------------------
> @Override
> public void afterBind() {
> }
> ---------------------------------------
>
> To make setColumnWidths work, please setting the layout of tree
> container to null
>
> I still have no any idea for the question 2.
>
> Thanks,
> lushiwei


You need to do this

public void afterBind() {
ITreeTableRidget kunden = ((ITreeTableRidget) getRidget("result"));
Tree tree = kunden.getUIControl();
}

- christian
Re: Two questions about Treetable [message #586536 is a reply to message #547925] Tue, 20 July 2010 08:53 Go to previous message
lushiwei lushiwei is currently offline lushiwei lushiweiFriend
Messages: 12
Registered: June 2010
Junior Member
Hi christian,

OK, I got the tree control.

Thanks
Re: Two questions about Treetable [message #586559 is a reply to message #548012] Wed, 21 July 2010 01:41 Go to previous message
lushiwei lushiwei is currently offline lushiwei lushiweiFriend
Messages: 12
Registered: June 2010
Junior Member
Hi Stephan,

Yes, it's the same with the Tree.

The method setColumnWidths works well when I put the Tree into its own Composite and set layout of composite to null.

You can get more information from the codes. ColumnUtils.applyColumnWidths(...) in line 132.

lushiwei
Previous Topic:Two questions about Treetable
Next Topic:Re: Custom marker views in a Riena application
Goto Forum:
  


Current Time: Thu Mar 28 10:55:47 GMT 2024

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

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

Back to the top