Example usage for org.eclipse.swt.widgets Tree Tree

List of usage examples for org.eclipse.swt.widgets Tree Tree

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Tree Tree.

Prototype

public Tree(Composite parent, int style) 

Source Link

Document

Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

Usage

From source file:SWTFileViewerDemo.java

/**
 * Creates the file tree view.//from   www.j av a2s .  com
 * 
 * @param parent
 *            the parent control
 */
private void createTreeView(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    gridLayout.marginHeight = gridLayout.marginWidth = 2;
    gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
    composite.setLayout(gridLayout);

    treeScopeLabel = new Label(composite, SWT.BORDER);
    treeScopeLabel.setText(SWTFileViewerDemo.getResourceString("details.AllFolders.text"));
    treeScopeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));

    tree = new Tree(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    tree.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));

    tree.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent event) {
            final TreeItem[] selection = tree.getSelection();
            if (selection != null && selection.length != 0) {
                TreeItem item = selection[0];
                File file = (File) item.getData(TREEITEMDATA_FILE);

                notifySelectedDirectory(file);
            }
        }

        public void widgetDefaultSelected(SelectionEvent event) {
            final TreeItem[] selection = tree.getSelection();
            if (selection != null && selection.length != 0) {
                TreeItem item = selection[0];
                item.setExpanded(true);
                treeExpandItem(item);
            }
        }
    });
    tree.addTreeListener(new TreeAdapter() {
        public void treeExpanded(TreeEvent event) {
            final TreeItem item = (TreeItem) event.item;
            final Image image = (Image) item.getData(TREEITEMDATA_IMAGEEXPANDED);
            if (image != null)
                item.setImage(image);
            treeExpandItem(item);
        }

        public void treeCollapsed(TreeEvent event) {
            final TreeItem item = (TreeItem) event.item;
            final Image image = (Image) item.getData(TREEITEMDATA_IMAGECOLLAPSED);
            if (image != null)
                item.setImage(image);
        }
    });
    createTreeDragSource(tree);
    createTreeDropTarget(tree);
}

From source file:org.eclipse.swt.examples.layoutexample.Tab.java

/**
 * Refreshes the composite and draws all controls
 * in the layout example./*from   w w  w.j  av a 2  s.c om*/
 */
void refreshLayoutComposite() {
    /* Remove children that are already laid out */
    children = layoutComposite.getChildren();
    for (Control child : children) {
        child.dispose();
    }
    /* Add all children listed in the table */
    TableItem[] items = table.getItems();
    children = new Control[items.length];
    String[] itemValues = new String[] { LayoutExample.getResourceString("Item", new String[] { "1" }),
            LayoutExample.getResourceString("Item", new String[] { "2" }),
            LayoutExample.getResourceString("Item", new String[] { "3" }) };
    for (int i = 0; i < items.length; i++) {
        String control = items[i].getText(1);
        String controlName = items[i].getText(0);
        if (control.equals("Button")) {
            Button button = new Button(layoutComposite, SWT.PUSH);
            button.setText(controlName);
            children[i] = button;
        } else if (control.equals("Canvas")) {
            Canvas canvas = new Canvas(layoutComposite, SWT.BORDER);
            children[i] = canvas;
        } else if (control.equals("Combo")) {
            Combo combo = new Combo(layoutComposite, SWT.NONE);
            combo.setItems(itemValues);
            combo.setText(controlName);
            children[i] = combo;
        } else if (control.equals("Composite")) {
            Composite composite = new Composite(layoutComposite, SWT.BORDER);
            children[i] = composite;
        } else if (control.equals("CoolBar")) {
            CoolBar coolBar = new CoolBar(layoutComposite, SWT.NONE);
            ToolBar toolBar = new ToolBar(coolBar, SWT.BORDER);
            ToolItem item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            CoolItem coolItem1 = new CoolItem(coolBar, 0);
            coolItem1.setControl(toolBar);
            toolBar = new ToolBar(coolBar, SWT.BORDER);
            item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "3" }));
            item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "4" }));
            CoolItem coolItem2 = new CoolItem(coolBar, 0);
            coolItem2.setControl(toolBar);
            Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            coolItem1.setSize(coolItem1.computeSize(size.x, size.y));
            coolItem2.setSize(coolItem2.computeSize(size.x, size.y));
            coolBar.setSize(coolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            children[i] = coolBar;
        } else if (control.equals("Group")) {
            Group group = new Group(layoutComposite, SWT.NONE);
            group.setText(controlName);
            children[i] = group;
        } else if (control.equals("Label")) {
            Label label = new Label(layoutComposite, SWT.NONE);
            label.setText(controlName);
            children[i] = label;
        } else if (control.equals("Link")) {
            Link link = new Link(layoutComposite, SWT.NONE);
            link.setText(controlName);
            children[i] = link;
        } else if (control.equals("List")) {
            org.eclipse.swt.widgets.List list = new org.eclipse.swt.widgets.List(layoutComposite, SWT.BORDER);
            list.setItems(itemValues);
            children[i] = list;
        } else if (control.equals("ProgressBar")) {
            ProgressBar progress = new ProgressBar(layoutComposite, SWT.NONE);
            progress.setSelection(50);
            children[i] = progress;
        } else if (control.equals("Scale")) {
            Scale scale = new Scale(layoutComposite, SWT.NONE);
            children[i] = scale;
        } else if (control.equals("Slider")) {
            Slider slider = new Slider(layoutComposite, SWT.NONE);
            children[i] = slider;
        } else if (control.equals("StyledText")) {
            StyledText styledText = new StyledText(layoutComposite,
                    SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
            styledText.setText(controlName);
            children[i] = styledText;
        } else if (control.equals("Table")) {
            Table table = new Table(layoutComposite, SWT.BORDER);
            table.setLinesVisible(true);
            TableItem item1 = new TableItem(table, 0);
            item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            TableItem item2 = new TableItem(table, 0);
            item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            children[i] = table;
        } else if (control.equals("Text")) {
            Text text = new Text(layoutComposite, SWT.BORDER);
            text.setText(controlName);
            children[i] = text;
        } else if (control.equals("ToolBar")) {
            ToolBar toolBar = new ToolBar(layoutComposite, SWT.BORDER);
            ToolItem item1 = new ToolItem(toolBar, 0);
            item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            ToolItem item2 = new ToolItem(toolBar, 0);
            item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            children[i] = toolBar;
        } else {
            Tree tree = new Tree(layoutComposite, SWT.BORDER);
            TreeItem item1 = new TreeItem(tree, 0);
            item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            TreeItem item2 = new TreeItem(tree, 0);
            item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            children[i] = tree;
        }
    }
}

