Ignore:
Timestamp:
05/01/08 15:12:45 (16 years ago)
Author:
ra33
Message:

Displaying better error messages when trying to create a frameset with a name that already exists.

File:
1 edited

Legend:

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

    r7 r8  
    1111import java.util.HashMap;
    1212
     13import org.expeditee.agents.ExistingFramesetException;
    1314import org.expeditee.io.Conversion;
    1415import org.expeditee.io.ExpReader;
     
    418419                int lastNumber = FrameIO.getLastNumber(DELETED_FRAMES);
    419420                String framePath;
    420                 try{
     421                try {
    421422                        // create the new frameset
    422423                        Frame one = FrameIO.CreateFrameset(DELETED_FRAMES, toDelete.path);
    423424                        framePath = one.path;
    424425                        lastNumber = 0;
    425                 } catch(Exception e){
     426                } catch (Exception e) {
    426427                        Frame zero = FrameIO.LoadFrame(DELETED_FRAMES + "0");
    427428                        framePath = zero.path;
     
    565566         * @return The first Frame of the new Frameset (Frame.1)
    566567         */
    567         public static Frame CreateFrameset(String frameset, String path) throws Exception{
     568        public static Frame CreateFrameset(String frameset, String path)
     569                        throws Exception {
    568570                return CreateFrameset(frameset, path, false);
    569571        }
     
    585587
    586588                // String must begin with a letter and end with a digit
    587                 if (!(Character.isLetter(frameName.charAt(0)) || Character.isDigit(frameName.charAt(0)))
     589                if (!(Character.isLetter(frameName.charAt(0)) || Character
     590                                .isDigit(frameName.charAt(0)))
    588591                                || !Character.isDigit(frameName.charAt(frameName.length() - 1)))
    589592                        return false;
     
    713716        }
    714717
    715         public static Frame CreateNewProfile(String username) throws Exception{
     718        public static Frame CreateNewProfile(String username) throws Exception {
    716719                Frame profile = CreateFrameset(username, PROFILE_PATH);
    717720                FrameUtils.CreateDefaultProfile(profile);
     
    771774        }
    772775
    773         private static String NameValidation(String toValidate) throws Exception{
     776        private static String NameValidation(String toValidate) throws Exception {
    774777                String result = "";
    775778
     
    780783                        // check for illegal characters
    781784                        if (ILLEGAL_CHARS.contains("" + cur)) {
    782                                 throw new Exception("Frameset name contains illegal character '"
    783                                                                 + cur + "' at position " + (i + 1));
     785                                throw new Exception(
     786                                                "Frameset name contains illegal character '" + cur
     787                                                                + "' at position " + (i + 1));
    784788                        }
    785789
     
    796800                                if (result.length() >= MAX_NAME_LENGTH) {
    797801                                        throw new Exception("Frameset name is too long (Max "
    798                                                                         + MAX_NAME_LENGTH + " characters)");
     802                                                        + MAX_NAME_LENGTH + " characters)");
    799803                                }
    800804                        }
     
    835839         *         frame)
    836840         */
    837         public static Frame CreateNewFrameset(String name) throws Exception{
     841        public static Frame CreateNewFrameset(String name) throws Exception {
    838842                String path = DisplayIO.getCurrentFrame().path;
    839843
     
    887891
    888892        public static Frame CreateFrameset(String frameset, String path,
    889                         boolean recreate) throws Exception{
     893                        boolean recreate) throws Exception {
    890894                String conversion = frameset + " --> ";
    891895
     
    897901
    898902                if (!recreate && FrameIO.DoesFramesetExist(frameset)) {
    899                         throw new Exception("A frameset called " + frameset + " already exists.");
     903                        throw new ExistingFramesetException(frameset);
    900904                }
    901905
Note: See TracChangeset for help on using the changeset viewer.