shell.setLayout(new GridLayout(2, false));
Group fieldGroup = new Group(shell, SWT.SHADOW_ETCHED_IN);
fieldGroup.setText("Select fields to include:");
fieldGroup.setLayout(new RowLayout(SWT.VERTICAL));
GridData fieldGroupLayoutData = new GridData();
fieldGroupLayoutData.verticalSpan = 2;
fieldGroup.setLayoutData(fieldGroupLayoutData);
List<IField> fields = generator.findAllFIelds(compilationUnit);
final List<Button> fieldButtons = new ArrayList<Button>();
for(IField field: fields) {
Button button = new Button(fieldGroup, SWT.CHECK);
button.setText(generator.getName(field) + "(" + generator.getType(field) + ")");
button.setData(field);
button.setSelection(true);
fieldButtons.add(button);
}
Button btnSelectAll = new Button(shell, SWT.PUSH);
btnSelectAll.setText("Select All");
GridData btnSelectAllLayoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
btnSelectAllLayoutData.verticalIndent = 10;
btnSelectAll.setLayoutData(btnSelectAllLayoutData);
btnSelectAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
for (Button button : fieldButtons) {
button.setSelection(true);
}
}
});
Button btnSelectNone = new Button(shell, SWT.PUSH);
btnSelectNone.setText("Deselect All");
GridData selectNoneGridData = new GridData();
selectNoneGridData.verticalAlignment = SWT.BEGINNING;
btnSelectNone.setLayoutData(selectNoneGridData);
btnSelectNone.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
for (Button button : fieldButtons) {
button.setSelection(false);
}
}
});
Group optionGroup = new Group(shell, SWT.SHADOW_ETCHED_IN);
optionGroup.setText("Options:");
optionGroup.setLayout(new RowLayout(SWT.VERTICAL));
GridData optionGridData = new GridData();
optionGridData.horizontalSpan = 2;
optionGridData.horizontalAlignment = SWT.FILL;
optionGroup.setLayoutData(optionGridData);