netbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lkisha...@apache.org
Subject [netbeans] branch master updated: NETBEANS-3685 New Group dialog allows to create a (none) group which can't be removed
Date Mon, 13 Jan 2020 17:31:47 GMT
This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e0710b  NETBEANS-3685 New Group dialog allows to create a (none) group which can't
be removed
4e0710b is described below

commit 4e0710b4611aeda2c5d528dac1af9fd7d5a5c7de
Author: Ludovic HOCHET <lhochet@gmail.com>
AuthorDate: Sun Jan 12 21:07:18 2020 +0100

    NETBEANS-3685 New Group dialog allows to create a (none) group which can't be removed
    
    Add checks to prevent adding/editing a group named (none), set error messages to 'group
exists' where applicable, also changes the visibility of ManageGroupsPanel.NONE_GOUP to package
private (instead of private) to check for the same name
---
 .../src/org/netbeans/modules/project/ui/groups/GroupEditPanel.java | 5 +++++
 .../org/netbeans/modules/project/ui/groups/ManageGroupsPanel.java  | 2 +-
 .../src/org/netbeans/modules/project/ui/groups/NewGroupPanel.java  | 7 +++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ide/projectui/src/org/netbeans/modules/project/ui/groups/GroupEditPanel.java
b/ide/projectui/src/org/netbeans/modules/project/ui/groups/GroupEditPanel.java
index 2194601..a6a63d6 100644
--- a/ide/projectui/src/org/netbeans/modules/project/ui/groups/GroupEditPanel.java
+++ b/ide/projectui/src/org/netbeans/modules/project/ui/groups/GroupEditPanel.java
@@ -25,6 +25,7 @@ import java.util.Set;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
 import static org.netbeans.modules.project.ui.groups.Bundle.*;
+import static org.netbeans.modules.project.ui.groups.ManageGroupsPanel.NONE_GOUP;
 import static org.netbeans.modules.project.ui.groups.NewGroupPanel.MAX_NAME;
 import org.netbeans.spi.project.ui.support.ProjectCustomizer;
 import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category;
@@ -57,6 +58,10 @@ public abstract class GroupEditPanel extends JPanel{
             }
             Set<Group> otherGroups = Group.allGroups();
             otherGroups.remove(actualGroup);
+            if (name.equalsIgnoreCase(NONE_GOUP)) {
+                getCategory().setErrorMessage(WARN_GroupExists());
+                return false;
+            }
             for (Group group : otherGroups) {
                 if (name.equalsIgnoreCase(group.getName())) {
                     getCategory().setErrorMessage(WARN_GroupExists());
diff --git a/ide/projectui/src/org/netbeans/modules/project/ui/groups/ManageGroupsPanel.java
b/ide/projectui/src/org/netbeans/modules/project/ui/groups/ManageGroupsPanel.java
index bbba1ab..bd88a04 100644
--- a/ide/projectui/src/org/netbeans/modules/project/ui/groups/ManageGroupsPanel.java
+++ b/ide/projectui/src/org/netbeans/modules/project/ui/groups/ManageGroupsPanel.java
@@ -43,7 +43,7 @@ public class ManageGroupsPanel extends javax.swing.JPanel implements PropertyCha
 
     private static final RequestProcessor RP = new RequestProcessor(ManageGroupsPanel.class.getName());
     
-    private static final String NONE_GOUP = "(none)";
+    static final String NONE_GOUP = "(none)";
     
     /**
      * Creates new form ManageGroupPanel
diff --git a/ide/projectui/src/org/netbeans/modules/project/ui/groups/NewGroupPanel.java b/ide/projectui/src/org/netbeans/modules/project/ui/groups/NewGroupPanel.java
index 27ef883..8881059 100644
--- a/ide/projectui/src/org/netbeans/modules/project/ui/groups/NewGroupPanel.java
+++ b/ide/projectui/src/org/netbeans/modules/project/ui/groups/NewGroupPanel.java
@@ -34,6 +34,7 @@ import org.netbeans.api.project.ProjectManager;
 import org.netbeans.api.project.ProjectUtils;
 import org.netbeans.api.project.ui.OpenProjects;
 import static org.netbeans.modules.project.ui.groups.Bundle.*;
+import static org.netbeans.modules.project.ui.groups.ManageGroupsPanel.NONE_GOUP;
 import org.netbeans.spi.project.ui.support.ProjectChooser;
 import org.openide.NotificationLineSupport;
 import org.openide.filesystems.FileObject;
@@ -95,6 +96,9 @@ public class NewGroupPanel extends JPanel {
             if (name.trim().length() <= 0 || name.trim().length() >= MAX_NAME) {
                 return false;
             }
+            if (name.equalsIgnoreCase(NONE_GOUP)) {
+                return false;
+            }
             for (Group group : Group.allGroups()) {
                 if (name.equalsIgnoreCase(group.getName())) {
                     return false;
@@ -536,6 +540,9 @@ public class NewGroupPanel extends JPanel {
             if (name.length() > MAX_NAME) {
                 notificationLineSupport.setErrorMessage(NewGroupPanel_too_long_warning());
             }
+            if (name.equalsIgnoreCase(NONE_GOUP)) {
+                notificationLineSupport.setErrorMessage(NewGroupPanel_exists_warning());
+            }
             for (Group group : Group.allGroups()) {
                 if (name.equalsIgnoreCase(group.getName())) {
                     notificationLineSupport.setErrorMessage(NewGroupPanel_exists_warning());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Mime
View raw message