Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Riena » Two questions about Treetable
Two questions about Treetable [message #586502] Mon, 19 July 2010 02:45 Go to next message
lushiwei lushiwei is currently offline lushiwei lushiwei
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 #586509 is a reply to message #586502] Mon, 19 July 2010 08:56 Go to previous messageGo to next message
Christian Campo is currently offline Christian Campo
Messages: 590
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 #586547 is a reply to message #586502] Tue, 20 July 2010 11:59 Go to previous messageGo to next message
Stephan Mann is currently offline Stephan Mann
Messages: 22
Registered: August 2010
Junior Member
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 #586571 is a reply to message #586502] Tue, 27 July 2010 23:26 Go to previous message
Elias Volanakis is currently offline Elias Volanakis
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.
Previous Topic:Changing the look of the error decoration
Next Topic:Two questions about Treetable
Goto Forum:
  


Current Time: Sat Nov 01 12:45:26 GMT 2014

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

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