Java 类com.intellij.openapi.project.ProjectManager 实例源码

项目:SmartQQ4IntelliJ    文件:IMWindowFactory.java   
public File getWorkDir() {
    Project p = this.project;
    if (p == null) {
        p = ProjectManager.getInstance().getDefaultProject();
        Project[] ps = ProjectManager.getInstance().getOpenProjects();
        if (ps != null) {
            for (Project t : ps) {
                if (!t.isDefault()) {
                    p = t;
                }
            }
        }
    }
    File dir = new File(p.getBasePath(), Project.DIRECTORY_STORE_FOLDER);
    return dir;
}
项目:Gherkin-TS-Runner    文件:MainComponent.java   
@Override
public void initComponent() {
    MessageBus bus = ApplicationManager.getApplication().getMessageBus();
    connection = bus.connect();

    ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerListener() {
        @Override
        public void projectOpened(Project project) {
            Config config = Config.getInstance(project);

            if(config == null) {
                return;
            }

            if(!config.isConfigFilled()) {
                Notifications.Bus.notify(
                        new Notification("Settings Error", "Gherkin TS Runner", "Settings have to be filled.", NotificationType.WARNING)
                );
                return;
            }

            connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new GherkinFileEditorManagerListener(project));
        }
    });

}
项目:hybris-integration-intellij-idea-plugin    文件:HybrisAntBuildListener.java   
private void findAntResult(final Map<Project, AntGenResult> resultMap) {
    for (Project project : ProjectManager.getInstance().getOpenProjects()) {
        final HybrisProjectSettings hybrisProjectSettings =
            HybrisProjectSettingsComponent.getInstance(project).getState();

        if (!hybrisProjectSettings.isHybrisProject()) {
            continue;
        }

        final File file = new File(project.getBasePath() + "/" + hybrisProjectSettings.getHybrisDirectory() + "/temp/ant.ser");
        if (file.exists()) {
            AntGenResult result = null;
            try (
                final FileInputStream fileIn = new FileInputStream(file);
                final ObjectInputStream in = new ObjectInputStream(fileIn)
            ) {
                result = (AntGenResult) in.readObject();
            } catch (IOException | ClassNotFoundException e) {
                e.printStackTrace();
            }
            FileUtil.delete(file);
            resultMap.put(project, result);
            return;
        }
    }
}
项目:hybris-integration-intellij-idea-plugin    文件:HybrisAntBuildListener.java   
private void triggerNextAction() {
    for (Project project : ProjectManager.getInstance().getOpenProjects()) {
        final STATES state = project.getUserData(STATE);
        if (state == null) {
            continue;
        }
        switch (state) {
            case CLEAN_ALL_NEEDED:
                project.putUserData(STATE, STATES.REFRESH_NEEDED);
                triggerCleanAll(project);
                return;
            case REFRESH_NEEDED:
                project.putUserData(STATE, null);
                ProjectRefreshAction.triggerAction(getDataContext(project));
                return;
        }
    }
}
项目:educational-plugin    文件:PyStudyDirectoryProjectGenerator.java   
@Nullable
@Override
public BooleanFunction<PythonProjectGenerator> beforeProjectGenerated(@Nullable Sdk sdk) {
  return generator -> {
    final List<Integer> enrolledCoursesIds = myGenerator.getEnrolledCoursesIds();
    final Course course = myGenerator.getSelectedCourse();
    if (course == null || !(course instanceof RemoteCourse)) return true;
    if (((RemoteCourse)course).getId() > 0 && !enrolledCoursesIds.contains(((RemoteCourse)course).getId())) {
      ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
        ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
        return StudyUtils.execCancelable(() -> EduStepicConnector.enrollToCourse(((RemoteCourse)course).getId(),
                                                                                 StudySettings.getInstance().getUser()));
      }, "Creating Course", true, ProjectManager.getInstance().getDefaultProject());
    }
    return true;
  };
}
项目:educational-plugin    文件:EduBuiltInServerUtils.java   
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;
}
项目:educational-plugin    文件:EduCreateNewStepikProjectDialog.java   
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)
  );
}
项目:educational-plugin    文件:StudyNewProjectPanel.java   
private void initCoursesCombobox() {
  myAvailableCourses =
    myGenerator.getCoursesUnderProgress(!isLocal, "Getting Available Courses", ProjectManager.getInstance().getDefaultProject());
  if (myAvailableCourses.contains(Course.INVALID_COURSE)) {
    setError(CONNECTION_ERROR);
  }
  else {
    addCoursesToCombobox(myAvailableCourses);
    final Course selectedCourse = StudyUtils.getFirst(myAvailableCourses);
    if (selectedCourse == null) return;
    setAuthors(selectedCourse);
    myDescriptionPane.setText(selectedCourse.getDescription());
    myDescriptionPane.setEditable(false);
    //setting the first course in list as selected
    myGenerator.setSelectedCourse(selectedCourse);
    if (myGenerator.getSelectedCourse() != null) {
      myCoursesComboBox.setSelectedItem(myGenerator.getSelectedCourse());
    }
    if (selectedCourse.isAdaptive() && !myGenerator.isLoggedIn()) {
      setError(LOGIN_TO_STEPIC_MESSAGE);
    }
    else {
      setOK();
    }
  }
}
项目:branch-window-title    文件:BranchNameFrameTitleBuilder.java   
/**
 * Look through all open projects and see if git head symlink file is contained in it.
 */
