use of org.eclipse.linuxtools.docker.core.IDockerContainerConfig in project linuxtools by eclipse.
the class ImageInspectContentProvider method getChildren.
@Override
public Object[] getChildren(Object parentElement) {
final Object propertyValue = ((Object[]) parentElement)[1];
if (propertyValue instanceof IDockerContainerConfig) {
final IDockerContainerConfig config = (IDockerContainerConfig) propertyValue;
return new Object[] { // $NON-NLS-1$
new Object[] { "Hostname", config.hostname() }, // $NON-NLS-1$
new Object[] { "Domainname", config.domainname() }, // $NON-NLS-1$
new Object[] { "User", config.user() }, new Object[] { "Memory", // $NON-NLS-1$
LabelProviderUtils.toString(config.memory()) }, new Object[] { "MemorySwap", // $NON-NLS-1$
LabelProviderUtils.toString(config.memorySwap()) }, new Object[] { "CpuShares", // $NON-NLS-1$
LabelProviderUtils.toString(config.cpuShares()) }, // $NON-NLS-1$
new Object[] { "Cpuset", config.cpuset() }, // $NON-NLS-1$
new Object[] { "AttachStdin", config.attachStdin() }, // $NON-NLS-1$
new Object[] { "AttachStdout", config.attachStdout() }, // $NON-NLS-1$
new Object[] { "AttachStderr", config.attachStderr() }, new Object[] { "PortSpecs", // $NON-NLS-1$
LabelProviderUtils.reduce(config.portSpecs()) }, // $NON-NLS-1$
new Object[] { "ExposedPorts", config.exposedPorts() }, // $NON-NLS-1$
new Object[] { "Tty", config.tty() }, // $NON-NLS-1$
new Object[] { "OpenStdin", config.openStdin() }, // $NON-NLS-1$
new Object[] { "StdinOnce", config.stdinOnce() }, // $NON-NLS-1$
new Object[] { "Env", LabelProviderUtils.reduce(config.env()) }, // $NON-NLS-1$
new Object[] { "Cmd", LabelProviderUtils.reduce(config.cmd()) }, // $NON-NLS-1$
new Object[] { "Image", config.image() }, new Object[] { "Volumes", // $NON-NLS-1$
LabelProviderUtils.reduce(config.volumes().keySet()) }, // $NON-NLS-1$
new Object[] { "WorkingDir", config.workingDir() }, new Object[] { "EntryPoint", // $NON-NLS-1$
LabelProviderUtils.reduce(config.entrypoint()) }, // $NON-NLS-1$
new Object[] { "NetworkDisabled", config.networkDisabled() }, new Object[] { "OnBuild", // $NON-NLS-1$
LabelProviderUtils.reduce(config.onBuild()) } };
} else if (propertyValue instanceof List<?>) {
@SuppressWarnings("unchecked") final List<Object> propertyValues = (List<Object>) propertyValue;
final Object[] result = new Object[propertyValues.size()];
for (int i = 0; i < propertyValues.size(); i++) {
result[i] = new Object[] { "", // $NON-NLS-1$
LabelProviderUtils.toString(propertyValues.get(i)) };
}
return result;
} else if (propertyValue instanceof Set<?>) {
@SuppressWarnings("unchecked") final Set<Object> propertyValues = (Set<Object>) propertyValue;
final Object[] result = new Object[propertyValues.size()];
Iterator<Object> iterator = propertyValues.iterator();
for (int i = 0; i < propertyValues.size(); i++) {
result[i] = new Object[] { // $NON-NLS-1$
"", LabelProviderUtils.toString(iterator.next()) };
}
return result;
} else if (propertyValue instanceof Map<?, ?>) {
final Map<?, ?> propertyValues = (Map<?, ?>) propertyValue;
final Object[] result = new Object[propertyValues.size()];
int i = 0;
for (Entry<?, ?> entry : propertyValues.entrySet()) {
result[i] = new Object[] { entry.getKey(), entry.getValue() };
i++;
}
return result;
}
return EMPTY;
}
use of org.eclipse.linuxtools.docker.core.IDockerContainerConfig in project linuxtools by eclipse.
the class RunImageCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final IDockerImage selectedImage = CommandUtils.getSelectedImage(activePart);
if (selectedImage == null) {
Activator.log(new DockerException(// $NON-NLS-1$
DVMessages.getString("RunImageUnableToRetrieveError.msg")));
} else {
try {
final ImageRun wizard = new ImageRun(selectedImage);
final boolean runImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
if (runImage) {
final IDockerContainerConfig containerConfig = wizard.getDockerContainerConfig();
final IDockerHostConfig hostConfig = wizard.getDockerHostConfig();
runImage(selectedImage, containerConfig, hostConfig, wizard.getDockerContainerName(), wizard.removeWhenExits());
}
} catch (DockerException | CoreException e) {
Activator.log(e);
}
}
return null;
}
Aggregations