Search in sources :

Example 1 with DockerImage

use of org.eclipse.linuxtools.internal.docker.core.DockerImage 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;
}
Also used : ArrayList(java.util.ArrayList) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) DockerImage(org.eclipse.linuxtools.internal.docker.core.DockerImage) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Example 2 with DockerImage

use of org.eclipse.linuxtools.internal.docker.core.DockerImage in project linuxtools by eclipse.

the class DockerImageHierarchyLabelProvider method getStyledText.

/**
 * @param image
 *            the {@link IDockerImage} to process
 * @return the {@link StyledString} to be displayed.
 */
public static StyledString getStyledText(final IDockerImage image) {
    final Map<String, List<String>> imageTagsByRepo = DockerImage.extractTagsByRepo(image.repoTags());
    final List<String> imageRepos = new ArrayList<>(imageTagsByRepo.keySet());
    Collections.sort(imageRepos);
    final StyledString result = new StyledString();
    imageRepos.forEach(repo -> {
        result.append(repo);
        final List<String> tags = imageTagsByRepo.get(repo);
        final String joinedTags = tags.stream().collect(// $NON-NLS-1$
        Collectors.joining(", "));
        result.append(':');
        // $NON-NLS-1$
        result.append(joinedTags, StyledString.COUNTER_STYLER);
        result.append(' ');
    });
    // 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) image).shortId(), StyledString.QUALIFIER_STYLER).append(')', // $NON-NLS-1$
    StyledString.QUALIFIER_STYLER);
    return result;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) DockerImage(org.eclipse.linuxtools.internal.docker.core.DockerImage) StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString)

Aggregations

ArrayList (java.util.ArrayList)2 StyledString (org.eclipse.jface.viewers.StyledString)2 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)2 DockerImage (org.eclipse.linuxtools.internal.docker.core.DockerImage)2 List (java.util.List)1