2.07 global-setting reset default | 全局设置 复位默认值 fixed #19

This commit is contained in:
林万程
2022-12-11 22:09:44 +08:00
parent a37d7b86cc
commit 9c6c811eec
9 changed files with 45 additions and 4 deletions

View File

@@ -36,7 +36,7 @@ public class DocFilter {
String[] split = LINE_SEPARATOR_PATTERN.split(text);
int lineCount = 0;
@NotNull StringBuilder sb = new StringBuilder();
for (String s : split) {
for (@NotNull String s : split) {
if (deletePrefix) {
s = DOC_PATTERN.matcher(s).replaceAll("");
}

View File

@@ -15,6 +15,7 @@ import java.awt.*;
public class AppSettingsComponent extends AbstractSettingsComponent {
private final JPanel myMainPanel;
private final JButton resetDefault = new JButton("Reset default ");
private final JBCheckBox showTreeComment = new JBCheckBox("Show tree comment ");
private final JBCheckBox compact = new JBCheckBox("compact ");
private final JBTextField treeTags = new JBTextField();
@@ -41,10 +42,12 @@ public class AppSettingsComponent extends AbstractSettingsComponent {
public AppSettingsComponent() {
myMainPanel = FormBuilder.createFormBuilder()
.addComponent(resetDefault, 1)
.addComponent(showPanel(), 1)
.addComponent(lineEndFilterPanel(), 1)
.addComponentFillVertically(new JPanel(), 0)
.getPanel();
resetDefault.addActionListener(e -> AppSettingsConfigurable.reset(AppSettingsState.DEFAULT_SETTING, this));
}
@NotNull

View File

@@ -109,6 +109,10 @@ public class AppSettingsConfigurable implements Configurable {
@Override
public void reset() {
@NotNull AppSettingsState settings = AppSettingsState.getInstance();
reset(settings, mySettingsComponent);
}
static void reset(@NotNull AppSettingsState settings, AppSettingsComponent mySettingsComponent) {
mySettingsComponent.setShowTreeComment(settings.showTreeComment);
mySettingsComponent.setCompact(settings.compact);

View File

@@ -21,6 +21,8 @@ import java.util.Locale;
)
public class AppSettingsState extends AbstractSettingsState implements PersistentStateComponent<AppSettingsState> {
public static final AppSettingsState DEFAULT_SETTING = new AppSettingsState();
public boolean showTreeComment = true;
public boolean compact = true;