ScrolledComposite Question [message #1827937] |
Wed, 27 May 2020 09:14 |
Christian Eugster Messages: 213 Registered: July 2009 Location: St. Gallen Switzerland |
Senior Member |
|
|
Hi
In a face dialog I want to show a list of items as composites. My current implementation seems to be incorrect: It only shows maximal 10 items, further items seem to be ignored. I looked now for a longer while for a solution without any success. Maybe someone may give me a hint. The code that builds the ui of the dialog looks like:
@Override
protected Control createDialogArea(final Composite parent)
{
this.setTitle();
this.setMessage();
Composite composite = new Composite(parent, SWT.BORDER);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new GridLayout());
Set<AddressGroup> extractedAddressGroups = extractAddressGroups(selection);
if (extractedAddressGroups.size() > 1)
{
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.heightHint = 120;
final ScrolledComposite scrolledComposite = new ScrolledComposite(composite, SWT.BORDER | SWT.SHADOW_ETCHED_IN | SWT.V_SCROLL);
scrolledComposite.addListener(SWT.Resize, new Listener()
{
@Override
public void handleEvent(Event event)
{
int width = scrolledComposite.getClientArea().width;
scrolledComposite.setMinSize( parent.computeSize( width, SWT.DEFAULT ) );
}
});
scrolledComposite.setLayout(layout);
scrolledComposite.setLayoutData(gridData);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
gridData = new GridData(GridData.FILL_HORIZONTAL);
//gridData.heightHint = extractedAddressGroups.size() * 46 + 20;
Composite mainAddressGroupComposite = new Composite(scrolledComposite, SWT.BORDER);
mainAddressGroupComposite.setLayout(layout);
mainAddressGroupComposite.setLayoutData(gridData);
AddressGroup[] addressGroups = extractedAddressGroups.toArray(new AddressGroup[0]);
this.addressGroupLines = new ArrayList<AddressGroupLine>();
for (int i = 0; i < addressGroups.length; i++)
{
Composite addressGroupComposite = new Composite(mainAddressGroupComposite, SWT.None);
addressGroupComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
addressGroupComposite.setLayout(new GridLayout(3, false));
if (i == 0)
{
test = addressGroupComposite;
}
System.out.println(this.addressGroupLines.add(new AddressGroupLine(i, addressGroupComposite, addressGroups[i])));
}
scrolledComposite.setContent(mainAddressGroupComposite);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
scrolledComposite.pack();
}
if (EditorSelector.values()[PersonSettings.getInstance().getEditorSelector()]
.equals(EditorSelector.MULTI_PAGE_EDITOR))
{
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
collectionSelector = new Button(composite, SWT.CHECK);
collectionSelector.setText("Gruppenadressen nur einmal auflisten");
collectionSelector.setLayoutData(gridData);
}
Label label = new Label(composite, SWT.None);
label.setLayoutData(new GridData());
label.setText("Sortierung");
DataMapKey[] keys = this.getSortKeys();
Combo combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
sortViewer = new ComboViewer(combo);
sortViewer.setContentProvider(new ArrayContentProvider());
sortViewer.setLabelProvider(new LabelProvider()
{
@Override
public String getText(Object element)
{
if (element instanceof DataMapKey)
{
DataMapKey key = (DataMapKey) element;
return key.getName();
}
return "";
}
});
sortViewer.setInput(this.getSortKeys());
sortViewer.setSelection(new StructuredSelection(new DataMapKey[] { keys[0] }));
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
shortList = new Button(composite, SWT.CHECK);
shortList.setLayoutData(gridData);
shortList.setText("Kurzliste");
shortList.setSelection(settings.getBoolean("short.list.selected"));
shortList.addSelectionListener(new SelectionListener()
{
@Override
public void widgetSelected(SelectionEvent e)
{
settings.put("short.list.selected", shortList.getSelection());
System.out.println(test.getBounds().height);
}
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
widgetSelected(e);
}
});
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
courseVisits = new Button(composite, SWT.CHECK);
courseVisits.setLayoutData(gridData);
courseVisits.setText("mit Kursteilnahmen");
courseVisits.setSelection(settings.getBoolean("course.visits.selected"));
courseVisits.addSelectionListener(new SelectionListener()
{
@Override
public void widgetSelected(SelectionEvent e)
{
settings.put("course.visits.selected", courseVisits.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
widgetSelected(e);
}
});
return parent;
}
Thank you
Christian
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03314 seconds