private Project getProjectForFile(VirtualFile gitHeadFile) {
  //
  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    try {
      VirtualFile[] contentRootArray = ProjectRootManager.getInstance(project).getContentRoots();
      for (VirtualFile virtualFile : contentRootArray) {
        String expectedLoc = virtualFile.getCanonicalPath() + "/.git/HEAD";
        if (expectedLoc.equals(gitHeadFile.getCanonicalPath())) {
          return project;
        }
      }
    } catch (Exception e) {
      // ignore
    }
  }
  return null;
}
项目:android-studio-plugin    文件:FileChangeListener.java   
public void after(List<? extends VFileEvent> events) {
    String sources = Utils.getPropertyValue("sources", true);
    List<String> sourcesList = Utils.getSourcesList(sources);
    for (VFileEvent e : events) {
        VirtualFile virtualFile = e.getFile();
        if (virtualFile != null && sourcesList.contains(virtualFile.getName()) && SOURCE_FOLDER_DEFAULT.equals(virtualFile.getParent().getName())) {
            Project[] projects = ProjectManager.getInstance().getOpenProjects();
            Project project = null;
            if (projects.length == 1) {
                project = projects[0];
            }
            System.out.println("Changed file " + virtualFile.getCanonicalPath());
            Crowdin crowdin = new Crowdin();
            String branch = Utils.getCurrentBranch(project);
            crowdin.uploadFile(virtualFile, branch);
        }
    }
}
项目:intellij-ce-playground    文件:PyStudyIntroductionCourseAction.java   
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  final File projectDir = new File(ProjectUtil.getBaseDir(), INTRODUCTION_FOLDER);
  if (projectDir.exists()) {
    ProjectUtil.openProject(projectDir.getPath(), null, false);
  }
  else {
    final PyStudyDirectoryProjectGenerator generator = new PyStudyDirectoryProjectGenerator();
    CourseInfo introCourse = getIntroCourseInfo(generator.getCourses());
    if (introCourse == null) {
      return;
    }
    final GenerateProjectCallback callback = new GenerateProjectCallback();
    final ProjectSpecificSettingsStep step = new ProjectSpecificSettingsStep(generator, callback);
    step.createPanel(); // initialize panel to set location
    step.setLocation(projectDir.toString());
    generator.setSelectedCourse(introCourse);

    final Project project = ProjectManager.getInstance().getDefaultProject();
    final List<Sdk> sdks = PyConfigurableInterpreterList.getInstance(project).getAllPythonSdks();
    Sdk sdk = sdks.isEmpty() ? null : sdks.iterator().next();
    step.setSdk(sdk);
    callback.consume(step);
  }
}
项目:intellij-ce-playground    文件:BuildoutFacet.java   
@NotNull
public static List<VirtualFile> getExtraPathForAllOpenModules() {
  final List<VirtualFile> results = new ArrayList<VirtualFile>();
  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    for (Module module : ModuleManager.getInstance(project).getModules()) {
      final BuildoutFacet buildoutFacet = getInstance(module);
      if (buildoutFacet != null) {
        for (String path : buildoutFacet.getConfiguration().getPaths()) {
          final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
          if (file != null) {
            results.add(file);
          }
        }
      }
    }
  }
  return results;
}
项目:intellij-ce-playground    文件:ShowSettingsAction.java   
public void actionPerformed(@NotNull AnActionEvent e) {
  Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
  if (project == null) {
    project = ProjectManager.getInstance().getDefaultProject();
  }

  final long startTime = System.nanoTime();
  SwingUtilities.invokeLater(new Runnable() {
    public void run() {
      final long endTime = System.nanoTime();
      if (ApplicationManagerEx.getApplicationEx().isInternal()) {
        System.out.println("Displaying settings dialog took " + ((endTime - startTime) / 1000000) + " ms");
      }
    }
  });
  ShowSettingsUtil.getInstance().showSettingsDialog(project, ShowSettingsUtilImpl.getConfigurableGroups(project, true));
}
项目:intellij-ce-playground    文件:LafManagerImpl.java   
public static void updateToolWindows() {
  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    for (String id : toolWindowManager.getToolWindowIds()) {
      final ToolWindow toolWindow = toolWindowManager.getToolWindow(id);
      for (Content content : toolWindow.getContentManager().getContents()) {
        final JComponent component = content.getComponent();
        if (component != null) {
          IJSwingUtilities.updateComponentTreeUI(component);
        }
      }
      final JComponent c = toolWindow.getComponent();
      if (c != null) {
        IJSwingUtilities.updateComponentTreeUI(c);
      }
    }
  }
}
项目:intellij-ce-playground    文件:DependencyInspection.java   
@Override
public JComponent createOptionsPanel() {
  final JButton editDependencies = new JButton(InspectionsBundle.message("inspection.dependency.configure.button.text"));
  editDependencies.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(editDependencies));
      if (project == null) project = ProjectManager.getInstance().getDefaultProject();
      ShowSettingsUtil.getInstance().editConfigurable(editDependencies, new DependencyConfigurable(project));
    }
  });

  JPanel depPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
  depPanel.add(editDependencies);
  return depPanel;
}
项目:intellij-ce-playground    文件:SingleInspectionProfilePanelTest.java   
public void testSettingsModification() throws Exception {
  Project project = ProjectManager.getInstance().getDefaultProject();
  InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
  InspectionProfileImpl profile = (InspectionProfileImpl)profileManager.getProfile(PROFILE);
  profile.initInspectionTools(project);

  InspectionProfileImpl model = (InspectionProfileImpl)profile.getModifiableModel();
  SingleInspectionProfilePanel panel = new SingleInspectionProfilePanel(profileManager, PROFILE, model, profile);
  panel.setVisible(true);
  panel.reset();

  JavaDocLocalInspection tool = getInspection(model);
  assertEquals("", tool.myAdditionalJavadocTags);
  tool.myAdditionalJavadocTags = "foo";
  model.setModified(true);
  panel.apply();
  assertEquals(1, InspectionProfileTest.countInitializedTools(model));

  assertEquals("foo", getInspection(profile).myAdditionalJavadocTags);
  panel.disposeUI();
}
项目:intellij-ce-playground    文件:CommandLineProcessor.java   
@Nullable
private static Project doOpenFile(VirtualFile virtualFile, int line) {
  final Project[] projects = ProjectManager.getInstance().getOpenProjects();
  if (projects.length == 0) {
    final PlatformProjectOpenProcessor processor = PlatformProjectOpenProcessor.getInstanceIfItExists();
    if (processor != null) {
      return PlatformProjectOpenProcessor.doOpenProject(virtualFile, null, false, line, null, false);
    }
    Messages.showErrorDialog("No project found to open file in", "Cannot open file");
    return null;
  }
  else {
    Project project = findBestProject(virtualFile, projects);
    if (line == -1) {
      new OpenFileDescriptor(project, virtualFile).navigate(true);
    }
    else {
      new OpenFileDescriptor(project, virtualFile, line-1, 0).navigate(true);
    }
    return project;
  }
}
项目:intellij-ce-playground    文件:IdeaModifiableModelsProvider.java   
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel() {
  final Project[] projects = ProjectManager.getInstance().getOpenProjects();
  for (Project project : projects) {
    if (!project.isInitialized()) {
      continue;
    }
    StructureConfigurableContext context = getProjectStructureContext(project);
    LibraryTableModifiableModelProvider provider = context != null ? context.createModifiableModelProvider(LibraryTablesRegistrar.APPLICATION_LEVEL) : null;
    final LibraryTable.ModifiableModel modifiableModel = provider != null ? provider.getModifiableModel() : null;
    if (modifiableModel != null) {
      return modifiableModel;
    }
  }
  return LibraryTablesRegistrar.getInstance().getLibraryTable().getModifiableModel();
}
项目:intellij-ce-playground    文件:GradleProjectImporter.java   
/**
 * Imports the given Gradle project.
 *
 * @param selectedFile the selected build.gradle or the project's root directory.
 */
