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();
}
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);
}
}
});
}
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);
}
}
});
}
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);
}
}
}
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());
}
}
}
Aggregations