Search in sources :

Example 46 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project azure-tools-for-java by Microsoft.

the class TableEntityForm method doOKAction.

@Override
protected void doOKAction() {
    final TableModel model = propertiesTable.getModel();
    final String partitionKey = model.getValueAt(0, 3).toString();
    final String rowKey = model.getValueAt(1, 3).toString();
    final Map<String, TableEntity.Property> properties = new LinkedHashMap<String, TableEntity.Property>();
    for (int row = 2; row != model.getRowCount(); row++) {
        TableEntity.PropertyType propertyType = (TableEntity.PropertyType) model.getValueAt(row, 2);
        String name = model.getValueAt(row, 1).toString();
        String value = model.getValueAt(row, 3).toString();
        TableEntity.Property property = getProperty(value, propertyType);
        properties.put(name, property);
    }
    ProgressManager.getInstance().run(new Task.Backgroundable(project, tableEntity == null ? "Creating entity" : "Updating entity", false) {

        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {
            progressIndicator.setIndeterminate(true);
        /*try {
                    if (tableEntity == null) {
                        tableEntity = StorageClientSDKManager.getManager().createTableEntity(storageAccount,
                                tableName,
                                partitionKey,
                                rowKey,
                                properties);
                    } else {
                        tableEntity.getProperties().clear();
                        tableEntity.getProperties().putAll(properties);
                        tableEntity = StorageClientSDKManager.getManager().updateTableEntity(storageAccount, tableEntity);
                    }

                    onFinish.run();
                } catch (AzureCmdException e) {
                    String msg = "An error occurred while attempting to create entity." + "\n" + String.format(message("webappExpMsg"), e.getMessage());
                    PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, e);
                }*/
        }
    });
    dispose();
}
Also used : Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) TableEntity(com.microsoft.tooling.msservices.model.storage.TableEntity) TableModel(javax.swing.table.TableModel) DefaultTableModel(javax.swing.table.DefaultTableModel)

Example 47 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project azure-tools-for-java by Microsoft.

the class BlobExplorerFileEditor method fillGrid.

public void fillGrid() {
    setUIState(true);
    ProgressManager.getInstance().run(new Task.Backgroundable(project, "Loading blobs...", false) {

        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {
            try {
                progressIndicator.setIndeterminate(true);
                if (directoryQueue.peekLast() == null) {
                    directoryQueue.addLast(StorageClientSDKManager.getManager().getRootDirectory(connectionString, blobContainer));
                }
                blobItems = StorageClientSDKManager.getManager().getBlobItems(connectionString, directoryQueue.peekLast());
                if (!queryTextField.getText().isEmpty()) {
                    for (int i = blobItems.size() - 1; i >= 0; i--) {
                        BlobItem blobItem = blobItems.get(i);
                        if (blobItem instanceof BlobFile && !blobItem.getName().startsWith(queryTextField.getText())) {
                            blobItems.remove(i);
                        }
                    }
                }
                ApplicationManager.getApplication().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        pathLabel.setText(directoryQueue.peekLast().getPath());
                        DefaultTableModel model = (DefaultTableModel) blobListTable.getModel();
                        while (model.getRowCount() > 0) {
                            model.removeRow(0);
                        }
                        for (BlobItem blobItem : blobItems) {
                            if (blobItem instanceof BlobDirectory) {
                                model.addRow(new Object[] { UIHelperImpl.loadIcon("storagefolder.png"), blobItem.getName(), "", "", "", blobItem.getUri() });
                            } else {
                                BlobFile blobFile = (BlobFile) blobItem;
                                model.addRow(new String[] { "", blobFile.getName(), UIHelperImpl.readableFileSize(blobFile.getSize()), new SimpleDateFormat().format(blobFile.getLastModified().getTime()), blobFile.getContentType(), blobFile.getUri() });
                            }
                        }
                        setUIState(false);
                        blobListTable.clearSelection();
                    }
                });
            } catch (AzureCmdException ex) {
                String msg = "An error occurred while attempting to query blob list." + "\n" + String.format(message("webappExpMsg"), ex.getMessage());
                PluginUtil.displayErrorDialogAndLog(message("errTtl"), msg, ex);
            }
        }
    });
}
Also used : BlobItem(com.microsoft.tooling.msservices.model.storage.BlobItem) Task(com.intellij.openapi.progress.Task) BlobDirectory(com.microsoft.tooling.msservices.model.storage.BlobDirectory) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) AzureCmdException(com.microsoft.azuretools.azurecommons.helpers.AzureCmdException) BlobFile(com.microsoft.tooling.msservices.model.storage.BlobFile) DefaultTableModel(javax.swing.table.DefaultTableModel) SimpleDateFormat(java.text.SimpleDateFormat)

