Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0270245c6d43e23a44862a95dc9fab86c2ca8a51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package org.eclipse.swt.examples.controls;

/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved
 */

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.events.*;

class TreeTab extends ScrollableTab {
	/* Example widgets and groups that contain them */
	Tree tree1, tree2;
	Group treeGroup, imageTreeGroup;

	/**
	 * Creates the "Example" group.
	 */
	void createExampleGroup () {
		super.createExampleGroup ();
		
		/* Create a group for the text tree */
		treeGroup = new Group (exampleGroup, SWT.NULL);
		treeGroup.setLayout (new GridLayout ());
		treeGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
		treeGroup.setText (ControlPlugin.getResourceString("Tree"));
	
		/* Create a group for the image tree */
		imageTreeGroup = new Group (exampleGroup, SWT.NULL);
		imageTreeGroup.setLayout (new GridLayout ());
		imageTreeGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
		imageTreeGroup.setText (ControlPlugin.getResourceString("Tree_With_Images"));
	}
	
	/**
	 * Creates the "Example" widgets.
	 */
	void createExampleWidgets () {
		/* Compute the widget style */
		int style = SWT.NONE;
		if (singleButton.getSelection()) style |= SWT.SINGLE;
		if (multiButton.getSelection()) style |= SWT.MULTI;
		if (borderButton.getSelection()) style |= SWT.BORDER;
	
		/* Create the text tree */
		tree1 = new Tree (treeGroup, style);
		TreeItem node1 = new TreeItem (tree1, SWT.NULL);
		node1.setText (ControlPlugin.getResourceString("Node_1"));
		TreeItem node2 = new TreeItem (tree1, SWT.NULL);
		node2.setText (ControlPlugin.getResourceString("Node_2"));
		TreeItem node3 = new TreeItem (tree1, SWT.NULL);
		node3.setText (ControlPlugin.getResourceString("Node_3"));
		TreeItem node4 = new TreeItem (tree1, SWT.NULL);
		node4.setText (ControlPlugin.getResourceString("Node_4"));
		TreeItem node1_1 = new TreeItem (node1, SWT.NULL);
		node1_1.setText (ControlPlugin.getResourceString("Node_1_1"));
		TreeItem node2_1 = new TreeItem (node2, SWT.NULL);
		node2_1.setText (ControlPlugin.getResourceString("Node_2_1"));
		TreeItem node3_1 = new TreeItem (node3, SWT.NULL);
		node3_1.setText (ControlPlugin.getResourceString("Node_3_1"));
		TreeItem node2_2 = new TreeItem (node2, SWT.NULL);
		node2_2.setText (ControlPlugin.getResourceString("Node_2_2"));
		TreeItem node2_2_1 = new TreeItem (node2_2, SWT.NULL);
		node2_2_1.setText (ControlPlugin.getResourceString("Node_2_2_1"));
	
		/* Create the image tree */	
		tree2 = new Tree (imageTreeGroup, style);
		node1 = new TreeItem (tree2, SWT.NULL);
		node1.setText (ControlPlugin.getResourceString("Node_1"));
		node1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
		node2 = new TreeItem (tree2, SWT.NULL);
		node2.setText (ControlPlugin.getResourceString("Node_2"));
		node2.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
		node3 = new TreeItem (tree2, SWT.NULL);
		node3.setText (ControlPlugin.getResourceString("Node_3"));
		node3.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
		node4 = new TreeItem (tree2, SWT.NULL);
		node4.setText (ControlPlugin.getResourceString("Node_4"));
		node4.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
		node1_1 = new TreeItem (node1, SWT.NULL);
		node1_1.setText (ControlPlugin.getResourceString("Node_1_1"));
		node1_1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
		node2_1 = new TreeItem (node2, SWT.NULL);
		node2_1.setText (ControlPlugin.getResourceString("Node_2_1"));
		node2_1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
		node3_1 = new TreeItem (node3, SWT.NULL);
		node3_1.setText (ControlPlugin.getResourceString("Node_3_1"));
		node3_1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
		node2_2 = new TreeItem(node2, SWT.NULL);
		node2_2.setText (ControlPlugin.getResourceString("Node_2_2"));
		node2_2.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
		node2_2_1 = new TreeItem (node2_2, SWT.NULL);
		node2_2_1.setText (ControlPlugin.getResourceString("Node_2_2_1"));
		node2_2_1.setImage (ControlPlugin.images[ControlPlugin.ciClosedFolder]);
	}
	
	/**
	 * Gets the "Example" widget children.
	 */
	Control [] getExampleWidgets () {
		return new Control [] {tree1, tree2};
	}
	
	/**
	 * Gets the text for the tab folder item.
	 */
	String getTabText () {
		return ControlPlugin.getResourceString("Tree");
	}
}

Back to the top