Search in sources :

Example 1 with NewDockerConnection

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

the class DockerComposeUpShortcut method createConfiguration.

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

Example 2 with NewDockerConnection

use of org.eclipse.linuxtools.internal.docker.ui.wizards.NewDockerConnection 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)2 NewDockerConnection (org.eclipse.linuxtools.internal.docker.ui.wizards.NewDockerConnection)2 DockerComposeUpDialog (org.eclipse.linuxtools.internal.docker.ui.wizards.DockerComposeUpDialog)1 ImageBuildDialog (org.eclipse.linuxtools.internal.docker.ui.wizards.ImageBuildDialog)1