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/Frame.java

    r1430 r1434  
    2020
    2121import java.io.File;
     22import java.nio.file.Paths;
    2223import java.sql.Time;
    2324import java.util.ArrayList;
     
    4142import org.expeditee.core.bounds.PolygonBounds;
    4243import org.expeditee.encryption.items.EncryptionPermissionTriple;
     44import org.expeditee.encryption.items.surrogates.Label;
    4345import org.expeditee.gio.EcosystemManager;
    4446import org.expeditee.gio.gesture.Gesture;
     
    190192        private String _groupFrameName;
    191193        private Frame _groupFrame = null;
     194
     195        private List<String> labelsOnLastBodySet;
    192196       
    193197        public enum BodyType {
     
    353357         */
    354358        public List<Item> getSortedItems(boolean requireVisible) {
    355                 ItemsList listToLoopOver = _body;
     359                ItemsList listToLoopOver = getBody(true);
    356360                listToLoopOver.sort();
    357361                return getItems(requireVisible, listToLoopOver);
     
    389393                        throw new NullPointerException("i");
    390394                }       
    391                 return _body.contains(i);
     395                return getBody(true).contains(i);
    392396        }
    393397
     
    404408         * @return the list of body text items.
    405409         */
    406         public List<Text> getBodyTextItems(boolean includeAnnotations)
    407         {
     410        public List<Text> getBodyTextItems(boolean includeAnnotations) {
     411                ensureBody();
     412               
    408413                List<Text> bodyTextItems = new ArrayList<Text>();
    409414               
     
    467472         *         found.
    468473         */
    469         public Item getItemWithID(int id)
    470         {
    471                 for (Item i : _body) {
     474        public Item getItemWithID(int id) {
     475                for (Item i : getAllFrameItemsRaw()) {
    472476                        if (i.getID() == id) {
    473477                                return i;
     
    761765                _permissionTriple = new PermissionTriple(permission);
    762766
    763                 if (_body.size() > 0) {
     767                if (getBody(false).size() > 0) {
    764768                        refreshItemPermissions(permission.getPermission(_owner, groupMembers));
    765769                }
     
    787791                _creationDate = date;
    788792                _modifiedDate = date;
    789                 for (Item i : _body) {
     793                for (Item i : getAllFrameItemsRaw()) {
    790794                        i.setDateCreated(date);
    791795                }
     
    855859
    856860        public void invalidateSorted() {
    857                 _body.invalidateSorted();
     861                getBody(false).invalidateSorted();
    858862        }
    859863
     
    871875                if (item == null) { return; }
    872876               
    873                 addItem(item, recalculate, _body);
     877                addItem(item, recalculate, getBody(false));
    874878                if (item.isSurrogate()) {
    875                         addItem(item, recalculate, _surrogateItemsBody);
     879                        addItem(item, recalculate, getSurrogateBody());
    876880                } else {
    877                         addItem(item, recalculate, _primaryItemsBody);
     881                        addItem(item, recalculate, getPrimaryBody());
    878882                }
    879883        }
     
    988992
    989993        public void addAllItems(Collection<Item> toAdd) {
    990                 addAllItems(toAdd, _body);
    991                 addAllItems(toAdd, _primaryItemsBody);
     994                addAllItems(toAdd, getBody(false));
     995                addAllItems(toAdd, getPrimaryBody());
    992996        }
    993997       
     
    10181022
    10191023        public void removeItem(Item item, boolean recalculate) {
    1020                 removeItem(item, recalculate, _body);
     1024                removeItem(item, recalculate, getBody(false));
    10211025                if (item.isSurrogate()) {
    1022                         removeItem(item, recalculate, _surrogateItemsBody);
     1026                        removeItem(item, recalculate, getSurrogateBody());
    10231027                        Set<Item> primariesSurrogates = item.getPrimary().getSurrogates();
    10241028                        primariesSurrogates.remove(item);
    10251029                } else {
    1026                         removeItem(item, recalculate, _primaryItemsBody);
     1030                        removeItem(item, recalculate, getPrimaryBody());
    10271031                }
    10281032        }
     
    10751079        }
    10761080
    1077         public void undo()
    1078         {
    1079                 boolean bReparse = false;
    1080                 boolean bRecalculate = false;
     1081        public void undo() {
     1082                boolean reparse = false;
     1083                boolean recalculate = false;
    10811084
    10821085                if (_undo.size() <= 0) {
     
    10921095                        _redo.push(undo);
    10931096                for(Item i : undo.items) {
    1094                         _body.add(i);
    1095                                 bReparse |= i.hasOverlay();
    1096                                 bRecalculate |= i.recalculateWhenChanged();
     1097                        this.addItem(i);
     1098                                reparse |= i.hasOverlay();
     1099                                recalculate |= i.recalculateWhenChanged();
    10971100                                if (i instanceof Line) {
    10981101                                        Line line = (Line) i;
     
    11051108                break;
    11061109                case movement:
    1107                         ItemsList changed = new ItemsList(_body);
    1108                         changed.retainHistory(undo.items);
     1110                        ItemsList body = getBody(true);
     1111                        ItemsList changed = new ItemsList(body);
     1112                        changed.retainAll(undo.items);
    11091113                        _redo.push(new History(changed, History.Type.movement));
    11101114                        for(Item i : undo.items) {
    11111115                                int index;
    1112                                 if(i.isVisible() && (index = _body.indexOf(i)) != -1) {
    1113                                         _body.set(index, i);
     1116                                if(i.isVisible() && (index = body.indexOf(i)) != -1) {
     1117                                        body.set(index, i);
    11141118                                }
    11151119                }
     
    11211125                StandardGestureActions.refreshHighlights();
    11221126               
    1123                 if (bReparse) {
     1127                if (reparse) {
    11241128                        FrameUtils.Parse(this, false, false);
    11251129                } else {
    1126                         notifyObservers(bRecalculate);
     1130                        notifyObservers(recalculate);
    11271131                }
    11281132               
     
    11521156                        _undo.push(redo);
    11531157                for(Item i : redo.items) {
    1154                         _body.remove(i);
     1158                        this.removeItem(i);
     1159                        //_body.remove(i);
    11551160                                bReparse |= i.hasOverlay();
    11561161                                bRecalculate |= i.recalculateWhenChanged();
     
    11651170                break;
    11661171                case movement:
    1167                         ItemsList changed = new ItemsList(_body);
    1168                         changed.retainHistory(redo.items);
     1172                        ItemsList body = getBody(true);
     1173                        ItemsList changed = new ItemsList(body);
     1174                        changed.retainAll(redo.items);
    11691175                        _undo.push(new History(changed, History.Type.movement));
    11701176                        for(Item i : redo.items) {
    11711177                                int index;
    1172                                 if(i.isVisible() && (index = _body.indexOf(i)) != -1) {
    1173                                         _body.set(index, i);
     1178                                if(i.isVisible() && (index = body.indexOf(i)) != -1) {
     1179                                        body.set(index, i);
    11741180                                }
    11751181                }
     
    13351341                // s.append(String.format("Last Mod. User: %s%n", _modifiedUser));
    13361342                // s.append(String.format("Last Mod. Date: %s%n", _modifiedDate));
    1337                 s.append(String.format("Items: %d%n", _body.size()));
     1343                s.append(String.format("Items: %d%n", getAllFrameItemsRaw().size()));
    13381344                return s.toString();
    13391345        }
     
    13791385        {
    13801386                // Check that this item is on the current frame
    1381                 if (!_body.contains(from)) {
     1387                if (!getBody(true).contains(from)) {
    13821388                        return null;
    13831389                }
     
    17891795         * Removes all non-title non-annotation items from this Frame. All removed
    17901796         * items are added to the backup-stack.
    1791          */
    1792         public void clear(boolean keepAnnotations)
     1797         */
     1798        @Deprecated
     1799        public void clearDeprecated(boolean keepAnnotations)
    17931800        {
    17941801                ItemsList newBody = new ItemsList();
     
    18141821                change();
    18151822
     1823                if (!keepAnnotations && _annotations != null) {
     1824                        _annotations.clear();
     1825                }
     1826        }
     1827       
     1828        /**
     1829         * Removes all items from the Frame except the Title Item and optionally the annotations.
     1830         * All removed items are added to the backup-stack.
     1831         *
     1832         * @param keepAnnotations true is annotations are not to be removed from the frame.
     1833         */
     1834        public void clear(boolean keepAnnotations) {
     1835                ItemsList body = getBody(true);
     1836                ItemsList deleted = new ItemsList();
     1837               
     1838                for (Item bodyItem: body) {
     1839                        boolean isAnnotationToKeep = bodyItem.isAnnotation() && keepAnnotations;
     1840                        boolean isFrameTitle = bodyItem.isFrameTitle();
     1841                        boolean isToBeRetained = isFrameTitle || isAnnotationToKeep;
     1842                        if (isToBeRetained) {
     1843                                continue;
     1844                        }
     1845                       
     1846                        this.removeItem(bodyItem);
     1847                        deleted.add(bodyItem);
     1848                }
     1849               
     1850                addToUndoDelete(deleted);
     1851                change();
     1852               
    18161853                if (!keepAnnotations && _annotations != null) {
    18171854                        _annotations.clear();
     
    19501987         */
    19511988        public String getFramesetPath() {
    1952                 return this.getPath() + File.separator + this.getFramesetName() + File.separator;
     1989                return Paths.get(this.getPath()).resolve(this.getFramesetName()).toString() + File.separator;
    19531990        }
    19541991
     
    22902327
    22912328                for (Overlay o : getOverlays()) {
    2292                         for(Item i : o.Frame._body) {
     2329                        for(Item i : o.Frame.getBody(false)) {
    22932330                                i.setOverlayPermission(o.permission);
    22942331                        }
     
    25682605        }
    25692606       
     2607        /**
     2608         * Returns a list of items for the specified BodyType.
     2609         *
     2610         * Asking for the primary or surrogate items gives you exactly those.
     2611         *
     2612         * Asking for the body items is a weird case because the body list is
     2613         * transitory.  Therefore, when asking for the body items, this
     2614         * function assumes that you want all items, reguardless of if they
     2615         * are primaries or surrogates.  As of 20/08/2019, there are no places
     2616         * in the code that asks for the body items to save.
     2617         * @param type
     2618         * @return
     2619         */
    25702620        public List<Item> getItemsToSave(BodyType type) {
    25712621                assert(!type.equals(BodyType.BodyDisplay));
     
    25742624                        return getItemsToSave(_surrogateItemsBody);
    25752625                case BodyDisplay:
    2576                         return getItemsToSave(_body);
     2626                        return getItemsToSave(new ItemsList(getAllFrameItemsRaw()));
    25772627                case PrimaryBody:
    25782628                default:
     
    26322682
    26332683        public Collection<Item> getAllItems() {
    2634                 ItemsList allItems = new ItemsList(_body);
     2684                ItemsList allItems = new ItemsList(getBody(true));
    26352685               
    26362686                allItems.addAll(_overlayItems);
     
    27212771        }
    27222772
    2723         public void dispose()
    2724         {
     2773        @Deprecated
     2774        public void disposeDeprecated() {
    27252775                clearObservers();
    27262776               
     
    27322782                _body = null;
    27332783                _frameName = null;
     2784        }
     2785       
     2786        /**
     2787         * Disposes off all references associated with this frame. 
     2788         * This operation is NOT REVERSEABLE through the history.
     2789         */
     2790        public void dispose() {
     2791                clearObservers();
     2792               
     2793                List<Item> allFrameItems = getAllFrameItemsRaw();
     2794               
     2795                for (Item i: allFrameItems) {
     2796                        i.dispose();
     2797                }
     2798
     2799                _frameName.dispose();
     2800                _frameName = null;
     2801                getBody(false).clear();
     2802                getPrimaryBody().clear();
     2803                getSurrogateBody().clear();
    27342804        }
    27352805
     
    28002870       
    28012871        public void moveItemToBodyHiddenDueToPermission(final Item i) {
    2802                 _body.remove(i);
     2872                getBody(true).remove(i);
    28032873                _bodyHiddenDueToPermissions.add(i);
    28042874        }
     
    28082878                        _bodyHiddenDueToPermissions.remove(i);
    28092879                        i.setPermission(newPermission);
    2810                         _body.add(i);
     2880                        getBody(true).add(i);
    28112881                }
    28122882        }
     
    28212891                }
    28222892
    2823                 for (Item i : _body) {
     2893                for (Item i : getBody(false)) {
    28242894                        if (i == null) {
    28252895                                continue;
     
    29503020        }
    29513021
    2952         public ItemsList getBody() {
     3022        public ItemsList getBody(boolean respectSurrogateMode) {
     3023                if (respectSurrogateMode) { ensureBody(); }             
    29533024                return _body;
    29543025        }
     3026
     3027        private void ensureBody() {
     3028                List<String> accessibleLabelsNames = Label.getAccessibleLabelsNames(getPrimaryBody());
     3029                if (!accessibleLabelsNames.equals(labelsOnLastBodySet)) {
     3030                        this.parse();
     3031                }
     3032        }
     3033       
     3034        protected void setBody(List<Item> newBody, List<String> labelsOnSet) {
     3035                _body.clear();
     3036                _body.addAll(newBody);
     3037                this.labelsOnLastBodySet = labelsOnSet;
     3038        }
     3039       
    29553040        protected ItemsList getPrimaryBody() {
    29563041                return _primaryItemsBody;
     
    29593044                return _surrogateItemsBody;
    29603045        }
     3046       
     3047
     3048        /**
     3049         * Gets all the items on the frame, regardless of whether they are primary or surrogate items.
     3050         *
     3051         * Bryce says: This function will likely only ever be used inside Frame itself, as callers from
     3052         * outside Frame should care about what the state of the Frame.
     3053         * @return
     3054         */
     3055        private List<Item> getAllFrameItemsRaw() {
     3056                Collection<Item> primaries = getPrimaryBody().underlying();
     3057                Collection<Item> surrogateBody = getSurrogateBody().underlying();
     3058                primaries.addAll(surrogateBody);
     3059                List<Item> allFrameItems = primaries.stream().distinct().collect(Collectors.toList());
     3060                return allFrameItems;
     3061        }
    29613062}
Note: See TracChangeset for help on using the changeset viewer.