use of org.eclipse.linuxtools.docker.core.IDockerContainer 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));
}
}
use of org.eclipse.linuxtools.docker.core.IDockerContainer in project linuxtools by eclipse.
the class DockerImageHierarchyViewSWTBotTest method shouldRetrieveImageHierarchyFromLeafImage.
@Test
public void shouldRetrieveImageHierarchyFromLeafImage() {
// given
final IDockerImage fooImage2 = this.connection.getImage("sha256:foo_image2");
// when
final IDockerImageHierarchyNode fooImage2Hierarchy = this.connection.resolveImageHierarchy(fooImage2);
// then
assertThat(fooImage2Hierarchy).isNotNull();
assertThat(fooImage2Hierarchy.getElement()).isEqualTo(fooImage2);
// 2 containers: foo_container21 and foo_container22
assertThat(fooImage2Hierarchy.getChildren()).hasSize(2);
assertThat((IDockerContainer) fooImage2Hierarchy.getChild("sha256:foo_container21").getElement()).isNotNull();
final IDockerImageHierarchyNode fooImage1Hierarchy = fooImage2Hierarchy.getParent();
final IDockerImage fooImage = (IDockerImage) fooImage1Hierarchy.getElement();
assertThat(fooImage.id()).isEqualTo("sha256:foo_image1");
// in this case, intermediate images shows a single child
assertThat(fooImage1Hierarchy.getChildren()).hasSize(1);
assertThat(fooImage1Hierarchy.getChildren()).containsExactly(fooImage2Hierarchy);
}
use of org.eclipse.linuxtools.docker.core.IDockerContainer in project linuxtools by eclipse.
the class DockerImageHierarchyViewSWTBotTest method shouldRetrieveImageHierarchyFromContainerBasedOnLeafImage.
@Test
public void shouldRetrieveImageHierarchyFromContainerBasedOnLeafImage() {
// given
// when
final IDockerContainer barContainer1 = this.connection.getContainer("sha256:bar_container1");
final IDockerImageHierarchyNode barContainer1Hierarchy = this.connection.resolveImageHierarchy(barContainer1);
// then
assertThat(barContainer1Hierarchy).isNotNull();
assertThat(barContainer1Hierarchy.getElement()).isEqualTo(barContainer1);
assertThat(barContainer1Hierarchy.getChildren()).isEmpty();
final IDockerImage barImageElement = (IDockerImage) barContainer1Hierarchy.getParent().getElement();
assertThat(barImageElement.id()).isEqualTo("sha256:bar_image1");
}
use of org.eclipse.linuxtools.docker.core.IDockerContainer in project linuxtools by eclipse.
the class DockerImageHierarchyViewSWTBotTest method shouldRetrieveImageHierarchyFromContainerBasedOnIntermediateImage.
@Test
public void shouldRetrieveImageHierarchyFromContainerBasedOnIntermediateImage() {
// given
final IDockerContainer fooContainer1 = this.connection.getContainer("sha256:foo_container1");
// when
final IDockerImageHierarchyNode fooContainer1Hierarchy = this.connection.resolveImageHierarchy(fooContainer1);
// then
assertThat(fooContainer1Hierarchy).isNotNull();
assertThat(fooContainer1Hierarchy.getElement()).isEqualTo(fooContainer1);
assertThat(fooContainer1Hierarchy.getChildren()).isEmpty();
final IDockerImage fooImage1 = (IDockerImage) fooContainer1Hierarchy.getParent().getElement();
assertThat(fooImage1.id()).isEqualTo("sha256:foo_image1");
// parent images hierarchy only shows the selected container as its
// child.
assertThat(fooContainer1Hierarchy.getParent().getChildren()).containsExactly(fooContainer1Hierarchy);
}
use of org.eclipse.linuxtools.docker.core.IDockerContainer in project linuxtools by eclipse.
the class BaseContainersCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<IDockerContainer> selectedContainers = getSelectedContainers(activePart);
final IDockerConnection connection = getCurrentConnection(activePart);
if (connection == null || selectedContainers.isEmpty()) {
return null;
}
final Job job = new Job(getJobName(selectedContainers)) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
if (confirmed(selectedContainers)) {
monitor.beginTask(getJobName(selectedContainers), selectedContainers.size());
for (final IDockerContainer container : selectedContainers) {
monitor.setTaskName(getTaskName(container));
executeInJob(container, connection);
monitor.worked(1);
}
}
monitor.done();
return Status.OK_STATUS;
}
};
// job.setPriority(Job.LONG);
job.setUser(true);
job.schedule();
return null;
}
Aggregations