This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 254320
Collapse All | Expand All

(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/Bundle.properties (+2 lines)
Lines 152-157 Link Here
152
ERR_Project_Name_Must_Entered=Project name must be entered.
152
ERR_Project_Name_Must_Entered=Project name must be entered.
153
ERR_Location_Read_Only=Project location is read only.
153
ERR_Location_Read_Only=Project location is read only.
154
ERR_Not_Valid_Filename=Project name "{0}" is not a valid filename.
154
ERR_Not_Valid_Filename=Project name "{0}" is not a valid filename.
155
ERR_Not_Valid_Foldername=Folder name "{0}" is not valid.
156
ERR_Trailing_Whitespace=Folder name "{0}" contains trailing whitespace.
155
157
156
LBL_savingDataLabel=Saving Project data ...
158
LBL_savingDataLabel=Saving Project data ...
157
LBL_Saving_Project_data=Saving Project data
159
LBL_Saving_Project_data=Saving Project data
(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/DefaultProjectOperationsImplementation.java (-3 / +31 lines)
Lines 756-778 Link Here
756
        if (projectNameText.indexOf('/') != -1 || projectNameText.indexOf('\\') != -1) {
756
        if (projectNameText.indexOf('/') != -1 || projectNameText.indexOf('\\') != -1) {
757
            return NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "ERR_Not_Valid_Filename", projectNameText);
757
            return NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "ERR_Not_Valid_Filename", projectNameText);
758
        }
758
        }
759
        if (hasTrailingWhiteSpace(projectNameText)) {
760
            return NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "ERR_Trailing_Whitespace", projectNameText); //NOI18N
761
        }
759
762
760
        if (location == null) {
763
        if (location == null) {
761
            return null; // #199241: skip other checks for remote projects
764
            return null; // #199241: skip other checks for remote projects
762
        }
765
        }
763
766
764
        File parent = location;
767
        File parent = location;
768
        String checkFileRes = null; // result of check of last path segment
765
        if (!location.exists()) {
769
        if (!location.exists()) {
766
            //if some dirs in teh chain are not created, consider it ok.
770
            //if some dirs in teh chain are not created, consider it ok.
771
            checkFileRes = checkFileOrFolderName(parent);
767
            parent = location.getParentFile();
772
            parent = location.getParentFile();
768
            while (parent != null && !parent.exists()) {
773
            while (parent != null && !parent.exists() && checkFileRes == null) {
774
                checkFileRes = checkFileOrFolderName(parent);
769
                parent = parent.getParentFile();
775
                parent = parent.getParentFile();
770
            }
776
            }
771
            if (parent == null) {
777
            if (parent == null) {
772
                return NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "ERR_Location_Does_Not_Exist");
778
                return NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "ERR_Location_Does_Not_Exist");
773
            }
779
            }
774
        }
780
        }
775
        
781
        if (checkFileRes != null) {
782
            return checkFileRes;
783
        }
784
776
        if (!parent.canWrite()) {
785
        if (!parent.canWrite()) {
777
            return NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "ERR_Location_Read_Only");
786
            return NbBundle.getMessage(DefaultProjectOperationsImplementation.class, "ERR_Location_Read_Only");
778
        }
787
        }
Lines 790-796 Link Here
790
        
799
        
791
        return null;
800
        return null;
792
    }
801
    }
793
    
802
803
    private static boolean hasTrailingWhiteSpace(String s) {
804
        return s.matches("(^\\s.*)|(.*\\s$)");                          //NOI18N
805
    }
806
807
    private static String checkFileOrFolderName(File f) {
808
        String n = f.getName();
809
        if (hasTrailingWhiteSpace(n)) {
810
            return NbBundle.getMessage(
811
                    DefaultProjectOperationsImplementation.class,
812
                    "ERR_Trailing_Whitespace", n);                      //NOI18N
813
        } else if (n.contains("/") || n.contains("\\")) {               //NOI18N
814
            return NbBundle.getMessage(
815
                    DefaultProjectOperationsImplementation.class,
816
                    "ERR_Not_Valid_Foldername", n);                     //NOI18N
817
        } else {
818
            return null;
819
        }
820
    }
821
794
    private static void close(final Project prj) {
822
    private static void close(final Project prj) {
795
        LifecycleManager.getDefault().saveAll();
823
        LifecycleManager.getDefault().saveAll();
796
        OpenProjects.getDefault().close(new Project[] {prj});
824
        OpenProjects.getDefault().close(new Project[] {prj});

Return to bug 254320