Changeset 1434 for trunk/src/org/expeditee/gui/FrameUtils.java
- Timestamp:
- 10/02/19 14:19:48 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameUtils.java
r1424 r1434 63 63 import org.expeditee.gio.EcosystemManager; 64 64 import org.expeditee.gio.gesture.StandardGestureActions; 65 import org.expeditee.gui.management.ResourceManager; 66 import org.expeditee.gui.management.ResourceUtil; 65 67 import org.expeditee.items.Circle; 66 68 import org.expeditee.items.Dot; … … 86 88 import org.expeditee.settings.Settings; 87 89 import org.expeditee.settings.UserSettings; 88 import org.expeditee.settings.templates.TemplateSettings;89 90 import org.expeditee.stats.Logger; 90 91 import org.expeditee.stats.SessionStats; … … 666 667 667 668 private static boolean createPictureInBody(Frame frame, Text txt) { 668 return createPicture(frame, txt, frame.getBody( ));669 return createPicture(frame, txt, frame.getBody(false)); 669 670 } 670 671 … … 726 727 727 728 private static boolean createWidgetInBody(Frame frame, Text txt) { 728 return createWidget(frame, txt, frame.getBody( ));729 } 730 731 public static List<String> ParseProfile(Frame profile) { 729 return createWidget(frame, txt, frame.getBody(false)); 730 } 731 732 public static List<String> ParseProfile(Frame profile) { 732 733 List<String> errors = new LinkedList<String>(); 733 734 734 735 if (profile == null) { 736 return errors; 737 } 738 739 if (profile.getFramesetName().equals(UserSettings.DEFAULT_PROFILE_NAME)) { 735 740 return errors; 736 741 } … … 771 776 } 772 777 778 // Tell the resource manager that it needs to refresh its context. 779 ResourceManager.invalidateAllResourceDirectories(); 780 773 781 return errors; 774 782 } … … 792 800 DisplayController.setCurrentFrame(firstFrame, true); 793 801 } 794 795 802 } 796 803 … … 843 850 throw new RuntimeException("Missing value for profile attribute" + name); 844 851 } 845 846 public static ArrayList<String> getDirs(Item item) { 847 ArrayList<String> dirsToAdd = new ArrayList<String>(); 852 853 public static List<String> getDirs(Item item) { 854 List<String> dirsToAdd = new ArrayList<String>(); 855 String currentFramesetFlag = ResourceUtil.CURRENT_FRAMESET_FLAG; 856 boolean need_file_sep_replace = (!File.separator.equals("/")); 857 848 858 String dirListFrameName = item.getAbsoluteLink(); 849 if (dirListFrameName != null) { 850 Frame dirListFrame = FrameIO.LoadFrame(dirListFrameName); 851 if (dirListFrame != null) { 852 for (Text t : dirListFrame.getBodyTextItems(false)) { 853 String dirName = t.getText().trim(); 854 File tester = new File(dirName); 855 if (tester.exists() && tester.isDirectory()) { 856 if (dirName.endsWith(File.separator)) { 857 dirsToAdd.add(dirName); 858 } else { 859 dirsToAdd.add(dirName + File.separator); 860 } 861 } 862 } 863 } 864 } 865 859 if (dirListFrameName == null) { 860 return dirsToAdd; 861 } 862 Frame dirListFrame = FrameIO.LoadFrame(dirListFrameName); 863 if (dirListFrame == null) { 864 return dirsToAdd; 865 } 866 867 List<Text> bodyTextItems = dirListFrame.getBodyTextItems(false); 868 for (Text t: bodyTextItems) { 869 String dirName = t.getText().trim(); 870 871 if (need_file_sep_replace) { 872 dirName = dirName.replace("/",File.separator); 873 } 874 875 boolean isSpecialCase = dirName.startsWith(currentFramesetFlag); 876 File filePath = Paths.get(FrameIO.PARENT_FOLDER).resolve(dirName).toFile(); 877 boolean locationExists = filePath.exists() && filePath.isDirectory(); 878 if (isSpecialCase || locationExists) { 879 if (dirName.endsWith(File.separator)) { 880 dirsToAdd.add(dirName); 881 } else { 882 dirsToAdd.add(dirName + File.separator); 883 } 884 } 885 } 886 866 887 return dirsToAdd; 867 888 } … … 1140 1161 */ 1141 1162 public static void Parse(Frame toParse, boolean firstParse, boolean ignoreAnnotations) { 1142 List<String> accessList = Label.getAccessibleLabelsNames( new ItemsList(toParse.getPrimaryBody()));1163 List<String> accessList = Label.getAccessibleLabelsNames(toParse.getPrimaryBody()); 1143 1164 1144 1165 ItemsList primaries = toParse.getPrimaryBody(); … … 1150 1171 toParse.getInteractableItems().clear(); 1151 1172 List<Item> newBody = parseFromPrimary(primaries, accessList); 1152 toParse.getBody().clear(); 1153 toParse.getBody().addAll(newBody); 1154 generatingSupportingItems(toParse, toParse.getBody(), ignoreAnnotations); 1173 toParse.setBody(newBody, accessList); 1174 generatingSupportingItems(toParse, toParse.getBody(false), ignoreAnnotations); 1155 1175 1156 1176 if (firstParse) { … … 1587 1607 CreateDefaultProfile(profileFor, profile, null, null); 1588 1608 } 1589 1609 1590 1610 /** 1591 1611 * Copies the content from the default profile to the specified profile. … … 1610 1630 try { 1611 1631 // If we do not have a default to copy, create one. 1632 String existingUsername = UserSettings.UserName.get(); 1633 UserSettings.UserName.set("default"); 1634 FrameIO.changeParentAndSubFolders(FrameIO.PARENT_FOLDER); 1635 UserSettings.setupDefaultFolders(); 1612 1636 defaultFrame = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME, null, null); 1637 UserSettings.UserName.set(existingUsername); 1638 FrameIO.changeParentAndSubFolders(FrameIO.PARENT_FOLDER); 1639 UserSettings.setupDefaultFolders(); 1613 1640 } catch (InvalidFramesetNameException invalidNameEx) { 1614 1641 MessageBay.errorMessage("Failed to create default profile named: " … … 1685 1712 } 1686 1713 MessageBay.suppressMessages(false); 1687 } else { 1688 title.setText("Default Profile Frame"); 1689 int xPos = 300; 1690 int yPos = 100; 1691 Text t; 1692 1693 // Add documentation links 1694 File helpDirectory = new File(FrameIO.HELP_PATH); 1695 if (helpDirectory != null) { 1696 File[] helpFramesets = helpDirectory.listFiles(); 1697 if (helpFramesets != null) { 1698 1699 // Add the title for the help index 1700 Text help = profile.addText(xPos, yPos, "@Expeditee Help", null); 1701 help.setSize(25); 1702 help.setFontStyle("Bold"); 1703 help.setFamily("SansSerif"); 1704 help.setColor(TemplateSettings.ColorWheel.get()[3]); 1705 1706 xPos += 25; 1707 System.out.println("Installing frameset: "); 1708 1709 boolean first_item = true; 1710 for (File helpFrameset : helpFramesets) { 1711 String framesetName = helpFrameset.getName(); 1712 if (!FrameIO.isValidFramesetName(framesetName)) { 1713 continue; 1714 } 1715 1716 if (first_item) { 1717 System.out.print(" " + framesetName); 1718 first_item = false; 1719 } else { 1720 System.out.print(", " + framesetName); 1721 } 1722 System.out.flush(); 1723 1724 Frame indexFrame = FrameIO.LoadFrame(framesetName + '1'); 1725 // Look through the folder for help index pages 1726 if (indexFrame != null && ItemUtils.FindTag(indexFrame.getSortedItems(), "@HelpIndex") != null) { 1727 // yPos += spacing; 1728 yPos += 30; 1729 t = profile.addText(xPos, yPos, '@' + indexFrame.getFramesetName(), null); 1730 t.setLink(indexFrame.getName()); 1731 t.setColor(Colour.GREY); 1732 } 1733 } 1734 System.out.println(); 1735 } 1736 } 1737 1738 xPos = 50; 1739 yPos = 100; 1740 1741 // Populate Start Pages and Settings 1742 File framesetDirectory = new File(FrameIO.FRAME_PATH); 1743 1744 if (framesetDirectory.exists()) { 1745 File[] startpagesFramesets = framesetDirectory.listFiles(); 1746 1747 if (startpagesFramesets != null) { 1748 // Add Start Page title 1749 Text templates = profile.addText(xPos, yPos, "@Start Pages", null); 1750 templates.setSize(25); 1751 templates.setFontStyle("Bold"); 1752 templates.setFamily("SansSerif"); 1753 templates.setColor(TemplateSettings.ColorWheel.get()[3]); 1754 1755 xPos += 25; 1756 1757 // Start Pages should be the first frame in its own frameset + 1758 // frameset name should be present in FrameUtils.startPages[]. 1759 for (File startpagesFrameset : startpagesFramesets) { 1760 String framesetName = startpagesFrameset.getName(); 1761 1762 // Only add link if frameset is a startpage 1763 for (int i = 0; i < startPages.length; i++) { 1764 if (framesetName.equals(startPages[i])) { 1765 Frame indexFrame = FrameIO.LoadFrame(framesetName + '1'); 1766 1767 // Add start page link 1768 if (indexFrame != null) { 1769 yPos += 30; 1770 t = profile.addText(xPos, yPos, '@' + indexFrame.getFramesetName(), null); 1771 t.setLink(indexFrame.getName()); 1772 t.setColor(Colour.GREY); 1773 } 1774 } 1775 } 1776 } 1777 } 1778 } 1779 1780 FrameIO.SaveFrame(profile); 1781 1782 // Populate settings frameset 1783 Settings.Init(); 1784 t = profile.addText(550, 100, "@Settings", null); 1785 t.setSize((float) 25.0); 1786 t.setFamily("SansSerif"); 1787 t.setFontStyle("Bold"); 1788 t.setColor(Colour.GREY); 1789 Settings.generateSettingsTree(t); 1790 System.out.println("@Settings: Default settings generation complete."); 1791 1792 FrameIO.SaveFrame(profile); 1793 } 1714 } 1794 1715 } 1795 1716
Note:
See TracChangeset
for help on using the changeset viewer.