-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGreetingState.java
More file actions
52 lines (46 loc) · 1.58 KB
/
Copy pathGreetingState.java
File metadata and controls
52 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package dev.simplified.tabsimile.header;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import dev.simplified.tabsimile.session.SessionManager;
import org.jetbrains.annotations.NotNull;
/**
* Whether the greeting label is showing in the header.
*
* <p>
* Application-level rather than project-level, which is what makes one toggle apply
* to every open Tabsimile tool window at once instead of only the window it was
* flipped in. The state lives in memory and is deliberately not persisted - there is
* no {@code PersistentStateComponent} here, so it resets when the IDE restarts.
*
* <p>
* Contrast {@link SessionManager}, which is the same idea one scope down: a project
* service, because session tabs belong to a project rather than to the application.
*/
@Service(Service.Level.APP)
public final class GreetingState {
private boolean visible;
/**
* Returns the application-wide greeting state.
*
* @return the single greeting-state instance
*/
public static @NotNull GreetingState getInstance() {
return ApplicationManager.getApplication().getService(GreetingState.class);
}
/**
* Returns whether the greeting label should be painted.
*
* @return true while the label is showing
*/
public boolean isVisible() {
return this.visible;
}
/**
* Sets whether the greeting label should be painted.
*
* @param visible true to show the label
*/
public void setVisible(boolean visible) {
this.visible = visible;
}
}