Changeset 64
- Timestamp:
- 05/16/08 14:15:11 (16 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/actions/Simple.java
r50 r64 218 218 if (testsFailed > 0) 219 219 FrameGraphics.DisplayMessage("Failed: " + testsFailed, Color.RED); 220 //Remove items from the cursor... 221 Frame.FreeItems.clear(); 220 222 } 221 223 -
trunk/src/org/expeditee/gui/FrameIO.java
r25 r64 40 40 PARENT_FOLDER = newFolder; 41 41 FRAME_PATH = PARENT_FOLDER + "framesets" + File.separator; 42 TRASH_PATH = PARENT_FOLDER + "trash" + File.separator; 42 43 IMAGES_PATH = PARENT_FOLDER + "images" + File.separator; 43 44 HELP_PATH = PARENT_FOLDER + "help" + File.separator; … … 52 53 * subdirectory in this directory. 53 54 */ 55 56 public static String TRASH_PATH; 54 57 55 58 public static String PARENT_FOLDER; … … 477 480 // disable caching of 0 frames 478 481 SuspendCache(); 479 482 480 483 Frame template = null; 481 484 if (templateFrame == null) … … 757 760 } 758 761 759 760 761 762 public static String ConvertToValidFramesetName(String toValidate) { 762 assert (toValidate != null && toValidate.length() > 0);763 763 assert (toValidate != null && toValidate.length() > 0); 764 764 765 StringBuffer result = new StringBuffer(); 765 766 766 if (Character.isDigit(toValidate.charAt(0))) {767 if (Character.isDigit(toValidate.charAt(0))) { 767 768 result.append(FRAME_NAME_LAST_CHAR); 768 769 } 769 770 770 771 boolean capital = false; 771 for (int i = 0; i < toValidate.length() && result.length() < MAX_NAME_LENGTH; i++) { 772 for (int i = 0; i < toValidate.length() 773 && result.length() < MAX_NAME_LENGTH; i++) { 772 774 char cur = toValidate.charAt(i); 773 775 … … 785 787 assert (result.length() > 0); 786 788 int lastCharIndex = result.length() - 1; 787 if (!Character.isLetter(result.charAt(lastCharIndex))) {788 if (lastCharIndex == 789 result.setCharAt(lastCharIndex, FRAME_NAME_LAST_CHAR);789 if (!Character.isLetter(result.charAt(lastCharIndex))) { 790 if (lastCharIndex == MAX_NAME_LENGTH - 1) 791 result.setCharAt(lastCharIndex, FRAME_NAME_LAST_CHAR); 790 792 else 791 793 result.append(FRAME_NAME_LAST_CHAR); 792 794 } 793 794 assert (IsValidFramesetName(result.toString()));795 796 assert (IsValidFramesetName(result.toString())); 795 797 return result.toString(); 796 798 } … … 957 959 * letter and contain only letters and digits in between. 958 960 * 959 * @param frameset the name to be tested 961 * @param frameset 962 * the name to be tested 960 963 * @return true if the frameset name is valid 961 964 */ … … 964 967 return false; 965 968 } 966 969 967 970 int nameLength = frameset.length(); 968 if ( frameset.length() <= 0 || nameLength > MAX_NAME_LENGTH){971 if (frameset.length() <= 0 || nameLength > MAX_NAME_LENGTH) { 969 972 return false; 970 973 } 971 972 int lastCharIndex = nameLength - 1;973 974 if (!Character.isLetter(frameset.charAt(0)) ||975 !Character.isLetter(frameset.charAt(lastCharIndex)))974 975 int lastCharIndex = nameLength - 1; 976 977 if (!Character.isLetter(frameset.charAt(0)) 978 || !Character.isLetter(frameset.charAt(lastCharIndex))) 976 979 return false; 977 980 … … 987 990 if (!FrameIO.DoesFramesetExist(framesetName)) 988 991 return false; 989 992 // Search all the available directories for the directory 990 993 for (String path : UserSettings.FrameDirs) { 991 994 String source = path + framesetName.toLowerCase() + File.separator; 992 995 File framesetDirectory = new File(source); 996 // Once we have found the directory move it to the trash 993 997 if (framesetDirectory.exists()) { 994 for (File f : framesetDirectory.listFiles()) 995 f.delete(); 996 return framesetDirectory.delete(); 998 String destPath = FrameIO.TRASH_PATH 999 + framesetName.toLowerCase(); 1000 int copyNumber = 1; 1001 File dest = new File(destPath + File.separator); 1002 //Create the trash folder if it doesnt already exist 1003 if (!dest.getParentFile().exists()) 1004 dest.mkdirs(); 1005 // If a frameset with the same name is already in the trash add 1006 // a number to the end 1007 while (dest.exists()) { 1008 dest = new File(destPath + ++copyNumber + File.separator ); 1009 } 1010 return framesetDirectory.renameTo(dest); 997 1011 } 998 1012 }
Note:
See TracChangeset
for help on using the changeset viewer.