use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class ImageRunSelectionPage method setDefaultValues.
/**
* Sets the default values from the optional given {@link IDockerImage} and
* {@link ILaunchConfiguration} elements
*/
private void setDefaultValues() {
final IDockerImage selectedImage = model.getSelectedImage();
if (selectedImage == null) {
return;
}
final IDockerImageInfo selectedImageInfo = getImageInfo(selectedImage);
// skip if a previous launch configuration was provided
if (this.lastLaunchConfiguration != null) {
try {
this.model.setContainerName(lastLaunchConfiguration.getAttribute(CONTAINER_NAME, ""));
this.model.setEntrypoint(lastLaunchConfiguration.getAttribute(ENTRYPOINT, ""));
this.model.setCommand(lastLaunchConfiguration.getAttribute(COMMAND, ""));
this.model.setPublishAllPorts(lastLaunchConfiguration.getAttribute(PUBLISH_ALL_PORTS, false));
final List<String> exposedPortInfos = lastLaunchConfiguration.getAttribute(PUBLISHED_PORTS, Collections.<String>emptyList());
// by the user.
if (selectedImageInfo != null) {
final List<ExposedPortModel> exposedPorts = ExposedPortModel.fromStrings(selectedImageInfo.config().exposedPorts());
model.setExposedPorts(exposedPorts);
final List<ExposedPortModel> selectedExposedPorts = ExposedPortModel.fromStrings(exposedPortInfos);
this.model.setSelectedPorts(new HashSet<>(selectedExposedPorts));
}
// links
this.model.setLinks(lastLaunchConfiguration.getAttribute(LINKS, Collections.<String>emptyList()));
// other options
this.model.setRemoveWhenExits(lastLaunchConfiguration.getAttribute(AUTO_REMOVE, false));
this.model.setInteractiveMode(lastLaunchConfiguration.getAttribute(INTERACTIVE, false));
this.model.setAllocatePseudoTTY(lastLaunchConfiguration.getAttribute(ALLOCATE_PSEUDO_CONSOLE, false));
this.model.setPrivileged(lastLaunchConfiguration.getAttribute(PRIVILEGED, false));
this.model.setBasicSecurity(lastLaunchConfiguration.getAttribute(READONLY, false));
} catch (CoreException e) {
Activator.log(e);
}
} else {
applyImageInfo(selectedImageInfo);
}
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class DockerExplorerLabelProvider method getImage.
@Override
public Image getImage(final Object element) {
if (element instanceof IDockerConnection) {
if (((IDockerConnection) element).isOpen()) {
return OPEN_CONNECTION_IMAGE;
} else {
return UNOPEN_CONNECTION_IMAGE;
}
} else if (element instanceof DockerImagesCategory) {
return CATEGORY_IMAGE;
} else if (element instanceof DockerContainersCategory) {
return CATEGORY_IMAGE;
} else if (element instanceof IDockerImage) {
return IMAGE_IMAGE;
} else if (element instanceof IDockerContainer) {
final IDockerContainer container = (IDockerContainer) element;
final EnumDockerStatus containerStatus = EnumDockerStatus.fromStatusMessage(container.status());
if (containerStatus == EnumDockerStatus.RUNNING) {
return STARTED_CONTAINER_IMAGE;
} else if (containerStatus == EnumDockerStatus.PAUSED) {
return PAUSED_CONTAINER_IMAGE;
} else {
return STOPPED_CONTAINER_IMAGE;
}
} else if (element instanceof DockerContainerLinksCategory || element instanceof DockerContainerLink) {
return CONTAINER_LINK_IMAGE;
} else if (element instanceof DockerContainerVolumesCategory || element instanceof DockerContainerVolume) {
return CONTAINER_VOLUME_IMAGE;
} else if (element instanceof DockerContainerPortMappingsCategory || element instanceof IDockerPortMapping) {
return CONTAINER_PORT_IMAGE;
} else if (element instanceof LoadingStub) {
return LOADING_IMAGE;
}
return null;
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class DockerImagesContentProvider method getElements.
@Override
public Object[] getElements(final Object inputElement) {
if (inputElement instanceof IDockerConnection) {
final IDockerConnection connection = (IDockerConnection) inputElement;
if (connection.isImagesLoaded()) {
final List<IDockerImage> images = connection.getImages();
if (images == null) {
return EMPTY;
}
return images.toArray();
}
loadImages(connection);
return EMPTY;
}
return EMPTY;
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class LabelProviderUtils method getStyledText.
/**
* @param dockerImage
* the {@link IDockerImage} to process
* @return the {@link StyledString} to be displayed.
*/
public static StyledString getStyledText(final IDockerImage dockerImage) {
final StyledString result = new StyledString(dockerImage.repo());
if (!dockerImage.tags().isEmpty()) {
final List<String> tags = new ArrayList<>(dockerImage.tags());
Collections.sort(tags);
result.append(":");
// $NON-NLS-1$
result.append(// $NON-NLS-1$
tags.stream().collect(Collectors.joining(", ")), StyledString.COUNTER_STYLER);
}
// TODO: remove the cast to 'DockerImage' once the 'shortId()'
// method is in the public API
// $NON-NLS-1$
result.append(" (", StyledString.QUALIFIER_STYLER).append(((DockerImage) dockerImage).shortId(), StyledString.QUALIFIER_STYLER).append(')', // $NON-NLS-1$
StyledString.QUALIFIER_STYLER);
return result;
}
use of org.eclipse.linuxtools.docker.core.IDockerImage in project linuxtools by eclipse.
the class DockerImageHierarchyViewAssertions method hasSelectedElement.
public void hasSelectedElement(final IDockerImage expectedSelection) {
notNullValue();
final IStructuredSelection selection = (IStructuredSelection) actual.getCommonViewer().getSelection();
if (selection.size() != 1) {
failWithMessage("Expected Docker Image Hierarchy view to have <%s> selected elements, but there was <%s>", 1, selection.size());
}
final Object selectedElement = ((IDockerImageHierarchyNode) selection.getFirstElement()).getElement();
if (selectedElement instanceof IDockerImage) {
final IDockerImage selectedImage = (IDockerImage) selectedElement;
if (!selectedImage.id().equals(expectedSelection.id())) {
failWithMessage("Expected Docker Image Hierarchy view to have a Docker images with id <%s> as the selected element, but it was <%s>", expectedSelection.id(), ((IDockerImage) selectedElement).id());
}
} else {
failWithMessage("Expected Docker Image Hierarchy view to have a Docker Image as the selected element, but it was a <%s>", selectedElement.getClass());
}
}
Aggregations