From source file:LayoutExample.java

/**
 * Refreshes the composite and draws all controls in the layout example.
 *//* ww w .  j  a v  a  2s . c o m*/
void refreshLayoutComposite() {
    /* Remove children that are already laid out */
    children = layoutComposite.getChildren();
    for (int i = 0; i < children.length; i++) {
        children[i].dispose();
    }
    /* Add all children listed in the table */
    TableItem[] items = table.getItems();
    children = new Control[items.length];
    String[] itemValues = new String[] { LayoutExample.getResourceString("Item", new String[] { "1" }),
            LayoutExample.getResourceString("Item", new String[] { "2" }),
            LayoutExample.getResourceString("Item", new String[] { "3" }) };
    for (int i = 0; i < items.length; i++) {
        String control = items[i].getText(1);
        if (control.equals("Button")) {
            Button button = new Button(layoutComposite, SWT.PUSH);
            button.setText(LayoutExample.getResourceString("Button_Index",
                    new String[] { new Integer(i).toString() }));
            children[i] = button;
        } else if (control.equals("Canvas")) {
            Canvas canvas = new Canvas(layoutComposite, SWT.BORDER);
            children[i] = canvas;
        } else if (control.equals("Combo")) {
            Combo combo = new Combo(layoutComposite, SWT.NONE);
            combo.setItems(itemValues);
            combo.setText(
                    LayoutExample.getResourceString("Combo_Index", new String[] { new Integer(i).toString() }));
            children[i] = combo;
        } else if (control.equals("Composite")) {
            Composite composite = new Composite(layoutComposite, SWT.BORDER);
            children[i] = composite;
        } else if (control.equals("CoolBar")) {
            CoolBar coolBar = new CoolBar(layoutComposite, SWT.NONE);
            ToolBar toolBar = new ToolBar(coolBar, SWT.BORDER);
            ToolItem item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            CoolItem coolItem1 = new CoolItem(coolBar, 0);
            coolItem1.setControl(toolBar);
            toolBar = new ToolBar(coolBar, SWT.BORDER);
            item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "3" }));
            item = new ToolItem(toolBar, 0);
            item.setText(LayoutExample.getResourceString("Item", new String[] { "4" }));
            CoolItem coolItem2 = new CoolItem(coolBar, 0);
            coolItem2.setControl(toolBar);
            Point size = toolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            coolItem1.setSize(coolItem1.computeSize(size.x, size.y));
            coolItem2.setSize(coolItem2.computeSize(size.x, size.y));
            coolBar.setSize(coolBar.computeSize(SWT.DEFAULT, SWT.DEFAULT));
            children[i] = coolBar;
        } else if (control.equals("Group")) {
            Group group = new Group(layoutComposite, SWT.NONE);
            group.setText(
                    LayoutExample.getResourceString("Group_Index", new String[] { new Integer(i).toString() }));
            children[i] = group;
        } else if (control.equals("Label")) {
            Label label = new Label(layoutComposite, SWT.NONE);
            label.setText(
                    LayoutExample.getResourceString("Label_Index", new String[] { new Integer(i).toString() }));
            children[i] = label;
        } else if (control.equals("List")) {
            List list = new List(layoutComposite, SWT.BORDER);
            list.setItems(itemValues);
            children[i] = list;
        } else if (control.equals("ProgressBar")) {
            ProgressBar progress = new ProgressBar(layoutComposite, SWT.NONE);
            progress.setSelection(50);
            children[i] = progress;
        } else if (control.equals("Scale")) {
            Scale scale = new Scale(layoutComposite, SWT.NONE);
            children[i] = scale;
        } else if (control.equals("Slider")) {
            Slider slider = new Slider(layoutComposite, SWT.NONE);
            children[i] = slider;
        } else if (control.equals("StyledText")) {
            StyledText styledText = new StyledText(layoutComposite,
                    SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
            styledText.setText(LayoutExample.getResourceString("StyledText_Index",
                    new String[] { new Integer(i).toString() }));
            children[i] = styledText;
        } else if (control.equals("Table")) {
            Table table = new Table(layoutComposite, SWT.BORDER);
            table.setLinesVisible(true);
            TableItem item1 = new TableItem(table, 0);
            item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            TableItem item2 = new TableItem(table, 0);
            item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            children[i] = table;
        } else if (control.equals("Text")) {
            Text text = new Text(layoutComposite, SWT.BORDER);
            text.setText(
                    LayoutExample.getResourceString("Text_Index", new String[] { new Integer(i).toString() }));
            children[i] = text;
        } else if (control.equals("ToolBar")) {
            ToolBar toolBar = new ToolBar(layoutComposite, SWT.BORDER);
            ToolItem item1 = new ToolItem(toolBar, 0);
            item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            ToolItem item2 = new ToolItem(toolBar, 0);
            item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            children[i] = toolBar;
        } else {
            Tree tree = new Tree(layoutComposite, SWT.BORDER);
            TreeItem item1 = new TreeItem(tree, 0);
            item1.setText(LayoutExample.getResourceString("Item", new String[] { "1" }));
            TreeItem item2 = new TreeItem(tree, 0);
            item2.setText(LayoutExample.getResourceString("Item", new String[] { "2" }));
            children[i] = tree;
        }
    }
}

