use of com.intellij.openapi.progress.ProgressIndicator in project azure-tools-for-java by Microsoft.
the class AzureNewDockerHostStep method updateDockerHostVMSizeComboBox.
private void updateDockerHostVMSizeComboBox(boolean prefferedSizesOnly) {
DefaultComboBoxModel<String> dockerHostVMSizeComboModel = new DefaultComboBoxModel<>();
if (prefferedSizesOnly) {
for (KnownDockerVirtualMachineSizes knownDockerVirtualMachineSize : KnownDockerVirtualMachineSizes.values()) {
dockerHostVMSizeComboModel.addElement(knownDockerVirtualMachineSize.name());
}
if (dockerHostVMSizeComboModel.getSize() > 0) {
dockerHostVMSizeComboModel.setSelectedItem(dockerHostVMSizeComboModel.getElementAt(0));
}
} else {
dockerHostVMSizeComboModel.addElement("<Loading...>");
ProgressManager.getInstance().run(new Task.Backgroundable(model.getProject(), "Loading VM Sizes...", false) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
progressIndicator.setIndeterminate(true);
Azure azureClient = ((AzureDockerSubscription) dockerSubscriptionComboBox.getSelectedItem()).azureClient;
PagedList<VirtualMachineSize> sizes = null;
try {
sizes = azureClient.virtualMachines().sizes().listByRegion(preferredLocation);
Collections.sort(sizes, new Comparator<VirtualMachineSize>() {
@Override
public int compare(VirtualMachineSize size1, VirtualMachineSize size2) {
if (size1.name().contains("Basic") && size2.name().contains("Basic")) {
return size1.name().compareTo(size2.name());
} else if (size1.name().contains("Basic")) {
return -1;
} else if (size2.name().contains("Basic")) {
return 1;
}
int coreCompare = Integer.valueOf(size1.numberOfCores()).compareTo(size2.numberOfCores());
if (coreCompare == 0) {
return Integer.valueOf(size1.memoryInMB()).compareTo(size2.memoryInMB());
} else {
return coreCompare;
}
}
});
} catch (Exception notHandled) {
}
PagedList<VirtualMachineSize> sortedSizes = sizes;
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
@Override
public void run() {
dockerHostVMSizeComboModel.removeAllElements();
if (sortedSizes != null) {
for (VirtualMachineSize vmSize : sortedSizes) {
dockerHostVMSizeComboModel.addElement(vmSize.name());
}
}
dockerHostVMSizeComboBox.repaint();
}
}, ModalityState.any());
}
});
}
dockerHostVMSizeComboBox.setModel(dockerHostVMSizeComboModel);
dockerHostVMSizeComboBox.setSelectedItem(newHost.hostVM.vmSize);
if (!newHost.hostVM.vmSize.equals((String) dockerHostVMSizeComboBox.getSelectedItem())) {
dockerHostVMSizeComboModel.addElement(newHost.hostVM.vmSize);
dockerHostVMSizeComboBox.setSelectedItem(newHost.hostVM.vmSize);
}
updateDockerSelectStorageComboBox((AzureDockerSubscription) dockerSubscriptionComboBox.getSelectedItem());
}
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());
}
}
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class SearchCommand method startSearching.
public void startSearching() {
final UsageViewContext context = createUsageViewContext();
final UsageViewPresentation presentation = new UsageViewPresentation();
presentation.setOpenInNewTab(FindSettings.getInstance().isShowResultsInSeparateView());
context.configure(presentation);
final FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation);
processPresentation.setShowNotFoundMessage(true);
processPresentation.setShowPanelIfOnlyOneUsage(true);
processPresentation.setProgressIndicatorFactory(new Factory<ProgressIndicator>() {
@Override
public ProgressIndicator create() {
FindProgressIndicator indicator = new FindProgressIndicator(mySearchContext.getProject(), presentation.getScopeText());
indicator.addStateDelegate(new AbstractProgressIndicatorExBase() {
@Override
public void cancel() {
super.cancel();
stopAsyncSearch();
}
});
return indicator;
}
});
PsiDocumentManager.getInstance(mySearchContext.getProject()).commitAllDocuments();
final ConfigurableUsageTarget target = context.getTarget();
((FindManagerImpl) FindManager.getInstance(mySearchContext.getProject())).getFindUsagesManager().addToHistory(target);
UsageViewManager.getInstance(mySearchContext.getProject()).searchAndShowUsages(new UsageTarget[] { target }, () -> new UsageSearcher() {
@Override
public void generate(@NotNull final Processor<Usage> processor) {
findUsages(processor);
}
}, processPresentation, presentation, new UsageViewManager.UsageViewStateListener() {
@Override
public void usageViewCreated(@NotNull UsageView usageView) {
context.setUsageView(usageView);
context.configureActions();
}
@Override
public void findingUsagesFinished(final UsageView usageView) {
}
});
}
Aggregations