Changeset 8


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.

Location:
trunk/src/org/expeditee
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/agents/CopyTree.java

    r7 r8  
    3333                _nameFrom = init.getFramesetName().toLowerCase();
    3434
    35                 // get the last used frame in the destination frameset
    36                 _lastNumber = FrameIO.getLastNumber(_nameTo);
     35                // create the new frameset
     36                try {
     37                        // get the last used frame in the destination frameset
     38                        _lastNumber = FrameIO.getLastNumber(_nameTo);
     39                        Frame one = FrameIO.CreateFrameset(_nameTo, init.path);
    3740
    38                 if (_lastNumber < 0) {
    39                         // create the new frameset
    40                         try {
    41                                 Frame one = FrameIO.CreateFrameset(_nameTo, init.path);
     41                        _framePath = one.path;
     42                        _lastNumber = -1;
     43                        _firstNumber = 1;
    4244
    43                                 _framePath = one.path;
    44                                 _lastNumber = -1;
    45                                 _firstNumber = 1;
    46 
    47                                 // copy the original .0 frame
    48                                 Frame zero = FrameIO.LoadFrame(init.getFramesetNameAdjusted()
    49                                                 + "0");
    50                                 processFrame(zero);
    51                         } catch (Exception e) {
    52                                 // TODO fix this up later.
    53                         }
    54                 } else {
     45                        // copy the original .0 frame
     46                        Frame zero = FrameIO
     47                                        .LoadFrame(init.getFramesetNameAdjusted() + "0");
     48                        processFrame(zero);
     49                } catch (ExistingFramesetException efe) {
    5550                        // get the frame path
    5651                        Frame zero = FrameIO.LoadFrame(_nameTo + "0");
    5752                        _framePath = zero.path;
    5853                        _firstNumber = _lastNumber + 1;
     54                } catch (Exception e) {
     55                        return false;
    5956                }
    6057
  • trunk/src/org/expeditee/gui/Browser.java

    r7 r8  
    3838
    3939        public static Browser _theBrowser;
    40        
     40
    4141        /**
    4242         * Constructs a new Browser object, then launches it
     
    5151                // FrameGraphics.ForceRepaint();
    5252        }
    53        
     53
    5454        public void setSizes(Dimension size) {
    5555                setSize(size);
     
    7777                Frame profile = FrameIO.LoadProfile(UserSettings.Username);
    7878                if (profile == null) {
    79                         try{
    80                         profile = FrameIO.CreateNewProfile(UserSettings.Username);
    81                         }catch(Exception e){
    82                                 //TODO fix this later
     79                        try {
     80                                profile = FrameIO.CreateNewProfile(UserSettings.Username);
     81                        } catch (Exception e) {
     82                                //TODO tell the user that there was a problem creating the profile frame and close nicely
     83                                assert(false);
    8384                        }
    8485                }
     
    128129                // Create the action handler for the
    129130                FrameMouseActions mouse = new FrameMouseActions();
    130                
     131
    131132                this.getContentPane().addMouseListener(mouse);
    132133                this.getContentPane().addMouseMotionListener(mouse);
     
    156157                super.paint(g);
    157158                FrameGraphics.Repaint();
    158                 //System.out.print('p');
     159                // System.out.print('p');
    159160        }
    160161
     
    166167                setupGraphics();
    167168                repaint();
    168                 //System.out.println("Resize");
     169                // System.out.println("Resize");
    169170        }
    170171
     
    205206
    206207        public void windowActivated(WindowEvent e) {
    207                 //System.out.println("Activated");
     208                // System.out.println("Activated");
    208209        }
    209210
     
    217218         */
    218219        public void windowStateChanged(WindowEvent e) {
    219                 //FrameGraphics.Repaint();
    220                 //System.out.println('C');
     220                // FrameGraphics.Repaint();
     221                // System.out.println('C');
    221222        }
    222223
  • 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
  • trunk/src/org/expeditee/gui/FrameKeyboardActions.java

    r7 r8  
    88import java.awt.event.KeyEvent;
    99import java.awt.event.KeyListener;
    10 import java.io.IOException;
    1110import java.util.ArrayList;
    1211import java.util.LinkedList;
     
    1615import org.expeditee.actions.Actions;
    1716import org.expeditee.actions.Simple;
     17import org.expeditee.agents.ExistingFramesetException;
    1818import org.expeditee.io.Logger;
    1919import org.expeditee.items.Dot;
     
    13301330                        linkTo.moveMouseToDefaultLocation();
    13311331                        // this needs to be done if the user doesnt move the mouse before
    1332                         // doing
    1333                         // tdfc while the cursor is set to the text cursor
     1332                        // doing Tdfc while the cursor is set to the text cursor
    13341333                        DisplayIO.setCursor(Item.DEFAULT_CURSOR);
    1335                 } catch (IOException ioe) {
    1336                         FrameGraphics
    1337                                         .ErrorMessage("An error occured when trying to create the new frameset");
     1334                } catch (ExistingFramesetException efe) {
     1335                        FrameGraphics.ErrorMessage(efe.getMessage());
    13381336                } catch (Exception e) {
     1337                        FrameGraphics.ErrorMessage("Frameset could not be created: "
     1338                                        + e.getMessage());
    13391339                }
    13401340        }
Note: See TracChangeset for help on using the changeset viewer.