From source file:DNDExample.java

private Control createWidget(int type, Composite parent, String prefix) {
    switch (type) {
    case BUTTON_CHECK: {
        Button button = new Button(parent, SWT.CHECK);
        button.setText(prefix + " Check box");
        return button;
    }//from  w ww  .j a va2s .  c om
    case BUTTON_TOGGLE: {
        Button button = new Button(parent, SWT.TOGGLE);
        button.setText(prefix + " Toggle button");
        return button;
    }
    case BUTTON_RADIO: {
        Button button = new Button(parent, SWT.RADIO);
        button.setText(prefix + " Radio button");
        return button;
    }
    case TABLE: {
        Table table = new Table(parent, SWT.BORDER | SWT.MULTI);
        TableColumn column1 = new TableColumn(table, SWT.NONE);
        TableColumn column2 = new TableColumn(table, SWT.NONE);
        for (int i = 0; i < 10; i++) {
            TableItem item = new TableItem(table, SWT.NONE);
            item.setText(0, prefix + " name " + i);
            item.setText(1, prefix + " value " + i);
        }
        column1.pack();
        column2.pack();
        return table;
    }
    case TEXT: {
        Text text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
        text.setText(prefix + " Text");
        return text;
    }
    case TREE: {
        Tree tree = new Tree(parent, SWT.BORDER);
        for (int i = 0; i < 3; i++) {
            TreeItem item = new TreeItem(tree, SWT.NONE);
            item.setText(prefix + " item " + i);
            for (int j = 0; j < 3; j++) {
                TreeItem subItem = new TreeItem(item, SWT.NONE);
                subItem.setText(prefix + " item " + j);
                for (int k = 0; k < 3; k++) {
                    TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);
                    subsubItem.setText(prefix + " item " + k);
                }
            }
        }
        return tree;
    }
    case CANVAS: {
        Canvas canvas = new Canvas(parent, SWT.BORDER);
        canvas.setData("STRINGS", new String[] { prefix + " Canvas widget" });
        canvas.addPaintListener(new PaintListener() {
            public void paintControl(PaintEvent e) {
                Canvas c = (Canvas) e.widget;
                Image image = (Image) c.getData("IMAGE");
                if (image != null) {
                    e.gc.drawImage(image, 5, 5);
                } else {
                    String[] strings = (String[]) c.getData("STRINGS");
                    if (strings != null) {
                        FontMetrics metrics = e.gc.getFontMetrics();
                        int height = metrics.getHeight();
                        int y = 5;
                        for (int i = 0; i < strings.length; i++) {
                            e.gc.drawString(strings[i], 5, y);
                            y += height + 5;
                        }
                    }
                }
            }
        });
        return canvas;
    }
    case LABEL: {
        Label label = new Label(parent, SWT.BORDER);
        label.setText(prefix + " Label");
        return label;
    }
    case LIST: {
        List list = new List(parent, SWT.BORDER);
        list.setItems(new String[] { prefix + " Item a", prefix + " Item b", prefix + " Item c",
                prefix + " Item d" });
        return list;
    }
    default:
        throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED);
    }
}

