本文整理汇总了Java中com.intellij.openapi.application.ApplicationManager.getApplication方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationManager.getApplication方法的具体用法?Java ApplicationManager.getApplication怎么用?Java ApplicationManager.getApplication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.application.ApplicationManager
的用法示例。
在下文中一共展示了ApplicationManager.getApplication方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getApplication
import com.intellij.openapi.application.ApplicationManager; //导入方法依赖的package包/类
@Nonnull
@CheckReturnValue
protected Application getApplication() {
if (fixture == null) {
throw new AssertionError("getApplication() must call after setUp()");
}
return ApplicationManager.getApplication();
}
示例2: setUp
import com.intellij.openapi.application.ApplicationManager; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
final IdeaTestFixtureFactory ideaFixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
testFixture = ideaFixtureFactory.createBareFixture();
testFixture.setUp();
application = ApplicationManager.getApplication();
underTest = GuiActionRunner.execute(SettingsPanel::new);
window = Containers.showInFrame(underTest.getComponent());
}
示例3: enablePlugins
import com.intellij.openapi.application.ApplicationManager; //导入方法依赖的package包/类
private void enablePlugins() {
notEnabledPlugins.stream().forEach(id -> {
PluginManager.enablePlugin(id.getIdString());
});
final ApplicationEx app = (ApplicationEx) ApplicationManager.getApplication();
app.restart(true);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:8,代码来源:CheckRequiredPluginsStep.java
示例4: generateFromStudentCourse
import com.intellij.openapi.application.ApplicationManager; //导入方法依赖的package包/类
public static void generateFromStudentCourse(Project project, Course course) {
StudyTaskManager.getInstance(project).setCourse(course);
course.setCourseMode(CCUtils.COURSE_MODE);
final VirtualFile baseDir = project.getBaseDir();
final Application application = ApplicationManager.getApplication();
application.invokeAndWait(() -> application.runWriteAction(() -> {
final VirtualFile[] children = baseDir.getChildren();
for (VirtualFile child : children) {
StudyUtils.deleteFile(child);
}
StudyGenerator.createCourse(course, baseDir);
}));
baseDir.refresh(false, true);
int index = 1;
int taskIndex = 1;
for (Lesson lesson : course.getLessons()) {
final VirtualFile lessonDir = project.getBaseDir().findChild(EduNames.LESSON + String.valueOf(index));
lesson.setIndex(index);
if (lessonDir == null) continue;
for (Task task : lesson.getTaskList()) {
final VirtualFile taskDir = lessonDir.findChild(EduNames.TASK + String.valueOf(taskIndex));
task.setIndex(taskIndex);
task.setLesson(lesson);
if (taskDir == null) continue;
for (final Map.Entry<String, TaskFile> entry : task.getTaskFiles().entrySet()) {
application.invokeAndWait(() -> application.runWriteAction(() -> createAnswerFile(project, taskDir, entry)));
}
taskIndex += 1;
}
index += 1;
taskIndex = 1;
}
course.initCourse(true);
application.invokeAndWait(() -> StudyUtils.registerStudyToolWindow(course, project));
synchronize(project);
}
示例5: handle
import com.intellij.openapi.application.ApplicationManager; //导入方法依赖的package包/类
@Override
protected Response handle(Request request) {
Project project = findProject(request.file);
if (project == null) {
throw new RuntimeException("Cannot find the target project");
}
Application application = ApplicationManager.getApplication();
Response response = new Response();
application.runReadAction(
() -> {
PsiFile psiFile =
PsiFileFactory.getInstance(project)
.createFileFromText(JavaLanguage.INSTANCE, request.text);
if (!(psiFile instanceof PsiJavaFile)) {
throw new RuntimeException("Cannot parse as Java file");
}
PsiJavaFile psiJavaFile = (PsiJavaFile) psiFile;
Set<String> processed = new HashSet<>();
for (PsiClass psiClass : psiJavaFile.getClasses()) {
psiClass.accept(
new JavaRecursiveElementWalkingVisitor() {
@Override
public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
try {
if (reference.getQualifier() != null) {
return;
}
String name = reference.getReferenceName();
if (processed.contains(name)) {
return;
}
processed.add(name);
Set<String> candidates = new HashSet<>();
for (PsiClass t : new ImportClassFix(reference).getClassesToImport()) {
candidates.add(String.format("import %s;", t.getQualifiedName()));
}
if (!candidates.isEmpty()) {
response.choices.add(candidates.stream().sorted().collect(toList()));
}
} finally {
super.visitReferenceElement(reference);
}
}
});
}
});
return response;
}