use of javax.swing.table.DefaultTableModel 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();
if (srgMap == null)
throw new NullPointerException("srgMap is null");
if (rgwaMap == null)
throw new NullPointerException("rgwaMap is null");
if (rgaspMap == null)
throw new NullPointerException("rgaspMap is null");
cleanTable();
DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
for (SubscriptionDetail sd : srgMap.keySet()) {
if (!sd.isSelected())
continue;
Map<String, WebAppUtils.AspDetails> aspMap = new HashMap<>();
try {
for (ResourceGroup rg : srgMap.get(sd)) {
for (AppServicePlan asp : rgaspMap.get(rg)) {
aspMap.put(asp.id(), new WebAppUtils.AspDetails(asp, rg));
}
}
} catch (NullPointerException npe) {
LOGGER.error("NPE while initializing App Service Plan map", npe);
}
for (ResourceGroup rg : srgMap.get(sd)) {
for (WebApp wa : rgwaMap.get(rg)) {
if (wa.javaVersion() != JavaVersion.OFF) {
tableModel.addRow(new String[] { wa.name(), wa.javaVersion().toString(), wa.javaContainer() + " " + wa.javaContainerVersion(), wa.resourceGroupName() });
} else {
tableModel.addRow(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();
webAppWebAppDetailsMap.put(wa.name(), webAppDetails);
}
}
}
table.setModel(tableModel);
if (tableModel.getRowCount() > 0)
tableModel.fireTableDataChanged();
}
use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.
the class WebAppDeployDialog method deploy.
private void deploy() {
DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
int selectedRow = table.getSelectedRow();
WebAppDetails wad = webAppWebAppDetailsMap.get(tableModel.getValueAt(selectedRow, 0));
WebApp webApp = wad.webApp;
boolean isDeployToRoot = deployToRootCheckBox.isSelected();
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Deploy Web App Progress", true) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
AzureDeploymentProgressNotification azureDeploymentProgressNotification = new AzureDeploymentProgressNotification(project);
try {
progressIndicator.setIndeterminate(true);
PublishingProfile pp = webApp.getPublishingProfile();
Date startDate = new Date();
azureDeploymentProgressNotification.notifyProgress(webApp.name(), startDate, null, 5, "Deploying Web App...");
WebAppUtils.deployArtifact(artifact.getName(), artifact.getOutputFilePath(), pp, isDeployToRoot, new UpdateProgressIndicator(progressIndicator));
String sitePath = buildSiteLink(wad.webApp, isDeployToRoot ? null : artifact.getName());
progressIndicator.setText("Checking Web App availability...");
progressIndicator.setText2("Link: " + sitePath);
azureDeploymentProgressNotification.notifyProgress(webApp.name(), startDate, sitePath, 75, "Checking Web App availability...");
int stepLimit = 5;
int sleepMs = 2000;
// to make warn up cancelable
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
for (int step = 0; step < stepLimit; ++step) {
if (WebAppUtils.isUrlAccessible(sitePath)) {
// warm up
break;
}
Thread.sleep(sleepMs);
}
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("deploy::warmup", e);
}
}
});
thread.start();
while (thread.isAlive()) {
if (progressIndicator.isCanceled())
return;
else
Thread.sleep(sleepMs);
}
azureDeploymentProgressNotification.notifyProgress(webApp.name(), startDate, sitePath, 100, message("runStatus"));
showLink(sitePath);
} catch (IOException | InterruptedException ex) {
ex.printStackTrace();
//LOGGER.error("deploy", ex);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ErrorWindow.show(project, ex.getMessage(), "Deploy Web App Error");
}
});
}
}
});
}
use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.
the class SubscriptionsDialog method doOKAction.
@Override
protected void doOKAction() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
int rc = model.getRowCount();
int unselectedCount = 0;
for (int ri = 0; ri < rc; ++ri) {
boolean selected = (boolean) model.getValueAt(ri, 0);
if (!selected)
unselectedCount++;
}
if (unselectedCount == rc) {
JOptionPane.showMessageDialog(contentPane, "Please select at least one subscription", "Subscription dialog info", JOptionPane.INFORMATION_MESSAGE);
return;
}
for (int ri = 0; ri < rc; ++ri) {
boolean selected = (boolean) model.getValueAt(ri, 0);
this.sdl.get(ri).setSelected(selected);
}
super.doOKAction();
}
use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.
the class WebAppDeployDialog method deleteAppService.
private void deleteAppService() {
DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
int selectedRow = table.getSelectedRow();
if (selectedRow >= 0) {
String appServiceName = (String) tableModel.getValueAt(selectedRow, 0);
WebAppDetails wad = webAppWebAppDetailsMap.get(appServiceName);
int choice = JOptionPane.showOptionDialog(WebAppDeployDialog.this.getContentPane(), "Do you really want to delete the App Service '" + appServiceName + "'?", "Delete App Service", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
if (choice == JOptionPane.NO_OPTION) {
return;
}
AppInsightsClient.createByType(AppInsightsClient.EventType.WebApp, appServiceName, "Delete");
try {
ProgressManager.getInstance().run(new Task.Modal(project, "Delete App Service Progress", true) {
@Override
public void run(ProgressIndicator progressIndicator) {
try {
progressIndicator.setIndeterminate(true);
progressIndicator.setText("Deleting App Service...");
WebAppUtils.deleteAppService(wad);
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
tableModel.removeRow(selectedRow);
tableModel.fireTableDataChanged();
editorPaneAppServiceDetails.setText("");
}
});
} catch (Exception ex) {
ex.printStackTrace();
//LOGGER.error("deleteAppService : Task.Modal ", ex);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ErrorWindow.show(project, ex.getMessage(), "Delete App Service Error");
}
});
}
}
});
} catch (Exception e) {
e.printStackTrace();
//LOGGER.error("deleteAppService", e);
ErrorWindow.show(project, e.getMessage(), "Delete App Service Error");
}
}
}
use of javax.swing.table.DefaultTableModel in project azure-tools-for-java by Microsoft.
the class SubscriptionsDialog method createUIComponents.
private void createUIComponents() {
DefaultTableModel model = new SubscriptionTableModel();
model.addColumn("");
model.addColumn("Subscription name");
model.addColumn("Subscription ID");
table = new JBTable();
table.setModel(model);
TableColumn column = table.getColumnModel().getColumn(0);
column.setMinWidth(23);
column.setMaxWidth(23);
table.setRowSelectionAllowed(false);
table.setCellSelectionEnabled(false);
AnActionButton refreshAction = new AnActionButton("Refresh", AllIcons.Actions.Refresh) {
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
AppInsightsClient.createByType(AppInsightsClient.EventType.Subscription, "", "Refresh", null);
refreshSubscriptions();
}
};
ToolbarDecorator tableToolbarDecorator = ToolbarDecorator.createDecorator(table).disableUpDownActions().addExtraActions(refreshAction);
panelTable = tableToolbarDecorator.createPanel();
}
Aggregations