Search in sources :

Example 76 with DockerException

use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.

the class ShowInSystemExplorerCommandHandler method getShowInSystemExplorerCommand.

/**
 * Prepare command for launching system explorer to show a path
 *
 * @param path
 *            the path to show
 * @return the command that shows the path
 * @see ShowInSystemExplorerHandler#getDefaultCommand()
 */
private String getShowInSystemExplorerCommand(final File path) {
    String command = ShowInSystemExplorerHandler.getDefaultCommand();
    if ("".equals(command)) {
        // $NON-NLS-1$
        Activator.log(new DockerException(CommandMessages.getString(// $NON-NLS-1$
        "command.showIn.systemExplorer.failure.command_unavailable")));
        return null;
    }
    try {
        command = Util.replaceAll(command, VARIABLE_RESOURCE, quotePath(path.getCanonicalPath()));
        command = Util.replaceAll(command, VARIABLE_RESOURCE_URI, path.getCanonicalFile().toURI().toString());
        File parent = path.getParentFile();
        if (parent != null) {
            command = Util.replaceAll(command, VARIABLE_FOLDER, quotePath(parent.getCanonicalPath()));
        }
        return command;
    } catch (IOException e) {
        Activator.logErrorMessage(CommandMessages.getString("command.showIn.systemExplorer.failure"), e);
        return null;
    }
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) IOException(java.io.IOException) File(java.io.File)

Example 77 with DockerException

use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.

the class TagImageCommandHandler method performTagImage.

private void performTagImage(final IDockerConnection connection, final IDockerImage image, final String tag) {
    final Job tagImageJob = new Job(DVMessages.getString(TAG_IMAGE_JOB_TITLE)) {

        @Override
        protected IStatus run(final IProgressMonitor monitor) {
            monitor.beginTask(DVMessages.getFormattedString(TAG_IMAGE_MSG, tag), 2);
            // handler refresh the images when done
            try {
                ((DockerConnection) connection).tagImage(image.id(), tag);
                monitor.worked(1);
                ((DockerConnection) connection).getImages(true);
                monitor.worked(1);
            } catch (final DockerException e) {
                Display.getDefault().syncExec(() -> MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DVMessages.getFormattedString(ERROR_TAGGING_IMAGE, tag), e.getMessage()));
            // for now
            } catch (InterruptedException e) {
            // do nothing
            } finally {
                monitor.done();
            }
            return Status.OK_STATUS;
        }
    };
    tagImageJob.schedule();
}
Also used : IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) DockerException(org.eclipse.linuxtools.docker.core.DockerException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Job(org.eclipse.core.runtime.jobs.Job)

Example 78 with DockerException

use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.

the class TagImageCommandHandler method execute.

@Override
public Object execute(final ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    final List<IDockerImage> selectedImages = CommandUtils.getSelectedImages(activePart);
    final IDockerConnection connection = CommandUtils.getCurrentConnection(activePart);
    if (selectedImages.size() != 1 || connection == null) {
        Activator.log(new DockerException(CommandMessages.getString(// $NON-NLS-1$
        "Command.missing.selection.failure")));
        return null;
    }
    final IDockerImage image = selectedImages.get(0);
    // TODO: remove the cast to DockerImage once the 'shortId' method has
    // been added in the API
    final ImageTag wizard = new ImageTag(((DockerImage) image).shortId());
    final boolean tagImage = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
    if (tagImage) {
        performTagImage(connection, image, wizard.getTag());
    }
    return null;
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) ImageTag(org.eclipse.linuxtools.internal.docker.ui.wizards.ImageTag) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage)

Aggregations

DockerException (org.eclipse.linuxtools.docker.core.DockerException)78 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)26 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)19 Job (org.eclipse.core.runtime.jobs.Job)17 IOException (java.io.IOException)16 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)16 DockerContainerNotFoundException (org.eclipse.linuxtools.docker.core.DockerContainerNotFoundException)16 ContainerNotFoundException (com.spotify.docker.client.exceptions.ContainerNotFoundException)15 ArrayList (java.util.ArrayList)14 DockerClient (com.spotify.docker.client.DockerClient)13 IDockerContainerInfo (org.eclipse.linuxtools.docker.core.IDockerContainerInfo)10 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)9 DockerCertificateException (com.spotify.docker.client.exceptions.DockerCertificateException)8 DockerTimeoutException (com.spotify.docker.client.exceptions.DockerTimeoutException)7 ProcessingException (javax.ws.rs.ProcessingException)7 IPath (org.eclipse.core.runtime.IPath)7 RunConsole (org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole)7 LogStream (com.spotify.docker.client.LogStream)6 File (java.io.File)6 HashMap (java.util.HashMap)6