use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class CoreProgressManager method getCurrentThreadProgressModality.
@NotNull
public static ModalityState getCurrentThreadProgressModality() {
ProgressIndicator indicator = threadTopLevelIndicators.get(Thread.currentThread().getId());
ModalityState modality = indicator == null ? null : indicator.getModalityState();
return modality != null ? modality : ModalityState.NON_MODAL;
}
use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class AbstractProgressIndicatorBase method setModalityProgress.
@Override
public void setModalityProgress(ProgressIndicator modalityProgress) {
LOG.assertTrue(!isRunning());
myModalityProgress = modalityProgress;
ModalityState currentModality = ApplicationManager.getApplication().getCurrentModalityState();
myModalityState = myModalityProgress != null ? ((ModalityStateEx) currentModality).appendProgress(myModalityProgress) : currentModality;
if (modalityProgress != null) {
((TransactionGuardImpl) TransactionGuard.getInstance()).enteredModality(myModalityState);
}
}
use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class PyIntegratedToolsProjectConfigurator method updateIntegratedTools.
private static void updateIntegratedTools(final Module module, final int delay) {
ModalityState modality = ModalityState.current();
final PyDocumentationSettings docSettings = PyDocumentationSettings.getInstance(module);
AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> ApplicationManager.getApplication().invokeLater(() -> {
LOG.debug("Integrated tools configurator has started");
if (module.isDisposed())
return;
@NotNull DocStringFormat docFormat = DocStringFormat.PLAIN;
//check setup.py
@NotNull String testRunner = detectTestRunnerFromSetupPy(module);
if (!testRunner.isEmpty()) {
LOG.debug("Test runner '" + testRunner + "' was discovered from setup.py in the module '" + module.getModuleFilePath() + "'");
}
//try to find test_runner import
final String extension = PythonFileType.INSTANCE.getDefaultExtension();
// Module#getModuleScope() and GlobalSearchScope#getModuleScope() search only in source roots
final GlobalSearchScope searchScope = module.getModuleScope();
final Collection<VirtualFile> pyFiles = FilenameIndex.getAllFilesByExt(module.getProject(), extension, searchScope);
for (VirtualFile file : pyFiles) {
if (file.getName().startsWith("test")) {
if (testRunner.isEmpty()) {
//find test runner import
testRunner = checkImports(file, module);
if (!testRunner.isEmpty()) {
LOG.debug("Test runner '" + testRunner + "' was detected from imports in the file '" + file.getPath() + "'");
}
}
} else if (docFormat == DocStringFormat.PLAIN) {
// detect docstring type
docFormat = checkDocstring(file, module);
if (docFormat != DocStringFormat.PLAIN) {
LOG.debug("Docstring format '" + docFormat + "' was detected from content of the file '" + file.getPath() + "'");
}
}
if (!testRunner.isEmpty() && docFormat != DocStringFormat.PLAIN) {
break;
}
}
// Check test runners available in the module SDK
if (testRunner.isEmpty()) {
//check if installed in sdk
final Sdk sdk = PythonSdkType.findPythonSdk(module);
if (sdk != null && sdk.getSdkType() instanceof PythonSdkType) {
final List<PyPackage> packages = PyPackageUtil.refreshAndGetPackagesModally(sdk);
if (packages != null) {
final boolean nose = PyPackageUtil.findPackage(packages, PyNames.NOSE_TEST) != null;
final boolean pytest = PyPackageUtil.findPackage(packages, PyNames.PY_TEST) != null;
if (nose)
testRunner = PythonTestConfigurationsModel.PYTHONS_NOSETEST_NAME;
else if (pytest)
testRunner = PythonTestConfigurationsModel.PY_TEST_NAME;
if (!testRunner.isEmpty()) {
LOG.debug("Test runner '" + testRunner + "' was detected from SDK " + sdk);
}
}
}
}
final TestRunnerService runnerService = TestRunnerService.getInstance(module);
if (runnerService != null) {
if (testRunner.isEmpty()) {
runnerService.setProjectConfiguration(PythonTestConfigurationsModel.PYTHONS_UNITTEST_NAME);
} else {
runnerService.setProjectConfiguration(testRunner);
LOG.info("Test runner '" + testRunner + "' was detected by project configurator");
}
}
// Documentation settings should have meaningful default already
if (docFormat != DocStringFormat.PLAIN) {
docSettings.setFormat(docFormat);
LOG.info("Docstring format '" + docFormat + "' was detected by project configurator");
}
}, modality), delay, TimeUnit.MILLISECONDS);
}
use of com.intellij.openapi.application.ModalityState in project flutter-intellij by flutter.
the class FlutterSettingsConfigurable method updateVersionText.
private void updateVersionText() {
final FlutterSdk sdk = FlutterSdk.forPath(getSdkPathText());
if (sdk == null) {
myVersionLabel.setText("");
return;
}
final ModalityState modalityState = ModalityState.current();
sdk.flutterVersion().start((ProcessOutput output) -> {
final String stdout = output.getStdout();
final String htmlText = "<html>" + StringUtil.replace(StringUtil.escapeXml(stdout.trim()), "\n", "<br/>") + "</html>";
ApplicationManager.getApplication().invokeLater(() -> updateVersionTextIfCurrent(sdk, htmlText), modalityState);
}, null);
}
use of com.intellij.openapi.application.ModalityState in project azure-tools-for-java by Microsoft.
the class SparkBatchJobDebuggerRunner method attachAndDebug.
private Observable<RunContentDescriptor> attachAndDebug(final ExecutionEnvironment environment, final RunProfileState state) {
final Project project = environment.getProject();
final JFrame ideFrame = WindowManager.getInstance().getFrame(project);
final ModalityState ideModalityState = ideFrame != null ? stateForComponent(ideFrame) : any();
return Observable.fromCallable(() -> {
// Invoke GenericDebuggerRunner#doExecute to start real VM attach and debugging
return doExecute(state, environment);
}).subscribeOn(new IdeaSchedulers(project).dispatchUIThread(ideModalityState));
}
Aggregations