Search in sources :

Example 1 with AzureSelectDockerWizard

use of com.microsoft.azuretools.docker.ui.wizards.publish.AzureSelectDockerWizard in project azure-tools-for-java by Microsoft.

the class AzureDockerUIResources method publish2DockerHostContainer.

public static void publish2DockerHostContainer(Shell shell, IProject project, DockerHost host) {
    try {
        AzureDockerUIResources.createArtifact(shell, project);
        AzureManager azureAuthManager = AuthMethodManager.getInstance().getAzureManager();
        // not signed in
        if (azureAuthManager == null) {
            return;
        }
        AzureDockerHostsManager dockerManager = AzureDockerHostsManager.getAzureDockerHostsManager(azureAuthManager);
        if (!dockerManager.isInitialized()) {
            AzureDockerUIResources.updateAzureResourcesWithProgressDialog(shell, project);
            if (AzureDockerUIResources.CANCELED) {
                return;
            }
            dockerManager = AzureDockerHostsManager.getAzureDockerHostsManagerEmpty(null);
        }
        if (dockerManager.getSubscriptionsMap().isEmpty()) {
            PluginUtil.displayErrorDialog(shell, "Create Docker Host", "Must select an Azure subscription first");
            return;
        }
        DockerHost dockerHost = (host != null) ? host : (dockerManager.getDockerPreferredSettings() != null) ? dockerManager.getDockerHostForURL(dockerManager.getDockerPreferredSettings().dockerApiName) : null;
        AzureDockerImageInstance dockerImageDescription = dockerManager.getDefaultDockerImageDescription(project.getName(), dockerHost);
        AzureSelectDockerWizard selectDockerWizard = new AzureSelectDockerWizard(project, dockerManager, dockerImageDescription);
        WizardDialog selectDockerHostDialog = new AzureWizardDialog(shell, selectDockerWizard);
        if (dockerHost != null) {
            selectDockerWizard.selectDefaultDockerHost(dockerHost, true);
        }
        if (selectDockerHostDialog.open() == Window.OK) {
            try {
                String url = selectDockerWizard.deploy();
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Web app published at: " + url);
            } catch (Exception ex) {
                PluginUtil.displayErrorDialogAndLog(shell, "Unexpected error detected while publishing to a Docker container", ex.getMessage(), ex);
                log.log(Level.SEVERE, "publish2DockerHostContainer: " + ex.getMessage(), ex);
            }
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, "publish2DockerHostContainer: " + e.getMessage(), e);
        e.printStackTrace();
    }
}
Also used : AzureDockerImageInstance(com.microsoft.azure.docker.model.AzureDockerImageInstance) AzureWizardDialog(com.microsoft.azuretools.core.components.AzureWizardDialog) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) AzureSelectDockerWizard(com.microsoft.azuretools.docker.ui.wizards.publish.AzureSelectDockerWizard) EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost) DockerHost(com.microsoft.azure.docker.model.DockerHost) AzureDockerHostsManager(com.microsoft.azure.docker.AzureDockerHostsManager) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AzureWizardDialog(com.microsoft.azuretools.core.components.AzureWizardDialog)

Aggregations

AzureDockerHostsManager (com.microsoft.azure.docker.AzureDockerHostsManager)1 AzureDockerImageInstance (com.microsoft.azure.docker.model.AzureDockerImageInstance)1 DockerHost (com.microsoft.azure.docker.model.DockerHost)1 EditableDockerHost (com.microsoft.azure.docker.model.EditableDockerHost)1 AzureWizardDialog (com.microsoft.azuretools.core.components.AzureWizardDialog)1 AzureSelectDockerWizard (com.microsoft.azuretools.docker.ui.wizards.publish.AzureSelectDockerWizard)1 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1