mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
plugin_components.md: 2023.1 ProjectActivity
This commit is contained in:
parent
afe5aa2d34
commit
1fd0a3cc31
@ -43,20 +43,34 @@ See also [Running Tasks Once](ide_infrastructure.md#running-tasks-once).
|
|||||||
|
|
||||||
### Project Open
|
### Project Open
|
||||||
|
|
||||||
|
<tabs>
|
||||||
|
|
||||||
|
<tab title="2023.1 and later">
|
||||||
|
|
||||||
|
Using [Kotlin](using_kotlin.md), implement [`ProjectActivity`](%gh-ic%/platform/core-api/src/com/intellij/openapi/startup/StartupActivity.kt) and register in `com.intellij.postStartupActivity` extension point.
|
||||||
|
|
||||||
|
</tab>
|
||||||
|
|
||||||
|
<tab title="Pre-2023.1">
|
||||||
|
|
||||||
To execute code when a project is being opened, use one of these two [extensions](plugin_extensions.md):
|
To execute code when a project is being opened, use one of these two [extensions](plugin_extensions.md):
|
||||||
|
|
||||||
#### `com.intellij.postStartupActivity`
|
`com.intellij.postStartupActivity`
|
||||||
[`StartupActivity`](%gh-ic%/platform/core-api/src/com/intellij/openapi/startup/StartupActivity.kt) for immediate execution on EDT.
|
: [`StartupActivity`](%gh-ic%/platform/core-api/src/com/intellij/openapi/startup/StartupActivity.kt) for immediate execution on EDT.
|
||||||
Implement `DumbAware` to indicate activity can run in background thread (in parallel with other such tasks).
|
Implement `DumbAware` to indicate activity can run in background thread (in parallel with other such tasks).
|
||||||
|
|
||||||
#### `com.intellij.backgroundPostStartupActivity`
|
`com.intellij.backgroundPostStartupActivity`
|
||||||
[`StartupActivity.Background`](%gh-ic%/platform/core-api/src/com/intellij/openapi/startup/StartupActivity.kt) for execution with 5 seconds delay in background thread (2019.3 or later).
|
: [`StartupActivity.Background`](%gh-ic%/platform/core-api/src/com/intellij/openapi/startup/StartupActivity.kt) for execution with 5 seconds delay in background thread (2019.3 or later).
|
||||||
|
|
||||||
Any long-running or CPU intensive tasks should be made visible to users by using `ProgressManager.run(Task.Backgroundable)`.
|
Any long-running or CPU intensive tasks should be made visible to users by using `ProgressManager.run(Task.Backgroundable)`.
|
||||||
Access to indices must be wrapped with `DumbService`, see also [General Threading Rules](general_threading_rules.md).
|
Access to indices must be wrapped with `DumbService`, see also [General Threading Rules](general_threading_rules.md).
|
||||||
|
|
||||||
See also [](ide_infrastructure.md#running-tasks-once).
|
See also [](ide_infrastructure.md#running-tasks-once).
|
||||||
|
|
||||||
|
</tab>
|
||||||
|
|
||||||
|
</tabs>
|
||||||
|
|
||||||
### Project and Application Close
|
### Project and Application Close
|
||||||
|
|
||||||
To execute code on project closing or application shutdown, implement the [`Disposable`](%gh-ic%/platform/util/src/com/intellij/openapi/Disposable.java) interface in a [Service](plugin_services.md) and place the code in the `dispose()` method.
|
To execute code on project closing or application shutdown, implement the [`Disposable`](%gh-ic%/platform/util/src/com/intellij/openapi/Disposable.java) interface in a [Service](plugin_services.md) and place the code in the `dispose()` method.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user