public void importProject(@NotNull VirtualFile selectedFile) {
  VirtualFile projectDir = selectedFile.isDirectory() ? selectedFile : selectedFile.getParent();
  File projectDirPath = virtualToIoFile(projectDir);

  // Sync Android SDKs paths *before* importing project. Studio will freeze if the project has a local.properties file pointing to a SDK
  // path that does not exist. The cause is that having 2 dialogs: one modal (the "Project Import" one) and another from
  // Messages.showErrorDialog (indicating the Android SDK path does not exist) produce a deadlock.
  try {
    LocalProperties localProperties = new LocalProperties(projectDirPath);
    if (isAndroidStudio()) {
      syncIdeAndProjectAndroidSdks(localProperties);
    }
  }
  catch (IOException e) {
    LOG.info("Failed to sync SDKs", e);
    showErrorDialog(e.getMessage(), "Project Import");
    return;
  }

  // Set up Gradle settings. Otherwise we get an "already disposed project" error.
  new GradleSettings(ProjectManager.getInstance().getDefaultProject());
  createProjectFileForGradleProject(selectedFile, null);
}
项目:intellij-ce-playground    文件:PerFileMappingsBase.java   
private void handleMappingChange(Collection<VirtualFile> files, Collection<VirtualFile> oldFiles, boolean includeOpenFiles) {
  Project project = getProject();
  FilePropertyPusher<T> pusher = getFilePropertyPusher();
  if (project != null && pusher != null) {
    for (VirtualFile oldFile : oldFiles) {
      if (oldFile == null) continue; // project
      oldFile.putUserData(pusher.getFileDataKey(), null);
    }
    if (!project.isDefault()) {
      PushedFilePropertiesUpdater.getInstance(project).pushAll(pusher);
    }
  }
  if (shouldReparseFiles()) {
    Project[] projects = project == null ? ProjectManager.getInstance().getOpenProjects() : new Project[] { project };
    for (Project p : projects) {
      PsiDocumentManager.getInstance(p).reparseFiles(files, includeOpenFiles);
    }
  }
}
项目:intellij-ce-playground    文件:PopupUtil.java   
public static void showBalloonForActiveFrame(@NotNull final String message, final MessageType type) {
  final Runnable runnable = new Runnable() {
    public void run() {
      final IdeFrame frame = IdeFocusManager.findInstance().getLastFocusedFrame();
      if (frame == null) {
        final Project[] projects = ProjectManager.getInstance().getOpenProjects();
        final Project project = projects == null || projects.length == 0 ? ProjectManager.getInstance().getDefaultProject() : projects[0];
        final JFrame jFrame = WindowManager.getInstance().getFrame(project);
        if (jFrame != null) {
          showBalloonForComponent(jFrame, message, type, true, project);
        } else {
          LOG.info("Can not get component to show message: " + message);
        }
        return;
      }
      showBalloonForComponent(frame.getComponent(), message, type, true, frame.getProject());
    }
  };
  UIUtil.invokeLaterIfNeeded(runnable);
}
项目:intellij-ce-playground    文件:JBProtocolCheckoutCommand.java   
@Override
public void perform(String vcsId, Map<String, String> parameters) {
  String repository = parameters.get(REPOSITORY_NAME_KEY);

  if (StringUtil.isEmpty(repository)) {
    return;
  }

  for (CheckoutProvider provider : CheckoutProvider.EXTENSION_POINT_NAME.getExtensions()) {
    if (provider instanceof CheckoutProviderEx) {
      CheckoutProviderEx providerEx = (CheckoutProviderEx)provider;
      if (providerEx.getVcsId().equals(vcsId)) {
        Project project = ProjectManager.getInstance().getDefaultProject();
        CheckoutProvider.Listener listener = ProjectLevelVcsManager.getInstance(project).getCompositeCheckoutListener();
        providerEx.doCheckout(project, listener, repository);
        break;
      }
    }
  }
}
项目:intellij-ce-playground    文件:GitInit.java   
@Override
public void actionPerformed(final AnActionEvent e) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    project = ProjectManager.getInstance().getDefaultProject();
  }
  FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  fcd.setShowFileSystemRoots(true);
  fcd.setTitle(GitBundle.getString("init.destination.directory.title"));
  fcd.setDescription(GitBundle.getString("init.destination.directory.description"));
  fcd.setHideIgnored(false);
  VirtualFile baseDir = e.getData(CommonDataKeys.VIRTUAL_FILE);
  if (baseDir == null) {
    baseDir = project.getBaseDir();
  }
  doInit(project, fcd, baseDir, baseDir);
}
项目:intellij-ce-playground    文件:ExternalSystemFacadeManager.java   
/**
 * @return gradle api facade to use
 * @throws Exception    in case of inability to return the facade
 */
@NotNull
public RemoteExternalSystemFacade getFacade(@Nullable Project project,
                                            @NotNull String externalProjectPath,
                                            @NotNull ProjectSystemId externalSystemId) throws Exception
{
  if (project == null) {
    project = ProjectManager.getInstance().getDefaultProject();
  }
  IntegrationKey key = new IntegrationKey(project, externalSystemId, externalProjectPath);
  final RemoteExternalSystemFacade facade = myFacadeWrappers.get(key);
  if (facade == null) {
    final RemoteExternalSystemFacade newFacade = (RemoteExternalSystemFacade)Proxy.newProxyInstance(
      ExternalSystemFacadeManager.class.getClassLoader(), new Class[]{RemoteExternalSystemFacade.class, Consumer.class},
      new MyHandler(key)
    );
    myFacadeWrappers.putIfAbsent(key, newFacade);
  }
  return myFacadeWrappers.get(key);
}
项目:intellij-ce-playground    文件:AndroidGradleProjectResolver.java   
@Nullable
private Project findProject() {
  String projectDir = resolverCtx.getProjectPath();
  if (isNotEmpty(projectDir)) {
    File projectDirPath = new File(toSystemDependentName(projectDir));
    Project[] projects = ProjectManager.getInstance().getOpenProjects();
    for (Project project : projects) {
      String basePath = project.getBasePath();
      if (basePath != null) {
        File currentPath = new File(basePath);
        if (filesEqual(projectDirPath, currentPath)) {
          return project;
        }
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:WelcomeFrame.java   
static void setupCloseAction(final JFrame frame) {
  frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
  frame.addWindowListener(
    new WindowAdapter() {
      public void windowClosing(final WindowEvent e) {
        frame.dispose();

        final Application app = ApplicationManager.getApplication();
        app.invokeLater(new DumbAwareRunnable() {
          public void run() {
            if (app.isDisposed()) {
              ApplicationManagerEx.getApplicationEx().exit();
              return;
            }

            final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
            if (openProjects.length == 0) {
              ApplicationManagerEx.getApplicationEx().exit();
            }
          }
        }, ModalityState.NON_MODAL);
      }
    }
  );
}
项目:intellij-ce-playground    文件:ApplicationImpl.java   
private boolean canExit() {
  for (ApplicationListener applicationListener : myDispatcher.getListeners()) {
    if (!applicationListener.canExitApplication()) {
      return false;
    }
  }

  ProjectManagerEx projectManager = (ProjectManagerEx)ProjectManager.getInstance();
  Project[] projects = projectManager.getOpenProjects();
  for (Project project : projects) {
    if (!projectManager.canClose(project)) {
      return false;
    }
  }

  return true;
}
项目:intellij-ce-playground    文件:InspectionProfileManagerImpl.java   
public static void onProfilesChanged() {
  //cleanup caches blindly for all projects in case ide profile was modified
  for (final Project project : ProjectManager.getInstance().getOpenProjects()) {
    //noinspection EmptySynchronizedStatement
    synchronized (HighlightingSettingsPerFile.getInstance(project)) {
    }

    UIUtil.invokeLaterIfNeeded(new Runnable() {
      @Override
      public void run() {
        if (!project.isDisposed()) {
          DaemonListeners.getInstance(project).updateStatusBar();
        }
      }
    });
  }
}
项目:intellij-ce-playground    文件:RefreshProgress.java   
private void updateIndicators(final boolean start) {
  // wrapping in invokeLater here reduces the number of events posted to EDT in case of multiple IDE frames
  UIUtil.invokeLaterIfNeeded(new Runnable() {
    public void run() {
      if (ApplicationManager.getApplication().isDisposed()) return;

      WindowManager windowManager = WindowManager.getInstance();
      if (windowManager == null) return;

      Project[] projects = ProjectManager.getInstance().getOpenProjects();
      if (projects.length == 0) projects = NULL_ARRAY;
      for (Project project : projects) {
        StatusBarEx statusBar = (StatusBarEx)windowManager.getStatusBar(project);
        if (statusBar != null) {
          if (start) {
            statusBar.startRefreshIndication(myMessage);
          }
          else {
            statusBar.stopRefreshIndication();
          }
        }
      }
    }
  });
}
项目:intellij-ce-playground    文件:EditorFactoryImpl.java   
public EditorFactoryImpl(ProjectManager projectManager) {
  projectManager.addProjectManagerListener(new ProjectManagerAdapter() {
    @Override
    public void projectOpened(final Project project) {
      // validate all editors are disposed after fireProjectClosed() was called, because it's the place where editor should be released
      Disposer.register(project, new Disposable() {
        @Override
        public void dispose() {
          final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
          final boolean isLastProjectClosed = openProjects.length == 0;
          validateEditorsAreReleased(project, isLastProjectClosed);
        }
      });
    }
  });
}
项目:SmartQQ4IntelliJ    文件:VFSUtils.java   
public static Project[] getOpenProjects() {
    Project[] openProjects = null;
    if (openProjects == null) {
        openProjects = ProjectManager.getInstance().getOpenProjects();
    }
    return openProjects;
}
项目:intellij-postfix-templates    文件:CustomPostfixTemplateProvider.java   
/**
 * Loads the postfix templates from the given virtual file and returns them.
 *
 * @param vFile virtual templates file
 * @return set of postfix templates
 */
@SuppressWarnings("WeakerAccess")
public Set<PostfixTemplate> loadTemplatesFrom(@NotNull VirtualFile vFile) {
    Set<PostfixTemplate> templates = new OrderedSet<>();

    ApplicationManager.getApplication().runReadAction(() -> {
        Project project = ProjectManager.getInstance().getOpenProjects()[0];

        CptFile cptFile = (CptFile) PsiManager.getInstance(project).findFile(vFile);
        if (cptFile != null) {
            CptTemplate[] cptTemplates = PsiTreeUtil.getChildrenOfType(cptFile, CptTemplate.class);
            if (cptTemplates != null) {
                for (CptTemplate cptTemplate : cptTemplates) {
                    for (CptMapping mapping : cptTemplate.getMappings().getMappingList()) {
                        StringBuilder sb = new StringBuilder();
                        for (PsiElement element : mapping.getReplacement().getChildren()) {
                            sb.append(element.getText());
                        }

                        templates.add(createTemplate(mapping.getMatchingClass(), mapping.getConditionClass(), cptTemplate.getTemplateName(), cptTemplate.getTemplateDescription(), sb.toString()));
                    }
                }
            }
        }
    });

    return combineTemplatesWithSameName(templates);
}
项目:hybris-integration-intellij-idea-plugin    文件:PermissionToSendStatisticsDialog.java   
@Override
public void doCancelAction() {
    super.doCancelAction();
    ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> {
        LOG.error("User chose to close the project.");
        ProjectManager.getInstance().closeProject(myProject);
    }));

}
项目:hybris-integration-intellij-idea-plugin    文件:HybrisProjectApplicationComponent.java   
@Override
public void initComponent() {
    disposable = Disposer.newDisposable();
    Disposer.register(disposable, projectManagerListener);

    ApplicationManager.getApplication().getMessageBus().connect(disposable).subscribe(
        ProjectManager.TOPIC,
        projectManagerListener
    );
}
项目:educational-plugin    文件:PyStudyDirectoryProjectGenerator.java   
@Nullable
@Override
public LabeledComponent<JComponent> getLanguageSettingsComponent(@NotNull Course selectedCourse) {
  final Project project = ProjectManager.getInstance().getDefaultProject();
  PyConfigurableInterpreterList instance = PyConfigurableInterpreterList.getInstance(project);
  if (instance == null) {
    return null;
  }
  final List<Sdk> sdks = instance.getAllPythonSdks();
  VirtualEnvProjectFilter.removeAllAssociated(sdks);
  // by default we create new virtual env in project, we need to add this non-existing sdk to sdk list
  ProjectJdkImpl fakeSdk = createFakeSdk(selectedCourse);
  if (fakeSdk != null) {
    sdks.add(0, fakeSdk);
  }
  PythonSdkChooserCombo combo = new PythonSdkChooserCombo(project, sdks, sdk -> true);
  if (fakeSdk != null) {
    patchRenderer(fakeSdk, combo);
    combo.getComboBox().setSelectedItem(fakeSdk);
  }
  if (SystemInfo.isMac && !UIUtil.isUnderDarcula()) {
    combo.putClientProperty("JButton.buttonType", null);
  }
  combo.setButtonIcon(PythonIcons.Python.InterpreterGear);
  combo.addChangedListener(e -> {
    Sdk selectedSdk = (Sdk)combo.getComboBox().getSelectedItem();
    mySettings.setSdk(selectedSdk == fakeSdk ? null : selectedSdk);
  });
  return LabeledComponent.create(combo, "Interpreter", BorderLayout.WEST);
}
项目:educational-plugin    文件:EduIntellijCourseProjectGeneratorBase.java   
@Override
public boolean beforeProjectGenerated() {
  if (myCourse == null || !(myCourse instanceof RemoteCourse)) return true;
  if (((RemoteCourse)myCourse).getId() > 0) {
    ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
      ProgressManager.getInstance().getProgressIndicator().setIndeterminate(true);
      return StudyUtils.execCancelable(() -> EduStepicConnector.enrollToCourse(((RemoteCourse)myCourse).getId(),
              StudySettings.getInstance().getUser()));
    }, "Creating Course", true, ProjectManager.getInstance().getDefaultProject());
  }
  return true;
}
项目:educational-plugin    文件:EduIntellijCourseProjectGeneratorBase.java   
@Nullable
@Override
public LabeledComponent<JComponent> getLanguageSettingsComponent(@NotNull Course selectedCourse) {
  myModel = ProjectStructureConfigurable.getInstance(ProjectManager.getInstance().getDefaultProject()).getProjectJdksModel();
  myJdkComboBox = new JdkComboBox(myModel, sdkTypeId -> sdkTypeId instanceof JavaSdkType && !((JavaSdkType)sdkTypeId).isDependent(), sdk -> true, sdkTypeId -> sdkTypeId instanceof JavaSdkType && !((JavaSdkType)sdkTypeId).isDependent(), true);
  ComboboxWithBrowseButton comboboxWithBrowseButton = new ComboboxWithBrowseButton(myJdkComboBox);
  FixedSizeButton setupButton = comboboxWithBrowseButton.getButton();
  myJdkComboBox.setSetupButton(setupButton, null, myModel, (JdkComboBox.JdkComboBoxItem) myJdkComboBox.getModel().getSelectedItem(), null, false);
  return LabeledComponent.create(comboboxWithBrowseButton, "Jdk", BorderLayout.WEST);
}
项目:educational-plugin    文件:EduCreateNewProjectDialog.java   
public EduCreateNewProjectDialog() {
  super(false);
  setTitle("New Project");
  Project defaultProject = ProjectManager.getInstance().getDefaultProject();
  myPanel = new EduCreateNewProjectPanel(defaultProject, this);
  setOKButtonText("Create");
  init();
}
项目:educational-plugin    文件:KotlinStudyOptionsProvider.java   
KotlinStudyOptionsProvider() {
  Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
  for (Project project : openProjects) {
    if (StudyTaskManager.getInstance(project).getCourse() != null) {
      StudyTwitterPluginConfigurator twitterConfigurator = StudyUtils.getTwitterConfigurator(project);
      if (twitterConfigurator != null) {
        twitterSettings = KotlinStudyTwitterSettings.getInstance(project);
        myAskToTweetCheckBox.setSelected(twitterSettings.askToTweet());
        break;
      }
    }
  }
  myAskToTweetCheckBox.addActionListener(e -> myIsModified = true);
}
项目:GravSupport    文件:GravProjectComponent.java   
/**
 * Returns the current project fr which the plugin is enabled from all opened projects of the IDE
 *
 * @return current opened project or null, if none exists or plugin is not enabled
 */
@Nullable
public static Project getEnabledProject() {
    for (Project each : ProjectManager.getInstance().getOpenProjects()) {
        if (GravProjectComponent.isEnabled(each)) {
            return each;
        }
    }
    return null;
}