Search in sources :

Example 36 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.

the class FilterContainersWithLabelsCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final boolean checked = !HandlerUtil.toggleCommandState(event.getCommand());
    if (activePart instanceof DockerContainersView) {
        final DockerContainersView containersView = (DockerContainersView) activePart;
        containersView.showContainersWithLabels(checked);
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DockerContainersView(org.eclipse.linuxtools.internal.docker.ui.views.DockerContainersView)

Example 37 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart 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)

Example 38 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.

the class PullImageCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
    if (connection == null) {
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), CommandMessages.getString(MISSING_CONNECTION), CommandMessages.getString(ERROR_PULLING_IMAGE_NO_CONNECTION));
    } else {
        final ImagePull wizard = new ImagePull(connection);
        final boolean pullImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
        if (pullImage) {
            performPullImage(connection, wizard.getSelectedImageName(), // part of the IRegistry interface
            (AbstractRegistry) wizard.getSelectedRegistryAccount());
        }
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) ImagePull(org.eclipse.linuxtools.internal.docker.ui.wizards.ImagePull)

Example 39 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.

the class PushImageCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final IDockerImage selectedImage = CommandUtils.getSelectedImage(activePart);
    final ImagePush wizard = new ImagePush(selectedImage, selectedImage.repo() + ":" + selectedImage.tags().get(0));
    final boolean pushImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
    if (pushImage) {
        final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
        performPushImage(wizard, connection);
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) ImagePush(org.eclipse.linuxtools.internal.docker.ui.wizards.ImagePush)

Example 40 with IWorkbenchPart

use of org.eclipse.ui.IWorkbenchPart in project linuxtools by eclipse.

the class RefreshCommandHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final List<Job> jobs = getRefreshJobs(activePart);
    for (Job job : jobs) {
        job.setPriority(Job.LONG);
        job.setUser(true);
        job.schedule();
    }
    return null;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)116 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)30 IEditorPart (org.eclipse.ui.IEditorPart)25 ISelection (org.eclipse.jface.viewers.ISelection)22 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)22 Shell (org.eclipse.swt.widgets.Shell)21 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)21 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)16 IEditorInput (org.eclipse.ui.IEditorInput)14 ArrayList (java.util.ArrayList)13 IViewPart (org.eclipse.ui.IViewPart)13 IFile (org.eclipse.core.resources.IFile)11 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)11 PartInitException (org.eclipse.ui.PartInitException)9 Job (org.eclipse.core.runtime.jobs.Job)8 DockerException (org.eclipse.linuxtools.docker.core.DockerException)7 IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)7 IResource (org.eclipse.core.resources.IResource)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Command (org.eclipse.gef.commands.Command)6