Skip to content

Commit

Permalink
Merge pull request #78 from mkacct/feature-settings-descriptions
Browse files Browse the repository at this point in the history
Added descriptions to GUI settings
  • Loading branch information
mkacct authored May 14, 2024
2 parents 5379fd2 + 49534cb commit 5e9e4bc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/main/java/datasource/configspec/ConfigSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ public static final class Section {
private static final String DEFAULT_ENTITY_TYPE = "check";

public final String title;
public final String desc;

private final String checkName;
private final String entityType;
private final List<Setting> settings;

public Section(String title, String checkName, String entityTypeOverride, List<Setting> settings) {
public Section(String title, String checkName, String desc, String entityTypeOverride, List<Setting> settings) {
if (title == null) {throw new NullPointerException("title");}
this.title = title;
this.checkName = checkName;
this.desc = desc;
this.entityType = (checkName != null) ? ((entityTypeOverride != null) ? entityTypeOverride : DEFAULT_ENTITY_TYPE) : null;
this.settings = (settings != null) ? new ArrayList<Setting>(settings) : null;
}
Expand Down Expand Up @@ -79,6 +81,7 @@ public boolean equals(Object obj) {
Section other = (Section)obj;
return CmpUtil.areEqual(this.title, other.title)
&& CmpUtil.areEqual(this.checkName, other.checkName)
&& CmpUtil.areEqual(this.desc, other.desc)
&& CmpUtil.areEqual(this.entityType, other.entityType)
&& CmpUtil.areEqual(this.settings, other.settings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private List<ConfigSpec.Section> readSections(JSONArray sectionsJson, Map<String
sections.add(new ConfigSpec.Section(
sectionJson.getString("title"),
getStringOrNull(sectionJson, "checkName"),
getStringOrNull(sectionJson, "desc"),
getStringOrNull(sectionJson, "entityTypeOverride"),
readSettings(sectionJson, selects)
));
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/gui/SettingsWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ private JPanel initInnerPanel() {
private JLabel initTitleLabel(JPanel innerPanel, ConfigSpec.Section section) {
JLabel titleLabel = GuiUtil.createHeading(section.title);
innerPanel.add(titleLabel);
if (section.desc != null) {
JLabel descLabel = new JLabel(section.desc);
innerPanel.add(descLabel);
}
innerPanel.add(Box.createVerticalStrut(GuiUtil.PAD));
return titleLabel;
}
Expand Down
33 changes: 22 additions & 11 deletions src/main/resources/config-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,28 @@
},
{
"title": "No Global Variables",
"checkName": "noGlobalVariables"
"checkName": "noGlobalVariables",
"desc": "Checks for static, non-final fields."
},
{
"title": "Required Overrides",
"checkName": "requiredOverrides"
"checkName": "requiredOverrides",
"desc": "Checks for classes that extends the Comparable interface and implements compareTo() without implementing equals() and classes that implement equals() without implementing hashCode()."
},
{
"title": "Unused Abstractions",
"checkName": "unusedAbstractions"
"checkName": "unusedAbstractions",
"desc": "Checks for any abstract classes that don't have any classes that extend it, or interfaces that don't have any classes implementing it."
},
{
"title": "Immutable Exceptions",
"checkName": "immutableExceptions"
"checkName": "immutableExceptions",
"desc": "Checks for exception classes without non-final fields. Any class whose name ends with 'Exception' or 'Error' will be checked."
},
{
"title": "Information Hiding",
"checkName": "informationHiding"
"checkName": "informationHiding",
"desc": "Checks for classes whose fields violate information hiding"
},
{
"title": "Program to Interface, Not Implementation",
Expand All @@ -147,7 +152,8 @@
"type": "String[]",
"desc": "List of user-specified allowed dependencies (add known interfaces and/or data classes here)."
}
]
],
"desc": "Checks for classes who program to concrete implementations rather than interfaces. Programming to interfaces generally provides more flexibility in applications."
},
{
"title": "Low Coupling",
Expand Down Expand Up @@ -178,11 +184,13 @@
"type": "boolean",
"desc": "Specifies whether Classes that reference themselves will be reported (cycles like A → A). Defaults to true."
}
]
],
"desc": "Checks for classes who are too closely dependent on one another, when alternative solutions allowing such classes to exist more independently are available."
},
{
"title": "Strategy Pattern",
"checkName": "strategyPattern"
"checkName": "strategyPattern",
"desc": "Checks if a class implements the Strategy pattern by checking for interfaces in its fields and if a concrete subclass implements it."
},
{
"title": "Observer Pattern",
Expand All @@ -203,11 +211,13 @@
"type": "boolean",
"desc": "Specifies whether to check for patterns with only a concrete subject, and no abstract subject."
}
]
],
"desc": "Checks if classes properly implement ways to notify multiple objects about events its observing. The observer pattern allows classes to subscribe and unsubscribe from watching for a certain event."
},
{
"title": "Adapter Pattern",
"checkName": "adapterPattern"
"checkName": "adapterPattern",
"desc": "Check if an adapter class does not implement an interface."
},
{
"title": "Constant Interface",
Expand All @@ -218,7 +228,8 @@
"type": "boolean",
"desc": "If true, interfaces with no fields nor methods (\"marker interfaces\") will be ignored. (Defaults to false.)"
}
]
],
"desc": "Checks for any interfaces that contains only fields and no methods. This is similar to Data Classes."
},
{
"title": "PlantUML Generator",
Expand Down

0 comments on commit 5e9e4bc

Please sign in to comment.