use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class RunDockerImageLaunchConfigurationDelegate method launch.
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) {
try {
ILaunchConfiguration config = launch.getLaunchConfiguration();
final IDockerContainerConfig containerConfig = getDockerContainerConfig(config);
final IDockerHostConfig hostConfig = getDockerHostConfig(config);
final IDockerConnection connection = getDockerConnection(config);
if (connection == null)
return;
final IDockerImage image = getDockerImage(config, connection);
RunImageCommandHandler.runImage(image, containerConfig, hostConfig, config.getAttribute(IRunDockerImageLaunchConfigurationConstants.CONTAINER_NAME, (String) null), config.getAttribute(IRunDockerImageLaunchConfigurationConstants.AUTO_REMOVE, false));
} catch (CoreException e) {
Activator.log(e);
}
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class RunImageMainTab method setDefaultValues.
private void setDefaultValues() {
final IDockerImage selectedImage = model.getSelectedImage();
if (selectedImage == null) {
return;
}
findImageInfo(selectedImage);
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class ImageSelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
Label connLbl = new Label(composite, SWT.NONE);
connLbl.setText(Messages.ImageSelectionDialog_connection_label);
ComboViewer connCmb = new ComboViewer(composite, SWT.READ_ONLY);
connCmb.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
connCmb.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
for (IDockerConnection conn : DockerConnectionManager.getInstance().getAllConnections()) {
try {
((DockerConnection) conn).open(false);
} catch (DockerException e) {
}
}
return DockerConnectionManager.getInstance().getAllConnections().stream().filter(c -> c.isOpen()).toArray(size -> new IDockerConnection[size]);
}
});
// $NON-NLS-1$
connCmb.setInput("place_holder");
Label imageLbl = new Label(composite, SWT.NONE);
imageLbl.setText(Messages.ImageSelectionDialog_image_label);
ComboViewer imageCmb = new ComboViewer(composite, SWT.READ_ONLY);
imageCmb.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
imageCmb.setContentProvider(new IStructuredContentProvider() {
@Override
public Object[] getElements(Object inputElement) {
IDockerConnection conn = (IDockerConnection) inputElement;
return conn.getImages().stream().filter(// $NON-NLS-1$
i -> !i.repoTags().get(0).equals("<none>:<none>")).toArray(size -> new IDockerImage[size]);
}
});
imageCmb.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
IDockerImage img = (IDockerImage) element;
return img.repoTags().get(0);
}
});
imageCmb.setInput(null);
connCmb.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = event.getStructuredSelection();
IDockerConnection conn = (IDockerConnection) sel.getFirstElement();
connection = conn;
imageCmb.setInput(conn);
}
});
imageCmb.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = event.getStructuredSelection();
IDockerImage img = (IDockerImage) sel.getFirstElement();
image = img;
getOkButton().setEnabled(true);
}
});
return composite;
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class DockerImageHierarchyNodeUtils method resolveChildrenImageNodes.
private static void resolveChildrenImageNodes(final List<IDockerImage> images, final List<IDockerContainer> containers, final String imageId, final List<String> imageRepoTags, final IDockerImageHierarchyNode parentNode) {
// recursively find all parents and build associated
// IDockerImageHierarchyNode instances
images.stream().filter(image -> image.parentId() != null && image.parentId().equals(imageId)).forEach(image -> {
final DockerImageHierarchyNode childNode = new DockerImageHierarchyImageNode(image, parentNode);
resolveChildrenImageNodes(images, containers, image.id(), image.repoTags(), childNode);
});
containers.stream().filter(container -> container.image() != null && imageRepoTags.contains(container.image())).forEach(container -> new DockerImageHierarchyContainerNode(container, parentNode));
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class ImageRunSelectionModel method refreshImageNames.
public void refreshImageNames() {
final List<String> refreshedImageNames = new ArrayList<>();
final Map<String, IDockerImage> refreshedImages = new HashMap<>();
final IDockerConnection connection = getSelectedConnection();
if (connection != null && connection.isOpen()) {
connection.getImages().stream().filter(image -> !image.isIntermediateImage() && !image.isDangling()).forEach(image -> {
image.repoTags().stream().forEach(repoTag -> {
refreshedImages.put(repoTag, image);
refreshedImageNames.add(repoTag);
});
});
Collections.sort(refreshedImageNames);
}
this.images = refreshedImages;
setImageNames(refreshedImageNames);
}
Aggregations