Search in sources :

Example 1 with AzureNewDockerWizardModel

use of com.microsoft.intellij.docker.wizards.createhost.AzureNewDockerWizardModel in project azure-tools-for-java by Microsoft.

the class AzureSelectDockerHostStep method onAddNewDockerHostAction.

private void onAddNewDockerHostAction() {
    AppInsightsClient.createByType(AppInsightsClient.EventType.DockerHost, "", "Add");
    AzureNewDockerWizardModel newDockerHostModel = new AzureNewDockerWizardModel(model.getProject(), dockerManager);
    AzureNewDockerWizardDialog wizard = new AzureNewDockerWizardDialog(newDockerHostModel);
    wizard.setTitle("Create Docker Host");
    wizard.show();
    if (wizard.getExitCode() == 0) {
        dockerHostsTable.setEnabled(false);
        DockerHost host = newDockerHostModel.getDockerHost();
        dockerImageDescription.host = host;
        dockerImageDescription.hasNewDockerHost = true;
        dockerImageDescription.sid = host.sid;
        model.setSubscription(this.dockerManager.getSubscriptionsMap().get(host.sid));
        AzureDockerPreferredSettings dockerPrefferedSettings = dockerManager.getDockerPreferredSettings();
        if (dockerPrefferedSettings == null) {
            dockerPrefferedSettings = new AzureDockerPreferredSettings();
        }
        dockerPrefferedSettings.region = host.hostVM.region;
        dockerPrefferedSettings.vmSize = host.hostVM.vmSize;
        dockerPrefferedSettings.vmOS = host.hostOSType.name();
        dockerManager.setDockerPreferredSettings(dockerPrefferedSettings);
        final DefaultTableModel tableModel = (DefaultTableModel) dockerHostsTable.getModel();
        if (dockerHostsTableSelection != null && (Boolean) tableModel.getValueAt(dockerHostsTableSelection.row, 0)) {
            tableModel.setValueAt(false, dockerHostsTableSelection.row, 0);
        }
        Vector<Object> row = new Vector<>();
        row.add(false);
        row.add(host.name);
        row.add("TO_BE_CREATED");
        row.add(host.hostOSType.toString());
        row.add(host.apiUrl);
        tableModel.insertRow(0, row);
        tableModel.setValueAt(true, 0, 0);
        dockerHostsTable.setRowSelectionInterval(0, 0);
        setFinishButtonState(doValidate(false) == null);
        setNextButtonState(doValidate(false) == null);
    }
}
Also used : AzureNewDockerWizardDialog(com.microsoft.intellij.docker.wizards.createhost.AzureNewDockerWizardDialog) DockerHost(com.microsoft.azure.docker.model.DockerHost) EditableDockerHost(com.microsoft.azure.docker.model.EditableDockerHost) DefaultTableModel(javax.swing.table.DefaultTableModel) AzureNewDockerWizardModel(com.microsoft.intellij.docker.wizards.createhost.AzureNewDockerWizardModel) Vector(java.util.Vector) AzureDockerPreferredSettings(com.microsoft.azure.docker.model.AzureDockerPreferredSettings)

Example 2 with AzureNewDockerWizardModel

use of com.microsoft.intellij.docker.wizards.createhost.AzureNewDockerWizardModel in project azure-tools-for-java by Microsoft.

the class CreateNewDockerHostAction method actionPerformed.

@Override
public void actionPerformed(NodeActionEvent e) {
    try {
        if (!AzureSignInAction.doSignIn(AuthMethodManager.getInstance(), project))
            return;
        AzureManager azureAuthManager = AuthMethodManager.getInstance().getAzureManager();
        // not signed in
        if (azureAuthManager == null) {
            return;
        }
        AzureDockerHostsManager dockerManager = AzureDockerHostsManager.getAzureDockerHostsManagerEmpty(azureAuthManager);
        if (!dockerManager.isInitialized()) {
            AzureDockerUIResources.updateAzureResourcesWithProgressDialog(project);
            if (AzureDockerUIResources.CANCELED) {
                return;
            }
            dockerManager = AzureDockerHostsManager.getAzureDockerHostsManagerEmpty(null);
        }
        if (dockerManager.getSubscriptionsMap().isEmpty()) {
            PluginUtil.displayErrorDialog("Create Docker Host", "Must select an Azure subscription first");
            return;
        }
        AzureNewDockerWizardModel newDockerHostModel = new AzureNewDockerWizardModel(project, dockerManager);
        AzureNewDockerWizardDialog wizard = new AzureNewDockerWizardDialog(newDockerHostModel);
        wizard.setTitle("Create Docker Host");
        wizard.show();
        if (wizard.getExitCode() == 0) {
            dockerHost = newDockerHostModel.getDockerHost();
            wizard.create();
            System.out.println("New Docker host will be created at: " + dockerHost.apiUrl);
        }
    } catch (Exception ex1) {
        ex1.printStackTrace();
    }
}
Also used : AzureNewDockerWizardDialog(com.microsoft.intellij.docker.wizards.createhost.AzureNewDockerWizardDialog) AzureManager(com.microsoft.azuretools.sdkmanage.AzureManager) AzureNewDockerWizardModel(com.microsoft.intellij.docker.wizards.createhost.AzureNewDockerWizardModel) AzureDockerHostsManager(com.microsoft.azure.docker.AzureDockerHostsManager)

Aggregations

AzureNewDockerWizardDialog (com.microsoft.intellij.docker.wizards.createhost.AzureNewDockerWizardDialog)2 AzureNewDockerWizardModel (com.microsoft.intellij.docker.wizards.createhost.AzureNewDockerWizardModel)2 AzureDockerHostsManager (com.microsoft.azure.docker.AzureDockerHostsManager)1 AzureDockerPreferredSettings (com.microsoft.azure.docker.model.AzureDockerPreferredSettings)1 DockerHost (com.microsoft.azure.docker.model.DockerHost)1 EditableDockerHost (com.microsoft.azure.docker.model.EditableDockerHost)1 AzureManager (com.microsoft.azuretools.sdkmanage.AzureManager)1 Vector (java.util.Vector)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1