Revision: 3818
Author: [email protected]
Date: Fri Jul 30 09:12:50 2010
Log: NEW - bug 2910: Project names should be unique
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2910

Fixed the ServerProjectsManagerPanel to enforce unique project names (ignoring case and leading/trailing spaces).
http://code.google.com/p/power-architect/source/detail?r=3818

Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ServerProjectsManagerPanel.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ServerProjectsManagerPanel.java Fri Jul 16 08:41:08 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/enterprise/ServerProjectsManagerPanel.java Fri Jul 30 09:12:50 2010
@@ -83,12 +83,20 @@
String name = JOptionPane.showInputDialog(dialogOwner, "Please specify the name of your project", "", JOptionPane.QUESTION_MESSAGE);

                 if (name != null) {
+ DefaultListModel model = (DefaultListModel) projects.getModel();
+                    for (int i = 0; i < model.size(); i++) {
+ if (((ProjectLocation) model.getElementAt(i)).getName().trim().equalsIgnoreCase(name.trim())) { + JOptionPane.showMessageDialog(dialogOwner, "A project called \"" + name + "\" already exists. Please use a different name.", "Duplicate project name", JOptionPane.ERROR_MESSAGE);
+                            return;
+                        }
+                    }
+
                     try {
ArchitectClientSideSession.createNewServerSession(getSelectedServerInfo(), name, session);
                     } catch (Exception ex) {
throw new RuntimeException("Unable to create new project", ex);
                     }
-
+
                     refreshInfoList();
                 }
             }
@@ -389,7 +397,7 @@
List<ProjectLocation> projects = ArchitectClientSideSession.getWorkspaceNames(serviceInfo); Collections.sort(projects, new Comparator<ProjectLocation>() { public int compare(ProjectLocation proj1, ProjectLocation proj2) { - return proj1.getName().toUpperCase().compareTo(proj2.getName().toUpperCase()); + return proj1.getName().compareToIgnoreCase(proj2.getName());
                     }
                 });

Reply via email to