当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationManager类代码示例

本文整理汇总了Java中com.intellij.openapi.application.ApplicationManager的典型用法代码示例。如果您正苦于以下问题:Java ApplicationManager类的具体用法?Java ApplicationManager怎么用?Java ApplicationManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ApplicationManager类属于com.intellij.openapi.application包,在下文中一共展示了ApplicationManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: smartInvokeAndWait

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
public static void smartInvokeAndWait(final Project p, final ModalityState state, final Runnable r) {
    if (isNoBackgroundMode() || ApplicationManager.getApplication().isDispatchThread()) {
        r.run();
    } else {
        final Semaphore semaphore = new Semaphore();
        semaphore.down();
        DumbService.getInstance(p).smartInvokeLater(() -> {
            try {
                r.run();
            } finally {
                semaphore.up();
            }
        }, state);
        semaphore.waitFor();
    }
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:17,代码来源:NavigatorUtil.java

示例2: doAction

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
@Override
public void doAction(AnActionEvent anActionEvent) {
    terminal.createNewSession();

    new Thread(() -> {
        try {
            // Wait 0.5 second for the terminal to show up, no wait works ok on WebStorm but not on Android Studio
            Thread.currentThread().sleep(500L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // Below code without ApplicationManager.getApplication().invokeLater() will throw exception
        // : IDEA Access is allowed from event dispatch thread only.
        ApplicationManager.getApplication().invokeLater(() -> {
            terminal.executeShell(command());
        });
    }).start();
}
 
开发者ID:beansoftapp,项目名称:react-native-console,代码行数:19,代码来源:ReactNativeTerminal.java

示例3: EduCreateNewStepikProjectDialog

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
public EduCreateNewStepikProjectDialog(int courseId) {
  this();

  StepicUser user = EduStepicAuthorizedClient.getCurrentUser();
  Project defaultProject = ProjectManager.getInstance().getDefaultProject();
  ApplicationManager.getApplication().invokeAndWait(() ->
    ProgressManager.getInstance()
      .runProcessWithProgressSynchronously(() -> {
        ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
        execCancelable(() -> {
          try {
            Course course = EduStepicConnector.getCourseFromStepik(user, courseId);
            if (course != null) {
              setTitle("New Project - " + course.getName());
            }

            setCourse(course);
          }
          catch (IOException e) {
            LOG.warn("Tried to create a project for course with id=" + courseId, e);
          }
          return null;
        });
      }, "Getting Available Courses", true, defaultProject)
  );
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:27,代码来源:EduCreateNewStepikProjectDialog.java

示例4: isAccepted

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
@Override
public boolean isAccepted(PsiClass klass) {
    return ApplicationManager.getApplication().runReadAction((Computable<Boolean>) () -> {
        if (isSketchClass(klass)) {
            final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(project);
            final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(klass);

            if (virtualFile == null) {
                return false;
            }

            return ! compilerConfiguration.isExcludedFromCompilation(virtualFile) &&
                    ! ProjectRootManager.getInstance(project)
                            .getFileIndex()
                            .isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.RESOURCES);
        }

        return false;
    });
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:21,代码来源:SketchClassFilter.java

示例5: transformFiles

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
private static void transformFiles(Course course, Project project) {
  List<VirtualFile> files = getAllAnswerTaskFiles(course, project);
  for (VirtualFile answerFile : files) {
    ApplicationManager.getApplication().runWriteAction(() -> {
      String answerName = answerFile.getName();
      String nameWithoutExtension = FileUtil.getNameWithoutExtension(answerName);
      String name = FileUtil.getNameWithoutExtension(nameWithoutExtension) + "." + FileUtilRt.getExtension(answerName);
      VirtualFile parent = answerFile.getParent();
      VirtualFile file = parent.findChild(name);
      try {
        if (file != null) {
          file.delete(CCProjectComponent.class);
        }
        VirtualFile windowsDescrFile = parent.findChild(FileUtil.getNameWithoutExtension(name) + EduNames.WINDOWS_POSTFIX);
        if (windowsDescrFile != null) {
          windowsDescrFile.delete(CCProjectComponent.class);
        }
        answerFile.rename(CCProjectComponent.class, name);
      }
      catch (IOException e) {
        LOG.error(e);
      }
    });
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:26,代码来源:CCProjectComponent.java

示例6: packCourse

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
private static void packCourse(@NotNull final VirtualFile baseDir, String locationDir, String zipName, boolean showMessage) {
  try {
    final File zipFile = new File(locationDir, zipName + ".zip");
    ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
    VirtualFile[] courseFiles = baseDir.getChildren();
    for (VirtualFile file : courseFiles) {
      ZipUtil.addFileOrDirRecursively(zos, null, new File(file.getPath()), file.getName(), null, null);
    }
    zos.close();
    if (showMessage) {
      ApplicationManager.getApplication().invokeLater(
        () -> Messages.showInfoMessage("Course archive was saved to " + zipFile.getPath(),
                                       "Course Archive Was Created Successfully"));

    }
  }
  catch (IOException e1) {
    LOG.error(e1);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:21,代码来源:CCCreateCourseArchive.java

示例7: run

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
@Override
public void run() {
    Bucklescript bucklescript = BucklescriptProjectComponent.getInstance(m_psiFile.getProject());
    BsQueryTypesServiceComponent.InferredTypes inferredTypes = bucklescript.queryTypes(m_psiFile.getVirtualFile());

    ApplicationManager.getApplication().runReadAction(() -> {
        for (PsiLet letStatement : m_letExpressions) {
            PsiElement letParent = letStatement.getParent();
            if (letParent instanceof RmlFile) {
                applyType(inferredTypes, letStatement);
            } else {
                PsiModule letModule = PsiTreeUtil.getParentOfType(letStatement, PsiModule.class);
                if (letModule != null && inferredTypes != null) {
                    BsQueryTypesServiceComponent.InferredTypes inferredModuleTypes = inferredTypes.getModuleType(letModule.getName());
                    if (inferredModuleTypes != null) {
                        applyType(inferredModuleTypes, letStatement);
                    }
                }
            }
        }
    });
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:23,代码来源:BscInferredTypesTask.java

示例8: run

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
@Override
public void run() {
    MerlinService merlin = ApplicationManager.getApplication().getComponent(MerlinService.class);
    if (merlin == null) {
        return;
    }

    String filename = m_psiFile.getVirtualFile().getCanonicalPath();

    // Update merlin buffer
    String source = m_psiFile.getText();

    int i = 0;
    for (PsiLet letStatement : m_letStatements) {
        LogicalPosition position = m_positions.get(i);
        if (position != null) {
            List<MerlinType> types = merlin.typeExpression(filename, source, new MerlinPosition(position));
            if (!types.isEmpty()) {
                // System.out.println(letStatement.getLetName().getText() + ": " + types.stream().map(merlinType -> merlinType.type).reduce("", (s, s2) -> s + s2.replaceAll("\n", "").replaceAll("\\s+", "") + ", "));
                // Display only the first one, might be wrong !?
                letStatement.setInferredType(types.get(0).type.replaceAll("\n", "").replaceAll("\\s+", " "));
            }
        }
        i++;
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:27,代码来源:MerlinQueryTypesTask.java

示例9: addCompletions

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
    MerlinService merlin = ApplicationManager.getApplication().getComponent(MerlinService.class);

    PsiFile originalFile = parameters.getOriginalFile();
    String text = originalFile.getText();
    LineNumbering lineNumbering = new LineNumbering(text);

    String suitablePrefix = findSuitablePrefix(parameters, text);

    MerlinPosition position = lineNumbering.offsetToPosition(parameters.getOffset());
    MerlinCompletion completion = merlin.completions(originalFile.getName(), text, position, suitablePrefix);

    for (MerlinCompletionEntry entry : completion.entries) {
        resultSet.addElement(LookupElementBuilder.
                create(entry.name).
                withIcon(getIcon(entry)).
                withTypeText(entry.desc));
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:21,代码来源:MerlinCompletionProvider.java

示例10: scanForModifiedClasses

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
public Map<String, HotSwapFile> scanForModifiedClasses( DebuggerSession session, HotSwapProgress progress )
{
  DebuggerManagerThreadImpl.assertIsManagerThread();

  Map<String, HotSwapFile> modifiedClasses = new HashMap<>();

  List<File> outputRoots = new ArrayList<>();
  ApplicationManager.getApplication().runReadAction(
    () -> {
       VirtualFile[] allDirs = OrderEnumerator.orderEntries( getIjProject() ).getAllSourceRoots();
       for( VirtualFile dir : allDirs )
       {
         outputRoots.add( new File( dir.getPath() ) );
       }
     } );
  long timeStamp = getTimeStamp( session );
  for( File root : outputRoots )
  {
    String rootPath = FileUtil.toCanonicalPath( root.getPath() );
    collectModifiedClasses( root, rootPath, modifiedClasses, progress, timeStamp );
  }
  setTimeStamp( session, System.currentTimeMillis() );
  return modifiedClasses;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:25,代码来源:HotSwapComponent.java

示例11: onProcessList

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
@Override
public void onProcessList(Set<LogProcess> processList) {
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final List<LogProcess> sortedList = new ArrayList<>(processList);
        sortedList.sort((l, r) -> {
            int c = l.getProcessName().compareTo(r.getProcessName());
            if (c == 0) {
                c = l.getProcessID() < r.getProcessID() ? -1 : 1;
            }
            return c;
        });
        UIUtil.invokeLaterIfNeeded(() -> {
            processListModel.removeAllElements();

            for (LogProcess client : sortedList) {
                processListModel.addElement(client);
            }
        });
    });

}
 
开发者ID:josesamuel,项目名称:logviewer,代码行数:22,代码来源:LogView.java

示例12: createAuthorizeListener

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
@NotNull
private HyperlinkAdapter createAuthorizeListener() {
  return new HyperlinkAdapter() {

    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      ApplicationManager.getApplication().getMessageBus().connect().subscribe(StudySettings.SETTINGS_CHANGED, () -> {
        StepicUser user = StudySettings.getInstance().getUser();
        if (user != null && !user.equals(myStepicUser)) {
          StudySettings.getInstance().setUser(myStepicUser);
          myStepicUser = user;
          updateLoginLabels(myStepicUser);
        }
      });

      EduStepicConnector.doAuthorize(() -> showDialog());
    }
  };
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:20,代码来源:StepicStudyOptions.java

示例13: createLessonContent

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
/**
 * Creates content (including its directory or module) of new lesson in project
 *
 * @param project Parameter is used in Java and Kotlin plugins
 * @param lesson  Lesson to create content for. It's already properly initialized and added to course.
 * @return PsiDirectory of created lesson
 */
default PsiDirectory createLessonContent(@NotNull Project project,
                                         @NotNull Lesson lesson,
                                         @Nullable IdeView view,
                                         @NotNull PsiDirectory parentDirectory) {
  final PsiDirectory[] lessonDirectory = new PsiDirectory[1];
  ApplicationManager.getApplication().runWriteAction(() -> {
    String lessonDirName = EduNames.LESSON + lesson.getIndex();
    lessonDirectory[0] = DirectoryUtil.createSubdirectories(lessonDirName, parentDirectory, "\\/");
  });
  if (lessonDirectory[0] != null) {
    if (view != null) {
      view.selectElement(lessonDirectory[0]);
    }
  }
  return lessonDirectory[0];
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:24,代码来源:EduPluginConfigurator.java

示例14: actionPerformed

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
    if (e.getProject() != null) {
        ScanManager scanManager = ScanManagerFactory.getScanManager(e.getProject());
        if (scanManager == null) {
            // Check if the project is supported now
            ScanManagerFactory scanManagerFactory = ServiceManager.getService(e.getProject(), ScanManagerFactory.class);
            scanManagerFactory.initScanManager(e.getProject());
            scanManager = ScanManagerFactory.getScanManager(e.getProject());
            if (scanManager == null) {
                return;
            }
            MessageBus messageBus = ApplicationManager.getApplication().getMessageBus();
            messageBus.syncPublisher(Events.ON_IDEA_FRAMEWORK_CHANGE).update();
        }
        scanManager.asyncScanAndUpdateResults(false);
    }
}
 
开发者ID:JFrogDev,项目名称:jfrog-idea-plugin,代码行数:19,代码来源:RefreshAction.java

示例15: focusOpenProject

import com.intellij.openapi.application.ApplicationManager; //导入依赖的package包/类
public static boolean focusOpenProject(int courseId, int stepId) {
  Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
  for (Project project : openProjects) {
    if (!project.isDefault()) {
      StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
      if (taskManager != null) {
        Course course = taskManager.getCourse();
        RemoteCourse remoteCourse = course instanceof RemoteCourse ? (RemoteCourse)course : null;
        if (remoteCourse != null && remoteCourse.getId() == courseId) {
          ApplicationManager.getApplication().invokeLater(() -> {
            requestFocus(project);
            navigateToStep(project, course, stepId);
          });
          return true;
        }
      }
    }
  }
  return false;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:21,代码来源:EduBuiltInServerUtils.java


注:本文中的com.intellij.openapi.application.ApplicationManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。