Ignore:
Timestamp:
10/02/19 14:19:48 (5 years ago)
Author:
bln4
Message:

Implementation of ProfileManager. Refactor + additional content for how new profiles are created. The refactoring split out the creation of the default profile from user profiles. Refactoring revealed a long term bug that was causing user profiles to generate with incorrect information. The additional content fixed this bug by introducing the ${USER.NAME} variable, so that the default profile frameset can specify resource locations located in the users resource directory.

org.expeditee.auth.AuthenticatorBrowser
org.expeditee.auth.account.Create
org.expeditee.gui.Browser
org.expeditee.gui.management.ProfileManager
org.expeditee.setting.DirectoryListSetting
org.expeditee.setting.ListSetting
org.expeditee.settings.UserSettings

Implementation of ResourceManager as a core location to get resources from the file system. Also the additional variable ${CURRENT_FRAMESET} to represent the current frameset, so that images can be stored in the directory of the current frameset. This increases portability of framesets.

org.expeditee.gui.FrameIO
org.expeditee.gui.management.ResourceManager
org.expeditee.gui.management.ResourceUtil
Audio:

#NB: Audio used to only operate on a single directory. This has been updated to work in a same way as images. That is: when you ask for a specific resouce, it looks to the user settings to find a sequence of directories to look at in order until it manages to find the desired resource.


There is still need however for a single(ish) source of truth for the .banks and .mastermix file. Therefore these files are now always located in resource-<username>\audio.
org.apollo.agents.MelodySearch
org.apollo.audio.structure.AudioStructureModel
org.apollo.audio.util.MultiTrackPlaybackController
org.apollo.audio.util.SoundDesk
org.apollo.gui.FrameLayoutDaemon
org.apollo.io.AudioPathManager
org.apollo.util.AudioPurger
org.apollo.widgets.FramePlayer
org.apollo.widgets.SampledTrack

Images:

org.expeditee.items.ItemUtils

Frames:

org.expeditee.gui.FrameIO

Fixed a error in the FramePlayer class caused by an incorrect use of toArray().

org.apollo.widgets.FramePlayer


Added several short cut keys to allow for the Play/Pause (Ctrl + P), mute (Ctrl + M) and volume up/down (Ctrl + +/-) when hovering over SampledTrack widgets.

org.apollo.widgets.SampledTrack


Changed the way that Authenticate.login parses the new users profile to be more consistance with other similar places in code.

org.expeditee.auth.account.Authenticate


Encapsulated _body, _surrogateItemsBody and _primaryItemsBody in Frame class. Also changed getBody function to take a boolean flag as to if it should respect the current surrogate mode. If it should then it makes sure that labels have not changed since last time getBody was called.

org.expeditee.gui.Frame

File:
1 edited

Legend:

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

    r1424 r1434  
    6363import org.expeditee.gio.EcosystemManager;
    6464import org.expeditee.gio.gesture.StandardGestureActions;
     65import org.expeditee.gui.management.ResourceManager;
     66import org.expeditee.gui.management.ResourceUtil;
    6567import org.expeditee.items.Circle;
    6668import org.expeditee.items.Dot;
     
    8688import org.expeditee.settings.Settings;
    8789import org.expeditee.settings.UserSettings;
    88 import org.expeditee.settings.templates.TemplateSettings;
    8990import org.expeditee.stats.Logger;
    9091import org.expeditee.stats.SessionStats;
     
    666667       
    667668        private static boolean createPictureInBody(Frame frame, Text txt) {
    668                 return createPicture(frame, txt, frame.getBody());
     669                return createPicture(frame, txt, frame.getBody(false));
    669670        }
    670671
     
    726727       
    727728        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) {               
    732733                List<String> errors = new LinkedList<String>();
    733734
    734735                if (profile == null) {
     736                        return errors;
     737                }
     738               
     739                if (profile.getFramesetName().equals(UserSettings.DEFAULT_PROFILE_NAME)) {
    735740                        return errors;
    736741                }
     
    771776                }
    772777
     778                // Tell the resource manager that it needs to refresh its context.
     779                ResourceManager.invalidateAllResourceDirectories();
     780               
    773781                return errors;
    774782        }
     
    792800                        DisplayController.setCurrentFrame(firstFrame, true);
    793801                }
    794 
    795802        }
    796803
     
    843850                throw new RuntimeException("Missing value for profile attribute" + name);
    844851        }
    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               
    848858                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               
    866887                return dirsToAdd;
    867888        }
     
    11401161         */     
    11411162        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());
    11431164               
    11441165                ItemsList primaries = toParse.getPrimaryBody();
     
    11501171                toParse.getInteractableItems().clear();
    11511172                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);
    11551175               
    11561176                if (firstParse) {
     
    15871607                CreateDefaultProfile(profileFor, profile, null, null);
    15881608        }
    1589 
     1609               
    15901610        /**
    15911611         * Copies the content from the default profile to the specified profile.
     
    16101630                                try {
    16111631                                        // 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();
    16121636                                        defaultFrame = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME, null, null);
     1637                                        UserSettings.UserName.set(existingUsername);
     1638                                        FrameIO.changeParentAndSubFolders(FrameIO.PARENT_FOLDER);
     1639                                        UserSettings.setupDefaultFolders();
    16131640                                } catch (InvalidFramesetNameException invalidNameEx) {
    16141641                                        MessageBay.errorMessage("Failed to create default profile named: "
     
    16851712                        }
    16861713                        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                }
    17941715        }
    17951716
Note: See TracChangeset for help on using the changeset viewer.