use of org.jkiss.dbeaver.ui.controls.itemlist.ObjectListControl in project dbeaver by serge-rider.
the class SelectObjectDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(title);
Composite group = (Composite) super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
group.setLayoutData(gd);
ObjectListControl<T> objectList = new ObjectListControl<T>(group, SWT.BORDER | (singleSelection ? SWT.SINGLE : SWT.MULTI), new ListContentProvider()) {
@NotNull
@Override
protected String getListConfigId(List<Class<?>> classList) {
return "ObjectsSelector";
}
@Override
protected LoadingJob<Collection<T>> createLoadService() {
return LoadingJob.createService(new AbstractLoadService<Collection<T>>() {
@Override
public Collection<T> evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
return objects;
}
@Override
public Object getFamily() {
return SelectObjectDialog.this;
}
}, new ObjectsLoadVisualizer());
}
};
objectList.createProgressPanel();
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
gd.minimumWidth = 300;
objectList.setLayoutData(gd);
objectList.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
selectedObjects.clear();
selectedObjects.addAll(selection.toList());
getButton(IDialogConstants.OK_ID).setEnabled(!selectedObjects.isEmpty());
}
});
objectList.setDoubleClickHandler(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (getButton(IDialogConstants.OK_ID).isEnabled()) {
okPressed();
}
}
});
objectList.loadData();
return group;
}
Aggregations