From source file:org.eclipse.swt.examples.dnd.DNDExample.java

private Control createWidget(int type, Composite parent, String prefix) {
    switch (type) {
    case BUTTON_CHECK: {
        Button button = new Button(parent, SWT.CHECK);
        button.setText(prefix + " Check box");
        return button;
    }//from  ww w  . j  a v a 2  s.  c  o m
    case BUTTON_TOGGLE: {
        Button button = new Button(parent, SWT.TOGGLE);
        button.setText(prefix + " Toggle button");
        return button;
    }
    case BUTTON_RADIO: {
        Button button = new Button(parent, SWT.RADIO);
        button.setText(prefix + " Radio button");
        return button;
    }
    case STYLED_TEXT: {
        StyledText text = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
        text.setText(prefix + " Styled Text");
        return text;
    }
    case TABLE: {
        Table table = new Table(parent, SWT.BORDER | SWT.MULTI);
        table.setHeaderVisible(true);
        TableColumn column0 = new TableColumn(table, SWT.LEFT);
        column0.setText("Name");
        TableColumn column1 = new TableColumn(table, SWT.RIGHT);
        column1.setText("Value");
        TableColumn column2 = new TableColumn(table, SWT.CENTER);
        column2.setText("Description");
        for (int i = 0; i < 10; i++) {
            TableItem item = new TableItem(table, SWT.NONE);
            item.setText(0, prefix + " name " + i);
            item.setText(1, prefix + " value " + i);
            item.setText(2, prefix + " description " + i);
            item.setImage(itemImage);
        }
        column0.pack();
        column1.pack();
        column2.pack();
        return table;
    }
    case TEXT: {
        Text text = new Text(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
        text.setText(prefix + " Text");
        return text;
    }
    case TREE: {
        Tree tree = new Tree(parent, SWT.BORDER | SWT.MULTI);
        tree.setHeaderVisible(true);
        TreeColumn column0 = new TreeColumn(tree, SWT.LEFT);
        column0.setText("Name");
        TreeColumn column1 = new TreeColumn(tree, SWT.RIGHT);
        column1.setText("Value");
        TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
        column2.setText("Description");
        for (int i = 0; i < 3; i++) {
            TreeItem item = new TreeItem(tree, SWT.NONE);
            item.setText(0, prefix + " name " + i);
            item.setText(1, prefix + " value " + i);
            item.setText(2, prefix + " description " + i);
            item.setImage(itemImage);
            for (int j = 0; j < 3; j++) {
                TreeItem subItem = new TreeItem(item, SWT.NONE);
                subItem.setText(0, prefix + " name " + i + " " + j);
                subItem.setText(1, prefix + " value " + i + " " + j);
                subItem.setText(2, prefix + " description " + i + " " + j);
                subItem.setImage(itemImage);
                for (int k = 0; k < 3; k++) {
                    TreeItem subsubItem = new TreeItem(subItem, SWT.NONE);
                    subsubItem.setText(0, prefix + " name " + i + " " + j + " " + k);
                    subsubItem.setText(1, prefix + " value " + i + " " + j + " " + k);
                    subsubItem.setText(2, prefix + " description " + i + " " + j + " " + k);
                    subsubItem.setImage(itemImage);
                }
            }
        }
        column0.pack();
        column1.pack();
        column2.pack();
        return tree;
    }
    case CANVAS: {
        Canvas canvas = new Canvas(parent, SWT.BORDER);
        canvas.setData("STRINGS", new String[] { prefix + " Canvas widget" });
        canvas.addPaintListener(e -> {
            Canvas c = (Canvas) e.widget;
            Image image = (Image) c.getData("IMAGE");
            if (image != null) {
                e.gc.drawImage(image, 5, 5);
            } else {
                String[] strings = (String[]) c.getData("STRINGS");
                if (strings != null) {
                    FontMetrics metrics = e.gc.getFontMetrics();
                    int height = metrics.getHeight();
                    int y = 5;
                    for (String string : strings) {
                        e.gc.drawString(string, 5, y);
                        y += height + 5;
                    }
                }
            }
        });
        return canvas;
    }
    case LABEL: {
        Label label = new Label(parent, SWT.BORDER);
        label.setText(prefix + " Label");
        return label;
    }
    case LIST: {
        List list = new List(parent, SWT.BORDER | SWT.MULTI);
        list.setItems(prefix + " Item a", prefix + " Item b", prefix + " Item c", prefix + " Item d");
        return list;
    }
    case COMBO: {
        Combo combo = new Combo(parent, SWT.BORDER);
        combo.setItems("Item a", "Item b", "Item c", "Item d");
        return combo;
    }
    default:
        throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED);
    }
}

