use of org.jkiss.dbeaver.core.DBeaverCore in project dbeaver by serge-rider.
the class SelectDataSourceDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(CoreMessages.dialog_select_datasource_title);
Composite group = (Composite) super.createDialogArea(parent);
GridData gd = new GridData(GridData.FILL_BOTH);
group.setLayoutData(gd);
DBeaverCore core = DBeaverCore.getInstance();
DBNNode rootNode = null;
if (project != null) {
DBNProject projectNode = core.getNavigatorModel().getRoot().getProject(project);
if (projectNode != null) {
rootNode = projectNode.getDatabases();
}
}
if (rootNode == null) {
rootNode = core.getNavigatorModel().getRoot();
}
DatabaseNavigatorTree dataSourceTree = new DatabaseNavigatorTree(group, rootNode, SWT.SINGLE | SWT.BORDER, false);
dataSourceTree.setLayoutData(new GridData(GridData.FILL_BOTH));
final Text descriptionText = new Text(group, SWT.READ_ONLY);
descriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
dataSourceTree.getViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof DBNProject || element instanceof DBNProjectDatabases || element instanceof DBNLocalFolder || element instanceof DBNDataSource;
}
});
dataSourceTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection structSel = (IStructuredSelection) event.getSelection();
Object selNode = structSel.isEmpty() ? null : structSel.getFirstElement();
if (selNode instanceof DBNDataSource) {
dataSource = ((DBNDataSource) selNode).getObject();
getButton(IDialogConstants.OK_ID).setEnabled(true);
String description = dataSource.getDescription();
if (description == null) {
description = dataSource.getName();
}
descriptionText.setText(description);
} else {
dataSource = null;
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
}
});
dataSourceTree.getViewer().addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (getButton(IDialogConstants.OK_ID).isEnabled()) {
okPressed();
}
}
});
return group;
}
use of org.jkiss.dbeaver.core.DBeaverCore in project dbeaver by serge-rider.
the class KeepAliveJob method run.
@Override
protected IStatus run(DBRProgressMonitor monitor) {
if (DBeaverCore.isClosing()) {
return Status.OK_STATUS;
}
final DBeaverCore core = DBeaverCore.getInstance();
final ProjectRegistry projectRegistry = core.getProjectRegistry();
if (projectRegistry == null) {
return Status.OK_STATUS;
}
for (DataSourceDescriptor ds : DataSourceRegistry.getAllDataSources()) {
checkDataSourceAlive(monitor, ds);
}
if (!DBeaverCore.isClosing()) {
scheduleMonitor();
}
return Status.OK_STATUS;
}
Aggregations