Search in sources :

Example 1 with CanceledByUserException

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

the class WebAppDeployDialog method updateAndFillTable.

private void updateAndFillTable() {
    try {
        ProgressDialog.get(getShell(), "Update Azure Local Cache Progress").run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Updating Azure local cache...", IProgressMonitor.UNKNOWN);
                try {
                    if (monitor.isCanceled()) {
                        throw new CanceledByUserException();
                    }
                    AzureModelController.updateResourceGroupMaps(new UpdateProgressIndicator(monitor));
                    Display.getDefault().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            doFillTable();
                        }
                    });
                } catch (CanceledByUserException ex) {
                    Display.getDefault().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            System.out.println("updateAndFillTable(): Canceled by user");
                            cancelPressed();
                        }
                    });
                } catch (Exception ex) {
                    ex.printStackTrace();
                    LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "run@ProgressDialog@updateAndFillTable@AppServiceCreateDialog", ex));
                }
                monitor.done();
            }
        });
    } catch (InvocationTargetException | InterruptedException ex) {
        ex.printStackTrace();
        LOG.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "updateAndFillTable@AppServiceCreateDialog", ex));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CanceledByUserException(com.microsoft.azuretools.utils.CanceledByUserException) UpdateProgressIndicator(com.microsoft.azuretools.core.utils.UpdateProgressIndicator) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CanceledByUserException(com.microsoft.azuretools.utils.CanceledByUserException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with CanceledByUserException

use of com.microsoft.azuretools.utils.CanceledByUserException 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)

Aggregations

CanceledByUserException (com.microsoft.azuretools.utils.CanceledByUserException)2 IOException (java.io.IOException)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 AnActionButtonRunnable (com.intellij.ui.AnActionButtonRunnable)1 UpdateProgressIndicator (com.microsoft.azuretools.core.utils.UpdateProgressIndicator)1 UpdateProgressIndicator (com.microsoft.azuretools.ijidea.utility.UpdateProgressIndicator)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1