Changeset 1434 for trunk


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

Location:
trunk/src/org
Files:
4 added
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/agents/MelodySearch.java

    r1244 r1434  
    1111
    1212import org.apollo.ApolloSystem;
    13 import org.apollo.io.AudioPathManager;
    1413import org.apollo.meldex.DynamicProgrammingAlgorithm;
    1514import org.apollo.meldex.McNabMongeauSankoffAlgorithm;
     
    2827import org.expeditee.gui.Frame;
    2928import org.expeditee.gui.FrameIO;
    30 import org.expeditee.settings.folders.FolderSettings;
     29import org.expeditee.gui.management.ResourceManager;
    3130import org.expeditee.items.Item;
    3231import org.expeditee.items.ItemUtils;
     
    3433import org.expeditee.items.widgets.WidgetCorner;
    3534import org.expeditee.items.widgets.WidgetEdge;
     35import org.expeditee.settings.folders.FolderSettings;
    3636
    3737/**
     
    278278                                               
    279279                                                // Get cached melody from file if it is up to date
    280                                                 String metaFilePath =
    281                                                         AudioPathManager.AUDIO_HOME_DIRECTORY
    282                                                         + MELODY_METAFILE_PREFIX
    283                                                         + localFilename
    284                                                         + MELODY_METAFILE_SUFFIX;
    285                                                
    286                                                 File localFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + localFilename);
     280                                                String metaFileRelativePath = MELODY_METAFILE_PREFIX + localFilename + MELODY_METAFILE_SUFFIX;
     281                                                String metaFilePath = ResourceManager.getAudioResource(metaFileRelativePath, DisplayController.getCurrentFrame()).getAbsolutePath();
     282                                               
     283                                                //File localFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + localFilename);
     284                                                File localFile = ResourceManager.getAudioResource(localFilename, DisplayController.getCurrentFrame());
    287285                                                if (!localFile.exists()) continue;
    288286                                               
  • trunk/src/org/apollo/audio/structure/AudioStructureModel.java

    r1244 r1434  
    1616import org.apollo.audio.ApolloSubjectChangedEvent;
    1717import org.apollo.io.AudioIO;
    18 import org.apollo.io.AudioPathManager;
    1918import org.apollo.mvc.AbstractSubject;
    2019import org.apollo.mvc.SubjectChangedEvent;
     
    3029import org.expeditee.gui.Frame;
    3130import org.expeditee.gui.FrameIO;
     31import org.expeditee.gui.management.ResourceManager;
    3232import org.expeditee.io.Conversion;
    3333import org.expeditee.items.ItemUtils;
     
    433433                                try {
    434434                                       
    435                                         tmodel.runningTimeMS = AudioIO.getRunningTime(AudioPathManager.AUDIO_HOME_DIRECTORY + localFilename);
     435                                        String localFilePath = ResourceManager.getAudioResource(localFilename, DisplayController.getCurrentFrame()).getAbsolutePath();
     436                                        tmodel.runningTimeMS = AudioIO.getRunningTime(localFilePath);
    436437                               
    437438                                } catch (IOException e) {
  • trunk/src/org/apollo/audio/util/MultiTrackPlaybackController.java

    r1102 r1434  
    2020import org.apollo.audio.structure.TrackGraphLoopException;
    2121import org.apollo.audio.structure.TrackGraphNode;
    22 import org.apollo.io.AudioPathManager;
    2322import org.apollo.io.AudioIO.AudioFileLoader;
    2423import org.apollo.mvc.AbstractSubject;
     
    3433import org.expeditee.gui.DisplayController;
    3534import org.expeditee.gui.DisplayObserver;
     35import org.expeditee.gui.management.ResourceManager;
    3636
    3737public class MultiTrackPlaybackController
     
    10041004                                               
    10051005                                                try {
     1006                                                        String filepath = ResourceManager.getAudioResource(absNode.getTrackNode().getLocalFilename(), DisplayController.getCurrentFrame()).getAbsolutePath();
    10061007                                                        stm = TrackModelLoadManager.getInstance().load(
    1007                                                                         AudioPathManager.AUDIO_HOME_DIRECTORY + absNode.getTrackNode().getLocalFilename(),
     1008                                                                        filepath,
    10081009                                                                        absNode.getTrackNode().getLocalFilename(),
    10091010                                                                        new Observer() { // opps, my confusing design pattern gone wrong!
  • trunk/src/org/apollo/audio/util/SoundDesk.java

    r375 r1434  
    7171       
    7272        /** Where the mixes are saved to. */
    73         private static final String MIX_BANKS_FILEPATH = AudioPathManager.AUDIO_HOME_DIRECTORY + ".banks";
    74        
    75         private static final String MASTER_MIX_FILEPATH = AudioPathManager.AUDIO_HOME_DIRECTORY + ".mastermix";
     73        private static final String MIX_BANKS_FILEPATH = AudioPathManager.AUDIO_USERNAME_HOME_DIRECTORY + ".banks";
     74       
     75        private static final String MASTER_MIX_FILEPATH = AudioPathManager.AUDIO_USERNAME_HOME_DIRECTORY + ".mastermix";
    7676       
    7777        private static final String NO_SOLO_PREFIX = "~#SOLOOFF#~";
  • trunk/src/org/apollo/gui/FrameLayoutDaemon.java

    r1258 r1434  
    1515import org.apollo.audio.util.Timeline;
    1616import org.apollo.io.AudioIO;
    17 import org.apollo.io.AudioPathManager;
    1817import org.apollo.mvc.AbstractSubject;
    1918import org.apollo.mvc.Observer;
     
    3231import org.expeditee.gui.Frame;
    3332import org.expeditee.gui.FreeItems;
     33import org.expeditee.gui.management.ResourceManager;
    3434import org.expeditee.items.Item;
    3535import org.expeditee.items.ItemUtils;
     
    766766                                // so cann afford to hang the thread a little for checking the actual time...
    767767                                if (runningTime <= 0) {
    768                                         File f = new File(AudioPathManager.AUDIO_HOME_DIRECTORY +
    769                                                         sampledTrackWidget.getLocalFileName());
     768                                        //File f = new File(AudioPathManager.AUDIO_HOME_DIRECTORY +
     769                                        //              sampledTrackWidget.getLocalFileName());
     770                                        File f = ResourceManager.getAudioResource(sampledTrackWidget.getLocalFileName(), DisplayController.getCurrentFrame());
    770771                                        if (f.exists()) {
    771772                                                try {
  • trunk/src/org/apollo/io/AudioPathManager.java

    r1327 r1434  
    77import java.io.IOException;
    88import java.io.UnsupportedEncodingException;
     9import java.util.ArrayList;
     10import java.util.List;
    911import java.util.Random;
     12import java.util.function.Predicate;
    1013
    1114import org.apollo.audio.structure.AudioStructureModel;
    1215import org.apollo.util.ApolloSystemLog;
    1316import org.apollo.util.RegExpFileFilter;
    14 import org.expeditee.auth.AuthenticatorBrowser;
     17import org.expeditee.gui.DisplayController;
    1518import org.expeditee.gui.FrameIO;
     19import org.expeditee.gui.management.ResourceManager;
    1620import org.expeditee.settings.UserSettings;
    1721
     
    2933
    3034        /** Suffixed with the native file separator */
    31         public static String AUDIO_HOME_DIRECTORY = null;
     35        public static String AUDIO_USERNAME_HOME_DIRECTORY = null;
    3236       
    3337        /** Stores all virtual names created by this repository. */
     
    3943
    4044        private static Random rand = new Random(System.currentTimeMillis());
    41 
    42         // **** DB
    43         // Some work to be done here => remove dependency in code on 'AUDIO_HOME_DIRECTORY'
    44         // and change it to use audio dir list from UserSettings
    45         public static void changeParentAndSubFolders(String newFolder) {
    46                
    47                 if (AuthenticatorBrowser.isAuthenticationRequired() && System.getProperty("user.name").equals(AuthenticatorBrowser.USER_NOBODY)) {
    48                         System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Nothing to do for user '" + AuthenticatorBrowser.USER_NOBODY + "'");
    49                         return;
    50                 }
    51                
    52                 if (UserSettings.PublicAndPrivateResources) {
    53                         //String resourcesPublicPath = FrameIO.PARENT_FOLDER + "resources-public" + File.separator;
    54                         String userName = UserSettings.UserName.get();
    55                         //String resourcesPrivateIndividualPath = FrameIO.PARENT_FOLDER + "resources-" + userName + File.separator;
    56                         if (AuthenticatorBrowser.isAuthenticationRequired()) {
    57                                 System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Setting 'audio' folder to resources-" + userName);
    58                         }
    59                         //AUDIO_HOME_DIRECTORY = resourcesPrivateIndividualPath + "audio" + File.separatorChar;
    60                         AUDIO_HOME_DIRECTORY = FrameIO.AUDIO_PRIVATE_PATH;
    61                 }
    62                 else {
    63                         AUDIO_HOME_DIRECTORY = FrameIO.PARENT_FOLDER + "audio" + File.separatorChar;;
    64                 }
    65         }
    66        
    67         public static void activateAndScanAudioDir()
    68         {
    69                 changeParentAndSubFolders(FrameIO.PARENT_FOLDER);
    70                
    71                 // Ensure audio directory exists
    72                 File dir = new File(AUDIO_HOME_DIRECTORY);
    73                 if (!dir.exists()) {
    74                         if (!dir.mkdir()) {
    75                                 ApolloSystemLog.println("Unable to create missing audio home directory");
    76                         }
    77                 }
    78 
     45       
     46        // TODO: this function called during startup?  In browser construction?  When FrameIO.changeParentAndSubFolders() is called?  Separation of apollo from expeditee core?
     47        public static void activateAndScanAudioDirs() {
     48                // If we are in old regime then there is no AUDIO_USERNAME_PRIVATE_PATH.
     49                AUDIO_USERNAME_HOME_DIRECTORY = FrameIO.AUDIO_USERNAME_PRIVATE_PATH == null ? FrameIO.AUDIO_PATH : FrameIO.AUDIO_USERNAME_PRIVATE_PATH;
     50               
    7951                // Load counter
    80                 loadCounter(AUDIO_HOME_DIRECTORY);
    81         }
    82        
     52                loadCounter();
     53        }
    8354       
    8455        /**
    8556         * Loads the counter
    86          * @param dir The dir where the audio files live.
    87          */
    88         private static void loadCounter(String audio_dir_str) {
    89                 File audio_dir = new File(audio_dir_str);
    90                
    91                 String[] files = getAudioFileNames(audio_dir);
    92                 if (files == null) { // Due to IO exception
    93                         ApolloSystemLog.printError("Failed to read audio directory");
    94                         return;
    95                 }
     57         */
     58        private static void loadCounter() {
     59                List<String> audioFileNames = getAudioFileNames();
     60               
    9661                long count = 0;
    97                 if (files != null) {
    98                         for (String f : files) {
    99        
    100                                 int start = -1, end = -1;
    101                                 for (int i = 0; i < f.length(); i++) {
    102                                         if (Character.isDigit(f.charAt(i)) && start == -1) {
    103                                                 start = i;
    104                                         } else if (!Character.isDigit(f.charAt(i)) && start != -1) {
    105                                                 end = i;
    106                                                 break;
    107                                         }
    108                                 }
    109                                
    110                                 if (start >= 0 && end == -1) {
    111                                         end = f.length();
    112                                 }
    113        
    114                                 if (start > 0 && end >= start) { // not start >= 0 since missing preable
    115        
    116                                         String tmp = f.substring(start, end);
    117                                         long l = Long.parseLong(tmp);
    118                                         if (l >= count)
    119                                                 count = l + 1;
    120                                 }
    121                         }
    122                 }
    123 
     62                for (String f : audioFileNames) {
     63                       
     64                        int start = -1, end = -1;
     65                        for (int i = 0; i < f.length(); i++) {
     66                                if (Character.isDigit(f.charAt(i)) && start == -1) {
     67                                        start = i;
     68                                } else if (!Character.isDigit(f.charAt(i)) && start != -1) {
     69                                        end = i;
     70                                        break;
     71                                }
     72                        }
     73                       
     74                        if (start >= 0 && end == -1) {
     75                                end = f.length();
     76                        }
     77
     78                        if (start > 0 && end >= start) { // not start >= 0 since missing preable
     79
     80                                String tmp = f.substring(start, end);
     81                                long l = Long.parseLong(tmp);
     82                                if (l >= count)
     83                                        count = l + 1;
     84                        }
     85                }
    12486                counter = count;
    125         }
    126        
    127         /**
    128          * @param dir
    129          * @return
    130          *              Null if an IO exception occurs
    131          */
    132         private static String[] getAudioFileNames(File dir) {
    133                 return dir.list(new RegExpFileFilter("^[A-Z]+\\d+.*$"));
    13487        }
    13588       
     
    14093         *              read list of files.
    14194         */
    142         public static String[] getAudioFileNames() {
    143                 File audioDir = new File(AUDIO_HOME_DIRECTORY);
    144                 if (!audioDir.exists() || !audioDir.isDirectory()) return null;
    145                 return getAudioFileNames(audioDir);
     95        public static List<String> getAudioFileNames() {
     96                Predicate<File> isFile = file -> {
     97                        File dirForFile = file.toPath().getParent().toFile();
     98                        if (!dirForFile.exists()) {
     99                                if (!dirForFile.mkdir()) {
     100                                        ApolloSystemLog.println("Unable to create missing audio directory: " + dirForFile.toString());
     101                                }
     102                        }
     103                        if (file.isFile()) {
     104                                return true;
     105                        }
     106                        return false;
     107                };             
     108                List<File> allFilesInAudioDirectories = ResourceManager.gatherAudioResources(isFile, DisplayController.getCurrentFrame());
     109                List<String> audioFileNames = new ArrayList<String>();
     110                RegExpFileFilter regExpFileFilter = new RegExpFileFilter("^[A-Z]+\\d+.*$");
     111                for (File file: allFilesInAudioDirectories) {
     112                        if (regExpFileFilter.accept(file, file.getAbsolutePath())) {
     113                                audioFileNames.add(file.getName());
     114                        }
     115                }
     116                return audioFileNames;
    146117        }
    147118       
     
    168139                String filename = generateRandomFilenameBase() + "." + extension;
    169140               
    170                 File f = new File(AUDIO_HOME_DIRECTORY + filename);
     141                File f = new File(AUDIO_USERNAME_HOME_DIRECTORY + filename);
    171142
    172143                if (AudioStructureModel.getInstance().getTrackGraphInfo(filename, null) != null ||
     
    206177
    207178                // Build the filename string
    208                 return preamble + counter;
     179                return UserSettings.UserName.get() + preamble + counter;
    209180               
    210181        }
     
    222193
    223194                // Ensure that the name base file exists. Assumes the audio home directory exists.
    224                 File vnameBase = new File(AUDIO_HOME_DIRECTORY + VIRTUAL_NAME_BASEFILE);
     195                File vnameBase = new File(AUDIO_USERNAME_HOME_DIRECTORY + VIRTUAL_NAME_BASEFILE);
    225196                if (!vnameBase.exists()) {
    226197                        try {
  • trunk/src/org/apollo/util/AudioPurger.java

    r1244 r1434  
    1111import org.apollo.widgets.SampledTrack;
    1212import org.expeditee.settings.folders.FolderSettings;
     13import org.expeditee.gui.DisplayController;
     14import org.expeditee.gui.management.ResourceManager;
    1315import org.expeditee.items.ItemUtils;
    1416
     
    2628        public static void purgeLocalAudio() {
    2729               
    28                 String[] audioFiles = AudioPathManager.getAudioFileNames();
    29                 if (audioFiles == null || audioFiles.length == 0) return;
     30                List<String> audioFiles = AudioPathManager.getAudioFileNames();
     31                if (audioFiles == null || audioFiles.size() == 0) return;
    3032               
    3133               
     
    5052                for (String audioFile : audioFiles) {
    5153                        if (!referencedAudio.contains(audioFile)) {
    52                                
    53                                 File unreferencedFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + audioFile);
     54                                File unreferencedFile = ResourceManager.getAudioResource(audioFile, DisplayController.getCurrentFrame());
     55                                //File unreferencedFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + audioFile);
    5456                                ApolloSystemLog.println("Deleting unreference audio file \"" + audioFile + "\"");
    5557                                unreferencedFile.delete();
    5658                               
    5759                                // Also delete any melody meta
    58                                 File melodyMetaFile = new File(
    59                                                 AudioPathManager.AUDIO_HOME_DIRECTORY +
    60                                                 MelodySearch.MELODY_METAFILE_PREFIX +
    61                                                 audioFile +
    62                                                 MelodySearch.MELODY_METAFILE_SUFFIX);
     60                                String melodyFileName = MelodySearch.MELODY_METAFILE_PREFIX + audioFile + MelodySearch.MELODY_METAFILE_SUFFIX;
     61                                File melodyMetaFile = ResourceManager.getAudioResource(melodyFileName, DisplayController.getCurrentFrame());
    6362                               
    6463                                if (melodyMetaFile.exists()) melodyMetaFile.delete();
  • trunk/src/org/apollo/widgets/FramePlayer.java

    r1102 r1434  
    107107               
    108108                // Read typed frames
    109                 File f = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + TYPED_FRAMED_HISTORY_FILE);
     109                File f = new File(AudioPathManager.AUDIO_USERNAME_HOME_DIRECTORY + TYPED_FRAMED_HISTORY_FILE);
    110110                if (f.exists()) {
    111111                        BufferedReader in = null;
     
    147147                try {
    148148                        // Open the vbase for appending
    149                         out = new FileWriter(AudioPathManager.AUDIO_HOME_DIRECTORY + TYPED_FRAMED_HISTORY_FILE, false);
     149                        out = new FileWriter(AudioPathManager.AUDIO_USERNAME_HOME_DIRECTORY + TYPED_FRAMED_HISTORY_FILE, false);
    150150                        for (String str : typedFrameNames) {
    151151                                out.write(str + "\n");
     
    802802                }
    803803               
    804             ComboBoxModel<String> model = new DefaultComboBoxModel<String>((String[]) orderedModelData.toArray());
     804            ComboBoxModel<String> model = new DefaultComboBoxModel<String>((String[]) orderedModelData.toArray(new String[] {}));
     805                //ComboBoxModel model = new DefaultComboBoxModel(orderedModelData.toArray());
    805806           
    806807            // Remove helper tags from model data
  • trunk/src/org/apollo/widgets/SampledTrack.java

    r1179 r1434  
    2323import javax.sound.sampled.LineUnavailableException;
    2424import javax.sound.sampled.UnsupportedAudioFileException;
     25import javax.swing.JSlider;
    2526import javax.swing.SwingUtilities;
    2627
     
    7071import org.expeditee.gui.FrameIO;
    7172import org.expeditee.gui.PopupManager;
     73import org.expeditee.gui.management.ResourceManager;
    7274import org.expeditee.items.ItemParentStateChangedEvent;
    7375import org.expeditee.items.ItemUtils;
     
    401403               
    402404                });
    403                
     405                               
    404406                fulltrackView.addKeyListener(new KeyListener() {
    405407
    406408                        @Override
    407                         public void keyPressed(KeyEvent e)
    408                         {
     409                        public void keyPressed(KeyEvent e) {
    409410                        }
    410411
    411412                        @Override
    412                         public void keyReleased(KeyEvent e)
    413                         {
     413                        public void keyReleased(KeyEvent e)     {
     414                               
     415                                // On 26th September, Bryce added P M + - keys to play/pause/resume, mute and adjust volume.
     416                                if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_P) {
     417                                        try {
     418                                                playbackControlPopup.playPauseResume();
     419                                        } catch (LineUnavailableException e1) {
     420                                                e1.printStackTrace();
     421                                        }
     422                                } else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_M) {
     423                                        boolean selected = playbackControlPopup.muteButton.isSelected();
     424                                        playbackControlPopup.muteButton.setSelected(!selected);
     425                                        playbackControlPopup.muteChanged();
     426                                } else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_SUBTRACT) {
     427                                        JSlider volumeSlider = playbackControlPopup.volumeSlider;
     428                                        int delta = Math.round(((float) (volumeSlider.getMaximum() - volumeSlider.getMinimum())) / 10f);
     429                                        int newVolume = Math.max(volumeSlider.getValue() - delta, volumeSlider.getMinimum());
     430                                        volumeSlider.setValue(newVolume);
     431                                        playbackControlPopup.volumeChanged();
     432                                } else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_ADD) {
     433                                        JSlider volumeSlider = playbackControlPopup.volumeSlider;
     434                                        int delta = Math.round(((float) (volumeSlider.getMaximum() - volumeSlider.getMinimum())) / 10f);
     435                                        int newVolume = Math.min(volumeSlider.getValue() + delta, volumeSlider.getMaximum());
     436                                        volumeSlider.setValue(newVolume);
     437                                        playbackControlPopup.volumeChanged();
     438                                }
     439                               
    414440                                // Toggle pitch-track indexing
    415                                 if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_I) {
     441                                else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_I) {
    416442                                        setShouldOmitIndexAudio(!shouldOmitIndexAudio());
    417443                                        DisplayController.requestRefresh(true);
     
    765791                                setLoadScreenMessage("Loading audio file...");
    766792                               
    767                                 f = new File(
    768                                                 AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     793                                //f = new File(
     794                                //              AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     795                                f = ResourceManager.getAudioResource(localFileName, getParentFrame());
    769796                        }
    770797                       
     
    809836                                        // If recovering - might be recovering an existing track that had been
    810837                                        // saved to the repository .. thus re-use the old file
    811                                         trackModel.setFilepath(AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     838                                        File audioResource = ResourceManager.getAudioResource(localFileName, getParentFrame());
     839                                        trackModel.setFilepath(audioResource.getAbsolutePath());
    812840                                }
    813841                               
     
    940968                // If saving for the file time then get a filename
    941969                if (trackModel.getFilepath() == null) {
    942                         trackModel.setFilepath(AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     970                        File audioResource = ResourceManager.getAudioResource(localFileName, DisplayController.getCurrentFrame());
     971                        trackModel.setFilepath(audioResource.getAbsolutePath());
    943972                        loadFilenameArgument = localFileName; // set to now local, next load will be local
    944973                }
     
    10291058               
    10301059                // Get rid of local file
    1031                 File oldLocalFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     1060                //File oldLocalFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     1061                File oldLocalFile = ResourceManager.getAudioResource(localFileName, getParentFrame());
    10321062                if (oldLocalFile.isFile() && oldLocalFile.exists()) {
    10331063                        try {
     
    11571187                        return recoveryFile.getAbsolutePath();
    11581188                }
    1159                        
    1160                 return AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName;
     1189               
     1190                File audioResource = ResourceManager.getAudioResource(localFileName, getParentFrame());                 
     1191                return audioResource.getAbsolutePath();
    11611192               
    11621193               
     
    20052036                                try {
    20062037       
    2007                                         if (!SoundDesk.getInstance().isPlaying(trackMix.getChannelID())) { // play / resume
    2008                                                
    2009                                                 int startFrame = -1, endFrame = -1;
    2010                                                
    2011                                                 // Resume playback?
    2012                                                 if (SoundDesk.getInstance().isPaused(trackMix.getChannelID())) {
    2013                                                         startFrame = SoundDesk.getInstance().getLastPlayedFramePosition(trackMix.getChannelID());
    2014                                                         if (startFrame >= 0 && startFrame < trackModel.getFrameCount()) {
    2015                                
    2016                                                                 // The user may have edited the audio track and reselected it
    2017                                                                 // since the last pause. Thus select an appropriate end frame
    2018                                                                 endFrame = (trackModel.getSelectionLength() > 1) ?
    2019                                                                                 trackModel.getSelectionStart() + trackModel.getSelectionLength():
    2020                                                                                         trackModel.getFrameCount() - 1;
    2021                                                                        
    2022                                                                 // Changed selection? it play range invalid?
    2023                                                                 if (endFrame <= startFrame || startFrame < trackModel.getSelectionStart()) {
    2024                                                                         startFrame = -1; // Play new selection (see below)
    2025                                                                
    2026                                                                 } else if (endFrame >= trackModel.getFrameCount()) {
    2027                                                                         endFrame = trackModel.getFrameCount() - 1;
    2028                                                                 }               
    2029                                                                
    2030                                                         }
    2031                                                 }
    2032                                                
    2033                                                 // Play from beginning of selection to end of selection
    2034                                                 if (startFrame < 0) {
    2035                                                         startFrame = trackModel.getSelectionStart();
    2036                                                         endFrame = (trackModel.getSelectionLength() > 1) ?
    2037                                                                         startFrame + trackModel.getSelectionLength():
    2038                                                                                 trackModel.getFrameCount() - 1;
    2039                                                 }
    2040        
    2041                                                 // Safety clamp:
    2042                                                 if (endFrame >= trackModel.getFrameCount()) {
    2043                                                         endFrame = trackModel.getFrameCount() - 1;
    2044                                                 }       
    2045                                                
    2046                                                 if (startFrame < endFrame) {
    2047                                                         SoundDesk.getInstance().playSampledTrackModel(
    2048                                                                         trackModel,
    2049                                                                         trackMix.getChannelID(),
    2050                                                                         startFrame,
    2051                                                                         endFrame,
    2052                                                                         0);
    2053                                                 }
    2054        
    2055                                         } else { // pause
    2056                                                
    2057                                                 TrackSequence ts = SoundDesk.getInstance().getTrackSequence(trackMix.getChannelID());
    2058 
    2059                                                 if (ts != null &&
    2060                                                                 ts.isPlaying()) {
    2061                                                        
    2062                                                         // Mark channel as paused.
    2063                                                         SoundDesk.getInstance().setPaused(trackMix.getChannelID(), true);
    2064                                                        
    2065                                                         // Stop playback for this channel
    2066                                                         ApolloPlaybackMixer.getInstance().stop(ts);
    2067                                                        
    2068                                                 }
    2069                                                
    2070                                         }
     2038                                        playPauseResume();
    20712039                                       
    20722040                                } catch (LineUnavailableException e1) {
     
    20942062                        } else if (e.getSource() == miscButton) {
    20952063                                expand(false);
     2064                        }
     2065                }
     2066
     2067                private void playPauseResume() throws LineUnavailableException {
     2068                        if (!SoundDesk.getInstance().isPlaying(trackMix.getChannelID())) { // play / resume
     2069                               
     2070                                int startFrame = -1, endFrame = -1;
     2071                               
     2072                                // Resume playback?
     2073                                if (SoundDesk.getInstance().isPaused(trackMix.getChannelID())) {
     2074                                        startFrame = SoundDesk.getInstance().getLastPlayedFramePosition(trackMix.getChannelID());
     2075                                        if (startFrame >= 0 && startFrame < trackModel.getFrameCount()) {
     2076
     2077                                                // The user may have edited the audio track and reselected it
     2078                                                // since the last pause. Thus select an appropriate end frame
     2079                                                endFrame = (trackModel.getSelectionLength() > 1) ?
     2080                                                                trackModel.getSelectionStart() + trackModel.getSelectionLength():
     2081                                                                        trackModel.getFrameCount() - 1;
     2082                                                       
     2083                                                // Changed selection? it play range invalid?
     2084                                                if (endFrame <= startFrame || startFrame < trackModel.getSelectionStart()) {
     2085                                                        startFrame = -1; // Play new selection (see below)
     2086                                               
     2087                                                } else if (endFrame >= trackModel.getFrameCount()) {
     2088                                                        endFrame = trackModel.getFrameCount() - 1;
     2089                                                }               
     2090                                               
     2091                                        }
     2092                                }
     2093                               
     2094                                // Play from beginning of selection to end of selection
     2095                                if (startFrame < 0) {
     2096                                        startFrame = trackModel.getSelectionStart();
     2097                                        endFrame = (trackModel.getSelectionLength() > 1) ?
     2098                                                        startFrame + trackModel.getSelectionLength():
     2099                                                                trackModel.getFrameCount() - 1;
     2100                                }
     2101
     2102                                // Safety clamp:
     2103                                if (endFrame >= trackModel.getFrameCount()) {
     2104                                        endFrame = trackModel.getFrameCount() - 1;
     2105                                }       
     2106                               
     2107                                if (startFrame < endFrame) {
     2108                                        SoundDesk.getInstance().playSampledTrackModel(
     2109                                                        trackModel,
     2110                                                        trackMix.getChannelID(),
     2111                                                        startFrame,
     2112                                                        endFrame,
     2113                                                        0);
     2114                                }
     2115
     2116                        } else { // pause
     2117                               
     2118                                TrackSequence ts = SoundDesk.getInstance().getTrackSequence(trackMix.getChannelID());
     2119
     2120                                if (ts != null &&
     2121                                                ts.isPlaying()) {
     2122                                       
     2123                                        // Mark channel as paused.
     2124                                        SoundDesk.getInstance().setPaused(trackMix.getChannelID(), true);
     2125                                       
     2126                                        // Stop playback for this channel
     2127                                        ApolloPlaybackMixer.getInstance().stop(ts);
     2128                                       
     2129                                }
     2130                               
    20962131                        }
    20972132                }
  • trunk/src/org/expeditee/auth/AuthenticatorBrowser.java

    r1389 r1434  
    8181       
    8282        private KeyStore keyStore = KeyStore.getInstance(KeystoreType);
    83         public static String USER_NOBODY = "nobody";
     83        public static String USER_NOBODY = "${USER.NAME}";
    8484               
    8585        private static final byte[] TRUE = "yes".getBytes();
     
    124124                g.setWindowSize(new Dimension(UserSettings.InitialWidth.get(), UserSettings.InitialHeight.get()));
    125125                setInputManagerWindowRoutines();
    126                
     126                               
    127127                // Load documentation and start pages
    128128                FrameUtils.extractResources(false);
     
    133133                // initialing settings does not require a user profile established
    134134                Settings.Init();
     135               
     136                // Ensure messages go to public directory whilst we are not logged into an account.
     137                FrameIO.MESSAGES_PATH = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-public").resolve("messages").toString() + File.separator;
    135138               
    136139                // navigate to authentication frame
  • trunk/src/org/expeditee/auth/account/Authenticate.java

    r1401 r1434  
    3232import org.expeditee.gui.Frame;
    3333import org.expeditee.gui.FrameIO;
     34import org.expeditee.gui.FrameUtils;
    3435import org.expeditee.gui.MessageBay;
    3536import org.expeditee.items.Item;
     
    9697                       
    9798                        // Parse the users profile to refresh settings.
    98                         Text settingsLink = new Text("settings");
    99                         settingsLink.setLink(oneFrame.getFramesetName() + "2");
    100                         Settings.parseSettings(settingsLink);
     99                        //Text settingsLink = new Text("settings");
     100                        //settingsLink.setLink(oneFrame.getFramesetName() + "2");
     101                        //Settings.parseSettings(settingsLink);
     102                        FrameUtils.ParseProfile(oneFrame);
    101103                       
    102104                        // At this point we at least login, but maybe with problems.
  • trunk/src/org/expeditee/auth/account/Create.java

    r1402 r1434  
    3636import org.expeditee.gui.MessageBay;
    3737import org.expeditee.gui.MessageBay.Progress;
     38import org.expeditee.gui.management.ProfileManager;
    3839import org.expeditee.io.ExpReader;
    3940import org.expeditee.items.Item;
     
    8586               
    8687                // Update in memory settings
     88                ProfileManager.ensureDefaultProfile();
    8789                System.setProperty("user.name", username);
    8890                UserSettings.UserName.set(username);
     
    119121               
    120122                System.err.println("**** Hardwired call in Apollo's AuthioPathManager");
    121                 AudioPathManager.activateAndScanAudioDir(); // ****
     123                AudioPathManager.activateAndScanAudioDirs(); // ****
    122124               
    123125                progress = progress(message + "Done.", progress, step, progressBar);
  • trunk/src/org/expeditee/gui/Browser.java

    r1415 r1434  
    269269                Text.InitFonts();
    270270
    271                 Settings.Init();
    272                 Frame userProfile = loadProfiles();
    273 
    274271                if (!AuthenticatorBrowser.isAuthenticationRequired() && UserSettings.PublicAndPrivateResources) {
    275                         String userName = UserSettings.ProfileName.get();
     272                        String userName = System.getProperty("user.name"); //UserSettings.ProfileName.get();
    276273                        if (!FrameIO.personalResourcesExist(userName)) {
    277274                                FrameIO.setupPersonalResources(userName);
    278275                        }
    279276                }
     277               
     278                Settings.Init();
     279                Frame userProfile = loadInitialProfiles();
     280                FrameIO.changeParentAndSubFolders(FrameIO.PARENT_FOLDER);
     281               
    280282                // Listen for save status to display during and after runtime
    281283                EntitySaveManager.getInstance().addSaveStateChangedEventListener(this);
     
    285287                       
    286288                        // Go to the start frame if specified, otherwise go to the profile frame
    287                         Frame start = null;
    288289                        if (getStartFrame() == null) {
    289290                                setStartFrame(UserSettings.StartFrame.get());
     
    293294                        }
    294295
     296                        Frame start = null;
    295297                        if ((start = FrameIO.LoadFrame(getStartFrame())) != null) {
    296298                                // Make sure HomeFrame gets set
     
    527529         * @return The user's profile frame.
    528530         */
    529         public static Frame loadProfiles()
     531        public static Frame loadInitialProfiles()
    530532        {
    531533                String defaultProfileName = UserSettings.DEFAULT_PROFILE_NAME;
    532                 String userName = UserSettings.ProfileName.get();
    533 
     534                String userName = System.getProperty("user.name");
     535
     536                Frame defaultProfile = loadProfile(defaultProfileName);
    534537                Frame userProfile = loadProfile(userName);
    535                 Frame defaultProfile = loadProfile(defaultProfileName);
    536538               
    537539                MessageBay.warningMessages(FrameUtils.ParseProfile(defaultProfile));
     
    544546                }
    545547               
    546                 MessageBay.warningMessages(FrameUtils.ParseProfile(userProfile));
     548                //MessageBay.warningMessages(FrameUtils.ParseProfile(userProfile));
    547549               
    548550                if (cursor != null && !FreeItems.hasCursor()) {
    549551                        FreeItems.setCursor(cursor);
    550552                }
     553               
     554                FrameUtils.ParseProfile(userProfile);
    551555               
    552556                return userProfile;
  • 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}
  • trunk/src/org/expeditee/gui/FrameIO.java

    r1433 r1434  
    5757import org.expeditee.encryption.io.EncryptedExpWriter;
    5858import org.expeditee.gio.EcosystemManager;
     59import org.expeditee.gui.management.ProfileManager;
     60import org.expeditee.gui.management.ResourceManager;
    5961import org.expeditee.io.Conversion;
    6062import org.expeditee.io.ExpReader;
     
    110112        public static String SHARED_FRAMESETS_PATH;
    111113        public static String CONTACTS_PATH;
    112         public static String RESOURCES_PRIVATE_PATH;
    113         public static String RESOURCES_PATH;
    114         public static String FRAME_PRIVATE_PATH;
    115         public static String IMAGES_PRIVATE_PATH;
    116         public static String AUDIO_PRIVATE_PATH;
    117         public static String HELP_PRIVATE_PATH;
    118114        public static String HELP_PATH;
    119115        public static String DEAD_DROPS_PATH;
    120116        public static String GROUP_PATH;
     117        public static String RESOURCES_PRIVATE_PATH;
     118        public static String RESOURCES_PATH;
     119        public static String FRAME_USERNAME_PRIVATE_PATH;
     120        public static String IMAGES_USERNAME_PRIVATE_PATH;
     121        public static String AUDIO_USERNAME_PRIVATE_PATH;
     122        public static String HELP_USERNAME_PRIVATE_PATH;
    121123
    122124        // Paths that appear to be unused.
     
    144146               
    145147                String resourcesPublicPath = PARENT_FOLDER + "resources-public" + File.separator;
    146                 String resourcesPrivateIndividualPath = PARENT_FOLDER + "resources-" + UserSettings.UserName.get() + File.separator;
     148                String resourcesPrivateUserPath = PARENT_FOLDER + "resources-" + UserSettings.UserName.get() + File.separator;
    147149               
    148150                if (UserSettings.PublicAndPrivateResources) {
     
    151153                        DICT_PATH = resourcesPublicPath + "dict" + File.separator;
    152154                        HELP_PATH = resourcesPublicPath + "documentation" + File.separator;
    153                         HELP_PRIVATE_PATH = resourcesPrivateIndividualPath + "documentation" + File.separator;
     155                        HELP_USERNAME_PRIVATE_PATH = resourcesPrivateUserPath + "documentation" + File.separator;
    154156                        FRAME_PATH = resourcesPublicPath + "framesets" + File.separator;
    155                         FRAME_PRIVATE_PATH = resourcesPrivateIndividualPath + "framesets" + File.separator;
    156                         MESSAGES_PATH = resourcesPrivateIndividualPath + "messages" + File.separator;
     157                        FRAME_USERNAME_PRIVATE_PATH = resourcesPrivateUserPath + "framesets" + File.separator;
     158                        MESSAGES_PATH = resourcesPrivateUserPath + "messages" + File.separator;
    157159                        IMAGES_PATH = resourcesPublicPath + "images" + File.separator;
    158                         IMAGES_PRIVATE_PATH = resourcesPrivateIndividualPath + "images" + File.separator;
     160                        IMAGES_USERNAME_PRIVATE_PATH = resourcesPrivateUserPath + "images" + File.separator;
    159161                        AUDIO_PATH = resourcesPublicPath + "audio" + File.separator;
    160                         AUDIO_PRIVATE_PATH = resourcesPrivateIndividualPath + "audio" + File.separator;
    161                         GROUP_PATH = resourcesPrivateIndividualPath + "groups" + File.separator;
     162                        AUDIO_USERNAME_PRIVATE_PATH = resourcesPrivateUserPath + "audio" + File.separator;
     163                        GROUP_PATH = resourcesPrivateUserPath + "groups" + File.separator;
    162164
    163165                        // Used only when extracting resources (when expeditee is run for first time)
     
    166168                        if (AuthenticatorBrowser.isAuthenticated()) {
    167169                                // Paths for the new regime while authenticated
    168                                 SHARED_FRAMESETS_PATH = resourcesPrivateIndividualPath + "framesets-shared" + File.separator;
    169                                 DEAD_DROPS_PATH = resourcesPrivateIndividualPath + "deaddrops" + File.separator;
    170                                 CONTACTS_PATH = resourcesPrivateIndividualPath + "contacts" + File.separator;
    171                                 MAIL_PATH = resourcesPrivateIndividualPath + "mail" + File.separator;
     170                                SHARED_FRAMESETS_PATH = resourcesPrivateUserPath + "framesets-shared" + File.separator;
     171                                DEAD_DROPS_PATH = resourcesPrivateUserPath + "deaddrops" + File.separator;
     172                                CONTACTS_PATH = resourcesPrivateUserPath + "contacts" + File.separator;
     173                                MAIL_PATH = resourcesPrivateUserPath + "mail" + File.separator;
    172174                        } else {
    173175                                SHARED_FRAMESETS_PATH = null;
     
    188190                       
    189191                        // These paths are not used by old regime.
    190                         HELP_PRIVATE_PATH = null;
    191                         FRAME_PRIVATE_PATH = null;
    192                         IMAGES_PRIVATE_PATH = null;
    193                         AUDIO_PRIVATE_PATH = null;
     192                        HELP_USERNAME_PRIVATE_PATH = null;
     193                        FRAME_USERNAME_PRIVATE_PATH = null;
     194                        IMAGES_USERNAME_PRIVATE_PATH = null;
     195                        AUDIO_USERNAME_PRIVATE_PATH = null;
    194196                        // - This last one is never used because old regime is never extracted.  If we are going to FrameUtils.extractResources then we are doing new regime.
    195197                        RESOURCES_PRIVATE_PATH = null;
     
    209211                }
    210212               
    211                 System.err.println("**** FrameIO::changeParentAndSubFolder(): Calling AudioPathManger.changeParentAndSubFolder()");
    212                 AudioPathManager.changeParentAndSubFolders(newFolder);
     213                //System.err.println("**** FrameIO::changeParentAndSubFolder(): Calling AudioPathManger.changeParentAndSubFolder()");
     214                //AudioPathManager.changeParentAndSubFolders(newFolder);
    213215        }
    214216       
     
    370372                return null;
    371373        }
    372 
    373         private static Frame LoadFromDisk(String framename, String knownPath,
    374                         boolean ignoreAnnotations) {
    375                 Frame loaded = null;
    376 
    377                 if (knownPath != null) {
    378                         loaded = LoadKnownPath(knownPath, framename);
    379                 } else {
    380                         List<String> directoriesToSearch = FolderSettings.FrameDirs.getAbsoluteDirs();
    381                        
    382                         for (String path : directoriesToSearch) {
    383                                 loaded = LoadKnownPath(path, framename);
    384                                 if (loaded != null) {
    385                                         break;
    386                                 }
    387                         }
    388                 }
    389 
    390                 if (loaded == null && FrameShare.getInstance() != null) {
    391                         loaded = FrameShare.getInstance().loadFrame(framename, knownPath);
    392                 }
    393 
    394                 if (loaded != null) {
    395                         FrameUtils.Parse(loaded, true, ignoreAnnotations);
    396                         FrameIO.setSavedProperties(loaded);
    397                 }
    398 
    399                 return loaded;
    400         }
     374       
     375        private static Frame LoadFromDisk(String frameName, String knownPath, boolean ignoreAnnotationsOnParse) {
     376                return ResourceManager.getExpediteeFrame(frameName, knownPath, ignoreAnnotationsOnParse);
     377        }
     378
     379//      private static Frame LoadFromDisk(String framename, String knownPath,
     380//                      boolean ignoreAnnotations) {
     381//              Frame loaded = null;
     382//
     383//              if (knownPath != null) {
     384//                      loaded = LoadKnownPath(knownPath, framename);
     385//              } else {
     386//                      List<String> directoriesToSearch = FolderSettings.FrameDirs.getAbsoluteDirs();
     387//                     
     388//                      for (String path : directoriesToSearch) {
     389//                              loaded = LoadKnownPath(path, framename);
     390//                              if (loaded != null) {
     391//                                      break;
     392//                              }
     393//                      }
     394//              }
     395//
     396//              if (loaded == null && FrameShare.getInstance() != null) {
     397//                      loaded = FrameShare.getInstance().loadFrame(framename, knownPath);
     398//              }
     399//
     400//              if (loaded != null) {
     401//                      FrameUtils.Parse(loaded, true, ignoreAnnotations);
     402//                      FrameIO.setSavedProperties(loaded);
     403//              }
     404//
     405//              return loaded;
     406//      }
    401407
    402408        /**
     
    563569        }
    564570
    565         private static Frame LoadKnownPath(String path, String frameName) {
     571        public static Frame LoadKnownPath(String path, String frameName) {
    566572                String fullPath = getFrameFullPathName(path, frameName);
    567573                if (fullPath == null) {
     
    13811387        public static boolean isProfileFrame(Frame toCheck)
    13821388        {
    1383                 if (toCheck.getNumber() == 0) {
     1389                if (toCheck.getNumber() == 0 || toCheck.getFramesetName().equals(UserSettings.DEFAULT_PROFILE_NAME)) {
    13841390                        return false;
    13851391                }
     
    14011407
    14021408        public static Frame CreateNewProfile(String username, Map<String, Setting> initialSettings, Map<String, Consumer<Frame>> toNotifyOnSet) throws InvalidFramesetNameException, ExistingFramesetException {
    1403                 Frame profile = CreateFrameset(username, PROFILE_PATH, true);
    1404                 if (profile != null) {
    1405                         FrameUtils.CreateDefaultProfile(username, profile, initialSettings, toNotifyOnSet);
     1409//              Frame profile = CreateFrameset(username, PROFILE_PATH, true);
     1410//              if (profile != null) {
     1411//                      FrameUtils.CreateDefaultProfile(username, profile, initialSettings, toNotifyOnSet);
     1412//              } else {
     1413//                      System.err.println("An error occured while attempting to create the profile named: " + username);
     1414//                      System.err.println("Unable to proceed.");
     1415//                      System.exit(1);
     1416//              }
     1417//              return profile;
     1418                if (username.equals(UserSettings.DEFAULT_PROFILE_NAME)) {
     1419                        ProfileManager.ensureDefaultProfile();
     1420                        return FrameIO.LoadFrame(UserSettings.DEFAULT_PROFILE_NAME + "1");
    14061421                } else {
    1407                         System.err.println("An error occured while attempting to create the profile named: " + username);
    1408                         System.err.println("Unable to proceed.");
    1409                         System.exit(1);
    1410                 }
    1411                 return profile;
     1422                        return ProfileManager.createProfile(username, initialSettings, toNotifyOnSet);
     1423                }
    14121424        }
    14131425
  • 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
  • trunk/src/org/expeditee/gui/ItemsList.java

    r1415 r1434  
    7171        }
    7272       
    73         public void retainHistory(ItemsList historyItems) {
     73        public void retainAll(ItemsList historyItems) {
    7474                items.retainAll(historyItems.items);
    7575        }
  • trunk/src/org/expeditee/gui/MessageBay.java

    r1415 r1434  
    222222        /** TODO: Comment. cts16 */
    223223        public synchronized static Text displayMessage(String message, String link, Colour color, boolean displayAlways,
    224                         String action) {
     224                        String action) {       
    225225                List<String> actions = new LinkedList<String>();
    226226                if (action != null) {
  • trunk/src/org/expeditee/items/ItemUtils.java

    r1426 r1434  
    3939import org.expeditee.gui.FreeItems;
    4040import org.expeditee.gui.Vector;
     41import org.expeditee.gui.management.ResourceManager;
    4142import org.expeditee.items.Item.HighlightMode;
    4243import org.expeditee.items.widgets.InteractiveWidgetInitialisationFailedException;
     
    376377         */
    377378        public static Picture CreatePicture(Text source, boolean tryRemote) {
    378                 String text = source.getText();
    379                 String path = "";
    380                 String fileName = "";
    381                 String size = "";
    382 
    383                 try {
    384                         // remove @i tag
    385                         text = text.replaceFirst("@i:", "");
    386                         text = text.replaceAll("\n", "");
    387                         text = text.trim();
    388 
    389                         int fileSuffixChar = text.indexOf('.');
    390                         if (fileSuffixChar < 0) {
    391                                 return null;
    392                         }
    393                         int endOfFileName = text.indexOf(' ', fileSuffixChar);
    394                         if (endOfFileName < 0) {
    395                                 path = text;
    396                                 size = "";
    397                         } else {
    398                                 path = text.substring(0, endOfFileName);
    399                                 size = text.substring(endOfFileName).trim();
    400                         }
    401                         fileName = path;
    402                        
    403                         if (!fileName.equals(Picture.REDACTED_IMAGE_NAME)) {
    404                                 // try images subdirectory
    405                                 File file = null;
    406 
    407                                 for (String dir : FolderSettings.ImageDirs.getAbsoluteDirs()) {
    408                                         file = new File(dir + path);
    409                                         if (file.exists() && !file.isDirectory()) {
    410                                                 break;
    411                                         }
    412                                 }
    413 
    414                                 if (file == null || !file.exists() || file.isDirectory()) {
    415                                         file = new File(path);
    416                                 }
    417 
    418                                 // try relative path
    419                                 if (!file.exists() || file.isDirectory()) {
    420                                         URL picture = new Object().getClass().getResource(path);
    421 
    422                                         // decode to remove %20 in windows folder names
    423                                         if (picture != null) {
    424                                                 try {
    425                                                         path = URLDecoder.decode(picture.getFile(), "UTF-8");
    426                                                 } catch (UnsupportedEncodingException e) {
    427                                                         // TODO Auto-generated catch block
    428                                                         e.printStackTrace();
    429                                                 }
    430                                         }
    431 
    432                                 } else {
    433                                         path = file.getPath();
    434                                 }
    435 
    436                                 // if the image isn't found by now, try remote servers
    437                                 file = new File(path);
    438                                 if (!file.exists() || file.isDirectory()) {
    439                                 if(tryRemote && FrameShare.getInstance().loadImage(fileName, null)) {
    440                                         // call CreatePicture again, but with tryRemote set to false so we won't get into an infinite loop
    441                                         // if something goes wrong with finding the downloaded image
    442                                         return CreatePicture(source, false);
    443                                 }
    444                                         return null;
    445                                 }
    446                         }
    447                 } catch (Exception e) {
    448                         return null;
    449                 }
    450 
    451                 try {
    452                         Picture pic = new Picture(source, fileName, path, size);
    453 
    454                         return pic;
    455                 } catch (Exception e) {
    456                         e.printStackTrace();
    457                         return null;
    458                 }
    459 
    460         }
     379                return ResourceManager.getExpediteePicture(source, tryRemote);
     380        }
     381//      public static Picture CreatePicture(Text source, boolean tryRemote) {
     382//              String text = source.getText();
     383//              String path = "";
     384//              String fileName = "";
     385//              String size = "";
     386//
     387//              try {
     388//                      // remove @i tag
     389//                      text = text.replaceFirst("@i:", "");
     390//                      text = text.replaceAll("\n", "");
     391//                      text = text.trim();
     392//
     393//                      int fileSuffixChar = text.indexOf('.');
     394//                      if (fileSuffixChar < 0) {
     395//                              return null;
     396//                      }
     397//                      int endOfFileName = text.indexOf(' ', fileSuffixChar);
     398//                      if (endOfFileName < 0) {
     399//                              path = text;
     400//                              size = "";
     401//                      } else {
     402//                              path = text.substring(0, endOfFileName);
     403//                              size = text.substring(endOfFileName).trim();
     404//                      }
     405//                      fileName = path;
     406//                     
     407//                      if (!fileName.equals(Picture.REDACTED_IMAGE_NAME)) {
     408//                              // try images subdirectory
     409//                              File file = null;
     410//
     411//                              List<String> absoluteDirs = FolderSettings.ImageDirs.getAbsoluteDirs();
     412//                              for (String dir : absoluteDirs) {
     413//                                      file = new File(dir + path);
     414//                                      if (file.exists() && !file.isDirectory()) {
     415//                                              break;
     416//                                      }
     417//                              }
     418//
     419//                              if (file == null || !file.exists() || file.isDirectory()) {
     420//                                      file = new File(path);
     421//                              }
     422//
     423//                              // try relative path
     424//                              if (!file.exists() || file.isDirectory()) {
     425//                                      URL picture = new Object().getClass().getResource(path);
     426//
     427//                                      // decode to remove %20 in windows folder names
     428//                                      if (picture != null) {
     429//                                              try {
     430//                                                      path = URLDecoder.decode(picture.getFile(), "UTF-8");
     431//                                              } catch (UnsupportedEncodingException e) {
     432//                                                      // TODO Auto-generated catch block
     433//                                                      e.printStackTrace();
     434//                                              }
     435//                                      }
     436//
     437//                              } else {
     438//                                      path = file.getPath();
     439//                              }
     440//
     441//                              // if the image isn't found by now, try remote servers
     442//                              file = new File(path);
     443//                              if (!file.exists() || file.isDirectory()) {
     444//                              if(tryRemote && FrameShare.getInstance().loadImage(fileName, null)) {
     445//                                      // call CreatePicture again, but with tryRemote set to false so we won't get into an infinite loop
     446//                                      // if something goes wrong with finding the downloaded image
     447//                                      return CreatePicture(source, false);
     448//                              }
     449//                                      return null;
     450//                              }
     451//                      }
     452//              } catch (Exception e) {
     453//                      return null;
     454//              }
     455//
     456//              try {
     457//                      Picture pic = new Picture(source, fileName, path, size);
     458//
     459//                      return pic;
     460//              } catch (Exception e) {
     461//                      e.printStackTrace();
     462//                      return null;
     463//              }
     464//
     465//      }
    461466       
    462467        public static Picture CreatePicture(Text source) {
  • trunk/src/org/expeditee/items/XRayable.java

    r1431 r1434  
    2727import org.expeditee.encryption.items.surrogates.Label;
    2828import org.expeditee.gui.DisplayController;
     29import org.expeditee.gui.Frame;
    2930
    3031public abstract class XRayable extends Item {
     
    5960                        return true;
    6061                } else {
    61                         List<String> accessibleLabelsNames = Label.getAccessibleLabelsNames(this.getParent().getBody());
     62                        Frame parent = this.getParent();
     63                        List<String> accessibleLabelsNames = Label.getAccessibleLabelsNames(parent.getBody(true));
    6264                        return accessibleLabelsNames.contains(encryptionLabel);
    6365                }
  • trunk/src/org/expeditee/setting/DirectoryListSetting.java

    r1245 r1434  
    33import java.io.File;
    44import java.util.ArrayList;
     5import java.util.HashMap;
    56import java.util.LinkedList;
    67import java.util.List;
     8import java.util.Map;
    79
     10import org.expeditee.gui.DisplayController;
    811import org.expeditee.gui.FrameIO;
    912import org.expeditee.gui.FrameUtils;
     
    1114
    1215public class DirectoryListSetting extends ListSetting<String> {
    13 
     16               
    1417        /*
    1518        public DirectoryListSetting(String tooltip, String name, List<String> value) {
     
    2326        @Override
    2427        public boolean setSetting(Text text) {
    25                 _value.addAll(FrameUtils.getDirs(text));
     28                List<String> dirs = FrameUtils.getDirs(text);
     29                if (!dirs.isEmpty()) {
     30                        _value.clear();
     31                        _value.addAll(dirs);
     32                }
    2633                return true;
    2734        }
    28 
     35       
    2936        public List<String> getAbsoluteDirs() {
    3037                String parent_folder = FrameIO.PARENT_FOLDER;
     
    4451                                // => use it 'as is'
    4552                                abs = rel;
    46                         }
    47                         else {
    48                                 abs = parent_folder + rel;
    49                                
     53                        } else {
     54                                abs = parent_folder + rel;     
    5055                        }
    5156                        value_absolute_dir.add(abs);
  • trunk/src/org/expeditee/setting/ListSetting.java

    r1242 r1434  
    2626import org.expeditee.gui.FrameIO;
    2727import org.expeditee.items.Text;
     28import org.expeditee.settings.UserSettings;
    2829
    2930public abstract class ListSetting<T> extends VariableSetting {
     
    6869                        listFrame.getTitleItem().delete();
    6970                       
    70                         int x = 100;
    71                         int y = 100;
     71                        int x = UserSettings.TitlePosition.get();
     72                        int y = UserSettings.TitlePosition.get();
    7273                        for (T v: _value) {
    7374                                if (v == null) continue;
  • trunk/src/org/expeditee/settings/Settings.java

    r1415 r1434  
    2121import java.lang.reflect.Field;
    2222import java.lang.reflect.Method;
     23import java.util.ArrayList;
    2324import java.util.Collection;
    2425import java.util.HashMap;
     
    3031import org.expeditee.gui.Frame;
    3132import org.expeditee.gui.FrameCreator;
     33import org.expeditee.gui.FrameIO;
    3234import org.expeditee.gui.MessageBay;
    3335import org.expeditee.items.Item;
     
    145147                List<VariableSetting> set = new LinkedList<VariableSetting>();
    146148               
    147                 Frame child = text.getChild();
     149                String linkForChild = text.getAbsoluteLink();
     150                Frame child = FrameIO.LoadFrame(linkForChild, FrameIO.PROFILE_PATH);
    148151               
    149152                if(child == null) return set;
  • trunk/src/org/expeditee/settings/UserSettings.java

    r1415 r1434  
    3535import org.expeditee.gui.FrameUtils;
    3636import org.expeditee.gui.MessageBay;
     37import org.expeditee.gui.management.ProfileManager;
    3738import org.expeditee.items.Text;
    3839import org.expeditee.setting.BooleanSetting;
     
    4243import org.expeditee.setting.IntegerSetting;
    4344import org.expeditee.setting.ListSetting;
     45import org.expeditee.setting.Setting;
    4446import org.expeditee.setting.StringSetting;
    4547import org.expeditee.settings.folders.FolderSettings;
     
    5254public abstract class UserSettings {
    5355       
    54         public static String DEFAULT_PROFILE_NAME = "default";
     56        public static final String DEFAULT_PROFILE_NAME = "default";
    5557         
    5658        public static Boolean PublicAndPrivateResources;
     
    6668                @Override
    6769                public boolean setSetting(Text text) {
    68                 if(text.getText().indexOf(':') == -1 || !text.hasLink()) {
    69                         text.setLink(UserSettings.ProfileName.get() + "1");
     70                String profileName = UserSettings.ProfileName.get();
     71                        if(text.getText().indexOf(':') == -1 || !text.hasLink()) {
     72                                if (!profileName.equals(ProfileManager.USER_NAME_PATTERN)) {
     73                                        text.setLink(profileName + "1");
     74                                }
    7075                        //text.setLink(FrameIO.LoadProfile(UserSettings.ProfileName.get()).getName());
    7176                }
     
    7984                        // MessageBay.warningMessage("Home frame: " + first
    8085                        // + " is not a valid frame.");
    81                         _value = FrameIO.LoadProfile(UserSettings.ProfileName.get()).getName();
     86                        _value = profileName + "1";//FrameIO.LoadProfile(UserSettings.ProfileName.get()).getName();
    8287                }
    8388                return true;
     
    104109        public static final IntegerSetting TitlePosition = new IntegerSetting("Position of title item in frame (TODO: find whether this is x-offset or y-offset)", "TitlePosition", 150);
    105110               
    106         public static final StringSetting UserName = new StringSetting("Profile name", FrameIO.ConvertToValidFramesetName(System.getProperty("user.name")));
    107        
    108         public static final StringSetting ProfileName = new StringSetting("Profile name", UserName.get());
     111        public static final StringSetting UserName = new StringSetting("User name", "${USER.NAME}"); // FrameIO.ConvertToValidFramesetName(System.getProperty("user.name"))
     112       
     113        public static final StringSetting ProfileName = new StringSetting("Profile name", "${USER.NAME}");
    109114               
    110115        public static final BooleanSetting AntiAlias = new BooleanSetting("Whether anti-aliasing should be enabled", "AntiAlias", false);
     
    246251                if (PublicAndPrivateResources) {
    247252                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.HELP_PATH);
    248                         FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.HELP_PRIVATE_PATH);
     253                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.HELP_USERNAME_PRIVATE_PATH);
    249254                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PATH);
    250                         FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PRIVATE_PATH);
     255                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_USERNAME_PRIVATE_PATH);
    251256                        FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MESSAGES_PATH);
    252257                        if (AuthenticatorBrowser.isAuthenticated()) {
     
    258263                       
    259264                        FolderSettings.ImageDirs.addAbsoluteDir(FrameIO.IMAGES_PATH);
    260                         FolderSettings.ImageDirs.addAbsoluteDir(FrameIO.IMAGES_PRIVATE_PATH);
     265                        FolderSettings.ImageDirs.addAbsoluteDir(FrameIO.IMAGES_USERNAME_PRIVATE_PATH);
    261266                        FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
    262267                       
    263268                        FolderSettings.AudioDirs.addAbsoluteDir(FrameIO.AUDIO_PATH);
    264                         FolderSettings.AudioDirs.addAbsoluteDir(FrameIO.AUDIO_PRIVATE_PATH);
     269                        FolderSettings.AudioDirs.addAbsoluteDir(FrameIO.AUDIO_USERNAME_PRIVATE_PATH);
    265270                        FolderSettings.AudioDirs.setDefault(FolderSettings.AudioDirs.get());
    266271                } else {
Note: See TracChangeset for help on using the changeset viewer.