-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToggleGreetingAction.java
More file actions
45 lines (38 loc) · 1.52 KB
/
Copy pathToggleGreetingAction.java
File metadata and controls
45 lines (38 loc) · 1.52 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
package dev.simplified.tabsimile.header;
import com.intellij.ide.ActivityTracker;
import com.intellij.openapi.actionSystem.ActionUpdateThread;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.DumbAware;
import org.jetbrains.annotations.NotNull;
/**
* The single checkable entry inside the right-hand header menu.
*
* <p>
* A {@link ToggleAction} renders with a checkmark in a popup menu and needs only the
* two accessors below - the action system paints the state rather than the action
* doing it.
*/
public final class ToggleGreetingAction extends ToggleAction implements DumbAware {
/** Constructs the greeting toggle. */
public ToggleGreetingAction() {
super("Show Greeting");
}
@Override
public boolean isSelected(@NotNull AnActionEvent event) {
return GreetingState.getInstance().isVisible();
}
@Override
public void setSelected(@NotNull AnActionEvent event, boolean state) {
GreetingState.getInstance().setVisible(state);
// Toolbars re-run update() on their own schedule, so without a nudge the
// greeting label would appear or vanish only on the next unrelated UI event.
// Bumping the activity count is the supported way to say "action state
// changed underneath you".
ActivityTracker.getInstance().inc();
}
@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
}