use of org.eclipse.linuxtools.docker.core.IDockerConnection2 in project linuxtools by eclipse.
the class OpenInHierarchyViewCommandHandler method execute.
@Override
public Object execute(ExecutionEvent event) {
// retrieve the selected image
final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
final IDockerConnection2 currentConnection = (IDockerConnection2) CommandUtils.getCurrentConnection(activePart);
// run a job to retrieve the image hierarchy
final RetrieveImageHierarchyJob retrieveImageHierarchyJob = new RetrieveImageHierarchyJob(currentConnection, CommandUtils.getSelectedElement(activePart));
retrieveImageHierarchyJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
// input
if (retrieveImageHierarchyJob.getImageHierarchy() == null) {
Activator.logWarningMessage(CommandMessages.getString(// $NON-NLS-1$
"command.showIn.imageHierarchyView.failure.missingHierarchy"));
}
Display.getDefault().asyncExec(() -> {
try {
final DockerImageHierarchyView dockerImageHierarchyView = (DockerImageHierarchyView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(DockerImageHierarchyView.VIEW_ID, null, IWorkbenchPage.VIEW_VISIBLE);
dockerImageHierarchyView.setConnection((IDockerConnection) currentConnection);
dockerImageHierarchyView.show(retrieveImageHierarchyJob.getImageHierarchy());
} catch (PartInitException e) {
Activator.logErrorMessage(CommandMessages.getString(// $NON-NLS-1$
"command.showIn.imageHierarchyView.failure"), e);
}
});
}
});
retrieveImageHierarchyJob.schedule();
//
return null;
}
Aggregations