b2bc22b0d18bd0f4caa9c203f94296afb2583372
[idea/community.git] / python / educational-python / student-python / src / com / jetbrains / edu / learning / settings / PyStudySettings.java
1 package com.jetbrains.edu.learning.settings;
2
3 import com.intellij.openapi.components.PersistentStateComponent;
4 import com.intellij.openapi.components.ServiceManager;
5 import com.intellij.openapi.components.State;
6 import com.intellij.openapi.components.Storage;
7 import com.intellij.openapi.project.Project;
8 import org.jetbrains.annotations.NotNull;
9 import org.jetbrains.annotations.Nullable;
10
11 @SuppressWarnings("MethodMayBeStatic")
12 @State(name = "PyStudySettings", storages = @Storage("py_study_settings.xml"))
13 public class PyStudySettings implements PersistentStateComponent<PyStudySettings.State> {
14
15   private State myState = new State();
16
17
18   public static class State {
19     public boolean askToTweet = true;
20   }
21
22   public static PyStudySettings getInstance(@NotNull final Project project) {
23     return ServiceManager.getService(project, PyStudySettings.class);
24   }
25   @Nullable
26   @Override
27   public State getState() {
28     return myState;
29   }
30
31   @Override
32   public void loadState(State state) {
33     myState = state;
34   }
35   
36   public boolean askToTweet() {
37     return myState.askToTweet;
38   }
39   
40   public void setAskToTweet(final boolean askToTweet) {
41     myState.askToTweet = askToTweet;
42   }
43 }