Changeset 12


Ignore:
Timestamp:
05/01/08 17:55:18 (16 years ago)
Author:
ra33
Message:

Remove non alpha numeric chars from frameset names

Location:
trunk/src/org/expeditee/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/Browser.java

    r10 r12  
    7878                UserSettings.Init();
    7979                UserSettings.Username = System.getProperty("user.name");
    80                 Frame profile = FrameIO.LoadProfile(UserSettings.Username);
     80                String userName = FrameIO.ConvertToValidFramesetName(UserSettings.Username);
     81                Frame profile = FrameIO.LoadProfile(userName);
    8182                if (profile == null) {
    8283                        try {
    83                                 profile = FrameIO.CreateNewProfile(UserSettings.Username);
     84                                profile = FrameIO.CreateNewProfile(userName);
    8485                        } catch (Exception e) {
    8586                                //TODO tell the user that there was a problem creating the profile frame and close nicely
  • trunk/src/org/expeditee/gui/FrameIO.java

    r10 r12  
    774774        }
    775775
    776         private static String NameValidation(String toValidate) throws Exception {
     776        public static String ConvertToValidFramesetName(String toValidate) {
    777777                String result = "";
    778778
     
    781781                        char cur = toValidate.charAt(i);
    782782
    783                         // check for illegal characters
    784                         if (ILLEGAL_CHARS.contains("" + cur)) {
    785                                 throw new Exception(
    786                                                 "Frameset name contains illegal character '" + cur
    787                                                                 + "' at position " + (i + 1));
    788                         }
    789 
    790783                        // capitalize all characters after spaces
    791                         if (cur == ' ') {
    792                                 capital = true;
    793                         } else {
     784                        if (Character.isLetterOrDigit(cur)) {
    794785                                if (capital) {
    795786                                        capital = false;
     
    799790
    800791                                if (result.length() >= MAX_NAME_LENGTH) {
    801                                         throw new Exception("Frameset name is too long (Max "
    802                                                         + MAX_NAME_LENGTH + " characters)");
     792                                        result = result.substring(0,MAX_NAME_LENGTH);
    803793                                }
    804                         }
    805                 }
    806 
     794                        } else {
     795                                capital = true;
     796                        }
     797                }
     798               
    807799                return result;
    808800        }
     
    900892
    901893                // ensure the framename is valid
    902                 frameset = NameValidation(frameset);
     894                frameset = ConvertToValidFramesetName(frameset);
    903895
    904896                if (frameset == null)
     
    970962                if (!FrameIO.DoesFramesetExist(framesetName))
    971963                        return false;
    972                
     964
    973965                for (String path : UserSettings.FrameDirs) {
    974966                        String source = path + framesetName.toLowerCase() + File.separator;
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r8 r12  
    13231323                        Frame linkTo = FrameIO.CreateNewFrameset(text.getFirstLine());
    13241324                        DisplayIO.setCursor(Item.DEFAULT_CURSOR);
    1325 
    13261325                        text.setLink(linkTo.getFrameName());
    1327 
    13281326                        text.getParent().setChanged(true);
    13291327                        FrameUtils.DisplayFrame(linkTo, true);
Note: See TracChangeset for help on using the changeset viewer.