com.intellij.openapi.startup.StartupManager Java Examples
The following examples show how to use
com.intellij.openapi.startup.StartupManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void setProjectName(@Nonnull String projectName) { String name = getName(); if (!projectName.equals(name)) { myName = projectName; StartupManager.getInstance(this).runWhenProjectIsInitialized(new DumbAwareRunnable() { @Override public void run() { if (isDisposed()) return; JFrame frame = WindowManager.getInstance().getFrame(ProjectImpl.this); String title = FrameTitleBuilder.getInstance().getProjectTitle(ProjectImpl.this); if (frame != null && title != null) { frame.setTitle(title); } } }); } }
Example #2
Source File: FavoritesManager.java From consulo with Apache License 2.0 | 6 votes |
@Override public void projectOpened() { if (!ApplicationManager.getApplication().isUnitTestMode()) { StartupManager.getInstance(myProject).registerPostStartupActivity(new DumbAwareRunnable() { @Override public void run() { final FavoritesListProvider[] providers = Extensions.getExtensions(EP_NAME, myProject); for (FavoritesListProvider provider : providers) { myProviders.put(provider.getListName(myProject), provider); } final MyRootsChangeAdapter myPsiTreeChangeAdapter = new MyRootsChangeAdapter(); PsiManager.getInstance(myProject).addPsiTreeChangeListener(myPsiTreeChangeAdapter, myProject); if (myName2FavoritesRoots.isEmpty()) { myDescriptions.put(myProject.getName(), "auto-added"); createNewList(myProject.getName()); } } }); } }
Example #3
Source File: BookmarkManager.java From consulo with Apache License 2.0 | 6 votes |
@Override public void loadState(final Element state) { StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() { @Override public void run() { BookmarksListener publisher = myBus.syncPublisher(BookmarksListener.TOPIC); for (Bookmark bookmark : myBookmarks) { bookmark.release(); publisher.bookmarkRemoved(bookmark); } myBookmarks.clear(); readExternal(state); } }); }
Example #4
Source File: DependenciesToolWindow.java From consulo with Apache License 2.0 | 6 votes |
@Inject public DependenciesToolWindow(final Project project, StartupManager startupManager) { myProject = project; startupManager.runWhenProjectIsInitialized(new Runnable() { @Override public void run() { final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject); if (toolWindowManager == null) return; ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.DEPENDENCIES, true, ToolWindowAnchor.BOTTOM, project); myContentManager = toolWindow.getContentManager(); toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowInspection); new ContentManagerWatcher(toolWindow, myContentManager); } }); }
Example #5
Source File: ConfigurationErrors.java From consulo with Apache License 2.0 | 6 votes |
public static void _do(@Nonnull final ConfigurationError error, @Nonnull final Project project, @Nonnull final PairProcessor<ConfigurationErrors, ConfigurationError> fun) { if (!project.isInitialized()) { StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() { @Override public void run() { fun.process(project.getMessageBus().syncPublisher(TOPIC), error); } }); return; } final MessageBus bus = project.getMessageBus(); if (EventQueue.isDispatchThread()) fun.process(bus.syncPublisher(TOPIC), error); else { //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { @Override public void run() { fun.process(bus.syncPublisher(TOPIC), error); } }); } }
Example #6
Source File: ProjectLoadingErrorsNotifierImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void registerErrors(Collection<? extends ConfigurationErrorDescription> errorDescriptions) { if (myProject.isDisposed() || myProject.isDefault() || errorDescriptions.isEmpty()) return; boolean first; synchronized (myLock) { first = myErrors.isEmpty(); for (ConfigurationErrorDescription description : errorDescriptions) { myErrors.putValue(description.getErrorType(), description); } } if (myProject.isInitialized()) { fireNotifications(); } else if (first) { StartupManager.getInstance(myProject).registerPostStartupActivity(new Runnable() { @Override public void run() { fireNotifications(); } }); } }
Example #7
Source File: DependenciesAnalyzeManager.java From consulo with Apache License 2.0 | 6 votes |
@Inject public DependenciesAnalyzeManager(final Project project, StartupManager startupManager) { myProject = project; startupManager.runWhenProjectIsInitialized(new Runnable() { @Override public void run() { ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject); ToolWindow toolWindow = toolWindowManager.registerToolWindow(ToolWindowId.MODULES_DEPENDENCIES, true, ToolWindowAnchor.RIGHT, project); myContentManager = toolWindow.getContentManager(); toolWindow.setIcon(AllIcons.Toolwindows.ToolWindowModuleDependencies); new ContentManagerWatcher(toolWindow, myContentManager); } }); }
Example #8
Source File: UpdateRequestsQueue.java From consulo with Apache License 2.0 | 6 votes |
public UpdateRequestsQueue(final Project project, @Nonnull ChangeListManagerImpl.Scheduler scheduler, final Runnable delegate) { myProject = project; myScheduler = scheduler; myTrackHeavyLatch = Boolean.parseBoolean(System.getProperty(ourHeavyLatchOptimization)); myDelegate = delegate; myPlVcsManager = ProjectLevelVcsManager.getInstance(myProject); myStartupManager = StartupManager.getInstance(myProject); myLock = new Object(); myWaitingUpdateCompletionQueue = new ArrayList<>(); // not initialized myStarted = false; myStopped = false; myIsStoppedGetter = new Getter<Boolean>() { @Override public Boolean get() { return isStopped(); } }; }
Example #9
Source File: LineStatusTrackerManager.java From consulo with Apache License 2.0 | 6 votes |
@Override public void projectOpened() { StartupManager.getInstance(myProject).registerPreStartupActivity(new Runnable() { @Override public void run() { final MyFileStatusListener fileStatusListener = new MyFileStatusListener(); final EditorFactoryListener editorFactoryListener = new MyEditorFactoryListener(); final MyVirtualFileListener virtualFileListener = new MyVirtualFileListener(); final FileStatusManager fsManager = FileStatusManager.getInstance(myProject); fsManager.addFileStatusListener(fileStatusListener, myDisposable); final EditorFactory editorFactory = EditorFactory.getInstance(); editorFactory.addEditorFactoryListener(editorFactoryListener, myDisposable); final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance(); virtualFileManager.addVirtualFileListener(virtualFileListener, myDisposable); } }); }
Example #10
Source File: ModuleVcsDetector.java From consulo with Apache License 2.0 | 6 votes |
@Override public void projectOpened() { if (ApplicationManager.getApplication().isUnitTestMode()) return; final StartupManager manager = StartupManager.getInstance(myProject); manager.registerStartupActivity(new Runnable() { @Override public void run() { if (myVcsManager.needAutodetectMappings()) { autoDetectVcsMappings(true); } myVcsManager.updateActiveVcss(); } }); manager.registerPostStartupActivity(new Runnable() { @Override public void run() { myConnection = myMessageBus.connect(); final MyModulesListener listener = new MyModulesListener(); myConnection.subscribe(ProjectTopics.MODULES, listener); myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, listener); } }); }
Example #11
Source File: RestoreUpdateTree.java From consulo with Apache License 2.0 | 6 votes |
@Override public void projectOpened() { StartupManager.getInstance(myProject).registerPostStartupActivity(new DumbAwareRunnable() { @Override public void run() { if (myUpdateInfo != null && !myUpdateInfo.isEmpty() && ProjectReloadState.getInstance(myProject).isAfterAutomaticReload()) { ActionInfo actionInfo = myUpdateInfo.getActionInfo(); if (actionInfo != null) { ProjectLevelVcsManagerEx.getInstanceEx(myProject).showUpdateProjectInfo(myUpdateInfo.getFileInformation(), VcsBundle.message("action.display.name.update"), actionInfo, false); CommittedChangesCache.getInstance(myProject).refreshIncomingChangesAsync(); } myUpdateInfo = null; } else { myUpdateInfo = null; } } }); }
Example #12
Source File: XBreakpointManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
public XBreakpointManagerImpl(final Project project, final XDebuggerManagerImpl debuggerManager, StartupManager startupManager) { myProject = project; myDebuggerManager = debuggerManager; myAllBreakpointsDispatcher = EventDispatcher.create(XBreakpointListener.class); myDependentBreakpointManager = new XDependentBreakpointManager(this); myLineBreakpointManager = new XLineBreakpointManager(project, myDependentBreakpointManager, startupManager); if (!project.isDefault()) { if (!ApplicationManager.getApplication().isUnitTestMode()) { HttpVirtualFileListener httpVirtualFileListener = this::updateBreakpointInFile; HttpFileSystem.getInstance().addFileListener(httpVirtualFileListener, project); } for (XBreakpointType<?, ?> type : XBreakpointUtil.getBreakpointTypes()) { addDefaultBreakpoint(type); } } }
Example #13
Source File: NotificationsManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
private static void doNotify(@Nonnull final Notification notification, @Nullable NotificationDisplayType displayType, @Nullable final Project project) { final NotificationsConfigurationImpl configuration = NotificationsConfigurationImpl.getInstanceImpl(); if (!configuration.isRegistered(notification.getGroupId())) { configuration.register(notification.getGroupId(), displayType == null ? NotificationDisplayType.BALLOON : displayType); } final NotificationSettings settings = NotificationsConfigurationImpl.getSettings(notification.getGroupId()); boolean shouldLog = settings.isShouldLog(); boolean displayable = settings.getDisplayType() != NotificationDisplayType.NONE; boolean willBeShown = displayable && NotificationsConfigurationImpl.getInstanceImpl().SHOW_BALLOONS; if (!shouldLog && !willBeShown) { notification.expire(); } if (NotificationsConfigurationImpl.getInstanceImpl().SHOW_BALLOONS) { final DumbAwareRunnable runnable = () -> showNotification(notification, project); if (project == null) { UIUtil.invokeLaterIfNeeded(runnable); } else if (!project.isDisposed()) { StartupManager.getInstance(project).runWhenProjectIsInitialized(runnable); } } }
Example #14
Source File: MessageViewImpl.java From consulo with Apache License 2.0 | 6 votes |
@Inject public MessageViewImpl(final Project project, final StartupManager startupManager, final ToolWindowManager toolWindowManager) { final Runnable runnable = new Runnable() { @Override public void run() { myToolWindow = toolWindowManager.registerToolWindow(ToolWindowId.MESSAGES_WINDOW, true, ToolWindowAnchor.BOTTOM, project, true); myToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowMessages); new ContentManagerWatcher(myToolWindow, getContentManager()); for (Runnable postponedRunnable : myPostponedRunnables) { postponedRunnable.run(); } myPostponedRunnables.clear(); } }; if (project.isInitialized()) { runnable.run(); } else { startupManager.registerPostStartupActivity(runnable::run); } }
Example #15
Source File: StatusBar.java From consulo with Apache License 2.0 | 6 votes |
public static void set(@Nullable final String text, @Nullable final Project project, @Nullable final String requestor) { if (project != null) { if (project.isDisposed()) return; if (!project.isInitialized()) { StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() { public void run() { project.getMessageBus().syncPublisher(TOPIC).setInfo(text, requestor); } }); return; } } final MessageBus bus = project == null ? ApplicationManager.getApplication().getMessageBus() : project.getMessageBus(); bus.syncPublisher(TOPIC).setInfo(text, requestor); }
Example #16
Source File: HeavyIdeaTestFixtureImpl.java From consulo with Apache License 2.0 | 6 votes |
private void setUpProject() throws Exception { new WriteCommandAction.Simple(null) { @Override protected void run() throws Throwable { File projectDir = FileUtil.createTempDirectory(myName + "_", "project"); FileUtil.delete(projectDir); myFilesToDelete.add(projectDir); LocalFileSystem.getInstance().refreshAndFindFileByIoFile(projectDir); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); new Throwable(projectDir.getPath()).printStackTrace(new PrintStream(buffer)); myProject = PlatformTestCase.createProject(projectDir, buffer.toString()); for (ModuleFixtureBuilder moduleFixtureBuilder : myModuleFixtureBuilders) { moduleFixtureBuilder.getFixture().setUp(); } StartupManagerImpl sm = (StartupManagerImpl)StartupManager.getInstance(myProject); sm.runStartupActivities(UIAccess.get()); sm.runPostStartupActivities(UIAccess.get()); ProjectManagerEx.getInstanceEx().openTestProject(myProject); LightPlatformTestCase.clearUncommittedDocuments(myProject); } }.execute().throwException(); }
Example #17
Source File: HaxelibProjectUpdater.java From intellij-haxe with Apache License 2.0 | 6 votes |
/** * Puts the next project on the event queue. */ private void queueNextProject() { synchronized (updateSyncToken) { LOG.assertTrue(null == updatingProject); // Get the next project from the queue. We're done if there's // nothing left. updatingProject = queue.poll(); // null if empty. if (updatingProject == null) return; LOG.assertTrue(updatingProject.isDirty()); LOG.assertTrue(!updatingProject.isUpdating()); updatingProject.setUpdating(true); } // Waiting for runWhenProjectIsInitialized() ensures that the project is // fully loaded and accessible. Otherwise, we crash. ;) StartupManager.getInstance(updatingProject.getProject()).runWhenProjectIsInitialized(new Runnable() { public void run() { LOG.debug("Starting haxelib library sync..."); runUpdate(); } }); }
Example #18
Source File: ConsoleLogProjectTracker.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 6 votes |
private void doPrintNotification(@NotNull final Notification notification, @NotNull final ConsoleLogConsole console) { StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() { @Override public void run() { if(!ShutDownTracker.isShutdownHookRunning() && !myProject.isDisposed()) { runReadAction( new Runnable() { @Override public void run() { console.doPrintNotification(notification); } } ); } } }); }
Example #19
Source File: ProjectUtils.java From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 | 6 votes |
/** * Runs a thread when initialized * * @param project * @param r */ 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(DisposeAwareRunnable.create(r, project)); return; } runDumbAware(project, r); }
Example #20
Source File: VueModuleBuilder.java From vue-for-idea with BSD 3-Clause "New" or "Revised" License | 6 votes |
static void runWhenNonModalIfModuleNotDisposed(@NotNull final Runnable runnable, @NotNull final Module module) { StartupManager.getInstance(module.getProject()).runWhenProjectIsInitialized(new Runnable() { @Override public void run() { if (ApplicationManager.getApplication().getCurrentModalityState() == ModalityState.NON_MODAL) { runnable.run(); } else { ApplicationManager.getApplication().invokeLater(runnable, ModalityState.NON_MODAL, new Condition() { @Override public boolean value(final Object o) { return module.isDisposed(); } }); } } }); }
Example #21
Source File: MSToolsProject.java From Microsoft-Cloud-Services-for-Android with MIT License | 6 votes |
@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) { } } }); }
Example #22
Source File: RunnableHelper.java From Aspose.OCR-for-Java with MIT License | 5 votes |
public static void runWhenInitialized(final Project project, final Runnable r) { if (project.isDisposed()) return; if (!project.isInitialized()) { StartupManager.getInstance(project).registerStartupActivity(new RunnableHelper.WriteAction(r)); return; } RunnableHelper.runWriteCommand(project, r); }
Example #23
Source File: GlobalConfigsToolWindowPanel.java From mule-intellij-plugins with Apache License 2.0 | 5 votes |
public GlobalConfigsToolWindowPanel(Project project) { super(true, true); myProject = project; if (myProject.isInitialized()) init(); else StartupManager.getInstance(myProject) .registerPostStartupActivity(() -> { init(); }); }
Example #24
Source File: PsiVFSListener.java From consulo with Apache License 2.0 | 5 votes |
@Inject public PsiVFSListener(@Nonnull Project project, Provider<ProjectFileIndex> fileIndex) { installGlobalListener(); myProject = project; myFileTypeManager = FileTypeManager.getInstance(); myFileIndex = fileIndex; myManager = (PsiManagerImpl)PsiManager.getInstance(project); myFileManager = (FileManagerImpl)myManager.getFileManager(); if (project.isDefault()) { return; } // events must handled only after pre-startup (https://upsource.jetbrains.com/intellij/review/IDEA-CR-47395) StartupManager.getInstance(project).registerPreStartupActivity(() -> { MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener()); connection.subscribe(FileTypeManager.TOPIC, new FileTypeListener() { @Override public void fileTypesChanged(@Nonnull FileTypeEvent e) { myFileManager.processFileTypesChanged(e.getRemovedFileType() != null); } }); connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new MyFileDocumentManagerAdapter()); }); }
Example #25
Source File: VcsInitialization.java From consulo with Apache License 2.0 | 5 votes |
VcsInitialization(@Nonnull final Project project) { myProject = project; if (project.isDefault()) return; StartupManager.getInstance(project).registerPostStartupActivity((DumbAwareRunnable)() -> { if (project.isDisposed()) return; myFuture = ((ProgressManagerImpl)ProgressManager.getInstance()).runProcessWithProgressAsynchronously( new Task.Backgroundable(myProject, "VCS Initialization") { @Override public void run(@Nonnull ProgressIndicator indicator) { execute(indicator); } }, myIndicator, null); }); }
Example #26
Source File: JSGraphQLLanguageUIProjectService.java From js-graphql-intellij-plugin with MIT License | 5 votes |
private void initToolWindow() { if (this.myToolWindowManager != null && !this.myProject.isDisposed()) { StartupManager.getInstance(this.myProject).runWhenProjectIsInitialized(() -> ApplicationManager.getApplication().invokeLater(() -> { myToolWindowManager.init(); final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(GRAPH_QL_TOOL_WINDOW_NAME); if (toolWindow != null) { createToolWindowResultEditor(toolWindow); } myToolWindowManagerInitialized = true; }, myProject.getDisposed())); } }
Example #27
Source File: EventLog.java From consulo with Apache License 2.0 | 5 votes |
private void doPrintNotification(@Nonnull final Notification notification, @Nonnull final EventLogConsole console) { StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() { @Override public void run() { if (!ShutDownTracker.isShutdownHookRunning() && !myProject.isDisposed()) { ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { console.doPrintNotification(notification); } }); } } }); }
Example #28
Source File: LightToolWindowManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public void projectOpened() { UIAccess lastUIAccess = Application.get().getLastUIAccess(); lastUIAccess.giveAndWaitIfNeed(this::initToolWindow); StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() { public void run() { if (getEditorMode() == null) { initListeners(); bindToDesigner(getActiveDesigner()); } } }); }
Example #29
Source File: FileStatusManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Inject public FileStatusManagerImpl(Project project, StartupManager startupManager, @SuppressWarnings("UnusedParameters") DirectoryIndex makeSureIndexIsInitializedFirst) { myProject = project; project.getMessageBus().connect().subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() { @Override public void globalSchemeChange(EditorColorsScheme scheme) { fileStatusesChanged(); } }); if (project.isDefault()) return; startupManager.registerPreStartupActivity(() -> { DocumentAdapter documentListener = new DocumentAdapter() { @Override public void documentChanged(DocumentEvent event) { if (event.getOldLength() == 0 && event.getNewLength() == 0) return; VirtualFile file = FileDocumentManager.getInstance().getFile(event.getDocument()); if (file != null) { refreshFileStatusFromDocument(file, event.getDocument()); } } }; final EditorFactory factory = EditorFactory.getInstance(); if (factory != null) { factory.getEventMulticaster().addDocumentListener(documentListener, myProject); } }); startupManager.registerPostStartupActivity(new DumbAwareRunnable() { @Override public void run() { fileStatusesChanged(); } }); }
Example #30
Source File: DumbServiceImpl.java From consulo with Apache License 2.0 | 5 votes |
private void queueUpdateFinished() { if (myState.compareAndSet(State.RUNNING_DUMB_TASKS, State.WAITING_FOR_FINISH)) { // There is no task to suspend with the current suspender. If the execution reverts to the dumb mode, a new suspender will be // created. // The current suspender, however, might have already got suspended between the point of the last check cancelled call and // this point. If it has happened it will be cleaned up when the suspender is closed on the background process thread. myCurrentSuspender = null; StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> TransactionGuard.getInstance().submitTransaction(myProject, myDumbStartTransaction, this::updateFinished)); } }