Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added descriptions to GUI settings #78

Merged
merged 5 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading