use of org.csstudio.trends.databrowser3.archive.ConnectJob in project org.csstudio.display.builder by kasemir.
the class ArchiveListGUI method connectToArchiveServer.
/**
* Connect to archive data server.
* <p>
* On success, set <code>server</code>, update <code>archive_table</code>
* @param url Server URL
*/
private void connectToArchiveServer(final String url) {
new ConnectJob(url) {
@Override
protected void archiveServerConnected(final String server_info, final ArchiveInfo[] infos) {
ArchiveListGUI.this.server_info = server_info;
if (urls.isDisposed())
return;
urls.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (info.isDisposed())
return;
ArchiveListGUI.this.url = url;
final List<ArchiveDataSource> archives = new ArrayList<>();
for (ArchiveInfo info : infos) archives.add(new ArchiveDataSource(url, info.getKey(), info.getName(), info.getDescription()));
archive_table.setInput(archives);
// Select all default archive data sources for this URL
final List<ArchiveDataSource> selected = new ArrayList<>();
for (ArchiveDataSource dataSource : default_archives) if (dataSource.getUrl().equals(url) && archives.contains(dataSource))
selected.add(dataSource);
archive_table.setSelection(new StructuredSelection(selected));
// Enable operations on server resp. archives
info.setEnabled(true);
handleArchiveUpdate();
}
});
}
@Override
protected void archiveServerError(final String url, final Exception ex) {
// Called from non-UI thread
if (info.isDisposed())
return;
info.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (info.isDisposed())
return;
info.setEnabled(false);
handleServerError(url, ex);
}
});
}
}.schedule();
}
Aggregations