Example 48 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project intellij-elixir by KronicDeth.

the class MixProjectRootStep method fetchDependencies.

private static void fetchDependencies(@NotNull final VirtualFile projectRoot, @NotNull final String mixPath) {
    final Project project = ProjectImportBuilder.getCurrentProject();
    String sdkPath = project != null ? ElixirSdkType.getSdkPath(project) : null;
    final String elixirPath = sdkPath != null ? JpsElixirSdkType.getScriptInterpreterExecutable(sdkPath).getAbsolutePath() : JpsElixirSdkType.getExecutableFileName(JpsElixirSdkType.SCRIPT_INTERPRETER);
    ProgressManager.getInstance().run(new Task.Modal(project, "Fetching dependencies", true) {

        @Override
        public void run(@NotNull final ProgressIndicator indicator) {
            indicator.setIndeterminate(true);
            GeneralCommandLine commandLine = new GeneralCommandLine();
            commandLine.withWorkDirectory(projectRoot.getCanonicalPath());
            commandLine.setExePath(elixirPath);
            commandLine.addParameter(mixPath);
            commandLine.addParameter("deps.get");
            try {
                OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getPreparedCommandLine(Platform.current()));
                handler.addProcessListener(new ProcessAdapter() {

                    @Override
                    public void onTextAvailable(ProcessEvent event, Key outputType) {
                        String text = event.getText();
                        indicator.setText2(text);
                    }
                });
                ProcessTerminatedListener.attach(handler);
                handler.startNotify();
                handler.waitFor();
                indicator.setText2("Refreshing");
            } catch (ExecutionException e) {
                LOG.warn(e);
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ExecutionException(com.intellij.execution.ExecutionException) Key(com.intellij.openapi.util.Key)

Example 49 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.

the class WaitForProgressToShow method runOrInvokeAndWaitAboveProgress.

public static void runOrInvokeAndWaitAboveProgress(final Runnable command, @Nullable final ModalityState modalityState) {
    final Application application = ApplicationManager.getApplication();
    if (application.isDispatchThread()) {
        command.run();
    } else {
        final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
        if (pi != null) {
            execute(pi);
            application.invokeAndWait(command);
        } else {
            final ModalityState notNullModalityState = modalityState == null ? ModalityState.NON_MODAL : modalityState;
            application.invokeAndWait(command, notNullModalityState);
        }
    }
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ModalityState(com.intellij.openapi.application.ModalityState) Application(com.intellij.openapi.application.Application)

Example 50 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.

the class WaitForProgressToShow method runOrInvokeLaterAboveProgress.

public static void runOrInvokeLaterAboveProgress(final Runnable command, @Nullable final ModalityState modalityState, @NotNull final Project project) {
    final Application application = ApplicationManager.getApplication();
    if (application.isDispatchThread()) {
        command.run();
    } else {
        final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
        if (pi != null) {
            execute(pi);
            application.invokeLater(command, pi.getModalityState(), o -> (!project.isOpen()) || project.isDisposed());
        } else {
            final ModalityState notNullModalityState = modalityState == null ? ModalityState.NON_MODAL : modalityState;
            application.invokeLater(command, notNullModalityState, project.getDisposed());
        }
    }
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ModalityState(com.intellij.openapi.application.ModalityState) Application(com.intellij.openapi.application.Application)

Aggregations

ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)352 Task (com.intellij.openapi.progress.Task)139 NotNull (org.jetbrains.annotations.NotNull)98 VirtualFile (com.intellij.openapi.vfs.VirtualFile)96 Project (com.intellij.openapi.project.Project)78 File (java.io.File)52 IOException (java.io.IOException)48 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)44 Nullable (org.jetbrains.annotations.Nullable)43 ProgressManager (com.intellij.openapi.progress.ProgressManager)35 List (java.util.List)30 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)28 Ref (com.intellij.openapi.util.Ref)27 VcsException (com.intellij.openapi.vcs.VcsException)25 ArrayList (java.util.ArrayList)23 ApplicationManager (com.intellij.openapi.application.ApplicationManager)22 Module (com.intellij.openapi.module.Module)21 Logger (com.intellij.openapi.diagnostic.Logger)20 java.util (java.util)20 Processor (com.intellij.util.Processor)18