Skip to content

Commit

Permalink
Fix to allow only radio button to be selected (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
pras0131 authored Sep 23, 2024
1 parent 63bec73 commit 26eebed
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?");

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 26eebed

Please sign in to comment.