Changeset 67 for trunk/src/org/expeditee/gui/FrameIO.java
- Timestamp:
- 05/19/08 12:03:18 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameIO.java
r64 r67 548 548 } 549 549 550 public static void RefreshCasheImages() { 551 SuspendCache(); 552 for (Frame f : _Cache.values()) 553 f.setBuffer(null); 554 ResumeCache(); 555 } 556 550 557 /** 551 558 * Creates a new frameset using the given name. This includes creating a new … … 603 610 } 604 611 612 public static String SaveFrame(Frame toSave, boolean inc) { 613 return SaveFrame(toSave, inc, true); 614 } 615 605 616 /** 606 617 * Saves the given Frame to disk in the corresponding frameset directory, if … … 613 624 * True if the saved frames counter should be incremented, false 614 625 * otherwise. 615 */ 616 public static String SaveFrame(Frame toSave, boolean inc) { 626 * @param checkBackup 627 * True if the frame should be checked for the back up tag 628 */ 629 public static String SaveFrame(Frame toSave, boolean inc, 630 boolean checkBackup) { 617 631 618 632 if (toSave == null) … … 630 644 .getFrameName()); 631 645 646 // Check if the frame exists 647 if (checkBackup && fullPath == null) { 648 // The first time a frame with the backup tag is saved, dont back it 649 // up 650 checkBackup = false; 651 } 652 632 653 FrameWriter writer = null; 654 int savedVersion; 633 655 try { 634 656 // if its a new frame or an existing Exp frame... 635 657 if (fullPath == null || fullPath.endsWith(ExpReader.EXTENTION)) { 636 658 writer = new ExpWriter(); 659 savedVersion = ExpReader.getVersion(fullPath); 637 660 } else { 638 661 writer = new KMSWriter(); 662 savedVersion = KMSReader.getVersion(fullPath); 639 663 } 640 641 if (toSave.getFrameNumber() > 0 664 // Check if we are trying to save an out of date version 665 if (savedVersion > toSave.getVersion(false) 666 && !toSave.getFramesetName().equalsIgnoreCase( 667 FrameGraphics.MESSAGES_FRAMESET_NAME)) { 668 // remove this frame from the cache if it is there 669 // This will make sure links to the original are set correctly 670 _Cache.remove(toSave.getFrameName().toLowerCase()); 671 int nextnum = ReadINF(toSave.path, toSave.getFramesetName()) + 1; 672 SuspendCache(); 673 Frame original = LoadFrame(toSave.getFrameName()); 674 toSave.setFrameNumber(nextnum); 675 ResumeCache(); 676 // Put the modified version in the cache 677 _Cache.put(toSave.getFrameName().toLowerCase(), toSave); 678 // Show the messages alerting the user 679 Text originalMessage = new Text(-1); 680 originalMessage.setColor(FrameGraphics.ERROR_COLOR); 681 originalMessage.setText(original.getFrameName() 682 + " was updated by another user."); 683 originalMessage.setLink(original.getFrameName()); 684 Text yourMessage = new Text(-1); 685 yourMessage.setColor(FrameGraphics.ERROR_COLOR); 686 yourMessage.setText("Your version was renamed " 687 + toSave.getFrameName()); 688 yourMessage.setLink(toSave.getFrameName()); 689 FrameGraphics.DisplayMessage(originalMessage); 690 FrameGraphics.DisplayMessage(yourMessage); 691 } else if (checkBackup 642 692 && ItemUtils.ContainsTag(toSave.getItems(), 643 693 ItemUtils.TAG_BACKUP)) { … … 649 699 int nextnum = ReadINF(toSave.path, toSave.getFramesetName()) + 1; 650 700 651 original.setFrameNumber(-nextnum); 652 SaveFrame(original, inc); 701 // Give it a negative framenumber so that when it is saved the 702 // backup tag will be ignored 703 original.setFrameNumber(nextnum); 704 original.change(); 705 SaveFrame(original, false, false); 653 706 654 707 Item i = ItemUtils.FindTag(toSave.getItems(), … … 657 710 toSave.setFrameNumber(orignum); 658 711 ResumeCache(); 659 } else if (toSave.getFrameNumber() < 0) {660 toSave.setFrameNumber(-toSave.getFrameNumber());661 712 } 662 713 … … 1000 1051 int copyNumber = 1; 1001 1052 File dest = new File(destPath + File.separator); 1002 // Create the trash folder if it doesnt already exist1053 // Create the trash folder if it doesnt already exist 1003 1054 if (!dest.getParentFile().exists()) 1004 1055 dest.mkdirs(); … … 1006 1057 // a number to the end 1007 1058 while (dest.exists()) { 1008 dest = new File(destPath + ++copyNumber + File.separator 1059 dest = new File(destPath + ++copyNumber + File.separator); 1009 1060 } 1010 1061 return framesetDirectory.renameTo(dest);
Note:
See TracChangeset
for help on using the changeset viewer.