Search in sources :

Example 1 with WebAppDetails

use of com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails in project azure-tools-for-java by Microsoft.

the class WebappsModule method createListener.

private void createListener() {
    String id = "WebappsModule";
    AzureUIRefreshListener listener = new AzureUIRefreshListener() {

        @Override
        public void run() {
            if (event.opsType == AzureUIRefreshEvent.EventType.SIGNIN || event.opsType == AzureUIRefreshEvent.EventType.SIGNOUT) {
                removeAllChildNodes();
            } else if (event.object == null && (event.opsType == AzureUIRefreshEvent.EventType.UPDATE || event.opsType == AzureUIRefreshEvent.EventType.REMOVE)) {
                if (hasChildNodes()) {
                    load(true);
                }
            } else if (event.object != null && event.object.getClass().toString().equals(WebAppDetails.class.toString())) {
                WebAppDetails webAppDetails = (WebAppDetails) event.object;
                switch(event.opsType) {
                    case ADD:
                        DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                try {
                                    addChildNode(new WebappNode(WebappsModule.this, webAppDetails.webApp, webAppDetails.resourceGroup, RUN_STATUS.equalsIgnoreCase(webAppDetails.webApp.inner().state()) ? WEB_RUN_ICON : WEB_STOP_ICON));
                                } catch (Exception ex) {
                                    DefaultLoader.getUIHelper().logError("WebappsModule::createListener ADD", ex);
                                    ex.printStackTrace();
                                }
                            }
                        });
                        break;
                    case UPDATE:
                        break;
                    case REMOVE:
                        break;
                    default:
                        break;
                }
            }
        }
    };
    AzureUIRefreshCore.addListener(id, listener);
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)

Example 2 with WebAppDetails

use of com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method doFillTable.

private void doFillTable() {
    Map<SubscriptionDetail, List<ResourceGroup>> srgMap = AzureModel.getInstance().getSubscriptionToResourceGroupMap();
    Map<ResourceGroup, List<WebApp>> rgwaMap = AzureModel.getInstance().getResourceGroupToWebAppMap();
    Map<ResourceGroup, List<AppServicePlan>> rgaspMap = AzureModel.getInstance().getResourceGroupToAppServicePlanMap();
    webAppDetailsMap.clear();
    table.removeAll();
    for (SubscriptionDetail sd : srgMap.keySet()) {
        if (!sd.isSelected())
            continue;
        Map<String, WebAppUtils.AspDetails> aspMap = new HashMap<>();
        for (ResourceGroup rg : srgMap.get(sd)) {
            for (AppServicePlan asp : rgaspMap.get(rg)) {
                aspMap.put(asp.id(), new WebAppUtils.AspDetails(asp, rg));
            }
        }
        for (ResourceGroup rg : srgMap.get(sd)) {
            for (WebApp wa : rgwaMap.get(rg)) {
                TableItem item = new TableItem(table, SWT.NULL);
                if (wa.javaVersion() != JavaVersion.OFF) {
                    item.setText(new String[] { wa.name(), wa.javaVersion().toString(), wa.javaContainer() + " " + wa.javaContainerVersion(), wa.resourceGroupName() });
                } else {
                    item.setText(new String[] { wa.name(), "Off", "N/A", wa.resourceGroupName() });
                }
                WebAppDetails webAppDetails = new WebAppDetails();
                webAppDetails.webApp = wa;
                webAppDetails.subscriptionDetail = sd;
                webAppDetails.resourceGroup = rg;
                webAppDetails.appServicePlan = aspMap.get(wa.appServicePlanId()).getAsp();
                webAppDetails.appServicePlanResourceGroup = aspMap.get(wa.appServicePlanId()).getRg();
                webAppDetailsMap.put(wa.name(), webAppDetails);
            }
        }
    }
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) HashMap(java.util.HashMap) TableItem(org.eclipse.swt.widgets.TableItem) WebAppUtils(com.microsoft.azuretools.utils.WebAppUtils) AppServicePlan(com.microsoft.azure.management.appservice.AppServicePlan) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) List(java.util.List) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) WebApp(com.microsoft.azure.management.appservice.WebApp)

Example 3 with WebAppDetails

use of com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method editAppService.

