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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
public class WindowDisplay
{
public WindowDisplay()
{
final Display display = PlatformUI.getWorkbench().getDisplay();
final Shell shell = new Shell(display, SWT.APPLICATION_MODAL
| SWT.CLOSE
| SWT.TITLE
| SWT.MAX
| SWT.RESIZE);
shell.setText("Métriques");
shell.setSize(700, 700);
shell.setLayout(new GridLayout(1, true));
Composite composite = new Composite(shell, SWT.None);
GridData compositeGridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
| GridData.HORIZONTAL_ALIGN_FILL| GridData.VERTICAL_ALIGN_FILL);
composite.setLayoutData(compositeGridData);
composite.setLayout(new GridLayout(2, false));
Composite treeComposite = new Composite(composite, SWT.FILL);
GridData treeCompositeGridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
| GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
treeCompositeGridData.horizontalSpan = 2;
treeComposite.setLayoutData(treeCompositeGridData);
treeComposite.setLayout(new GridLayout(1, false));
Tree tree = new Tree(treeComposite, SWT.BORDER);
GridData treeGridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
| GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
tree.setLayoutData(treeGridData);
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TreeColumn column1 = new TreeColumn(tree, SWT.NONE);
column1.setText("column1");
TreeColumn column2 = new TreeColumn(tree, SWT.NONE);
column2.setText("column2");
TreeColumn column3 = new TreeColumn(tree, SWT.NONE);
column3.setText("column3");
TreeColumn column4 = new TreeColumn(tree, SWT.NONE);
column4.setText("column4");
TreeColumn column5 = new TreeColumn(tree, SWT.NONE);
column5.setText("column5");
TreeColumn column6 = new TreeColumn(tree, SWT.NONE);
column6.setText("column6");
TreeItem branch = new TreeItem(tree, SWT.NONE);
branch.setText("Racine");
TreeItem treeItem = new TreeItem(branch, SWT.NONE);
treeItem.setText("sousracine1");
TreeItem leaf = null;
TreeItem leafItem = null;
TreeItem subLeafItem = null;
for (A a : getlistOfAs())
{
leaf = new TreeItem(treeItem, SWT.NONE);
leaf.setText(new String[]
{ a.getName(), String.valueOf(a.getValue()) });
}
for (B b : getListOfBs())
{
leaf = new TreeItem(treeItem, SWT.NONE);
leaf.setText(new String[]
{ b.getName(), String.valueOf(b.getValue()) });
for (Ba bA : b.getListOfAs())
{
leafItem = new TreeItem(leaf, SWT.NONE);
leafItem.setText(new String[]
{ bA.getName(), String.valueOf(bA.getValue()) });
}
}
for (C c : getListOfCs())
{
treeItem = new TreeItem(branch, SWT.NONE);
treeItem.setText(c.getName());
leaf = new TreeItem(treeItem, SWT.NONE);
leaf.setText("Projet");
for (A cA : c.getListOfAs())
{
leafItem = new TreeItem(leaf, SWT.NONE);
leafItem.setText(new String[]
{ cA.getName(), String.valueOf(cA.getValue()) });
}
for (B cB : C.getListOfBs())
{
leafItem = new TreeItem(leaf, SWT.NONE);
leafItem.setText(new String[]
{ cB.getName(), String.valueOf(cB.getValue()) });
for (A cBA : cB.getListOfAs())
{
subLeafItem = new TreeItem(leafItem, SWT.NONE);
subLeafItem.setText(new String[]
{ cBA.getName(), String.valueOf(cBA.getValue()) });
}
}
for (C cC : C.getListOfCs())
{
leaf = new TreeItem(treeItem, SWT.NONE);
leaf.setText(cC.getName());
for (A cCa : cC.getListOfAs())
{
leafItem = new TreeItem(leaf, SWT.NONE);
leafItem.setText(new String[]
{ cCa.getName(), String.valueOf(cCa.getValue()) });
}
for (B cCB : cC.getListOfBs())
{
leafItem = new TreeItem(leaf, SWT.NONE);
leafItem.setText(new String[]
{ cCB.getName(), String.valueOf(cCB.getValue()) });
for (A cCBA : cCB.getListOfAs())
{
subLeafItem = new TreeItem(leafItem, SWT.NONE);
subLeafItem.setText(new String[]
{ cCBA.getName(), String.valueOf(cCBA.getValue()) });
}
}
}
}
branch.setExpanded(true);// Lorsque j'ajoute ce noeud tout va bien !!!!!!!!!!?????????
branch = new TreeItem(tree, SWT.NONE);
branch.setText("");
branch.setExpanded(true);
column1.pack();
column2.pack();
column3.pack();
column4.pack();
column5.pack();
column6.pack();
shell.setLocation(300, 100);
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
}
} |