From source file:CustomControlExample.java

/**
 * Creates the "Example" widgets.//from  w  ww. j a  va 2  s .co m
 */
void createExampleWidgets() {
    /* Compute the widget style */
    int style = getDefaultStyle();
    if (singleButton.getSelection())
        style |= SWT.SINGLE;
    if (multiButton.getSelection())
        style |= SWT.MULTI;
    if (checkButton.getSelection())
        style |= SWT.CHECK;
    if (fullSelectionButton.getSelection())
        style |= SWT.FULL_SELECTION;
    if (borderButton.getSelection())
        style |= SWT.BORDER;

    /* Create the text tree */
    tree1 = new Tree(treeGroup, style);
    if (multipleColumns.getSelection()) {
        for (int i = 0; i < columnTitles.length; i++) {
            TreeColumn treeColumn = new TreeColumn(tree1, SWT.NONE);
            treeColumn.setText(columnTitles[i]);
        }
    }
    for (int i = 0; i < 4; i++) {
        TreeItem item = new TreeItem(tree1, SWT.NONE);
        setItemText(item, i, ControlExample.getResourceString("Node_" + (i + 1)));
        if (i < 3) {
            TreeItem subitem = new TreeItem(item, SWT.NONE);
            setItemText(subitem, i, ControlExample.getResourceString("Node_" + (i + 1) + "_1"));
        }
    }
    TreeItem treeRoots[] = tree1.getItems();
    TreeItem item = new TreeItem(treeRoots[1], SWT.NONE);
    setItemText(item, 1, ControlExample.getResourceString("Node_2_2"));
    item = new TreeItem(item, SWT.NONE);
    setItemText(item, 1, ControlExample.getResourceString("Node_2_2_1"));
    textNode1 = treeRoots[0];
    packColumns(tree1);

    /* Create the image tree */
    tree2 = new Tree(imageTreeGroup, style);
    Image image = instance.images[ControlExample.ciClosedFolder];
    if (multipleColumns.getSelection()) {
        for (int i = 0; i < columnTitles.length; i++) {
            TreeColumn treeColumn = new TreeColumn(tree2, SWT.NONE);
            treeColumn.setText(columnTitles[i]);
        }
    }
    for (int i = 0; i < 4; i++) {
        item = new TreeItem(tree2, SWT.NONE);
        setItemText(item, i, ControlExample.getResourceString("Node_" + (i + 1)));
        item.setImage(image);
        if (i < 3) {
            TreeItem subitem = new TreeItem(item, SWT.NONE);
            setItemText(subitem, i, ControlExample.getResourceString("Node_" + (i + 1) + "_1"));
            subitem.setImage(image);
        }
    }
    treeRoots = tree2.getItems();
    item = new TreeItem(treeRoots[1], SWT.NONE);
    setItemText(item, 1, ControlExample.getResourceString("Node_2_2"));
    item.setImage(image);
    item = new TreeItem(item, SWT.NONE);
    setItemText(item, 1, ControlExample.getResourceString("Node_2_2_1"));
    item.setImage(image);
    imageNode1 = treeRoots[0];
    packColumns(tree2);
}