private void editAppService() {
    int selectedRow = table.getSelectedRow();
    if (selectedRow >= 0) {
        DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
        String appServiceName = (String) tableModel.getValueAt(selectedRow, 0);
        WebAppDetails wad = webAppWebAppDetailsMap.get(appServiceName);
        AppServiceChangeSettingsDialog d = AppServiceChangeSettingsDialog.go(wad, project);
        if (d == null) {
            // something went wrong - report an error!
            return;
        }
        WebApp wa = d.getWebApp();
        doFillTable();
        selectTableRowWithWebAppName(wa.name());
    }
//fillAppServiceDetails();
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) DefaultTableModel(javax.swing.table.DefaultTableModel) WebApp(com.microsoft.azure.management.appservice.WebApp)

Example 4 with WebAppDetails

use of com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method fillAppServiceDetails.

private void fillAppServiceDetails() {
    DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
    int selectedRow = table.getSelectedRow();
    if (selectedRow >= 0) {
        String appServiceName = (String) tableModel.getValueAt(selectedRow, 0);
        WebAppDetails wad = webAppWebAppDetailsMap.get(appServiceName);
        SubscriptionDetail sd = wad.subscriptionDetail;
        AppServicePlan asp = wad.appServicePlan;
        StringBuilder sb = new StringBuilder();
        sb.append("<div style=\"margin: 7px 7px 7px 7px;\">");
        sb.append(String.format("App Service Name:&nbsp;<b>%s</b><br/>", appServiceName));
        sb.append(String.format("Subscription Name:&nbsp;<b>%s</b>;&nbsp;ID:&nbsp;<b>%s</b><br/>", sd.getSubscriptionName(), sd.getSubscriptionId()));
        String aspName = asp == null ? "N/A" : asp.name();
        String aspPricingTier = asp == null ? "N/A" : asp.pricingTier().toString();
        sb.append(String.format("App Service Plan Name:&nbsp;<b>%s</b>;&nbsp;Pricing Tier:&nbsp;<b>%s</b><br/>", aspName, aspPricingTier));
        String link = buildSiteLink(wad.webApp, null);
        sb.append(String.format("Link:&nbsp;<a href=\"%s\">%s</a>", link, link));
        sb.append("</div>");
        editorPaneAppServiceDetails.setText(sb.toString());
    }
//        listWebAppDetails.setModel(listModel);
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) DefaultTableModel(javax.swing.table.DefaultTableModel) SubscriptionDetail(com.microsoft.azuretools.authmanage.models.SubscriptionDetail) AppServicePlan(com.microsoft.azure.management.appservice.AppServicePlan)

Example 5 with WebAppDetails

use of com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method doValidate.

@Nullable
@Override
protected ValidationInfo doValidate() {
    int selectedRow = table.getSelectedRow();
    if (selectedRow < 0) {
        return new ValidationInfo("Please select an App Service to deploy to", table);
    }
    DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
    WebAppDetails wad = webAppWebAppDetailsMap.get(tableModel.getValueAt(selectedRow, 0));
    if (wad.webApp.javaVersion() == JavaVersion.OFF) {
        return new ValidationInfo("Please select java based App Service", table);
    }
    return super.doValidate();
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) ValidationInfo(com.intellij.openapi.ui.ValidationInfo) DefaultTableModel(javax.swing.table.DefaultTableModel) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

WebAppDetails (com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails)8 DefaultTableModel (javax.swing.table.DefaultTableModel)6 WebApp (com.microsoft.azure.management.appservice.WebApp)4 AppServicePlan (com.microsoft.azure.management.appservice.AppServicePlan)3 SubscriptionDetail (com.microsoft.azuretools.authmanage.models.SubscriptionDetail)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Task (com.intellij.openapi.progress.Task)2 AnActionButtonRunnable (com.intellij.ui.AnActionButtonRunnable)2 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)2 UpdateProgressIndicator (com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator)2 CanceledByUserException (com.microsoft.azuretools.utils.CanceledByUserException)2 WebAppUtils (com.microsoft.azuretools.utils.WebAppUtils)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ValidationInfo (com.intellij.openapi.ui.ValidationInfo)1 PublishingProfile (com.microsoft.azure.management.appservice.PublishingProfile)1 AzureCmdException (com.microsoft.azuretools.azurecommons.helpers.AzureCmdException)1 AzureDeploymentProgressNotification (com.microsoft.intellij.deploy.AzureDeploymentProgressNotification)1 Date (java.util.Date)1