Search in sources :

Example 1 with IDockerImage

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);
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IDockerContainerConfig(org.eclipse.linuxtools.docker.core.IDockerContainerConfig) CoreException(org.eclipse.core.runtime.CoreException) IDockerHostConfig(org.eclipse.linuxtools.docker.core.IDockerHostConfig) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage)

Example 2 with IDockerImage

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);
}
Also used : IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage)

Example 3 with IDockerImage

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;
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Shell(org.eclipse.swt.widgets.Shell) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) DockerConnectionManager(org.eclipse.linuxtools.docker.core.DockerConnectionManager) SelectionDialog(org.eclipse.ui.dialogs.SelectionDialog) Display(org.eclipse.swt.widgets.Display) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ComboViewer(org.eclipse.jface.viewers.ComboViewer) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Composite(org.eclipse.swt.widgets.Composite) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) DockerException(org.eclipse.linuxtools.docker.core.DockerException) SWT(org.eclipse.swt.SWT) GridData(org.eclipse.swt.layout.GridData) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Label(org.eclipse.swt.widgets.Label) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage)

Example 4 with IDockerImage

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));
}
Also used : List(java.util.List) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) IDockerImageHierarchyNode(org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode) IDockerImageHierarchyNode(org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode)

Example 5 with IDockerImage

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);
}
Also used : BaseDatabindingModel(org.eclipse.linuxtools.internal.docker.ui.databinding.BaseDatabindingModel) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) Collection(java.util.Collection) DockerConnectionManager(org.eclipse.linuxtools.docker.core.DockerConnectionManager) Assert(org.eclipse.core.runtime.Assert) Set(java.util.Set) HashMap(java.util.HashMap) UUID(java.util.UUID) WritableList(org.eclipse.core.databinding.observable.list.WritableList) ArrayList(java.util.ArrayList) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) List(java.util.List) Map(java.util.Map) Collections(java.util.Collections) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage)

Aggregations

IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)41 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)16 DockerException (org.eclipse.linuxtools.docker.core.DockerException)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)8 IDockerImageHierarchyNode (org.eclipse.linuxtools.docker.core.IDockerImageHierarchyNode)7 List (java.util.List)6 CoreException (org.eclipse.core.runtime.CoreException)6 IDockerHostConfig (org.eclipse.linuxtools.docker.core.IDockerHostConfig)6 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)5 IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)5 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)5 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)5 HashMap (java.util.HashMap)4 Map (java.util.Map)3 Job (org.eclipse.core.runtime.jobs.Job)3 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)3 IDockerContainerConfig (org.eclipse.linuxtools.docker.core.IDockerContainerConfig)3 IDockerImageInfo (org.eclipse.linuxtools.docker.core.IDockerImageInfo)3 DockerContainerConfig (org.eclipse.linuxtools.internal.docker.core.DockerContainerConfig)3