use of org.eclipse.linuxtools.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerVolume 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.internal.docker.ui.views.DockerExplorerContentProvider.DockerContainerVolume in project linuxtools by eclipse.
the class ShowInSystemExplorerCommandHandler method execute.
@Override
public Object execute(final ExecutionEvent event) {
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final List<DockerContainerVolume> volumes = CommandUtils.getSelectedVolumes(activePart);
if (volumes == null || volumes.isEmpty()) {
return null;
}
final DockerContainerVolume selectedVolume = volumes.get(0);
final File hostFile = new File(selectedVolume.getHostPath());
final String launchCmd = getShowInSystemExplorerCommand(hostFile);
if (launchCmd == null) {
return null;
}
final Job job = new Job(CommandMessages.getString("command.showIn.systemExplorer")) {
// $NON-NLS-1$
@Override
protected IStatus run(final IProgressMonitor monitor) {
try {
final Process p = getLaunchProcess(launchCmd, hostFile);
final int retCode = p.waitFor();
if (retCode != 0 && !Util.isWindows()) {
Activator.log(new DockerException(CommandMessages.getFormattedString(// $NON-NLS-1$
"command.showIn.systemExplorer.failure.command.execute", launchCmd, Integer.toString(retCode))));
}
} catch (IOException | InterruptedException e) {
Activator.logErrorMessage(CommandMessages.getFormattedString(// $NON-NLS-1$
"command.showIn.systemExplorer.failure", launchCmd), e);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return null;
}
Aggregations