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);
}
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);
}
}
}
}
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();
}
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: <b>%s</b><br/>", appServiceName));
sb.append(String.format("Subscription Name: <b>%s</b>; ID: <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: <b>%s</b>; Pricing Tier: <b>%s</b><br/>", aspName, aspPricingTier));
String link = buildSiteLink(wad.webApp, null);
sb.append(String.format("Link: <a href=\"%s\">%s</a>", link, link));
sb.append("</div>");
editorPaneAppServiceDetails.setText(sb.toString());
}
// listWebAppDetails.setModel(listModel);
}
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();
}
Aggregations