use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class ConnectionInfoPropertySection method updateConnectionInfo.
private void updateConnectionInfo(final IDockerConnection connection) {
// Set the tree empty while we wait for the real data
if (getTreeViewer() != null) {
getTreeViewer().setInput(null);
getTreeViewer().expandAll();
}
final Job loadConnectionInfoJob = new Job(DVMessages.getString(LoadingConnectionInfo)) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
monitor.beginTask(DVMessages.getString(LoadingConnectionInfo), 1);
if (connection.getState() != EnumDockerConnectionState.ESTABLISHED) {
return Status.OK_STATUS;
}
try {
final IDockerConnectionInfo info = connection.getInfo();
Display.getDefault().asyncExec(() -> {
if (info != null && getTreeViewer() != null) {
getTreeViewer().setInput(info);
getTreeViewer().expandAll();
}
});
} catch (DockerException e) {
Activator.log(e);
}
monitor.done();
return Status.OK_STATUS;
}
};
loadConnectionInfoJob.schedule();
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class DockerExplorerContentProvider method loadContainers.
/**
* Call the {@link IDockerConnection#getContainers(boolean)} in a background
* job to avoid blocking the UI.
*
* @param containersCategory
* the selected {@link DockerContainersCategory}
*/
private void loadContainers(final DockerContainersCategory containersCategory) {
final Job loadContainersJob = new LoadingJob(// $NON-NLS-1$
DVMessages.getString("ContainersLoadJob.msg"), containersCategory) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
containersCategory.getConnection().getContainers(true);
return Status.OK_STATUS;
}
};
loadContainersJob.schedule();
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class DockerImagesContentProvider method loadImages.
/**
* Call the {@link IDockerConnection#getImages(boolean)} in a background job
* to avoid blocking the UI.
*
* @param connection
* the selected {@link DockerConnection}
*/
private void loadImages(final IDockerConnection connection) {
final Job loadImagesJob = new Job(DVMessages.getFormattedString("ImagesLoadJob.msg", connection.getUri())) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
connection.getImages(true);
Display.getDefault().asyncExec(() -> {
viewer.refresh();
});
return Status.OK_STATUS;
}
};
loadImagesJob.schedule();
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class DockerImagesView method changeEvent.
@Override
public void changeEvent(final IDockerConnection connection, final int type) {
if (type == IDockerConnectionManagerListener.UPDATE_SETTINGS_EVENT) {
final Job refreshJob = new Job(DVMessages.getString("ImagesRefresh.msg")) {
@Override
protected IStatus run(IProgressMonitor monitor) {
connection.getImages(true);
return Status.OK_STATUS;
}
};
refreshJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
Display.getDefault().asyncExec(() -> refreshViewTitle());
}
});
refreshJob.schedule();
} else if (type == IDockerConnectionManagerListener.RENAME_EVENT) {
Display.getDefault().asyncExec(() -> refreshViewTitle());
}
}
use of org.eclipse.core.runtime.jobs.Job in project linuxtools by eclipse.
the class DockerImagesView method setConnection.
private void setConnection(final IDockerConnection connection) {
if (connection != null && connection.equals(this.connection)) {
return;
}
if (this.connection != null) {
this.connection.removeImageListener(this);
}
this.connection = connection;
if (this.viewer != null && this.connection != null) {
final Job refreshJob = new Job(DVMessages.getString("ImagesRefresh.msg")) {
@Override
protected IStatus run(IProgressMonitor monitor) {
connection.getImages(true);
connection.addImageListener(DockerImagesView.this);
Display.getDefault().asyncExec(() -> {
if (!viewer.getControl().isDisposed()) {
viewer.setInput(connection);
refreshViewTitle();
}
});
return Status.OK_STATUS;
}
};
refreshJob.schedule();
} else if (this.viewer != null) {
viewer.setInput(new IDockerContainer[0]);
form.setText(DVMessages.getString(NoConnectionSelected));
}
}
Aggregations