Search in sources :

Example 1 with UpdateProgressIndicator

use of com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator in project azure-tools-for-java by Microsoft.

the class WebAppDeployDialog method updateAndFillTable.

private void updateAndFillTable() {
    ProgressManager.getInstance().run(new Task.Modal(project, "Update Azure Local Cache Progress", true) {

        @Override
        public void run(ProgressIndicator progressIndicator) {
            progressIndicator.setIndeterminate(true);
            try {
                if (progressIndicator.isCanceled()) {
                    throw new CanceledByUserException();
                }
                AzureModelController.updateResourceGroupMaps(new UpdateProgressIndicator(progressIndicator));
                ApplicationManager.getApplication().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        doFillTable();
                    }
                }, ModalityState.any());
            } catch (CanceledByUserException ex) {
                //AzureModel.getInstance().setResourceGroupToWebAppMap(null);
                ApplicationManager.getApplication().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        System.out.println("updateAndFillTable(): Canceled by user");
                        doCancelAction();
                    }
                }, ModalityState.any());
            } catch (Exception ex) {
                ex.printStackTrace();
                LOGGER.debug("updateAndFillTable", ex);
            }
        }
    });
}
Also used : Task(com.intellij.openapi.progress.Task) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) CanceledByUserException(com.microsoft.azuretools.utils.CanceledByUserException) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator) CanceledByUserException(com.microsoft.azuretools.utils.CanceledByUserException) IOException(java.io.IOException)

Example 2 with UpdateProgressIndicator

use of com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator 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");
                    }
                });
            }
        }
    });
}
Also used : WebAppDetails(com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails) Task(com.intellij.openapi.progress.Task) DefaultTableModel(javax.swing.table.DefaultTableModel) AzureDeploymentProgressNotification(com.microsoft.intellij.deploy.AzureDeploymentProgressNotification) Date(java.util.Date) CanceledByUserException(com.microsoft.azuretools.utils.CanceledByUserException) IOException(java.io.IOException) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AnActionButtonRunnable(com.intellij.ui.AnActionButtonRunnable) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator) PublishingProfile(com.microsoft.azure.management.appservice.PublishingProfile) WebApp(com.microsoft.azure.management.appservice.WebApp)

Example 3 with UpdateProgressIndicator

use of com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator in project azure-tools-for-java by Microsoft.

the class AppServiceChangeSettingsDialog method doOKAction.

@Override
protected void doOKAction() {
    ProgressManager.getInstance().run(new Task.Modal(null, "Changing App Service Settings...", true) {

        @Override
        public void run(ProgressIndicator progressIndicator) {
            try {
                progressIndicator.setIndeterminate(true);
                webApp = editAppService(webApp, new UpdateProgressIndicator(progressIndicator));
                ApplicationManager.getApplication().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        superDoOKAction();
                    }
                });
            } catch (Exception ex) {
                ex.printStackTrace();
                // TODO: show error message
                LOGGER.error("doOKAction :: Task.Modal", ex);
                ApplicationManager.getApplication().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        ErrorWindow.show(project, ex.getMessage(), "Create App Service Error");
                    }
                });
            }
        }
    });
}
Also used : Task(com.intellij.openapi.progress.Task) IProgressIndicator(com.microsoft.azuretools.utils.IProgressIndicator) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator)

Example 4 with UpdateProgressIndicator

use of com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator in project azure-tools-for-java by Microsoft.

the class AppServiceCreateDialog method doOKAction.

@Override
protected void doOKAction() {
    ProgressManager.getInstance().run(new Task.Modal(project, "Create App Service Progress", true) {

        @Override
        public void run(ProgressIndicator progressIndicator) {
            try {
                progressIndicator.setIndeterminate(true);
                progressIndicator.setText("Creating Web App Service...");
                webApp = WebAppUtils.createAppService(new UpdateProgressIndicator(progressIndicator), model);
                ApplicationManager.getApplication().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        superDoOKAction();
                    }
                });
            } catch (CloudException ex) {
                ex.printStackTrace();
                //LOGGER.error("run@Progress@doOKAction@@AppServiceCreateDialog", ex);
                ApplicationManager.getApplication().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        ErrorWindow.show(project, ex.getMessage(), "Create App Service Error");
                    }
                });
            } catch (IOException | InterruptedException | AzureCmdException | WebAppUtils.WebAppException ex) {
                ex.printStackTrace();
                LOGGER.error("run@Progress@doOKAction@AppServiceCreateDialog", ex);
            }
        }
    });
}
Also used : Task(com.intellij.openapi.progress.Task) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UpdateProgressIndicator(com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator) CloudException(com.microsoft.azure.CloudException)

Aggregations

ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)4 Task (com.intellij.openapi.progress.Task)4 UpdateProgressIndicator (com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator)4 AnActionButtonRunnable (com.intellij.ui.AnActionButtonRunnable)2 CanceledByUserException (com.microsoft.azuretools.utils.CanceledByUserException)2 IOException (java.io.IOException)2 CloudException (com.microsoft.azure.CloudException)1 PublishingProfile (com.microsoft.azure.management.appservice.PublishingProfile)1 WebApp (com.microsoft.azure.management.appservice.WebApp)1 IProgressIndicator (com.microsoft.azuretools.utils.IProgressIndicator)1 WebAppDetails (com.microsoft.azuretools.utils.WebAppUtils.WebAppDetails)1 AzureDeploymentProgressNotification (com.microsoft.intellij.deploy.AzureDeploymentProgressNotification)1 Date (java.util.Date)1 DefaultTableModel (javax.swing.table.DefaultTableModel)1