mbien commented on code in PR #6772:
URL: https://github.com/apache/netbeans/pull/6772#discussion_r1411513837
##########
ide/projectui/src/org/netbeans/modules/project/ui/groups/GroupsMenu.java:
##########
@@ -137,36 +129,20 @@ private static void manageGroups() {
final JButton select = new JButton();
Mnemonics.setLocalizedText(select, GroupsMenu_manage_select_group());
select.setDefaultCapable(true);
- panel.addPropertyChangeListener(new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getPropertyName().equals("selection")) {
- select.setEnabled(panel.isExactlyOneGroupSelected());
- }
+ panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
+ if (evt.getPropertyName().equals("selection")) {
+ select.setEnabled(panel.isExactlyOneGroupSelected());
}
});
- select.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- RP.post(new Runnable() {
- @Override
- public void run() {
- Group.setActiveGroup(panel.getSelectedGroups()[0],
false);
- }
- });
- }
+ select.addActionListener((ActionEvent e) -> {
+ RP.post(() -> Group.setActiveGroup(panel.getSelectedGroups()[0],
false));
});
final JButton newGroup = new JButton();
newGroup.setDefaultCapable(false);
Mnemonics.setLocalizedText(newGroup, GroupsMenu_manage_new_group());
- newGroup.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- newGroup();
- }
- });
+ // invokeLater ensures that the parent is disposed before the new
dialog opens
+ // so that it can set a parent which doesn't disappear - fixes race
condition
+ newGroup.addActionListener(e ->
SwingUtilities.invokeLater(GroupsMenu::newGroup));
Review Comment:
thats the fix, rest is cleanup.
The UX is a bit weird here since creating a group closes both dialogs - what
if a user wants to create a group and then switch to another group? Or create
two groups?
Not closing the first dialog would require a few more updates, e.g. the list
doesn't update, and UX-wise it would also be not ideal to create a group and
having to press cancel to get out of the dialog (select group reloads the
group).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists