forked from DetachHead/rebased
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReSTService.java
More file actions
79 lines (62 loc) · 2.64 KB
/
Copy pathReSTService.java
File metadata and controls
79 lines (62 loc) · 2.64 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.jetbrains.python;
import com.intellij.openapi.components.RoamingType;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.module.Module;
import com.jetbrains.python.defaultProjectAwareService.PyDefaultProjectAwareModuleConfiguratorImpl;
import com.jetbrains.python.defaultProjectAwareService.PyDefaultProjectAwareService;
import com.jetbrains.python.defaultProjectAwareService.PyDefaultProjectAwareServiceClasses;
import com.jetbrains.python.defaultProjectAwareService.PyDefaultProjectAwareServiceModuleConfigurator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class ReSTService extends PyDefaultProjectAwareService<
ReSTService.ServiceState, ReSTService, ReSTService.AppService, ReSTService.ModuleService> {
static final String MODULE_STATE_COMPONENT = "ReSTService";
private static final PyDefaultProjectAwareServiceClasses<ServiceState, ReSTService, AppService, ModuleService, ReSTServiceFactory> SERVICE_CLASSES =
new PyDefaultProjectAwareServiceClasses<>(AppService.class, ReSTServiceFactory.class);
protected ReSTService() {
super(new ServiceState());
}
protected ReSTService(Module module) {
super(new ServiceState(), MODULE_STATE_COMPONENT, ReSTService.ServiceState.class, module);
}
public final void setWorkdir(String workDir) {
var state = getState();
state.DOC_DIR = workDir;
if (myModule != null) {
loadState(state);
}
}
public static ReSTService getInstance(@Nullable Module module) {
return SERVICE_CLASSES.getService(module);
}
public static @NotNull PyDefaultProjectAwareServiceModuleConfigurator getConfigurator() {
return new PyDefaultProjectAwareModuleConfiguratorImpl<>(SERVICE_CLASSES);
}
public final String getWorkdir() {
return getState().DOC_DIR;
}
public final boolean txtIsRst() {
return getState().TXT_IS_RST;
}
public final void setTxtIsRst(boolean isRst) {
var state = getState();
state.TXT_IS_RST = isRst;
if (myModule != null) {
loadState(state);
}
}
public static final class ServiceState {
public String DOC_DIR = "";
public boolean TXT_IS_RST = false;
}
@State(name = "AppReSTService", storages = @Storage(value = "ReSTService.xml", roamingType = RoamingType.DISABLED))
public static final class AppService extends ReSTService {
}
public static final class ModuleService extends ReSTService {
ModuleService(Module module) {
super(module);
}
}
}