本文整理了Java中com.intellij.openapi.application.ApplicationManager.getApplication()
方法的一些代码示例,展示了ApplicationManager.getApplication()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationManager.getApplication()
方法的具体详情如下:
包路径:com.intellij.openapi.application.ApplicationManager
类名称:ApplicationManager
方法名:getApplication
暂无
代码示例来源:origin: pedrovgs/AndroidWiFiADB
public void actionPerformed(final AnActionEvent event) {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
public void run() {
androidWifiADB.updateProject(event.getProject());
androidWifiADB.connectDevices();
}
});
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
private static void startTemplate(@NotNull Editor editor, @NotNull Template template, @NotNull Project project) {
Runnable runnable = () -> {
if (project.isDisposed() || editor.isDisposed()) return;
CommandProcessor.getInstance().executeCommand(project, () ->
TemplateManager.getInstance(project).startTemplate(editor, template, null), "Introduce function", null);
};
if (ApplicationManager.getApplication().isUnitTestMode()) {
runnable.run();
}
else {
ApplicationManager.getApplication().invokeLater(runnable);
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
private static void setHighlighting(@NotNull PsiElement element, @NotNull AnnotationHolder holder, @NotNull TextAttributesKey key) {
holder.createInfoAnnotation(element, null).setEnforcedTextAttributes(TextAttributes.ERASE_MARKER);
String description = ApplicationManager.getApplication().isUnitTestMode() ? key.getExternalName() : null;
holder.createInfoAnnotation(element, description).setTextAttributes(key);
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Override
public void initComponent() {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
EditorFactory.getInstance().addEditorFactoryListener(myListener, this);
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
private void showNotification(@NotNull String message, NotificationType type) {
ApplicationManager.getApplication().invokeLater(() -> {
String title = getPresentableName();
Notifications.Bus.notify(GoConstants.GO_EXECUTION_NOTIFICATION_GROUP.createNotification(title, message, type, null), myProject);
});
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Nullable
public static String retrieveGoPathFromEnvironment() {
if (ApplicationManager.getApplication().isUnitTestMode()) return null;
String path = EnvironmentUtil.getValue(GoConstants.GO_PATH);
return path != null ? path : PathMacros.getInstance().getValue(GoConstants.GO_PATH);
}
}
代码示例来源:origin: JetBrains/ideavim
@Override
public final void init() {
if (ApplicationManager.getApplication().isUnitTestMode()) {
initOnce();
}
else {
if (!myInitialized) {
myInitialized = true;
initOnce();
}
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
private void perform(@NotNull PsiFile file, @Nullable String pathToImport) {
if (file instanceof GoFile && pathToImport != null) {
Project project = file.getProject();
CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> {
if (!isAvailable()) return;
if (((GoFile)file).getImportedPackagesMap().containsKey(pathToImport)) return;
((GoFile)file).addImport(pathToImport, null);
}), "Add import", null);
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
public void setLibraryRootUrls(@NotNull Collection<String> libraryRootUrls) {
if (!myState.getUrls().equals(libraryRootUrls)) {
myState.setUrls(libraryRootUrls);
incModificationCount();
ApplicationManager.getApplication().getMessageBus().syncPublisher(LIBRARIES_TOPIC).librariesChanged(libraryRootUrls);
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
public GoModuleLibrariesInitializer(@NotNull Module module) {
myModule = module;
myAlarm = ApplicationManager.getApplication().isUnitTestMode() ? new Alarm() : new Alarm(Alarm.ThreadToUse.POOLED_THREAD, myModule);
myConnection = myModule.getMessageBus().connect();
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Override
public void chooseAndSetSdk(@Nullable Module module) {
Sdk projectSdk = ProjectSettingsService.getInstance(myProject).chooseAndSetSdk();
if (projectSdk == null && module != null) {
ApplicationManager.getApplication().runWriteAction(() -> {
if (!module.isDisposed()) {
ModuleRootModificationUtil.setSdkInherited(module);
}
});
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
public static void showModulesConfigurable(@NotNull Project project) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!project.isDisposed()) {
ShowSettingsUtil.getInstance().editConfigurable(project, new GoConfigurableProvider.GoProjectSettingsConfigurable(project));
}
}
代码示例来源:origin: JetBrains/ideavim
public void postKey(@NotNull KeyStroke stroke, @NotNull Editor editor) {
final Component component = SwingUtilities.getAncestorOfClass(Window.class, editor.getComponent());
final KeyEvent event = createKeyEvent(stroke, component);
ApplicationManager.getApplication().invokeLater(() -> {
if (logger.isDebugEnabled()) {
logger.debug("posting " + event);
}
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(event);
});
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
private void scheduleUpdate(int delay) {
myAlarm.cancelAllRequests();
UpdateRequest updateRequest = new UpdateRequest();
if (isTestingMode) {
ApplicationManager.getApplication().invokeLater(updateRequest);
}
else {
myAlarm.addRequest(updateRequest, delay);
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Override
public Result performLookupAction() {
ApplicationManager.getApplication().invokeLater(() -> {
GoAutoImportConfigurable configurable = new GoAutoImportConfigurable(myProject, true);
ShowSettingsUtil.getInstance().editConfigurable(myProject, configurable, configurable::focusList);
});
return Result.HIDE_LOOKUP;
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
public static void showModulesConfigurable(@NotNull Project project) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!project.isDisposed()) {
Configurable configurable = new GoLibrariesConfigurableProvider(project).createConfigurable(true);
ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
}
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
public static void showModulesConfigurable(@NotNull Module module) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!module.isDisposed()) {
ShowSettingsUtil.getInstance().editConfigurable(module.getProject(), new GoModuleSettingsConfigurable(module, true));
}
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
public void setUseGoPathFromSystemEnvironment(boolean useGoPathFromSystemEnvironment) {
if (myState.isUseGoPathFromSystemEnvironment() != useGoPathFromSystemEnvironment) {
myState.setUseGoPathFromSystemEnvironment(useGoPathFromSystemEnvironment);
if (!GoSdkUtil.getGoPathsRootsFromEnvironment().isEmpty()) {
incModificationCount();
ApplicationManager.getApplication().getMessageBus().syncPublisher(LIBRARIES_TOPIC).librariesChanged(getLibraryRootUrls());
}
}
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
private void setUpProjectSdk() {
ApplicationManager.getApplication().runWriteAction(() -> {
Sdk sdk = getProjectDescriptor().getSdk();
ProjectJdkTable.getInstance().addJdk(sdk);
ProjectRootManager.getInstance(myFixture.getProject()).setProjectSdk(sdk);
});
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
private void doTest() {
PsiFile file = myFixture.configureByFile(getTestName(true) + ".go");
resolveAllReferences(file);
myFixture.checkHighlighting();
ApplicationManager.getApplication().runWriteAction(
() -> OptimizeImportsAction.actionPerformedImpl(DataManager.getInstance().getDataContext(myFixture.getEditor().getContentComponent())));
myFixture.checkResultByFile(getTestName(true) + "_after.go");
}
内容来源于网络,如有侵权,请联系作者删除!