Composite container = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(container, SWT.NONE);
new Label(composite, SWT.NONE).setText(selectionLabel);
ContentProposalAdapter proposalAdapter = null;
Text txtSelection = null;
Table table = null;
if (multi)
{
table = new Table(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
viewer = new TableViewer(table);
viewer.setContentProvider(new ArrayContentProvider());
viewer.addFilter(new ViewerFilter()
{
public boolean select(Viewer viewer, Object parentElement, Object element)
{
@SuppressWarnings("unchecked")
E castedElement = (E) element;
return filter == null || filter.select(castedElement);
}
});
if (comparator != null)
{
viewer.setSorter(new ViewerSorter()
{
@Override
public int compare(Viewer viewer, Object o1, Object o2)
{
@SuppressWarnings("unchecked")
E e1 = (E) o1;
@SuppressWarnings("unchecked")
E e2 = (E) o2;
return comparator.compare(e1, e2);
}
});
}
synchronized (elements)
{
viewer.setInput(elements);
}
if (labelProvider != null)
{
viewer.setLabelProvider(labelProvider);
}
}
else
{
txtSelection = new Text(composite, SWT.BORDER);
ControlDecoration selectionDecor = new ControlDecoration(txtSelection,
SWT.LEFT | SWT.TOP);
FieldDecoration proposalDecor = FieldDecorationRegistry.getDefault().getFieldDecoration(
FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
selectionDecor.setImage(proposalDecor.getImage());
selectionDecor.setDescriptionText(proposalDecor.getDescription());
ExclusionContentProposalProvider<E> proposalProvider = new ExclusionContentProposalProvider<E>(
elements, filter, descriptor);
proposalAdapter = new ContentProposalAdapter(txtSelection,
new TextContentAdapter(), proposalProvider, null, null);
proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
if (labelProvider != null)
{
proposalAdapter.setLabelProvider(labelProvider);
}
if (selectedName != null)
{
txtSelection.setText(selectedName);
}
}
updateSelection();
updateButtons();
// Hookup listeners
if (proposalAdapter != null)
{
proposalAdapter.addContentProposalListener(new IContentProposalListener()
{
public void proposalAccepted(IContentProposal proposal)
{
@SuppressWarnings("unchecked")
WrappedContentProposal<E> valueProposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<E>) proposal;