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

Fix to allow only one radio button to be selected #32

Merged
merged 1 commit into from
Sep 23, 2024
Merged
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
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