From 26eebed8fddc7f75a5deff34441174ed558d3529 Mon Sep 17 00:00:00 2001 From: pras0131 Date: Mon, 23 Sep 2024 19:09:00 +0200 Subject: [PATCH] Fix to allow only radio button to be selected (#32) --- .../eclipse/amazonq/views/FeedbackDialog.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/FeedbackDialog.java b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/FeedbackDialog.java index 0fdda025..400a194b 100644 --- a/plugin/src/software/aws/toolkits/eclipse/amazonq/views/FeedbackDialog.java +++ b/plugin/src/software/aws/toolkits/eclipse/amazonq/views/FeedbackDialog.java @@ -213,8 +213,22 @@ private void createQuestionSection(final Composite container) { RowLayout sentimentContainerLayout = new RowLayout(SWT.HORIZONTAL); sentimentContainerLayout.spacing = 0; sentimentContainer.setLayout(sentimentContainerLayout); - createCustomRadioButton(sentimentContainer, "icons/HappyFace.png", "Satisfied", SWT.NONE, true); - createCustomRadioButton(sentimentContainer, "icons/FrownyFace.png", "Unsatisfied", SWT.NONE, false); + CustomRadioButton positiveSentimentButton = createCustomRadioButton(sentimentContainer, "icons/HappyFace.png", "Satisfied", SWT.NONE, true); + CustomRadioButton negativeSentimentButton = createCustomRadioButton(sentimentContainer, "icons/FrownyFace.png", "Unsatisfied", SWT.NONE, false); + positiveSentimentButton.getRadioButton().addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + negativeSentimentButton.getRadioButton().setSelection(false); + selectedSentiment = Sentiment.POSITIVE; + } + }); + negativeSentimentButton.getRadioButton().addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + positiveSentimentButton.getRadioButton().setSelection(false); + selectedSentiment = Sentiment.NEGATIVE; + } + }); createLabel(questionsContainer, "What do you like about the AWS Toolkit? What can we improve?"); @@ -266,15 +280,10 @@ private void createSeparator(final Composite parent) { separatorLabel.setLayoutData(separatorGithubLayout); } - private void createCustomRadioButton(final Composite parent, final String imagePath, final String text, final int style, final boolean isSelected) { + private CustomRadioButton createCustomRadioButton(final Composite parent, final String imagePath, final String text, final int style, final boolean isSelected) { CustomRadioButton button = new CustomRadioButton(parent, loadImage(imagePath), text, style); button.getRadioButton().setSelection(isSelected); - button.getRadioButton().addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(final SelectionEvent e) { - // Handle button selection - } - }); + return button; } private String getBodyMessageForReportIssueOrRequestFeature() {