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
| public class TestSWT {
public static void main(String[] args) {
Display display = new Display();
try {
test(display);
}
finally {
display.dispose();
}
}
private static void test(Display display) {
Shell shell = new Shell(display);
GridLayoutFactory.swtDefaults().applyTo(shell);
createControl(shell);
shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
}
private static void createControl(final Composite parent) {
final Composite comp = new Composite(parent, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(comp);
GridLayoutFactory.fillDefaults().spacing(LayoutConstants.getSpacing()).numColumns(3).equalWidth(false).applyTo(comp);
Label labelTitre = new Label(comp,SWT.NONE);
labelTitre.setText("Informations concernants les numéros de configuration");
//labelTitre.setFont(new Font(null,"Arial",14,0)); // pas de dispose !
GridData titreGD = new GridData(SWT.FILL, SWT.CENTER, true, false);
titreGD.horizontalSpan = 4;
titreGD.heightHint = 40;
final ScrolledComposite scrolledComposite = new ScrolledComposite (comp, SWT.V_SCROLL);
GridDataFactory.fillDefaults().align(SWT.FILL,SWT.FILL).grab(false, false).applyTo(scrolledComposite);
labelTitre.setLayoutData(titreGD);
final Group groupTT = new Group(scrolledComposite,SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL,SWT.FILL).grab(false, false).applyTo(groupTT);
scrolledComposite.setContent(groupTT);
Group groupOM = new Group(comp,SWT.NONE);
Group groupOT = new Group(comp,SWT.NONE);
GridLayout gridTT = new GridLayout(2,false);
groupTT.setLayout(gridTT);
Label labelTTtitre = new Label(groupTT,SWT.NONE);
labelTTtitre.setText("Renommer les Tests Type");
//labelTTtitre.setFont(new Font(null,"Arial",10,0)); // pas de dispose !
GridData ttGridData = new GridData(GridData.FILL_HORIZONTAL);
ttGridData.horizontalSpan = 2;
labelTTtitre.setLayoutData(ttGridData);
/*listMat = MyWizard.one.getListTableChecked();
//String name = MyWizard.one.getName();
java.util.List<String> nameMatSansAff = new ArrayList<String>();
for(int i = 0; i<listMat.size(); i++){
String[] nameMat = listMat.get(i).split(name);
nameMatSansAff.add(nameMat[0]);
}*/
/*java.util.List<String> nameTestType = new ArrayList<String>();
for(int i = 0; i<nameMatSansAff.size(); i++){
String[] nameTT = nameMatSansAff.get(i).split("_");
boolean exist = false;
for(int t = 0; t<nameTT.length; t++){
for(int j = 0; j<nameTestType.size(); j++){
if(nameTT[t].equals(nameTestType.get(j))){
exist = true;
}
}
if(!exist){
nameTestType.add(nameTT[t]);
}
}
}*/
for(int i=0; i<10; i++){
Label labelTT = new Label(groupTT,SWT.NONE);
labelTT.setText("toto"+i);
//labelTT.setFont(new Font(null,"Arial",9,0)); // pas de dispose !
Text textTT = new Text(groupTT,SWT.BORDER);
textTT.setText("");
GridData textGD = new GridData(GridData.FILL_HORIZONTAL);
textGD.widthHint = 100;
textTT.setLayoutData(textGD);
}
scrolledComposite.setMinSize(groupTT.computeSize(SWT.DEFAULT, SWT.DEFAULT));
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
comp.getShell().addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
((GridData)scrolledComposite.getLayoutData()).heightHint=
Math.max(0, comp.getShell().getSize().y/5);
comp.layout(true,true);
}
});
/*// avec ça la scrolled composite s'adapter à la hauteur de la fenêtre disponible au dessous du scrolled composite
// ne fonctionne que s'il n'y a pas de composant en dessous (il faudrait retirer la hauteur prise par ces composants)
comp.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
((GridData)scrolledComposite.getLayoutData()).heightHint=Math.min(
Math.max(0, comp.getSize().y-scrolledComposite.getLocation().y), scrolledComposite.getMinHeight());
comp.layout(true,true);
}
});*/
}
} |
Partager