use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class ImageRunNetworkModel method refreshContainerNames.
public void refreshContainerNames() {
final List<String> refreshedContainerNames = new ArrayList<>();
final IDockerConnection connection = this.connection;
if (connection != null && connection.isOpen()) {
connection.getContainers().stream().filter(container -> EnumDockerStatus.fromStatusMessage(container.status()) == EnumDockerStatus.RUNNING).forEach(container -> {
refreshedContainerNames.add(container.name());
});
Collections.sort(refreshedContainerNames);
}
setContainerNames(refreshedContainerNames);
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection 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);
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class ImageRunSelectionModel method refreshConnectionNames.
public void refreshConnectionNames() {
this.connectionNames = new ArrayList<>();
this.connections = new HashMap<>();
for (IDockerConnection connection : DockerConnectionManager.getInstance().getConnections()) {
String name = connection.getName();
connections.put(name, connection);
connectionNames.add(name);
}
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class ImageTagSelectionPage method searchTags.
private void searchTags() {
try {
final BlockingQueue<List<DockerImageTagSearchResult>> searchResultQueue = new ArrayBlockingQueue<>(1);
ImageTagSelectionPage.this.getContainer().run(true, true, monitor -> {
monitor.beginTask(WizardMessages.getString(// $NON-NLS-1$
"ImageTagSelectionPage.searchTask"), 2);
final String selectedImageName = ImageTagSelectionPage.this.model.getSelectedImage().getName();
try {
final List<IRepositoryTag> repositoryTags = registry.getTags(selectedImageName);
// we have to convert to list of RepositoryTag which
// can be sorted
final List<RepositoryTag> tags = repositoryTags.stream().map(c -> (RepositoryTag) c).collect(Collectors.toList());
Collections.sort(tags);
monitor.worked(1);
final IDockerConnection connection = model.getSelectedConnection();
final List<DockerImageTagSearchResult> searchResults = repositoryTags.stream().map(t -> new DockerImageTagSearchResult(selectedImageName, t, connection.hasImage(selectedImageName, t.getName()))).collect(Collectors.toList());
monitor.worked(1);
searchResultQueue.offer(searchResults);
} catch (DockerException e) {
} finally {
monitor.done();
}
});
List<DockerImageTagSearchResult> res = searchResultQueue.poll(10, TimeUnit.SECONDS);
final List<DockerImageTagSearchResult> searchResult = (res == null) ? new ArrayList<>() : res;
Display.getCurrent().asyncExec(() -> {
ImageTagSelectionPage.this.model.setImageTagSearchResult(searchResult);
// refresh the wizard buttons
getWizard().getContainer().updateButtons();
});
// display a warning in the title area if the search result is empty
if (searchResult.isEmpty()) {
this.setMessage(WizardMessages.getString(// $NON-NLS-1$
"ImageTagSelectionPage.noTagWarning"), WARNING);
} else if (searchResult.size() == 1) {
this.setMessage(WizardMessages.getString(// $NON-NLS-1$
"ImageTagSelectionPage.oneTagMatched"), INFORMATION);
} else {
this.setMessage(WizardMessages.getFormattedString(// $NON-NLS-1$
"ImageTagSelectionPage.tagsMatched", Integer.toString(searchResult.size())), INFORMATION);
}
} catch (InvocationTargetException | InterruptedException e) {
Activator.log(e);
}
}
use of org.eclipse.linuxtools.docker.core.IDockerConnection in project linuxtools by eclipse.
the class ConnectionSettingsContentProvider method getElements.
@Override
public Object[] getElements(final Object inputElement) {
if (inputElement instanceof IDockerConnection) {
final IDockerConnection connection = (IDockerConnection) inputElement;
IDockerConnectionSettings data = connection.getSettings();
if (data != null) {
return data.getProperties();
}
}
return EMPTY;
}
Aggregations