Search in sources :

Example 1 with ImageBuildDialog

use of org.eclipse.linuxtools.internal.docker.ui.wizards.ImageBuildDialog in project linuxtools by eclipse.

the class BuildDockerImageShortcut method createConfiguration.

/**
 * Create a launch configuration based on a Dockerfile resource, and
 * optionally save it to the underlying resource.
 *
 * @param dockerfile
 *            a {@code Dockerfile} file to build
 * @return a launch configuration generated for the Dockerfile build.
 */
@Override
protected ILaunchConfiguration createConfiguration(final IResource dockerfile) {
    try {
        if (!DockerConnectionManager.getInstance().hasConnections()) {
            Display.getDefault().asyncExec(() -> {
                boolean confirm = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), LaunchMessages.getString(// $NON-NLS-1$
                "BuildDockerImageShortcut.no.connections.msg"), LaunchMessages.getString(// $NON-NLS-1$
                "BuildDockerImageShortcut.no.connections.desc"));
                if (confirm) {
                    final NewDockerConnection newConnWizard = new NewDockerConnection();
                    CommandUtils.openWizard(newConnWizard, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
                }
            });
            return null;
        } else {
            final ImageBuildDialog dialog = new ImageBuildDialog(getActiveWorkbenchShell());
            final int result = dialog.open();
            if (result == IDialogConstants.OK_ID) {
                return LaunchConfigurationUtils.createBuildImageLaunchConfiguration(dialog.getConnection(), dialog.getRepoName(), dockerfile);
            }
        }
    } catch (CoreException e) {
        Activator.log(e);
    }
    return null;
}
Also used : NewDockerConnection(org.eclipse.linuxtools.internal.docker.ui.wizards.NewDockerConnection) CoreException(org.eclipse.core.runtime.CoreException) ImageBuildDialog(org.eclipse.linuxtools.internal.docker.ui.wizards.ImageBuildDialog)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 ImageBuildDialog (org.eclipse.linuxtools.internal.docker.ui.wizards.ImageBuildDialog)1 NewDockerConnection (org.eclipse.linuxtools.internal.docker.ui.wizards.NewDockerConnection)1