TableTree is not possible to modify

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

TableTree is not possible to modify

Postby elka » Mon Apr 18, 2005 6:00 am

How do you add a TableTree to a shell and add columns with items and then sucessfully populate these items?

I try to add items to the columns and items with the names "item 00, item 10, item 100" etc shows up. These are not visible in the code and I am not able to change the text on them.

When looking around something called TreeTableItem is used for this purpose but this widget does not exist in swt-designer. Also if I try to write the code myself the swt-designer crashes...

What do I do?
elka
 
Posts: 2
Joined: Mon Apr 18, 2005 5:48 am

Re: TableTree is not possible to modify

Postby Eric Clayberg » Mon Apr 18, 2005 9:05 am

elka wrote:How do you add a TableTree to a shell and add columns with items and then sucessfully populate these items? I try to add items to the columns and items with the names "item 00, item 10, item 100" etc shows up. These are not visible in the code and I am not able to change the text on them. When looking around something called TreeTableItem is used for this purpose but this widget does not exist in swt-designer. Also if I try to write the code myself the swt-designer crashes...
What do I do?

The JFace TableTree has been deprecated in Eclipse 3.1. You should use a normal Tree with TreeColumns and TreeItems. The following example was created in Eclipse 3.1 M6...

Code: Select all
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;

public class TableTreeExample {

   private Tree tree;
   protected Shell shell;

   public static void main(String[] args) {
      try {
         TableTreeExample window = new TableTreeExample();
         window.open();
      } catch (Exception e) {
         e.printStackTrace();
      }
   }

   public void open() {
      final Display display = Display.getDefault();
      createContents();
      shell.open();
      shell.layout();
      while (!shell.isDisposed()) {
         if (!display.readAndDispatch())
            display.sleep();
      }
   }

   protected void createContents() {
      shell = new Shell();
      shell.setLayout(new GridLayout());
      shell.setSize(355, 258);
      shell.setText("SWT Application");

      tree = new Tree(shell, SWT.BORDER);
      tree.setLayoutData(new GridData(GridData.FILL_BOTH));
      tree.setHeaderVisible(true);

      final TreeColumn firstColumn = new TreeColumn(tree, SWT.NONE);
      firstColumn.setWidth(100);
      firstColumn.setText("First");

      final TreeColumn secondColumn = new TreeColumn(tree, SWT.NONE);
      secondColumn.setWidth(100);
      secondColumn.setText("Second");

      final TreeItem firstItem = new TreeItem(tree, SWT.NONE);
      firstItem.setText(1, "B");
      firstItem.setText(0, "A");

      final TreeItem childItem = new TreeItem(firstItem, SWT.NONE);
      childItem.setText(1, "F");
      childItem.setText(0, "E");

      final TreeItem secondItem = new TreeItem(tree, SWT.NONE);
      secondItem.setText(1, "D");
      secondItem.setText(0, "C");
   }
}
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby elka » Mon Apr 18, 2005 11:26 pm

Thank you for your answer but how does it work in swt-designer with eclipse 3.0.1?

I tried your example but TreeColumn and setHeaderVisible do not exist(?)/work.
elka
 
Posts: 2
Joined: Mon Apr 18, 2005 5:48 am

Postby Eric Clayberg » Tue Apr 19, 2005 3:40 am

elka wrote:Thank you for your answer but how does it work in swt-designer with eclipse 3.0.1? I tried your example but TreeColumn and setHeaderVisible do not exist(?)/work.

TreeColumns are new as of Eclipse 3.1. The older JFace TableTree viewer is also deprecated as of 3.1.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest