protected void runStartupActivities() { final StartupManagerImpl startupManager = (StartupManagerImpl) StartupManager.getInstance(myProject); startupManager.runStartupActivities(); startupManager.startCacheUpdate(); startupManager.runPostStartupActivities(); }
private void moveFocusToEditor() { StartupManager.getInstance(myProject) .runWhenProjectIsInitialized( new Runnable() { @Override public void run() { ToolWindowManager.getInstance(myProject) .getToolWindow(ToolWindowId.PROJECT_VIEW) .show( new Runnable() { @Override public void run() { FileEditor[] editors = FileEditorManager.getInstance(myProject).getSelectedEditors(); if (editors.length > 0) { final JComponent focusedComponent = editors[0].getPreferredFocusedComponent(); if (focusedComponent != null) { ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { IdeFocusManager.getInstance(myProject) .requestFocus(focusedComponent, true); } }); } } } }); } }); }
public void commitSynchronously( @NotNull Document document, @NotNull Project project, PsiFile excludeFile) { assert !isDisposed; if (!project.isInitialized() && !project.isDefault()) { @NonNls String s = project + "; Disposed: " + project.isDisposed() + "; Open: " + project.isOpen(); s += "; SA Passed: "; try { s += ((StartupManagerImpl) StartupManager.getInstance(project)).startupActivityPassed(); } catch (Exception e) { s += e; } throw new RuntimeException(s); } ApplicationManager.getApplication().assertWriteAccessAllowed(); synchronized (documentsToCommit) { setCommitStage(document, CommitStage.ABOUT_TO_BE_SYNC_COMMITTED, true); removeCommitFromQueue(document); } ProgressIndicatorBase indicator = new ProgressIndicatorBase(); indicator.start(); log("About to commit sync", document, true, indicator); Runnable finish = commit(document, project, excludeFile, indicator, true, "Sync commit"); log("Committed sync", document, true, finish, indicator); assert finish != null; finish.run(); }
public MPSFileBasedIndexProjectHandler( final Project project, final ProjectRootManagerEx rootManager, ProjectManager projectManager, FileBasedIndex index, StartupModuleMaker maker) { super(project); myRootManager = rootManager; myProjectManager = projectManager; myIndex = index; final MPSUnindexedFilesUpdater updater = new MPSUnindexedFilesUpdater(myIndex, myRootManager); final StartupManagerEx startupManager = (StartupManagerEx) StartupManager.getInstance(myProject); if (startupManager == null) return; startupManager.registerPreStartupActivity( new Runnable() { public void run() { startupManager.registerCacheUpdater(updater); myIndex.registerIndexableSet(MPSFileBasedIndexProjectHandler.this, myProject); DumbServiceImpl.getInstance(myProject) .queueCacheUpdate(Collections.<CacheUpdater>singletonList(updater)); } }); }
@Override public void projectOpened() { super.projectOpened(); if (myProject.isDefault()) { return; } StartupManager.getInstance(myProject) .registerPostStartupActivity( new Runnable() { @Override public void run() { final AbstractExternalSystemSettings pantsSettings = ExternalSystemApiUtil.getSettings(myProject, PantsConstants.SYSTEM_ID); final boolean resolverVersionMismatch = pantsSettings instanceof PantsSettings && ((PantsSettings) pantsSettings).getResolverVersion() != PantsResolver.VERSION; if (resolverVersionMismatch && /* additional check */ PantsUtil.isPantsProject(myProject)) { final int answer = Messages.showYesNoDialog( myProject, PantsBundle.message( "pants.project.generated.with.old.version", myProject.getName()), PantsBundle.message("pants.name"), PantsIcons.Icon); if (answer == Messages.YES) { PantsUtil.refreshAllProjects(myProject); } } } }); }
private LocalTask doActivate(Task origin, boolean explicitly) { final LocalTaskImpl task = origin instanceof LocalTaskImpl ? (LocalTaskImpl) origin : new LocalTaskImpl(origin); if (explicitly) { task.setUpdated(new Date()); } myActiveTask.setActive(false); task.setActive(true); addTask(task); if (task.isIssue()) { StartupManager.getInstance(myProject) .runWhenProjectIsInitialized( new Runnable() { public void run() { ProgressManager.getInstance() .run( new com.intellij.openapi.progress.Task.Backgroundable( myProject, "Updating " + task.getId()) { public void run(@NotNull ProgressIndicator indicator) { updateIssue(task.getId()); } }); } }); } LocalTask oldActiveTask = myActiveTask; boolean isChanged = !task.equals(oldActiveTask); myActiveTask = task; if (isChanged) { myDispatcher.getMulticaster().taskDeactivated(oldActiveTask); myDispatcher.getMulticaster().taskActivated(task); } return task; }
@Override public void moduleAdded() { if (!myModuleInitialized) { myConnection.subscribe( ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { scheduleUpdate(); } }); myConnection.subscribe(GoLibrariesService.LIBRARIES_TOPIC, newRootUrls -> scheduleUpdate()); Project project = myModule.getProject(); StartupManager.getInstance(project) .runWhenProjectIsInitialized( () -> { if (!project.isDisposed() && !myModule.isDisposed()) { for (PsiFileSystemItem vendor : FilenameIndex.getFilesByName( project, GoConstants.VENDOR, GoUtil.moduleScope(myModule), true)) { if (vendor.isDirectory()) { showVendoringNotification(); break; } } } }); VirtualFileManager.getInstance().addVirtualFileListener(myFilesListener); } scheduleUpdate(0); myModuleInitialized = true; }
@Override protected void doSetModuleDescriptor(ModuleDescriptor moduleDescriptor) { assert moduleDescriptor instanceof SolutionDescriptor; SolutionDescriptor newDescriptor = (SolutionDescriptor) moduleDescriptor; newDescriptor.setNamespace(myModule.getName()); // addLibs(newDescriptor); super.doSetModuleDescriptor(newDescriptor); try { ApplicationManager.getApplication() .getComponent(JdkStubSolutionManager.class) .claimSdk(myModule); } catch (final DifferentSdkException e) { // TODO this seems to behave suspiciously in tests StartupManager.getInstance(myModule.getProject()) .runWhenProjectIsInitialized( new Runnable() { @Override public void run() { Messages.showErrorDialog( myModule.getProject(), "There are more than one different SDKs used in modules with MPS facets.\n" + "Trying to use " + e.getRequestedSdk().getName() + " while " + e.getCurrentSdk().getName() + " is already used." + "\n", "Multiple SDKs not supported in MPS plugin"); } }); } }
@Override public void initComponent() { StartupManager.getInstance(myProject) .registerPostStartupActivity( new Runnable() { @Override public void run() { initialize(); } }); }
@Override public void projectOpened() { StartupManager.getInstance(myProject) .registerPostStartupActivity( new Runnable() { @Override public void run() { myToolWindowReady = true; processFileEditorChange(getActiveLayoutXmlEditor()); } }); }
protected void tearDown() throws Exception { ((StartupManagerImpl) StartupManager.getInstance(getProject())).prepareForNextTest(); checkAllTimersAreDisposed(); CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings(); checkForSettingsDamage(); doTearDown(); super.tearDown(); myThreadTracker.checkLeak(); }
@Override public void projectOpened() { StartupManager startupManager = StartupManager.getInstance(myProject); if (startupManager == null) { return; // upsource } startupManager.registerPostStartupActivity( new DumbAwareRunnable() { @Override public void run() { final Set<Profile> profiles = new HashSet<Profile>(); profiles.add(getProjectProfileImpl()); profiles.addAll(getProfiles()); profiles.addAll(InspectionProfileManager.getInstance().getProfiles()); final Application app = ApplicationManager.getApplication(); Runnable initInspectionProfilesRunnable = () -> { for (Profile profile : profiles) { initProfileWrapper(profile); } fireProfilesInitialized(); }; if (app.isUnitTestMode() || app.isHeadlessEnvironment()) { initInspectionProfilesRunnable.run(); UIUtil .dispatchAllInvocationEvents(); // do not restart daemon in the middle of the test } else { app.executeOnPooledThread(initInspectionProfilesRunnable); } myScopeListener = new NamedScopesHolder.ScopeListener() { @Override public void scopesChanged() { for (Profile profile : getProfiles()) { ((InspectionProfile) profile).scopesChanged(); } } }; myHolder.addScopeListener(myScopeListener); myLocalScopesHolder.addScopeListener(myScopeListener); Disposer.register( myProject, new Disposable() { @Override public void dispose() { myHolder.removeScopeListener(myScopeListener); myLocalScopesHolder.removeScopeListener(myScopeListener); } }); } }); }
@Override public void projectOpened() { if (ApplicationManager.getApplication().isUnitTestMode()) return; StartupManager.getInstance(myProject) .runWhenProjectIsInitialized( new Runnable() { @Override public void run() { runStatisticsService(); } }); }
public void projectOpened() { StartupManager.getInstance(myProject) .runWhenProjectIsInitialized( new Runnable() { public void run() { if (!ApplicationManager.getApplication().isUnitTestMode() && DartLineBreakpointType.getJSBreakpointType() != null) { removeDartLineBreakpoints(myProject); } // removeJSBreakpointsInDartFiles(myProject); // todo remove above and uncomment // this line in 13.1.1 (when JavaScriptDebugAware.isOnlySourceMappedBreakpoints() is // introduced) final boolean dartSdkWasEnabledInOldModel = hasJSLibraryMappingToOldDartSdkGlobalLib(myProject); deleteDartSdkGlobalLibConfiguredInOldIde(); final String dartSdkGlobalLibName = importKnowledgeAboutOldDartSdkAndReturnGlobalLibName(myProject); final Collection<VirtualFile> pubspecYamlFiles = FilenameIndex.getVirtualFilesByName( myProject, PUBSPEC_YAML, GlobalSearchScope.projectScope(myProject)); for (VirtualFile pubspecYamlFile : pubspecYamlFiles) { final Module module = ModuleUtilCore.findModuleForFile(pubspecYamlFile, myProject); if (module != null && FileTypeIndex.containsFileOfType( DartFileType.INSTANCE, module.getModuleContentScope())) { excludePackagesFolders(module, pubspecYamlFile); if (dartSdkGlobalLibName != null && dartSdkWasEnabledInOldModel && ModuleType.get(module) instanceof WebModuleTypeBase && !DartSdkGlobalLibUtil.isDartSdkGlobalLibAttached( module, dartSdkGlobalLibName)) { ApplicationManager.getApplication() .runWriteAction( new Runnable() { public void run() { DartSdkGlobalLibUtil.configureDependencyOnGlobalLib( module, dartSdkGlobalLibName); } }); } } } } }); }
public void initComponent() { if (!ApplicationManager.getApplication().isUnitTestMode()) { myCacheRefreshTimer = UIUtil.createNamedTimer( "TaskManager refresh", myConfig.updateInterval * 60 * 1000, new ActionListener() { public void actionPerformed(ActionEvent e) { if (myConfig.updateEnabled && !myUpdating) { updateIssues(null); } } }); myCacheRefreshTimer.setInitialDelay(0); StartupManager.getInstance(myProject) .registerPostStartupActivity( new Runnable() { public void run() { myCacheRefreshTimer.start(); } }); } // make sure that the default task is exist LocalTask defaultTask = findTask(LocalTaskImpl.DEFAULT_TASK_ID); if (defaultTask == null) { defaultTask = createDefaultTask(); addTask(defaultTask); } // search for active task LocalTask activeTask = null; final List<LocalTask> tasks = getLocalTasks(); Collections.sort(tasks, TASK_UPDATE_COMPARATOR); for (LocalTask task : tasks) { if (activeTask == null) { if (task.isActive()) { activeTask = task; } } else { task.setActive(false); } } if (activeTask == null) { activeTask = defaultTask; } myActiveTask = activeTask; doActivate(myActiveTask, false); myDispatcher.getMulticaster().taskActivated(myActiveTask); }
public static void runWhenInitialized(final Project project, final Runnable r) { if (project.isDisposed()) return; if (isNoBackgroundMode()) { r.run(); return; } if (!project.isInitialized()) { StartupManager.getInstance(project).registerPostStartupActivity(r); return; } runDumbAware(project, r); }
@Override protected void tearDown() throws Exception { try { DaemonCodeAnalyzerSettings.getInstance() .setImportHintEnabled(true); // return default value to avoid unnecessary save final Project project = getProject(); if (project != null) { ((StartupManagerImpl) StartupManager.getInstance(project)).checkCleared(); ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project)).cleanupAfterTest(); } } finally { super.tearDown(); } // ((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed(); }
public void initComponent() { StartupManager.getInstance(myProject) .runWhenProjectIsInitialized( new Runnable() { @Override public void run() { ModelAccess.instance() .runReadAction( new Runnable() { @Override public void run() { MPSProject mpsProject = myProject.getComponent(MPSProject.class); List<Solution> projectSolutions = mpsProject.getProjectSolutions(); List<String> updatedSolutions = new ArrayList<String>(); for (Solution solution : projectSolutions) { try { SolutionDescriptor moduleDescriptor = solution.getModuleDescriptor(); if (moduleDescriptor != null && moduleDescriptor.getGitTimeUpdate() != null) { String gitHubUrl = moduleDescriptor.getGitHubUrl(); if (!(moduleDescriptor .getGitTimeUpdate() .equals(GitHubUtil.getLastUpdateTime(gitHubUrl)))) { updatedSolutions.add(solution.getModuleFqName()); } } } catch (IOException e) { // } } if (!updatedSolutions.isEmpty()) { String message = updatedSolutions.toString().replace("[", "").replace("]", ""); JFrame frame = new JFrame(); frame.setTitle("New Update"); JOptionPane.showMessageDialog( frame, "New update is available for following libraries:\n" + message); } } }); } }); }
public PsiVFSListener(Project project) { myProject = project; myFileTypeManager = FileTypeManager.getInstance(); myProjectRootManager = ProjectRootManager.getInstance(project); myManager = (PsiManagerImpl) PsiManager.getInstance(project); myFileManager = (FileManagerImpl) myManager.getFileManager(); myConnection = project.getMessageBus().connect(project); StartupManager.getInstance(project) .registerPreStartupActivity( new Runnable() { @Override public void run() { final BulkVirtualFileListenerAdapter adapter = new BulkVirtualFileListenerAdapter(PsiVFSListener.this); myConnection.subscribe( VirtualFileManager.VFS_CHANGES, new BulkFileListener() { @Override public void before(@NotNull List<? extends VFileEvent> events) { adapter.before(events); } @Override public void after(@NotNull List<? extends VFileEvent> events) { myReportedUnloadedPsiChange = false; adapter.after(events); myReportedUnloadedPsiChange = false; } }); myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener()); myConnection.subscribe( FileTypeManager.TOPIC, new FileTypeListener.Adapter() { @Override public void fileTypesChanged(@NotNull FileTypeEvent e) { myFileManager.processFileTypesChanged(); } }); myConnection.subscribe( AppTopics.FILE_DOCUMENT_SYNC, new MyFileDocumentManagerAdapter()); myFileManager.markInitialized(); } }); }
public void projectOpened() { StartupManager.getInstance(myProject) .registerPostStartupActivity( new DumbAwareRunnable() { public void run() { final FavoritesListProvider[] extensions = Extensions.getExtensions(FavoritesListProvider.EP_NAME, myProject); for (FavoritesListProvider extension : extensions) { final String name = extension.getListName(myProject); if (!myName2FavoritesRoots.containsKey(name)) { createNewList(name, extension.canBeRemoved(), extension.isTreeLike()); } else if (!myReadOnlyLists.contains(name) && !extension.canBeRemoved()) { myReadOnlyLists.add(name); } final FavoritesListProvider.Operation addOperation = extension.getCustomAddOperation(); if (!myAddHandlers.containsKey(name)) { myAddHandlers.put(name, addOperation); } final FavoritesListProvider.Operation editOperation = extension.getCustomEditOperation(); if (!myEditHandlers.containsKey(name)) { myEditHandlers.put(name, editOperation); } final FavoritesListProvider.Operation deleteOperation = extension.getCustomDeleteOperation(); if (!myDeleteHandlers.containsKey(name)) { myDeleteHandlers.put(name, deleteOperation); } final TreeCellRenderer treeCellRenderer = extension.getTreeCellRenderer(); if (treeCellRenderer != null && !myCustomRenderers.containsKey(name)) { myCustomRenderers.put(name, treeCellRenderer); } final Comparator<FavoritesTreeNodeDescriptor> comparator = extension.getNodeDescriptorComparator(); if (comparator != null && !myComparators.containsKey(name)) { myComparators.put(name, comparator); } } final MyRootsChangeAdapter myPsiTreeChangeAdapter = new MyRootsChangeAdapter(); PsiManager.getInstance(myProject) .addPsiTreeChangeListener(myPsiTreeChangeAdapter, myProject); } }); }
private void updateUnindexedFiles(ProgressIndicator indicator) { PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot(); PushedFilePropertiesUpdater.getInstance(myProject).pushAllPropertiesNow(); boolean trackResponsiveness = !ApplicationManager.getApplication().isUnitTestMode(); if (trackResponsiveness) snapshot.logResponsivenessSinceCreation("Pushing properties"); indicator.setIndeterminate(true); indicator.setText(IdeBundle.message("progress.indexing.scanning")); myIndex.clearIndicesIfNecessary(); CollectingContentIterator finder = myIndex.createContentIterator(indicator); snapshot = PerformanceWatcher.takeSnapshot(); myIndex.iterateIndexableFilesConcurrently(finder, myProject, indicator); myIndex.filesUpdateEnumerationFinished(); if (trackResponsiveness) snapshot.logResponsivenessSinceCreation("Indexable file iteration"); List<VirtualFile> files = finder.getFiles(); if (myOnStartup && !ApplicationManager.getApplication().isUnitTestMode()) { // full VFS refresh makes sense only after it's loaded, i.e. after scanning files to index is // finished ((StartupManagerImpl) StartupManager.getInstance(myProject)).scheduleInitialVfsRefresh(); } if (files.isEmpty()) { return; } snapshot = PerformanceWatcher.takeSnapshot(); if (trackResponsiveness) LOG.info("Unindexed files update started: " + files.size() + " files to update"); indicator.setIndeterminate(false); indicator.setText(IdeBundle.message("progress.indexing.updating")); indexFiles(indicator, files); if (trackResponsiveness) snapshot.logResponsivenessSinceCreation("Unindexed files update"); }
@Override public void projectOpened() { StartupManager.getInstance(myProject) .registerPostStartupActivity( new Runnable() { @Override public void run() { try { // get project root dir and check if this is an Android project // if (AndroidStudioHelper.isAndroidGradleModule(myProject.getBaseDir())) { if (isAndroidProject()) { createActivityTemplates(); } } catch (IOException ignored) { } } }); }
@Override public void loadState(final Element state) { // startup manager is needed cause the contract is that you can't use read and write locks // on component load - it can cause a deadlock (MPS-2811) StartupManager.getInstance(getProject()) .runWhenProjectIsInitialized( new Runnable() { @Override public void run() { ModelAccess.instance() .runReadAction( new Runnable() { @Override public void run() { read(state, getProject().getComponent(MPSProject.class)); } }); } }); }
@Override public void projectOpened() { final StartupManager manager = StartupManager.getInstance(myProject); manager.registerPostStartupActivity( new DumbAwareRunnable() { @Override public void run() { ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject); if (toolWindowManager != null) { // Can be null in tests if (!Registry.is("vcs.merge.toolwindows")) { ToolWindow toolWindow = toolWindowManager.registerToolWindow( ToolWindowId.VCS, true, ToolWindowAnchor.BOTTOM, myProject, true); myContentManager = toolWindow.getContentManager(); toolWindow.setIcon(AllIcons.Toolwindows.VcsSmallTab); toolWindow.installWatcher(myContentManager); } } else { myContentManager = ContentFactory.SERVICE.getInstance().createContentManager(true, myProject); } } }); addInitializationRequest( VcsInitObject.AFTER_COMMON, new Runnable() { @Override public void run() { if (!ApplicationManager.getApplication().isUnitTestMode()) { VcsRootChecker[] checkers = Extensions.getExtensions(VcsRootChecker.EXTENSION_POINT_NAME); if (checkers.length != 0) { VcsRootScanner.start(myProject, checkers); } } } }); }
public void projectOpened() { if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { StartupManager.getInstance(myProject) .registerPostStartupActivity( new Runnable() { public void run() { myPaletteWindow = new PaletteWindow(myProject); myPaletteToolWindow = ToolWindowManager.getInstance(myProject) .registerToolWindow( IdeBundle.message("toolwindow.palette"), myPaletteWindow, ToolWindowAnchor.RIGHT, myProject, true); myPaletteToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowPalette); setContent(); final MyFileEditorManagerListener myListener = new MyFileEditorManagerListener(); myFileEditorManager.addFileEditorManagerListener(myListener, myProject); } }); } }
@Override public void loadState(ExternalDependenciesState state) { ArrayList<ProjectExternalDependency> oldDependencies = new ArrayList<ProjectExternalDependency>(myDependencies); myDependencies.clear(); for (DependencyOnPluginState dependency : state.myDependencies) { myDependencies.add( new DependencyOnPlugin( dependency.myId, dependency.myMinVersion, dependency.myMaxVersion, dependency.myChannel)); } if (!oldDependencies.equals(myDependencies) && !myDependencies.isEmpty()) { StartupManager.getInstance(myProject) .runWhenProjectIsInitialized( new DumbAwareRunnable() { @Override public void run() { CheckRequiredPluginsActivity.runCheck(myProject); } }); } }
/** * Converts and loads the project at the specified path. * * @param filePath the path to open the project. * @return the project, or null if the user has cancelled opening the project. */ @Override @Nullable public Project convertAndLoadProject(String filePath) throws IOException { final String fp = toCanonicalName(filePath); final ConversionResult conversionResult = ConversionService.getInstance().convert(fp); if (conversionResult.openingIsCanceled()) { return null; } final Project project = loadProjectWithProgress(filePath); if (project == null) return null; if (!conversionResult.conversionNotNeeded()) { StartupManager.getInstance(project) .registerPostStartupActivity( new Runnable() { @Override public void run() { conversionResult.postStartupActivity(project); } }); } return project; }
public void projectOpened() { StartupManager.getInstance(myProject) .runWhenProjectIsInitialized( new Runnable() { @Override public void run() { final Course course = CCProjectService.getInstance(myProject).getCourse(); if (course != null) { myProject .getMessageBus() .connect(myProject) .subscribe( FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() { @Override public void selectionChanged(@NotNull FileEditorManagerEvent event) { final VirtualFile oldFile = event.getOldFile(); if (oldFile == null) { return; } if (CCProjectService.getInstance(myProject).isTaskFile(oldFile)) { FileEditorManager.getInstance(myProject).closeFile(oldFile); ApplicationManager.getApplication() .runWriteAction( new Runnable() { @Override public void run() { try { oldFile.delete(myProject); } catch (IOException e) { LOG.error(e); } } }); } } }); myListener = new FileDeletedListener(); VirtualFileManager.getInstance().addVirtualFileListener(myListener); final CCEditorFactoryListener editorFactoryListener = new CCEditorFactoryListener(); EditorFactory.getInstance() .addEditorFactoryListener(editorFactoryListener, myProject); VirtualFile[] files = FileEditorManager.getInstance(myProject).getOpenFiles(); for (VirtualFile file : files) { if (CCProjectService.getInstance(myProject).isTaskFile(file)) { FileEditorManager.getInstance(myProject).closeFile(file); continue; } FileEditor fileEditor = FileEditorManager.getInstance(myProject).getSelectedEditor(file); if (fileEditor instanceof PsiAwareTextEditorImpl) { Editor editor = ((PsiAwareTextEditorImpl) fileEditor).getEditor(); editorFactoryListener.editorCreated( new EditorFactoryEvent( new EditorFactoryImpl(ProjectManager.getInstance()), editor)); } } } } }); }
@Override protected void setUp() throws Exception { super.setUp(); ((StartupManagerImpl) StartupManager.getInstance(getProject())).runPostStartupActivities(); }
@Override public boolean openProject(final Project project) { if (isLight(project)) { throw new AssertionError("must not open light project"); } final Application application = ApplicationManager.getApplication(); if (!application.isUnitTestMode() && !((ProjectEx) project).getStateStore().checkVersion()) { return false; } synchronized (myOpenProjects) { if (myOpenProjects.contains(project)) { return false; } myOpenProjects.add(project); cacheOpenProjects(); } fireProjectOpened(project); final StartupManagerImpl startupManager = (StartupManagerImpl) StartupManager.getInstance(project); waitForFileWatcher(project); boolean ok = myProgressManager.runProcessWithProgressSynchronously( new Runnable() { @Override public void run() { startupManager.runStartupActivities(); // dumb mode should start before post-startup activities // only when startCacheUpdate is called from UI thread, we can guarantee that // when the method returns, the application has entered dumb mode UIUtil.invokeAndWaitIfNeeded( new Runnable() { @Override public void run() { startupManager.startCacheUpdate(); } }); startupManager.runPostStartupActivitiesFromExtensions(); UIUtil.invokeLaterIfNeeded( new Runnable() { @Override public void run() { startupManager.runPostStartupActivities(); } }); } }, ProjectBundle.message("project.load.progress"), true, project); if (!ok) { closeProject(project, false, false, true); notifyProjectOpenFailed(); return false; } if (!application.isHeadlessEnvironment() && !application.isUnitTestMode()) { // should be invoked last startupManager.runWhenProjectIsInitialized( new Runnable() { @Override public void run() { final TrackingPathMacroSubstitutor macroSubstitutor = ((ProjectEx) project) .getStateStore() .getStateStorageManager() .getMacroSubstitutor(); if (macroSubstitutor != null) { StorageUtil.notifyUnknownMacros(macroSubstitutor, project, null); } } }); } return true; }