-
Couldn't load subscription status.
- Fork 102
1023: Added an additional path field for UCT configuration dialog (to cover theme folder scanning) #1024
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
1023: Added an additional path field for UCT configuration dialog (to cover theme folder scanning) #1024
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,13 +27,7 @@ | |
| import java.awt.event.WindowAdapter; | ||
| import java.awt.event.WindowEvent; | ||
| import java.util.Objects; | ||
| import javax.swing.JButton; | ||
| import javax.swing.JCheckBox; | ||
| import javax.swing.JComboBox; | ||
| import javax.swing.JComponent; | ||
| import javax.swing.JLabel; | ||
| import javax.swing.JPanel; | ||
| import javax.swing.KeyStroke; | ||
| import javax.swing.*; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| @SuppressWarnings({"PMD.TooManyFields", "PMD.ExcessiveImports"}) | ||
|
|
@@ -44,7 +38,9 @@ public class ConfigurationDialog extends AbstractDialog { | |
|
|
||
| private JCheckBox enable; | ||
| private LabeledComponent<TextFieldWithBrowseButton> modulePath; | ||
| private LabeledComponent<TextFieldWithBrowseButton> additionalPath; | ||
| private JCheckBox ignoreCurrentVersion; | ||
| private JCheckBox hasAdditionalPath; | ||
| private JComboBox<ComboBoxItemData> currentVersion; | ||
| private JComboBox<ComboBoxItemData> targetVersion; | ||
| private JComboBox<ComboBoxItemData> issueSeverityLevel; | ||
|
|
@@ -59,6 +55,8 @@ public class ConfigurationDialog extends AbstractDialog { | |
| private JLabel modulePathError;//NOPMD | ||
| private JLabel enableComment;//NOPMD | ||
| private JLabel enableCommentPath;//NOPMD | ||
| private JLabel additionalPathLabel;//NOPMD | ||
| private JLabel additionalPathError;//NOPMD | ||
|
|
||
| /** | ||
| * Configuration dialog. | ||
|
|
@@ -76,6 +74,7 @@ public ConfigurationDialog(final @NotNull Project project) { | |
| setTitle(ConfigureUctAction.ACTION_NAME); | ||
| getRootPane().setDefaultButton(buttonOk); | ||
|
|
||
| hasAdditionalPath.addActionListener(event -> refreshAdditionalFields(hasAdditionalPath.isSelected())); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, call this method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pay attention, this method should be called after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your code review. I fixed. Please check. |
||
| buttonOk.addActionListener(event -> onOK()); | ||
| buttonCancel.addActionListener(event -> onCancel()); | ||
|
|
||
|
|
@@ -98,9 +97,13 @@ public void windowClosing(final WindowEvent event) { | |
| modulePathError.setText(""); | ||
| modulePathError.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); | ||
| modulePathError.setForeground(new Color(252, 119, 83)); | ||
| additionalPathError.setText(""); | ||
| additionalPathError.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); | ||
| additionalPathError.setForeground(new Color(252, 119, 83)); | ||
| enableComment.setForeground(JBColor.blue); | ||
| enableCommentPath.setForeground(JBColor.blue); | ||
| setDefaultValues(); | ||
| refreshAdditionalFields(hasAdditionalPath.isSelected()); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -120,12 +123,19 @@ public static void open(final @NotNull Project project) { | |
| */ | ||
| private void onOK() { | ||
| modulePathError.setText(""); | ||
| additionalPathError.setText(""); | ||
|
|
||
| if (modulePath.getComponent().getText().isEmpty() | ||
| || !UctModulePathValidatorUtil.validate(modulePath.getComponent().getText())) { | ||
| modulePathError.setText("The `Path To Analyse` field is empty or invalid"); | ||
| return; | ||
| } | ||
| if (hasAdditionalPath.isSelected() && additionalPath.getComponent().getText().isEmpty() | ||
| || hasAdditionalPath.isSelected() | ||
| && !UctModulePathValidatorUtil.validate(additionalPath.getComponent().getText())) { | ||
| additionalPathError.setText("The `Path To Analyse` field is empty or invalid"); | ||
| return; | ||
| } | ||
| settingsService.setEnabled(enable.isSelected()); | ||
|
|
||
| final ComboBoxItemData currentVersionItemData = | ||
|
|
@@ -155,7 +165,8 @@ private void onOK() { | |
| ) | ||
| ); | ||
| settingsService.setIgnoreCurrentVersion(ignoreCurrentVersion.isSelected()); | ||
|
|
||
| settingsService.setHasAdditionalPath(hasAdditionalPath.isSelected()); | ||
| settingsService.setAdditionalPath(additionalPath.getComponent().getText()); | ||
| exit(); | ||
| } | ||
|
|
||
|
|
@@ -221,6 +232,15 @@ private void setDefaultValues() { | |
| } | ||
| final Boolean shouldIgnore = settingsService.shouldIgnoreCurrentVersion(); | ||
| ignoreCurrentVersion.setSelected(Objects.requireNonNullElse(shouldIgnore, false)); | ||
|
|
||
| final Boolean isShowAdditionalPath = settingsService.getHasAdditionalPath(); | ||
| hasAdditionalPath.setSelected( | ||
| Objects.requireNonNullElse(isShowAdditionalPath, false) | ||
| ); | ||
|
|
||
| if (settingsService.getAdditionalPath() != null) { | ||
| additionalPath.getComponent().setText(settingsService.getAdditionalPath()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -271,5 +291,20 @@ private void createUIComponents() { | |
| new FileChooserDescriptor(false, true, false, false, false, false) | ||
| ) | ||
| ); | ||
|
|
||
| additionalPath = new LabeledComponent<>(); | ||
| additionalPath.setComponent(new TextFieldWithBrowseButton()); | ||
| additionalPath.getComponent().addBrowseFolderListener( | ||
| new TextBrowseFolderListener( | ||
| new FileChooserDescriptor(false, true, false, false, false, false) | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| private void refreshAdditionalFields(final boolean isEnabled) { | ||
| additionalPath.setEnabled(isEnabled); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your code review. I fixed. Please check. |
||
| additionalPath.setVisible(isEnabled); | ||
| additionalPathLabel.setVisible(isEnabled); | ||
| additionalPathError.setVisible(isEnabled); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, do not use wildcard imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your code review. I fixed. Please check.