use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.
the class InterruptibleActivity method execute.
public final int execute() {
final Application application = ApplicationManager.getApplication();
/* TODO: uncomment assertion when problems in Perforce plugin are fixed.
LOG.assertTrue(!application.isDispatchThread(), "InterruptibleActivity is supposed to be lengthy thus must not block Swing UI thread");
*/
final Semaphore semaphore = new Semaphore();
semaphore.down();
application.executeOnPooledThread(() -> {
try {
start();
} finally {
semaphore.up();
}
});
final int rc = waitForSemaphore(semaphore);
if (rc != 0) {
application.executeOnPooledThread(() -> interrupt());
}
return rc;
}
use of com.intellij.openapi.application.Application in project android by JetBrains.
the class AppBarConfigurationDialog method generatePreviews.
private void generatePreviews() {
PsiFile expandedFile = generateXml(false);
PsiFile collapsedFile = generateXml(true);
myExpandedPreviewFuture = cancel(myExpandedPreviewFuture);
myCollapsedPreviewFuture = cancel(myCollapsedPreviewFuture);
Application application = ApplicationManager.getApplication();
myExpandedPreviewFuture = application.executeOnPooledThread(() -> updateExpandedImage(expandedFile));
myCollapsedPreviewFuture = application.executeOnPooledThread(() -> updateCollapsedImage(collapsedFile));
}
use of com.intellij.openapi.application.Application in project intellij-plugins by JetBrains.
the class BuiltInFlexCompilerHandler method stopCompilerProcess.
public void stopCompilerProcess() {
final Runnable runnable = () -> {
cancelAllCompilations(true);
closeSocket();
};
final Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
application.executeOnPooledThread(runnable);
} else {
runnable.run();
}
}
use of com.intellij.openapi.application.Application in project intellij-plugins by JetBrains.
the class FlexCompilationManager method refreshAndFindFileInWriteAction.
static VirtualFile refreshAndFindFileInWriteAction(final String outputFilePath, final String... possibleBaseDirs) {
final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
final Ref<VirtualFile> outputFileRef = new Ref<>();
final Application app = ApplicationManager.getApplication();
app.invokeAndWait(() -> outputFileRef.set(app.runWriteAction(new NullableComputable<VirtualFile>() {
public VirtualFile compute() {
VirtualFile outputFile = localFileSystem.refreshAndFindFileByPath(outputFilePath);
//}
if (outputFile == null) {
for (final String baseDir : possibleBaseDirs) {
outputFile = localFileSystem.refreshAndFindFileByPath(baseDir + "/" + outputFilePath);
if (outputFile != null) {
break;
}
}
}
if (outputFile == null)
return null;
// it's important because this file has just been created
outputFile.refresh(false, false);
return outputFile;
}
})));
return outputFileRef.get();
}
use of com.intellij.openapi.application.Application in project intellij-plugins by JetBrains.
the class FlexBaseRunner method launchWithSelectedApplication.
public static void launchWithSelectedApplication(final String urlOrPath, final LauncherParameters launcherParams) {
switch(launcherParams.getLauncherType()) {
case OSDefault:
BrowserUtil.open(urlOrPath);
break;
case Browser:
final Runnable runnable1 = () -> BrowserLauncher.getInstance().browse(BrowserUtil.isAbsoluteURL(urlOrPath) ? urlOrPath : VfsUtilCore.pathToUrl(urlOrPath), launcherParams.getBrowser());
final Application application1 = ApplicationManager.getApplication();
if (application1.isDispatchThread()) {
runnable1.run();
} else {
application1.invokeLater(runnable1);
}
break;
case Player:
try {
if (SystemInfo.isMac) {
if (launcherParams.isNewPlayerInstance()) {
Runtime.getRuntime().exec(new String[] { ExecUtil.getOpenCommandPath(), "-n", "-a", launcherParams.getPlayerPath(), urlOrPath });
} else {
Runtime.getRuntime().exec(new String[] { ExecUtil.getOpenCommandPath(), "-a", launcherParams.getPlayerPath(), urlOrPath });
}
} else {
Runtime.getRuntime().exec(new String[] { launcherParams.getPlayerPath(), urlOrPath });
}
// todo read error stream, report errors
// todo keep process to be able to kill it on user demand
} catch (final IOException e) {
final Runnable runnable2 = () -> Messages.showErrorDialog(FlexBundle.message("cant.launch", urlOrPath, launcherParams.getPlayerPath(), e.getMessage()), CommonBundle.getErrorTitle());
final Application application2 = ApplicationManager.getApplication();
if (application2.isDispatchThread()) {
runnable2.run();
} else {
application2.invokeLater(runnable2);
}
}
break;
}
}
Aggregations