Search in sources :

Example 1 with DockerComposeUpDialog

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

Aggregations

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