mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-29 01:37:51 +08:00
persisting_state_of_components.md: add dummy getInstance() method to code sample for clarification
This commit is contained in:
parent
b47aa4671d
commit
a77d8ab0ac
@ -1,6 +1,6 @@
|
|||||||
[//]: # (title: Persisting State of Components)
|
[//]: # (title: Persisting State of Components)
|
||||||
|
|
||||||
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
<!-- Copyright 2000-2021 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
||||||
|
|
||||||
The IntelliJ Platform provides an API that allows components or services to persist their state between restarts of the IDE.
|
The IntelliJ Platform provides an API that allows components or services to persist their state between restarts of the IDE.
|
||||||
You can use either a simple API to persist a few values or persist the state of more complicated components using the [`PersistentStateComponent`](upsource:///platform/projectModel-api/src/com/intellij/openapi/components/PersistentStateComponent.java) interface.
|
You can use either a simple API to persist a few values or persist the state of more complicated components using the [`PersistentStateComponent`](upsource:///platform/projectModel-api/src/com/intellij/openapi/components/PersistentStateComponent.java) interface.
|
||||||
@ -42,6 +42,10 @@ In the former case, the state class instance is typically stored as a field in t
|
|||||||
@State(...)
|
@State(...)
|
||||||
class MyService implements PersistentStateComponent<MyService.State> {
|
class MyService implements PersistentStateComponent<MyService.State> {
|
||||||
|
|
||||||
|
public static MyService getInstance() {
|
||||||
|
// implementation according to Application/Project level service
|
||||||
|
}
|
||||||
|
|
||||||
static class State {
|
static class State {
|
||||||
public String value;
|
public String value;
|
||||||
}
|
}
|
||||||
@ -187,4 +191,4 @@ Components save their state in the following files:
|
|||||||
|
|
||||||
* Project-level: project (`.ipr`) file.
|
* Project-level: project (`.ipr`) file.
|
||||||
However, if the workspace option in the `plugin.xml` file is set to `true`, then the workspace (`.iws`) file is used instead.
|
However, if the workspace option in the `plugin.xml` file is set to `true`, then the workspace (`.iws`) file is used instead.
|
||||||
* Module-level: module (`.iml`) file.
|
* Module-level: module (`.iml`) file.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user