Search in sources :

Example 1 with IDockerConnection2

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;
}
Also used : RetrieveImageHierarchyJob(org.eclipse.linuxtools.internal.docker.ui.jobs.RetrieveImageHierarchyJob) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) PartInitException(org.eclipse.ui.PartInitException) IDockerConnection2(org.eclipse.linuxtools.docker.core.IDockerConnection2) DockerImageHierarchyView(org.eclipse.linuxtools.internal.docker.ui.views.DockerImageHierarchyView)

Aggregations

IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)1 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)1 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)1 IDockerConnection2 (org.eclipse.linuxtools.docker.core.IDockerConnection2)1 RetrieveImageHierarchyJob (org.eclipse.linuxtools.internal.docker.ui.jobs.RetrieveImageHierarchyJob)1 DockerImageHierarchyView (org.eclipse.linuxtools.internal.docker.ui.views.DockerImageHierarchyView)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 PartInitException (org.eclipse.ui.PartInitException)1