Changeset 1242 for trunk


Ignore:
Timestamp:
03/15/19 16:48:00 (5 years ago)
Author:
bln4
Message:

Support for new regime in the form of new fields and conditional setting of all paths fields.

Settings are now able to generate their own representation. This allows for the user to explicitly inspect the default values.

When profiles are created, an optional parameter may now be provided. If not null, the new map parameter can contain default values for settings to apply to this profile. This allows for the creation of profiles to that have (for example), their username set to an explicit value. Multiuser mode uses this functionality for usernames and key values among other things.

Frames can now be asked were they are located on the file system. Furthermore, frame indirection is now a thing. Rather than containing data to display, an exp file can contain a line in the format of "REDIRECT:<path>" to go looking for that data. Frames are able to return both their logical (their exp file) and real (the file actually containing the data) paths.

Frames can now store data.

Further fixes to how edits from other users are loaded in.

Location:
trunk/src/org
Files:
1 added
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/ApolloSystem.java

    r1102 r1242  
    3232import org.expeditee.gui.Frame;
    3333import org.expeditee.gui.FrameIO;
    34 import org.expeditee.settings.UserSettings;
    3534import org.expeditee.items.Item;
    3635import org.expeditee.items.Text;
     36import org.expeditee.settings.UserSettings;
    3737
    3838/**
     
    155155                if (profile == null) {
    156156                        try {
    157                                 profile = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME);
     157                                profile = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME, null);
    158158                        } catch (Exception e) {
    159159                                e.printStackTrace();
  • trunk/src/org/expeditee/actions/Misc.java

    r1197 r1242  
    4646import org.expeditee.gio.gesture.StandardGestureActions;
    4747import org.expeditee.gui.AttributeUtils;
    48 import org.expeditee.io.Conversion;
    4948import org.expeditee.gui.DisplayController;
    50 import org.expeditee.io.ExpReader;
    5149import org.expeditee.gui.Frame;
    5250import org.expeditee.gui.FrameGraphics;
     
    5856import org.expeditee.gui.Reminders;
    5957import org.expeditee.gui.TimeKeeper;
     58import org.expeditee.io.Conversion;
     59import org.expeditee.io.ExpReader;
    6060import org.expeditee.items.Item;
    6161import org.expeditee.items.ItemUtils;
     
    13341334                homeFrame.removeAllItems(homeFrame.getItems());
    13351335                homeFrame.addText(0, 0, "title", null);
    1336                 FrameUtils.CreateDefaultProfile(UserSettings.UserName.get(), homeFrame);
     1336                FrameUtils.CreateDefaultProfile(UserSettings.UserName.get(), homeFrame, null);
    13371337        }
    13381338       
     
    15231523        String frameName = frame.getName();
    15241524           
    1525         String frameDir = framePath + Conversion.getFramesetName(frameName)
    1526             + File.separator;
     1525        String frameDir = frame.getFramesetPath(); //framePath + Conversion.getFramesetName(frameName) + File.separator;
    15271526        String localFname = Conversion.getFrameNumber(frameName)
    15281527            + ExpReader.EXTENTION;
  • trunk/src/org/expeditee/core/Colour.java

    r1097 r1242  
    11package org.expeditee.core;
     2
     3import org.expeditee.items.Text;
    24
    35/**
     
    911 *
    1012 */
    11 public class Colour {
     13public class Colour implements Representable {
    1214
    1315        private short r, g, b, a;
     
    280282                return new Colour(this);
    281283        }
     284
     285        @Override
     286        public Text generateRepresentation(String content, String frameset) {
     287                Text t = new Text(content);
     288                t.setColor(this);
     289                return t;
     290        }
    282291}
  • trunk/src/org/expeditee/gio/gesture/StandardGestureActions.java

    r1228 r1242  
    9090                CUT,
    9191                DELETE,
    92                 DROP_DOWN, // F0 (ESC) (Seems to locate the cursor underneath the current/last item?)
     92                DROP_DOWN, // F0 (ESC) (Positions the cursor below the current text item.  Similar to enter in traditional editors.)
    9393                EXTRACT_ATTRIBUTES,
    9494                EXTRUDE,
     
    743743                                RefreshGestureData data = (RefreshGestureData) gesture.getData();
    744744                                if (data.shouldReloadFrameFirst()) {
    745                                         MessageBay.displayMessage("Forced reload before forced refresh");
     745                                        MessageBay.displayMessage("Loaded in data from external edit made my another user.");
    746746                                        DisplayController.Reload(DisplayController.TwinFramesSide.LEFT);
    747747                                }
  • trunk/src/org/expeditee/gui/Browser.java

    r1224 r1242  
    536536        }
    537537
    538         protected static Frame loadProfile(String userName)
    539         {
     538        protected static Frame loadProfile(String userName)     {
    540539                Frame profile = FrameIO.LoadProfile(userName);
    541540               
    542541                if (profile == null) {
    543542                        try {
    544                                 profile = FrameIO.CreateNewProfile(userName);
     543                                profile = FrameIO.CreateNewProfile(userName, null);
    545544                        } catch (Exception e) {
    546545                                // TODO tell the user that there was a problem creating the
  • trunk/src/org/expeditee/gui/Frame.java

    r1229 r1242  
    1919package org.expeditee.gui;
    2020
     21import java.io.File;
    2122import java.sql.Time;
    2223import java.util.ArrayList;
     
    3536import org.expeditee.core.Image;
    3637import org.expeditee.core.bounds.PolygonBounds;
     38import org.expeditee.gio.EcosystemManager;
     39import org.expeditee.gio.gesture.Gesture;
     40import org.expeditee.gio.gesture.Gesture.GestureType;
    3741import org.expeditee.gio.gesture.StandardGestureActions;
     42import org.expeditee.gio.gesture.StandardGestureActions.StandardGestureType;
     43import org.expeditee.gio.gesture.data.RefreshGestureData;
    3844import org.expeditee.gio.input.KBMInputEvent.Key;
    3945import org.expeditee.gio.input.StandardInputEventListeners;
    4046import org.expeditee.io.Conversion;
     47import org.expeditee.io.ExpReader;
    4148import org.expeditee.items.Constraint;
    4249import org.expeditee.items.Dot;
     
    132139        // for drawing purposes
    133140        private List<Widget> _iWidgets = new ArrayList<Widget>();
     141       
     142        // frame data
     143        private Item frameData = new Text("Frame Data");
    134144
    135145        private int _lineCount = 0;
     
    167177
    168178        /** Default constructor, nothing is set. */
    169         public Frame()
    170         {
     179        public Frame() {
    171180        }
    172181
     
    292301         *            true if the frame should be recalculated first.
    293302         */
    294         public void notifyObservers(boolean bRecalculate)
    295         {
     303        public void notifyObservers(boolean bRecalculate) {
    296304                if (bRecalculate) {
    297305                        recalculate();
     
    17991807         * @return The newly created Text Item
    18001808         */
    1801         public Text createBlankText(String templateType)
    1802         {
     1809        public Text createBlankText(String templateType) {
     1810                File file = new File(getFramePathReal());
     1811                long fileLastModified = file.lastModified();
     1812                long frameLastModified = this.getLastModifyPrecise();
     1813                //if (ExpReader.getVersion(getFramePathReal()) > this._version) {
     1814                if (fileLastModified > frameLastModified) {
     1815                        GestureType refreshGestureType = StandardGestureActions.getInstance().gestureType(StandardGestureType.REFRESH);
     1816                        RefreshGestureData refreshGestureData = new RefreshGestureData(true, false);
     1817                        try {
     1818                                StandardGestureActions.getInstance().onGesture(new Gesture(refreshGestureType, refreshGestureData));
     1819                                EcosystemManager.getMiscManager().beep();
     1820                        } catch (NullPointerException e) {
     1821                                //Detected more recent data on file system than on Frame in memory.  Unfortunately not in a position to cause a refresh.
     1822                        }
     1823                }
     1824               
    18031825                SessionStats.CreatedText();
    18041826                Text t;
     
    18341856                return t;
    18351857        }
    1836 
    1837         public Item createDot()
    1838         {
     1858       
     1859        /**
     1860         * Returns the data associated with the frame.
     1861         * @return
     1862         */
     1863        public List<String> getData() {
     1864                return frameData.getData();
     1865        }
     1866       
     1867        /**
     1868         * Adds a piece of data to be associated with the frame.
     1869         * @param dataItem
     1870         */
     1871        public void addToData(String dataItem) {
     1872                frameData.addToData(dataItem);
     1873        }
     1874
     1875        /**
     1876         * Returns the path (String) to the .exp file that this Frame represents.
     1877         * This follows redirects, meaning that it provides the actual file from which
     1878         * the frames data is drawn from.
     1879         * @return The path to the .exp file that this Frame represents
     1880         * @see getFramePathLogical
     1881         * @see getFramesetPath
     1882         */
     1883        public String getFramePathReal() {
     1884                String framesetPath = getFramesetPath();
     1885                String redirect = ExpReader.redirectTo(getFramePathLogical());
     1886               
     1887                if (redirect == null) {
     1888                        return getFramePathLogical();
     1889                }
     1890               
     1891                while (redirect != null) {
     1892                        framesetPath = getFramesetPath() + redirect;
     1893                        redirect = ExpReader.redirectTo(redirect);
     1894                }
     1895                return framesetPath;
     1896        }
     1897
     1898        /**
     1899         * Returns the path (String) to the .exp file that this Frame represents.
     1900         * Does not follow redirects, opting to instead provide the logical path to this file.
     1901         * @return The path to the .exp file that this Frame represents
     1902         * @see getFramePathReal
     1903         * @see getFramesetPath
     1904         */
     1905        public String getFramePathLogical() {
     1906                return getFramesetPath() + this.getNumber() + ExpReader.EXTENTION;
     1907        }
     1908
     1909        /**
     1910         * Returns the path (String) to the frameset directory that the file that this Frame represents is contained within.
     1911         * @return The path to this Frames frameset directory
     1912         * @see getFramesetPathLogical
     1913         * @see getFramesetPathReal
     1914         */
     1915        public String getFramesetPath() {
     1916                return this.getPath() + File.separator + this.getFramesetName() + File.separator;
     1917        }
     1918
     1919        public Item createDot() {
    18391920                Item dot = new Dot(DisplayController.getMouseX(), DisplayController.getMouseY(), getNextItemID());
    18401921
     
    24622543        {
    24632544                Collection<Item> allItems = new LinkedHashSet<Item>(_body);
     2545               
    24642546                allItems.addAll(_overlayItems);
    24652547                allItems.addAll(_vectorItems);
  • trunk/src/org/expeditee/gui/FrameIO.java

    r1232 r1242  
    3333import java.io.Writer;
    3434import java.nio.channels.FileChannel;
     35import java.nio.file.Paths;
    3536import java.sql.Time;
     37import java.util.Arrays;
    3638import java.util.Collection;
    3739import java.util.HashMap;
    3840import java.util.LinkedList;
    3941import java.util.List;
     42import java.util.Map;
     43import java.util.stream.Collectors;
    4044
    4145import org.expeditee.actions.Actions;
    4246import org.expeditee.agents.ExistingFramesetException;
     47import org.expeditee.agents.InvalidFramesetNameException;
    4348import org.expeditee.auth.Authenticator;
    4449import org.expeditee.auth.EncryptedExpReader;
    4550import org.expeditee.auth.EncryptedExpWriter;
    4651import org.expeditee.auth.gui.MailBay;
     52import org.expeditee.gio.EcosystemManager;
    4753import org.expeditee.io.Conversion;
    4854import org.expeditee.io.ExpReader;
     
    5965import org.expeditee.items.UserAppliedPermission;
    6066import org.expeditee.network.FrameShare;
     67import org.expeditee.setting.Setting;
    6168import org.expeditee.settings.UserSettings;
    6269import org.expeditee.settings.folders.FolderSettings;
     
    7986
    8087        public static void changeParentFolder(String newFolder) {
     88                // Partial Paths.
    8189                PARENT_FOLDER = newFolder;
     90                String resourcesPublicPath = PARENT_FOLDER + "resources-public" + File.separator;
     91                String resourcesPrivateIndividualPath = PARENT_FOLDER + "resources-" + UserSettings.UserName.get() + File.separator;
     92               
     93                // Standard paths.
    8294                PUBLIC_PATH = PARENT_FOLDER + "public" + File.separator;
    83                 FRAME_PATH = PARENT_FOLDER + "framesets" + File.separator;
    8495                MESSAGES_PATH = PARENT_FOLDER + "messages" + File.separator;
    8596                TRASH_PATH = PARENT_FOLDER + "trash" + File.separator;
    86                 IMAGES_PATH = PARENT_FOLDER + IMAGES_FOLDER;
    8797                HELP_PATH = PARENT_FOLDER + "documentation" + File.separator;
    88                 DICT_PATH = PARENT_FOLDER + "dict" + File.separator;
    89                 FONT_PATH = PARENT_FOLDER + "fonts" + File.separator;
    9098                PROFILE_PATH = PARENT_FOLDER + "profiles" + File.separator;
    9199                EXPORTS_DIR = PARENT_FOLDER + "exports" + File.separator;
    92100                STATISTICS_DIR = PARENT_FOLDER + "statistics" + File.separator;
    93101                LOGS_DIR = PARENT_FOLDER + "logs" + File.separator;
    94                 SHARED_BY_ME_FRAMESETS = PARENT_FOLDER + "framesets-shared-by-me" + File.separator;
    95                 SHARED_WITH_ME_FRAMESETS = PARENT_FOLDER + "framesets-shared-with-me" + File.separator;
    96         }
    97 
    98         /**
    99          * The default location for storing the framesets. Each frameset has its own
    100          * subdirectory in this directory.
    101          */
    102         public static String IMAGES_FOLDER = "images" + File.separator;
    103 
     102                               
     103                // New regime paths.
     104                if (UserSettings.multiUserMode) {
     105                        SHARED_FRAMESETS_PATH = resourcesPrivateIndividualPath + "framesets-shared" + File.separator;
     106                        RESOURCES_PRIVATE = PARENT_FOLDER + "resources-private" + File.separator;
     107                        RESOURCES_PATH = resourcesPublicPath + "documentation" + File.separator;
     108                        FRAME_PRIVATE_PATH = resourcesPrivateIndividualPath + "framesets" + File.separator;
     109                        IMAGES_PRIVATE_PATH = resourcesPrivateIndividualPath + "images" + File.separator;
     110                        CONTACTS_PATH = resourcesPrivateIndividualPath + "contacts" + File.separator;
     111                } else {
     112                        // If we are using the old regime then these paths should not be used.
     113                        SHARED_FRAMESETS_PATH = null;
     114                        RESOURCES_PRIVATE = null;               
     115                        RESOURCES_PATH = null;
     116                        FRAME_PRIVATE_PATH = null;
     117                        IMAGES_PRIVATE_PATH = null;
     118                        CONTACTS_PATH = null;
     119                }
     120               
     121                // Conditional paths
     122                if (UserSettings.multiUserMode) {
     123                        FONT_PATH = resourcesPublicPath + "fonts" + File.separator;
     124                        DICT_PATH = resourcesPublicPath + "dict" + File.separator;
     125                        IMAGES_PATH = resourcesPublicPath + "images" + File.separator;
     126                        FRAME_PATH = resourcesPublicPath + "framesets" + File.separator;
     127                } else {
     128                        FONT_PATH = PARENT_FOLDER + "fonts" + File.separator;
     129                        DICT_PATH = PARENT_FOLDER + "dict" + File.separator;
     130                        IMAGES_PATH = PARENT_FOLDER + "images" + File.separator;
     131                        FRAME_PATH = PARENT_FOLDER + "framesets" + File.separator;
     132                }
     133        }
     134
     135        // The parent path that all others are relative to.  Also referred to as Expeditee Home.
     136        public static String PARENT_FOLDER;
     137       
     138        // The below paths are categorised based on their use in the new/old regime.  See UserSettings.appendDefaultFolders for more inforamtion.
     139        // Paths used by Both the new regime (multiuser mode) and the old regime.
     140        public static String PROFILE_PATH;
     141        public static String FRAME_PATH;
     142        public static String MESSAGES_PATH;
     143        public static String IMAGES_PATH;
     144        public static String PUBLIC_PATH;
    104145        public static String TRASH_PATH;
    105 
    106         public static String PARENT_FOLDER;
    107 
    108         public static String FRAME_PATH;
    109 
    110         public static String MESSAGES_PATH;
    111 
    112         public static String PUBLIC_PATH;
    113 
    114         public static String IMAGES_PATH;
    115 
     146       
     147        // Paths used by both the new regime and the old regime, that points to different locations based on regime setting.
     148        public static String FONT_PATH;
     149        public static String DICT_PATH;
     150        public static String EXPORTS_DIR;
     151        public static String STATISTICS_DIR;
     152        public static String LOGS_DIR;
     153       
     154        // Paths used only by new regime.
     155        public static String SHARED_FRAMESETS_PATH;
     156        public static String CONTACTS_PATH;
     157        public static String RESOURCES_PRIVATE;
     158        public static String RESOURCES_PATH;
     159        public static String FRAME_PRIVATE_PATH;
     160        public static String IMAGES_PRIVATE_PATH;
     161       
     162        // Paths used only by old regime.
    116163        public static String HELP_PATH;
    117 
    118         public static String FONT_PATH;
    119164       
     165        // Paths that appear to be unused.
    120166        public static String TEMPLATES_PATH;
     167                       
     168        // Variables for controlling cache functionality.
     169        public static final int MAX_NAME_LENGTH = 64;
     170        public static final int MAX_CACHE = 100;
     171        private static HashMap<String, Frame> _Cache = new FrameCache();
     172        private static boolean ENABLE_CACHE = true;
     173        private static boolean _UseCache = true;
     174        private static boolean _SuspendedCache = false;
    121175       
    122         public static String DICT_PATH;
    123 
    124         public static String PROFILE_PATH;
    125 
    126         public static String EXPORTS_DIR;
    127 
    128         public static String STATISTICS_DIR;
     176        private static final String INF_FILENAME = "frame.inf";
    129177       
    130         public static String SHARED_BY_ME_FRAMESETS;
    131        
    132         public static String SHARED_WITH_ME_FRAMESETS;
    133 
    134         public static String LOGS_DIR;
    135 
    136         private static final String INF_FILENAME = "frame.inf";
    137 
    138         public static final String ILLEGAL_CHARS = ";:\\/?";
    139 
    140         public static final int MAX_NAME_LENGTH = 64;
    141 
    142         public static final int MAX_CACHE = 100;
    143 
    144         private static HashMap<String, Frame> _Cache = new FrameCache();
    145 
    146         // private static HashMap<String, String> _FramesetNameCache = new
    147         // HashMap<String, String>();
    148 
    149         private static boolean ENABLE_CACHE = true;
    150 
    151         private static boolean _UseCache = true;
    152 
    153         private static boolean _SuspendedCache = false;
    154 
    155178        // All methods are static, this should not be instantiated
    156179        private FrameIO() {
     
    202225        }
    203226       
     227        /**
     228         * Loads a frame with the specified name. 
     229         * By using a dot separated framename, users are able to specify the path to find the frameset in.
     230         * @param frameName The frame to load.
     231         * @return the loaded frame
     232         */
    204233        public static Frame LoadFrame(String frameName) {
    205                 return LoadFrame(frameName, null, false);
     234                if (frameName.contains(".")) {
     235                        String[] split = frameName.split("\\.");
     236                        String[] pathSplit = Arrays.copyOfRange(split, 0, split.length - 1);
     237                        String name = split[split.length - 1];
     238                        String path = Arrays.asList(pathSplit).stream().collect(Collectors.joining(File.separator));
     239                        return LoadFrame(name, Paths.get(FrameIO.PARENT_FOLDER).resolve(path).toString() + File.separator, false);
     240                } else {
     241                        return LoadFrame(frameName, null, false); //framesets-bryce.home1
     242                }
    206243        }
    207244
     
    214251                        return null;
    215252                }
    216 
     253               
    217254                String frameNameLower = frameName.toLowerCase();
    218255                // first try reading from cache
     
    221258                        Frame frame = _Cache.get(frameNameLower);
    222259                       
    223                         // if frame is cache is older than the one on disk then don't use the cached one
    224                         String p = frame.getPath() + frame.getNumber() + ".exp";
    225                         File file = new File(p);
    226                         if (file.lastModified() <= frame.getLastModifyPrecise()) {
     260                        // if frame in cache is older than the one on disk then don't use the cached one
     261                        File file = new File(frame.getFramePathReal());
     262                        long lastModified = file.lastModified();
     263                        if (lastModified <= frame.getLastModifyPrecise()) {
    227264                                return frame;
    228265                        }
     
    232269                                + " from disk.");
    233270
    234                 return LoadFromDisk(frameName, path, ignoreAnnotations);
     271                Frame fromDisk = LoadFromDisk(frameName, path, ignoreAnnotations);
     272                return fromDisk;
    235273        }
    236274
     
    250288               
    251289                try{
    252                                 FileInputStream source_fis = new FileInputStream(source);
    253                                 inputChannel = source_fis.getChannel();
     290                        FileInputStream source_fis = new FileInputStream(source);
     291                        inputChannel = source_fis.getChannel();
     292                       
     293                        FileOutputStream dest_fos = new FileOutputStream(dest);
     294                        outputChannel = dest_fos.getChannel();
    254295                               
    255                                 FileOutputStream dest_fos = new FileOutputStream(dest);
    256                                 outputChannel = dest_fos.getChannel();
    257                                
    258                                 outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
    259                                 inputChannel.close();
    260                                 outputChannel.close();
    261                                 source_fis.close();
    262                                 dest_fos.close();
     296                        outputChannel.transferFrom(inputChannel, 0, inputChannel.size());
     297                        inputChannel.close();
     298                        outputChannel.close();
     299                        source_fis.close();
     300                        dest_fos.close();
    263301                }               
    264302                catch(Exception e){     
     
    301339
    302340                if (knownPath != null) {
    303                         loaded = LoadKnowPath(knownPath, framename);
     341                        loaded = LoadKnownPath(knownPath, framename);
    304342                } else {
    305343                        List<String> directoriesToSearch = FolderSettings.FrameDirs.get();
    306344                       
    307                         if (UserSettings.Authenticated.get()) {
     345                        if (Authenticator.Authenticated) {
    308346                                // if we are running Expeditee Authenticated, consult user profile as location for framesets first
    309347                                String profilePath = FrameIO.PROFILE_PATH + UserSettings.UserName.get() + File.separator;
     
    312350                       
    313351                        for (String path : directoriesToSearch) {
    314                                 loaded = LoadKnowPath(path, framename);
     352                                loaded = LoadKnownPath(path, framename);
    315353                                if (loaded != null) {
    316354                                        break;
     
    325363                if (loaded != null) {
    326364                        FrameUtils.Parse(loaded, true, ignoreAnnotations);
     365                        FrameIO.setSavedProperties(loaded);
    327366                }
    328367
     
    357396        /**
    358397         * Gets the full path and file name of the frame.
    359          *
     398         * This is a alias for Frame::getFramePathLogical
    360399         * @param path-
    361400         *            the directory in which to look for the frameset containing the
     
    475514        }
    476515
    477         private static Frame LoadKnowPath(String path, String frameName) {
     516        private static Frame LoadKnownPath(String path, String frameName) {
    478517                String fullPath = getFrameFullPathName(path, frameName);
    479518                if (fullPath == null) {
     
    483522                try {
    484523                        FrameReader reader;
    485 
     524                       
     525                        // Get the frameset name.
     526                        int i = frameName.length() - 1;
     527                        for (; i >= 0; i--) {
     528                                if (!Character.isDigit(frameName.charAt(i))) {
     529                                        break;
     530                                }       
     531                        }
     532                        if (i < 0) {
     533                                System.err.println("LoadKnownFrame was provided with a invalid Frame name: " + frameName);
     534                                return null;
     535                        }
     536                        String framesetName = frameName.substring(0, i + 1);
     537                       
     538                        String redirectTo = ExpReader.redirectTo(fullPath);
     539                        while (redirectTo != null) {
     540                                fullPath = path + framesetName + File.separator + redirectTo;
     541                                redirectTo = ExpReader.redirectTo(fullPath);
     542                        }
     543                       
    486544                        if (fullPath.endsWith(ExpReader.EXTENTION)) {
    487545                                if (EncryptedExpReader.isEncryptedExpediteeFile(fullPath)) {
    488                                         //final boolean isProfile = frameName.startsWith(UserSettings.UserName.get());
    489                                         //reader = new EncryptedExpReader(frameName, isProfile);
    490546                                        reader = new EncryptedExpReader(frameName);
    491547                                } else {
     
    919975
    920976        private static boolean isValidFrameNameChar(char c) {
    921                 return Character.isLetterOrDigit(c) || c == '-';
     977                return c == '-' || c == '.' || Character.isLetterOrDigit(c);
    922978        }
    923979
     
    9521008         *
    9531009         * @param toSave
    954          *            The Frame to save to disk
     1010         *              The Frame to save to disk
    9551011         * @param inc
    956          *            True if the saved frames counter should be incremented, false
    957          *            otherwise.
     1012         *              True if the saved frames counter should be incremented, false otherwise.
    9581013         * @param checkBackup
    959          *            True if the frame should be checked for the back up tag
    960          */
    961         public static String SaveFrame(Frame toSave, boolean inc,
    962                         boolean checkBackup) {
    963 
     1014         *              True if the frame should be checked for the back up tag
     1015         */
     1016        public static String SaveFrame(Frame toSave, boolean inc, boolean checkBackup) {
    9641017                // TODO When loading a frame maybe append onto the event history too-
    9651018                // with a break to indicate the end of a session
    966 
     1019               
    9671020                if (toSave == null || !toSave.hasChanged() || toSave.isSaved()) {
    9681021                        return "";
     
    9821035
    9831036                // Save frame that is not local through the Networking classes
    984                 // TODO
    9851037                if (!toSave.isLocal()) {
    9861038                        return FrameShare.getInstance().saveFrame(toSave);
     
    10121064                try {
    10131065                        // if its a new frame or an existing Exp frame...
    1014                         if (fullPath == null || fullPath.endsWith(ExpReader.EXTENTION)) {
    1015                                 if (UserSettings.Authenticated.get() &&
    1016                                                 toSave.getNumber() != Authenticator.PUBLIC_KEY_FRAME &&
     1066                        if (fullPath == null || fullPath.endsWith(ExpReader.EXTENTION)) {                               
     1067                                if (toSave.getNumber() != Authenticator.CREDENTIALS_FRAME &&
    10171068                                                toSave.getEncryptionLabel() != null) {
    10181069                                        writer = new EncryptedExpWriter(toSave.getEncryptionLabel());
     
    10221073                                        savedVersion = ExpReader.getVersion(fullPath);
    10231074                                }
     1075                               
     1076                                // Is the file this would be saved to a redirect?
     1077                                String redirectTo = ExpReader.redirectTo(fullPath);
     1078                                if (redirectTo != null) {
     1079                                        String redirectedPath = toSave.getFramePathReal();
     1080                                        writer.setOutputLocation(redirectedPath);
     1081                                }
     1082                               
    10241083                        } else {
    10251084                                writer = new KMSWriter();
     
    10421101                        // Check if we are trying to save an out of date version
    10431102                        String framesetName = toSave.getFramesetName();
    1044                         long frameLastModify = toSave.getLastModifyPrecise();
    1045                         long fileLastModify = new File(fullPath).lastModified();
    1046                         boolean versionConflict = frameLastModify < fileLastModify;
    10471103                        boolean isBayFrameset =
    10481104                                        framesetName.equalsIgnoreCase(MessageBay.MESSAGES_FRAMESET_NAME) ||
    10491105                                        framesetName.equalsIgnoreCase(MailBay.EXPEDITEE_MAIL_FRAMESET_NAME);
    1050                         if ((savedVersion > toSave.getVersion() || versionConflict) && !isBayFrameset) {
     1106                        long frameLastModify = toSave.getLastModifyPrecise();
     1107                        long fileLastModify = new File(toSave.getFramePathReal()).lastModified();
     1108                        boolean fileModifyConflict = fileLastModify > frameLastModify && !isBayFrameset;
     1109                        boolean versionConflict = savedVersion > toSave.getVersion() && !isBayFrameset;
     1110                        if (fileModifyConflict || versionConflict) {
    10511111                                // remove this frame from the cache if it is there
    10521112                                // This will make sure links to the original are set correctly
     
    10631123                                Text originalMessage = new Text(-1);
    10641124                                originalMessage.setColor(MessageBay.ERROR_COLOR);
    1065                                 originalMessage.setText(original.getName()
    1066                                                 + " was updated by another user.");
     1125                                StringBuilder message = new StringBuilder(original.getName()
     1126                                                + " was updated by another user. ");
     1127                                if (fileModifyConflict) {
     1128                                        message.append("{ File modify conflict }");
     1129                                }
     1130                                if (versionConflict) {
     1131                                        message.append("{ Version conflict }");
     1132                                }
     1133                                originalMessage.setText(message.toString());
    10671134                                originalMessage.setLink(original.getName());
    10681135                                Text yourMessage = new Text(-1);
     
    10731140                                MessageBay.displayMessage(originalMessage);
    10741141                                MessageBay.displayMessage(yourMessage);
     1142                                EcosystemManager.getMiscManager().beep();
    10751143                        } else if (checkBackup
    10761144                                        && ItemUtils.ContainsExactTag(toSave.getItems(),
     
    11121180                                ResumeCache();
    11131181                        }
    1114                         // Update general stuff about frame
    1115                         setSavedProperties(toSave);
    11161182
    11171183                        // int oldMode = FrameGraphics.getMode();
    11181184                        // if (oldMode != FrameGraphics.MODE_XRAY)
    11191185                        // FrameGraphics.setMode(FrameGraphics.MODE_XRAY, true);
     1186                       
    11201187                        writer.writeFrame(toSave);
    11211188                        // FrameGraphics.setMode(oldMode, true);
    11221189                        toSave.setSaved();
     1190                       
     1191                        // Update general stuff about frame
     1192                        setSavedProperties(toSave);
     1193                       
    11231194                        if (inc) {
    11241195                                SessionStats.SavedFrame(toSave.getName());
     
    11441215                        // re-parsing)
    11451216                        if (isProfileFrame(toSave)) {
    1146                                 Frame profile = FrameIO.LoadFrame(toSave.getFramesetName()
    1147                                                 + "1");
     1217                                Frame profile = FrameIO.LoadFrame(toSave.getFramesetName() + "1");
    11481218                                assert (profile != null);
    11491219                                FrameUtils.ParseProfile(profile);
     
    11551225                        return null;
    11561226                }
     1227                toSave.notifyObservers(false);
    11571228
    11581229                return writer.getFileContents();
     
    12121283                _Cache.put(toAdd.getName().toLowerCase(), toAdd);
    12131284        }
     1285       
     1286        public static void ClearCache() {
     1287                _Cache.clear();
     1288        }
    12141289
    12151290        /**
     
    12411316        }
    12421317
    1243         public static Frame CreateNewProfile(String username) throws Exception {
     1318        public static Frame CreateNewProfile(String username, Map<String, Setting> initialSettings) throws InvalidFramesetNameException, ExistingFramesetException {
    12441319                Frame profile = CreateFrameset(username, PROFILE_PATH, true);
    1245                 FrameUtils.CreateDefaultProfile(username, profile);
     1320                FrameUtils.CreateDefaultProfile(username, profile, initialSettings);
    12461321                return profile;
    12471322        }
     
    14771552        }
    14781553
    1479         public static Frame CreateFrameset(String frameset, String path, boolean recreate) throws Exception
    1480         {
     1554        public static Frame CreateFrameset(String frameset, String path, boolean recreate) throws InvalidFramesetNameException, ExistingFramesetException {
    14811555                String conversion = frameset + " --> ";
    14821556
    14831557                if (!isValidFramesetName(frameset)) {
    1484                         throw new Exception("Invalid frameset name");
     1558                        throw new InvalidFramesetNameException(frameset);
    14851559                }
    14861560
     
    15571631                base.setOwner(UserSettings.UserName.get());
    15581632                SaveFrame(base, true);
     1633               
     1634                FrameIO.setSavedProperties(base);
    15591635
    15601636                Logger.Log(Logger.SYSTEM, Logger.NEW_FRAMESET, "Created new frameset: " + frameset);
     
    18011877                        e.printStackTrace();
    18021878                }
    1803                 // } else {
    1804                 //                     
    1805                 //                     
    1806                 //                     
    1807                 // MessageBay
    1808                 // .errorMessage("Recieved save request for unknown public frame: "
    1809                 // + frameName);
    1810                 // }
    18111879        }
    18121880
     
    18221890                toSave.setActiveTime(activeTime);
    18231891        }
    1824 
    18251892}
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r1220 r1242  
    2424import java.io.IOException;
    2525import java.io.InputStream;
     26import java.lang.reflect.InvocationTargetException;
    2627import java.net.JarURLConnection;
     28import java.net.URISyntaxException;
    2729import java.net.URL;
    2830import java.net.URLConnection;
     31import java.nio.file.Path;
     32import java.nio.file.Paths;
    2933import java.util.ArrayList;
    3034import java.util.Arrays;
     
    3640import java.util.LinkedList;
    3741import java.util.List;
     42import java.util.Map;
    3843import java.util.jar.JarEntry;
    3944import java.util.jar.JarFile;
     45import java.util.stream.Collectors;
    4046import java.util.zip.ZipEntry;
    4147
     48import org.expeditee.agents.ExistingFramesetException;
     49import org.expeditee.agents.InvalidFramesetNameException;
    4250import org.expeditee.auth.gui.MailBay;
    4351import org.expeditee.core.Colour;
     
    6775import org.expeditee.items.widgets.WidgetCorner;
    6876import org.expeditee.items.widgets.WidgetEdge;
     77import org.expeditee.setting.Setting;
    6978import org.expeditee.settings.Settings;
    7079import org.expeditee.settings.UserSettings;
     
    7685
    7786        /**
    78          * The list of known start pages framesets which will have prepopulated
    79          * links in the home frame.
     87         * The list of known start pages framesets which will have prepopulated links in
     88         * the home frame.
    8089         */
    8190        public static final String[] startPages = { "exploratorysearch", "webbrowser" };
     
    99108        private static Item _tdfcItem = null;
    100109
    101         public static float getResponseTimeTotal()
    102         {
     110        public static float getResponseTimeTotal() {
    103111                return _ResponseTimeSum;
    104112        }
    105113
    106         public static float getLastResponseTime()
    107         {
     114        public static float getLastResponseTime() {
    108115                return _LastResponse;
    109116        }
    110117
    111118        /**
    112          * Checks if the given top Item is above the given bottom Item, allowing for
    113          * the X coordinates to be off by a certain width...
     119         * Checks if the given top Item is above the given bottom Item, allowing for the
     120         * X coordinates to be off by a certain width...
    114121         *
    115122         * @param item1
     
    140147
    141148                // Ensure the two items
    142                 if ((minX >= startX && minX <= endX)
    143                                 || (maxX >= startX && maxX <= endX)
    144                                 || (startX >= minX && startX <= maxX)
     149                if ((minX >= startX && minX <= endX) || (maxX >= startX && maxX <= endX) || (startX >= minX && startX <= maxX)
    145150                                || (endX >= minX && endX <= maxX)) {
    146151                        return true;
     
    150155        }
    151156
    152         public static boolean sameBulletType(String bullet1, String bullet2)
    153         {
     157        public static boolean sameBulletType(String bullet1, String bullet2) {
    154158                if (bullet1 == null || bullet2 == null) {
    155159                        return false;
     
    160164                }
    161165
    162                 if (Character.isLetter(bullet1.charAt(0))
    163                                 && Character.isLetter(bullet2.charAt(0))) {
     166                if (Character.isLetter(bullet1.charAt(0)) && Character.isLetter(bullet2.charAt(0))) {
    164167                        return true;
    165168                }
    166169
    167                 if (Character.isDigit(bullet1.charAt(0))
    168                                 && Character.isDigit(bullet2.charAt(0))) {
     170                if (Character.isDigit(bullet1.charAt(0)) && Character.isDigit(bullet2.charAt(0))) {
    169171                        return true;
    170172                }
     
    205207         * @return
    206208         */
    207         public static int Align(List<Text> toAlign, boolean moveAll, int adjust,
    208                         List<Item> changedItems) {
     209        public static int Align(List<Text> toAlign, boolean moveAll, int adjust, List<Item> changedItems) {
    209210                Collections.sort(toAlign);
    210211
    211212                /*
    212                  * Single items dont need alignment But if there are two items we may
    213                  * still want to format them... ie if they are too close together.
     213                 * Single items dont need alignment But if there are two items we may still want
     214                 * to format them... ie if they are too close together.
    214215                 */
    215216                if (toAlign.size() < 1) {
     
    232233                        lastBullet = StandardGestureActions.getAutoBullet(above.getText());
    233234                } else {
    234                         lastBullet = StandardGestureActions.getBullet(toAlign.get(0)
    235                                         .getText());
     235                        lastBullet = StandardGestureActions.getBullet(toAlign.get(0).getText());
    236236                }
    237237                if (needsRenumbering(lastBullet)) {
     
    251251
    252252                                        // if we changed the item, add to changedItems list
    253                                         if (changedItems != null
    254                                                         && oldText != currentText.getText()
     253                                        if (changedItems != null && oldText != currentText.getText()
    255254                                                        && !changedItems.contains(currentText)) {
    256255                                                Item copy = currentText.copy();
     
    293292
    294293                        if (UserSettings.FormatSpacingMax.get() != null) {
    295                                 double maxSpace = UserSettings.FormatSpacingMax.get()
    296                                                 * above.getSize();
     294                                double maxSpace = UserSettings.FormatSpacingMax.get() * above.getSize();
    297295                                if (maxSpace < space) {
    298296                                        space = (int) Math.round(maxSpace);
     
    301299
    302300                        if (UserSettings.FormatSpacingMin.get() != null) {
    303                                 double minSpace = UserSettings.FormatSpacingMin.get()
    304                                                 * above.getSize();
     301                                double minSpace = UserSettings.FormatSpacingMin.get() * above.getSize();
    305302                                if (minSpace > space) {
    306303                                        space = (int) Math.round(minSpace);
     
    309306
    310307                        // Need to do things differently for FORMAT than for DROPPING
    311                         if (moveAll && above != curr.getNameItem()
    312                                         && above != curr.getTitleItem()) {
     308                        if (moveAll && above != curr.getNameItem() && above != curr.getTitleItem()) {
    313309                                x = above.getX();
    314                                 int y = above.getBounds().getMaxY()
    315                                                 + space
    316                                                 + (from.getY() - from.getBounds().getMinY());
    317 
    318                                 if (changedItems != null
    319                                                 && (from.getX() != x || from.getY() != y)
    320                                                 && !changedItems.contains(from)) {
     310                                int y = above.getBounds().getMaxY() + space + (from.getY() - from.getBounds().getMinY());
     311
     312                                if (changedItems != null && (from.getX() != x || from.getY() != y) && !changedItems.contains(from)) {
    321313                                        Item copy = from.copy();
    322314                                        copy.setID(from.getID());
     
    343335                        int newPos = bottom + space + diff;
    344336
    345                         if (changedItems != null
    346                                         && ((moveAll && current.getX() != x) || current.getY() != newPos)
     337                        if (changedItems != null && ((moveAll && current.getX() != x) || current.getY() != newPos)
    347338                                        && !changedItems.contains(current)) {
    348339                                Item copy = current.copy();
     
    411402                        // next move
    412403                        if (opposite.hasChanged() && opposite.equals(toSave)) {
    413                                 if (EcosystemManager.getGraphicsManager().showDialog("Changes", "Leaving this frame will discard changes made in the " + side + " Frame. Continue?")) {
     404                                if (EcosystemManager.getGraphicsManager().showDialog("Changes",
     405                                                "Leaving this frame will discard changes made in the " + side + " Frame. Continue?")) {
    414406                                        FrameIO.SaveFrame(toSave);
    415407                                        DisplayController.Reload(DisplayController.getSideFrameIsOn(opposite));
     
    420412                        } else if (opposite.hasOverlay(toSave)) {
    421413                                if (toSave.hasChanged()) {
    422                                         if (EcosystemManager.getGraphicsManager().showDialog("Changes", "Leaving this frame will discard changes made in the " + side + " Frame. Continue?")) {
     414                                        if (EcosystemManager.getGraphicsManager().showDialog("Changes",
     415                                                        "Leaving this frame will discard changes made in the " + side + " Frame. Continue?")) {
    423416                                                FrameIO.SaveFrame(toSave);
    424417                                                DisplayController.Reload(DisplayController.getSideFrameIsOn(opposite));
     
    440433        }
    441434
    442         // TODO: consider reloating this method to Frame class?   
    443         protected static Item getAnnotation(Frame frame, String annotationStr)
    444         {
     435        // TODO: consider reloating this method to Frame class?
     436        protected static Item getAnnotation(Frame frame, String annotationStr) {
    445437                Item matched_item = null;
    446438
    447439                // check for an updated template...
    448                 for (Item i : frame.getAnnotationItems()) {                             
     440                for (Item i : frame.getAnnotationItems()) {
    449441
    450442                        if (ItemUtils.startsWithTag(i, annotationStr)) {
     
    458450        }
    459451
    460         protected static void doFrameTransition(Item frameTransition, Frame from, Frame to)
    461         {
    462                 String s = frameTransition.getText();           
     452        protected static void doFrameTransition(Item frameTransition, Frame from, Frame to) {
     453                String s = frameTransition.getText();
    463454                String[] s_array = s.split(":");
    464                 if(s_array.length > 1){
     455                if (s_array.length > 1) {
    465456                        String slide_mode_method = s_array[1].trim();
    466                        
     457
    467458                        FrameTransition transition = new FrameTransition(from.getBuffer(), slide_mode_method);
    468                        
     459
    469460                        DisplayController.setTransition(from, transition);
    470                        
     461
    471462                        System.out.println("Triggered on annotation: " + s);
    472463                } else {
    473464                        System.err.println("Warning: failed to detect frameTransition type");
    474                         // TODO: print list as a result of reflection listing     
    475                 }
    476         }                               
     465                        // TODO: print list as a result of reflection listing
     466                }
     467        }
    477468
    478469        /**
    479470         * Displays the given Frame on the display. If the current frame has changed
    480471         * since the last save then it will be saved before the switch is made. The
    481          * caller can also dictate whether the current frame is added to the
    482          * back-stack or not.
     472         * caller can also dictate whether the current frame is added to the back-stack
     473         * or not.
    483474         *
    484475         * @param toDisplay
    485476         *            The Frame to display on the screen
    486477         * @param addToBack
    487          *            True if the current Frame should be added to the back-stack,
    488          *            False otherwise
     478         *            True if the current Frame should be added to the back-stack, False
     479         *            otherwise
    489480         */
    490         public static void DisplayFrame(Frame toDisplay, boolean addToBack, boolean incrementStats)
    491         {
     481        public static void DisplayFrame(Frame toDisplay, boolean addToBack, boolean incrementStats) {
    492482                if (toDisplay == null) {
    493483                        return;
    494484                }
    495                
     485
    496486                final PermissionPair framePermissions = toDisplay.getPermission();
    497                 if (framePermissions != null && framePermissions.getPermission(toDisplay.getOwner()) == UserAppliedPermission.denied) {
     487                if (framePermissions != null
     488                                && framePermissions.getPermission(toDisplay.getOwner()) == UserAppliedPermission.denied) {
    498489                        MessageBay.errorMessage("Insufficient permissions to navigate to frame: " + toDisplay.getName());
    499490                        return;
     
    569560                        // Only need to worry about frame transitions when in Audience Mode
    570561
    571                         // Test to see if frame transition specified through annotation, and perform it if one if found
     562                        // Test to see if frame transition specified through annotation, and perform it
     563                        // if one if found
    572564                        Item frameTransition = getAnnotation(toDisplay, "@frameTransition");
    573565                        if (frameTransition != null) {
    574                                 doFrameTransition(frameTransition,current,toDisplay);
     566                                doFrameTransition(frameTransition, current, toDisplay);
    575567                        }
    576568                }
     
    586578
    587579        /**
    588          * Loads and displays the Frame with the given framename, and adds the
    589          * current frame to the back-stack if required.
     580         * Loads and displays the Frame with the given framename, and adds the current
     581         * frame to the back-stack if required.
    590582         *
    591583         * @param framename
    592584         *            The name of the Frame to load and display
    593585         * @param addToBack
    594          *            True if the current Frame should be added to the back-stack,
    595          *            false otherwise
     586         *            True if the current Frame should be added to the back-stack, false
     587         *            otherwise
    596588         */
    597         public static void DisplayFrame(String frameName, boolean addToBack,
    598                         boolean incrementStats) {
     589        public static void DisplayFrame(String frameName, boolean addToBack, boolean incrementStats) {
    599590                Frame newFrame = getFrame(frameName);
    600591
     
    606597
    607598        /**
    608          * Loads and displays the Frame with the given framename and adds the
    609          * current frame to the back-stack. This is the same as calling
    610          * DisplayFrame(framename, true)
     599         * Loads and displays the Frame with the given framename and adds the current
     600         * frame to the back-stack. This is the same as calling DisplayFrame(framename,
     601         * true)
    611602         *
    612603         * @param framename
     
    629620
    630621        /**
    631          * Creates a new Picture Item from the given Text source Item and adds it to
    632          * the given Frame.
     622         * Creates a new Picture Item from the given Text source Item and adds it to the
     623         * given Frame.
    633624         *
    634625         * @return True if the image was created successfully, false otherwise
     
    647638                                // MessageBay.errorMessage("Expected image path after @i:");
    648639                        } else {
    649                                 MessageBay.errorMessage("Image " + imagePath
    650                                                 + " could not be loaded");
     640                                MessageBay.errorMessage("Image " + imagePath + " could not be loaded");
    651641                        }
    652642                        return false;
     
    658648
    659649        /**
    660          * Creates an interactive widget and adds it to a frame. If txt has no
    661          * parent the parent will be set to frame.
     650         * Creates an interactive widget and adds it to a frame. If txt has no parent
     651         * the parent will be set to frame.
    662652         *
    663653         * @param frame
     
    713703        }
    714704
    715         public static List<String> ParseProfile(Frame profile)
    716         {
     705        public static List<String> ParseProfile(Frame profile) {
    717706                List<String> errors = new LinkedList<String>();
    718                
     707
    719708                if (profile == null) {
    720709                        return errors;
     
    722711
    723712                /*
    724                  * Make sure the correct cursor shows when turning off the custom cursor
    725                  * and reparsing the profile frame
     713                 * Make sure the correct cursor shows when turning off the custom cursor and
     714                 * reparsing the profile frame
    726715                 */
    727716                FreeItems.getCursor().clear();
     
    739728                                        continue;
    740729                                }
    741                                
     730
    742731                                String attribute = attributeFullCase.trim().toLowerCase().replaceAll("^@", "");
    743732
     
    764753         * @param profile
    765754         */
    766         public static void loadFirstFrame(Frame profile)
    767         {
     755        public static void loadFirstFrame(Frame profile) {
    768756                if (UserSettings.HomeFrame.get() == null) {
    769757                        UserSettings.HomeFrame.set(profile.getName());
     
    781769        }
    782770
    783         public static Colour[] getColorWheel(Frame frame)
    784         {
     771        public static Colour[] getColorWheel(Frame frame) {
    785772                if (frame != null) {
    786773                        List<Text> textItems = frame.getBodyTextItems(false);
     
    797784        }
    798785
    799         public static String getLink(Item item, String alt)
    800         {
     786        public static String getLink(Item item, String alt) {
    801787                if (item == null || !(item instanceof Text)) {
    802788                        return alt;
     
    816802        }
    817803
    818         public static String getDir(String name)
    819         {
     804        public static String getDir(String name) {
    820805                if (name != null) {
    821806                        File tester = new File(name);
     
    833818        }
    834819
    835         public static ArrayList<String> getDirs(Item item)
    836         {
     820        public static ArrayList<String> getDirs(Item item) {
    837821                ArrayList<String> dirsToAdd = new ArrayList<String>();
    838822                String dirListFrameName = item.getAbsoluteLink();
     
    857841        }
    858842
    859         public static void Parse(Frame toParse)
    860         {
     843        public static void Parse(Frame toParse) {
    861844                Parse(toParse, false);
    862845        }
    863846
    864847        /**
    865          * Checks for any special Annotation items and updates the display as
    866          * necessary. Special Items: Images, overlays, sort.
     848         * Checks for any special Annotation items and updates the display as necessary.
     849         * Special Items: Images, overlays, sort.
    867850         *
    868851         */
    869         public static void Parse(Frame toParse, boolean firstParse)
    870         {
     852        public static void Parse(Frame toParse, boolean firstParse) {
    871853                Parse(toParse, firstParse, false);
    872854        }
     
    877859         * @param firstParse
    878860         * @param ignoreAnnotations
    879          *            used to prevent infinate loops such as when performing TDFC
    880          *            with an ao tag linked to a frame with an frameImage of a frame
    881          *            which also has an ao tag on it.
     861         *            used to prevent infinate loops such as when performing TDFC with
     862         *            an ao tag linked to a frame with an frameImage of a frame which
     863         *            also has an ao tag on it.
    882864         */
    883         public static void Parse(Frame toParse, boolean firstParse, boolean ignoreAnnotations)
    884         {
     865        public static void Parse(Frame toParse, boolean firstParse, boolean ignoreAnnotations) {
    885866                // TODO check why we are getting toParse == null... when profile frame
    886867                // is being created and change the lines below
     
    892873                        ItemUtils.EnclosedCheck(toParse.getItems());
    893874                }
    894                
     875
    895876                List<Item> items = toParse.getItems();
    896877
     
    937918                }
    938919
    939                 //DotType pointtype = DotType.square;
    940                 //boolean filledPoints = true;
     920                // DotType pointtype = DotType.square;
     921                // boolean filledPoints = true;
    941922
    942923                UserAppliedPermission permission = toParse.getUserAppliedPermission();
     
    958939                                                        Text txt = (Text) i;
    959940                                                        String line = txt.getFirstLine();
    960                                                         line = ItemUtils.StripTag(line,
    961                                                                         ItemUtils.GetTag(ItemUtils.TAG_POINTTYPE));
     941                                                        line = ItemUtils.StripTag(line, ItemUtils.GetTag(ItemUtils.TAG_POINTTYPE));
    962942
    963943                                                        if (line != null) {
    964944                                                                line = line.toLowerCase();
    965945                                                                if (line.indexOf(" ") > 0) {
    966                                                                         String fill = line.substring(line
    967                                                                                         .indexOf(" ") + 1);
     946                                                                        String fill = line.substring(line.indexOf(" ") + 1);
    968947                                                                        if (fill.startsWith("nofill")) {
    969                                                                                 //filledPoints = false;
     948                                                                                // filledPoints = false;
    970949                                                                        } else {
    971                                                                                 //filledPoints = true;
     950                                                                                // filledPoints = true;
    972951                                                                        }
    973952                                                                }
    974953
    975954                                                                if (line.startsWith("circle")) {
    976                                                                         //pointtype = DotType.circle;
     955                                                                        // pointtype = DotType.circle;
    977956                                                                } else {
    978                                                                         //pointtype = DotType.square;
     957                                                                        // pointtype = DotType.square;
    979958                                                                }
    980959                                                        }
    981                                                 }// check for new VECTOR items
    982                                                 else if (!DisplayController.isXRayMode()
    983                                                                 && ItemUtils.startsWithTag(i,
    984                                                                                 ItemUtils.TAG_VECTOR)
     960                                                } // check for new VECTOR items
     961                                                else if (!DisplayController.isXRayMode() && ItemUtils.startsWithTag(i, ItemUtils.TAG_VECTOR)
    985962                                                                && i.getLink() != null) {
    986963                                                        if (!i.getAbsoluteLink().equals(toParse.getName())) {
    987                                                                 addVector(vectors, UserAppliedPermission.none,
    988                                                                                 permission, i);
     964                                                                addVector(vectors, UserAppliedPermission.none, permission, i);
    989965                                                        }
    990966                                                } else if (!DisplayController.isXRayMode()
    991                                                                 && ItemUtils.startsWithTag(i,
    992                                                                                 ItemUtils.TAG_ACTIVE_VECTOR)
    993                                                                 && i.getLink() != null) {
     967                                                                && ItemUtils.startsWithTag(i, ItemUtils.TAG_ACTIVE_VECTOR) && i.getLink() != null) {
    994968                                                        if (!i.getAbsoluteLink().equals(toParse.getName())) {
    995                                                                 addVector(vectors,
    996                                                                                 UserAppliedPermission.followLinks,
    997                                                                                 permission, i);
     969                                                                addVector(vectors, UserAppliedPermission.followLinks, permission, i);
    998970                                                        }
    999971                                                }
    1000972                                                // check for new OVERLAY items
    1001                                                 else if (!ignoreAnnotations && ItemUtils.startsWithTag(i, ItemUtils.TAG_OVERLAY) && i.getLink() != null) {
     973                                                else if (!ignoreAnnotations && ItemUtils.startsWithTag(i, ItemUtils.TAG_OVERLAY)
     974                                                                && i.getLink() != null) {
    1002975                                                        if (i.getAbsoluteLink().equalsIgnoreCase(toParse.getName())) {
    1003976                                                                // This frame contains an active overlay which
     
    1014987                                                }
    1015988                                                // check for ACTIVE_OVERLAY items
    1016                                                 else if (!ignoreAnnotations
    1017                                                                 && ItemUtils.startsWithTag(i,
    1018                                                                                 ItemUtils.TAG_ACTIVE_OVERLAY)
     989                                                else if (!ignoreAnnotations && ItemUtils.startsWithTag(i, ItemUtils.TAG_ACTIVE_OVERLAY)
    1019990                                                                && i.getLink() != null) {
    1020991                                                        String link = i.getAbsoluteLink();
     
    1022993                                                                // This frame contains an active overlay which
    1023994                                                                // points to itself
    1024                                                                 MessageBay
    1025                                                                 .errorMessage(toParse.getName()
    1026                                                                                 + " contains an @ao which links to itself");
     995                                                                MessageBay.errorMessage(toParse.getName() + " contains an @ao which links to itself");
    1027996                                                                continue;
    1028997                                                        }
     
    10321001                                                        if (current != null) {
    10331002                                                                for (Overlay o : current.getOverlays()) {
    1034                                                                         if (o.Frame.getName()
    1035                                                                                         .equalsIgnoreCase(link)) {
     1003                                                                        if (o.Frame.getName().equalsIgnoreCase(link)) {
    10361004                                                                                overlayFrame = o.Frame;
    10371005                                                                        }
     
    10431011
    10441012                                                        // get level if specified
    1045                                                         String level = new AttributeValuePair(i.getText())
    1046                                                                         .getValue();
     1013                                                        String level = new AttributeValuePair(i.getText()).getValue();
    10471014                                                        // default permission (if none is specified)
    1048                                                         PermissionPair permissionLevel = new PermissionPair(
    1049                                                                         level, UserAppliedPermission.followLinks);
     1015                                                        PermissionPair permissionLevel = new PermissionPair(level,
     1016                                                                        UserAppliedPermission.followLinks);
    10501017
    10511018                                                        if (overlayFrame != null) {
    1052                                                                 Overlay existingOverlay = Overlay.getOverlay(
    1053                                                                                 overlays, overlayFrame);
     1019                                                                Overlay existingOverlay = Overlay.getOverlay(overlays, overlayFrame);
    10541020                                                                // If it wasn't in the list create it and add
    10551021                                                                // it.
    10561022                                                                if (existingOverlay == null) {
    1057                                                                         Overlay newOverlay = new Overlay(
    1058                                                                                         overlayFrame,
    1059                                                                                         permissionLevel
    1060                                                                                         .getPermission(overlayFrame
    1061                                                                                                         .getOwner()));
     1023                                                                        Overlay newOverlay = new Overlay(overlayFrame,
     1024                                                                                        permissionLevel.getPermission(overlayFrame.getOwner()));
    10621025                                                                        i.setOverlay(newOverlay);
    10631026                                                                        overlays.add(newOverlay);
    10641027                                                                } else {
    1065                                                                         existingOverlay.Frame
    1066                                                                         .setPermission(permissionLevel);
     1028                                                                        existingOverlay.Frame.setPermission(permissionLevel);
    10671029                                                                }
    10681030                                                        }
     
    10711033                                                else {
    10721034                                                        if (!DisplayController.isXRayMode()) {
    1073                                                                 if (ItemUtils.startsWithTag(i,
    1074                                                                                 ItemUtils.TAG_IMAGE, true)) {
     1035                                                                if (ItemUtils.startsWithTag(i, ItemUtils.TAG_IMAGE, true)) {
    10751036                                                                        if (!i.hasEnclosures()) {
    10761037                                                                                createPicture(toParse, (Text) i);
    10771038                                                                        }
    10781039                                                                        // check for frame images
    1079                                                                 } else if (ItemUtils.startsWithTag(i,
    1080                                                                                 ItemUtils.TAG_FRAME_IMAGE)
    1081                                                                                 && i.getLink() != null
    1082                                                                                 && !i.getAbsoluteLink()
    1083                                                                                 .equalsIgnoreCase(
    1084                                                                                                 toParse.getName())) {
     1040                                                                } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_FRAME_IMAGE) && i.getLink() != null
     1041                                                                                && !i.getAbsoluteLink().equalsIgnoreCase(toParse.getName())) {
    10851042                                                                        XRayable image = null;
    10861043                                                                        if (i.hasEnclosures()) {
     
    10951052                                                                        // FrameImage
    10961053                                                                        toParse.addItem(image);
    1097                                                                 } else if (ItemUtils.startsWithTag(i,
    1098                                                                                 ItemUtils.TAG_BITMAP_IMAGE)
    1099                                                                                 && i.getLink() != null
    1100                                                                                 && !i.getAbsoluteLink()
    1101                                                                                 .equalsIgnoreCase(
    1102                                                                                                 toParse.getName())) {
     1054                                                                } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_BITMAP_IMAGE) && i.getLink() != null
     1055                                                                                && !i.getAbsoluteLink().equalsIgnoreCase(toParse.getName())) {
    11031056                                                                        XRayable image = null;
    11041057                                                                        if (i.hasEnclosures()) {
     
    11161069                                                                } else if (ItemUtils.startsWithTag(i, "@c")) {
    11171070                                                                        // Can only have a @c
    1118                                                                         if (!i.hasEnclosures()
    1119                                                                                         && i.getLines().size() == 1) {
     1071                                                                        if (!i.hasEnclosures() && i.getLines().size() == 1) {
    11201072                                                                                toParse.addItem(new Circle((Text) i));
    11211073                                                                        }
    11221074                                                                        // Check for JSItem
    1123                                                                 } else if(ItemUtils.startsWithTag(i, "@js")) {
     1075                                                                } else if (ItemUtils.startsWithTag(i, "@js")) {
    11241076                                                                        toParse.addItem(new JSItem((Text) i));
    11251077                                                                        // Check for interactive widgets
     
    11381090                                Logger.Log(e);
    11391091                                e.printStackTrace();
    1140                                 MessageBay.warningMessage("Exception occured when loading "
    1141                                                 + i.getClass().getSimpleName() + "(ID: " + i.getID()
    1142                                                 + ") " + e.getMessage() != null ? e.getMessage() : "");
     1092                                MessageBay.warningMessage("Exception occured when loading " + i.getClass().getSimpleName() + "(ID: "
     1093                                                + i.getID() + ") " + e.getMessage() != null ? e.getMessage() : "");
    11431094                        }
    11441095                }
     
    11461097                /*
    11471098                 * for (Item i : items) { if (i instanceof Dot) { ((Dot)
    1148                  * i).setPointType(pointtype); ((Dot) i).useFilledPoints(filledPoints);
    1149                  * } }
     1099                 * i).setPointType(pointtype); ((Dot) i).useFilledPoints(filledPoints); } }
    11501100                 */
    11511101
     
    11661116         * @param i
    11671117         */
    1168         private static void addVector(List<Vector> vectors, UserAppliedPermission defaultPermission, UserAppliedPermission framePermission, Item i)
    1169         {
     1118        private static void addVector(List<Vector> vectors, UserAppliedPermission defaultPermission,
     1119                        UserAppliedPermission framePermission, Item i) {
    11701120                // TODO It is possible to get into an infinite loop if a
    11711121                // frame contains an @ao which leads to a frame with an
     
    11741124
    11751125                // Get the permission from off the vector frame
    1176                 UserAppliedPermission vectorPermission = UserAppliedPermission.getPermission(vector.getAnnotationValue("permission"), defaultPermission);
    1177                
     1126                UserAppliedPermission vectorPermission = UserAppliedPermission
     1127                                .getPermission(vector.getAnnotationValue("permission"), defaultPermission);
     1128
    11781129                // If the frame permission is lower, use that
    11791130                vectorPermission = UserAppliedPermission.min(vectorPermission, framePermission);
    1180                
     1131
    11811132                // Highest permissable permission for vectors is copy
    11821133                vectorPermission = UserAppliedPermission.min(vectorPermission, UserAppliedPermission.copy);
     
    11951146        }
    11961147
    1197         public static Item onItem(float floatX, float floatY, boolean changeLastEdited)
    1198         {
     1148        public static Item onItem(float floatX, float floatY, boolean changeLastEdited) {
    11991149                return onItem(DisplayController.getCurrentFrame(), floatX, floatY, changeLastEdited);
    12001150        }
    12011151
    12021152        /**
    1203          * Searches through the list of items on this frame to find one at the given
    1204          * x,y coordinates.
     1153         * Searches through the list of items on this frame to find one at the given x,y
     1154         * coordinates.
    12051155         *
    12061156         * @param x
     
    12551205                } else {
    12561206                        if (LastEdited != null) {
    1257                                 if (LastEdited.contains(x, y)
    1258                                                 && !FreeItems.getInstance().contains(LastEdited)
     1207                                if (LastEdited.contains(x, y) && !FreeItems.getInstance().contains(LastEdited)
    12591208                                                && LastEdited.getParent() == DisplayController.getCurrentFrame()
    1260                                                 && LastEdited.getParent().getItems().contains(LastEdited))
    1261                                 {
     1209                                                && LastEdited.getParent().getItems().contains(LastEdited)) {
    12621210                                        LastEdited.setOverlayPermission(UserAppliedPermission.full);
    12631211                                        return LastEdited;
     
    12731221
    12741222                                // do not check annotation items in audience mode
    1275                                 //TODO: Upon hover of Rubbish Bin, Undo and Restore Widgets, flickering occurs depending on the mouse distance from a corner. Resolve this.
     1223                                // TODO: Upon hover of Rubbish Bin, Undo and Restore Widgets, flickering occurs
     1224                                // depending on the mouse distance from a corner. Resolve this.
    12761225                                if (i.isVisible() && !(DisplayController.isAudienceMode() && i.isAnnotation())) {
    12771226                                        if (i instanceof WidgetCorner) {
     
    12831232                                                                Widget iw = wc.getWidgetSource();
    12841233
    1285                                                                 if(iw.getBounds().contains(x, y)){
    1286 
    1287                                                                         if( !FreeItems.getInstance().contains(i))
    1288                                                                         {
    1289                                                                                 possibles.add(i);                                                       
     1234                                                                if (iw.getBounds().contains(x, y)) {
     1235
     1236                                                                        if (!FreeItems.getInstance().contains(i)) {
     1237                                                                                possibles.add(i);
    12901238                                                                        }
    1291                                                                 }       
     1239                                                                }
    12921240                                                        }
    12931241                                                }
    12941242                                        }
    12951243
    1296                                         if (i.contains(new Point(x, y))){
    1297                                                 if(!FreeItems.getInstance().contains(i)) {
    1298                                                         possibles.add(i);                               
     1244                                        if (i.contains(new Point(x, y))) {
     1245                                                if (!FreeItems.getInstance().contains(i)) {
     1246                                                        possibles.add(i);
    12991247                                                }
    13001248                                        }
     
    13161264                // return closest x,y pair to mouse
    13171265                Item closest = possibles.get(0);
    1318                 int distance = (int) Math.round(Math.sqrt(Math.pow(
    1319                                 Math.abs(closest.getX() - x), 2)
    1320                                 + Math.pow(Math.abs(closest.getY() - y), 2)));
     1266                int distance = (int) Math.round(
     1267                                Math.sqrt(Math.pow(Math.abs(closest.getX() - x), 2) + Math.pow(Math.abs(closest.getY() - y), 2)));
    13211268
    13221269                for (Item i : possibles) {
    1323                         int d = (int) Math.round(Math.sqrt(Math.pow(Math.abs(i.getX() - x),
    1324                                         2) + Math.pow(Math.abs(i.getY() - y), 2)));
     1270                        int d = (int) Math
     1271                                        .round(Math.sqrt(Math.pow(Math.abs(i.getX() - x), 2) + Math.pow(Math.abs(i.getY() - y), 2)));
    13251272
    13261273                        // System.out.println(d);
     
    13361283                        }
    13371284
    1338                 }       
     1285                }
    13391286
    13401287                return closest;
    13411288        }
    1342        
     1289
    13431290        /**
    13441291         * Checks if the mouse is currently over an item.
    13451292         *
    1346          * @return
    1347          *              True if the mouse is over any item, false otherwise.
     1293         * @return True if the mouse is over any item, false otherwise.
    13481294         */
    1349         public static boolean hasCurrentItem()
    1350         {
     1295        public static boolean hasCurrentItem() {
    13511296                return getCurrentItem() != null;
    13521297        }
    13531298
    1354         public synchronized static Item getCurrentItem()
    1355         {
    1356                 return onItem(DisplayController.getCurrentFrame(), DisplayController.getMouseX(), DisplayController.getMouseY(), true);
    1357         }
    1358 
    1359         public static PolygonBounds getEnlosingPolygon()
    1360         {
     1299        public synchronized static Item getCurrentItem() {
     1300                return onItem(DisplayController.getCurrentFrame(), DisplayController.getMouseX(), DisplayController.getMouseY(),
     1301                                true);
     1302        }
     1303
     1304        public static PolygonBounds getEnlosingPolygon() {
    13611305                Collection<Item> enclosure = getEnclosingLineEnds();
    1362                
     1306
    13631307                if (enclosure == null || enclosure.size() == 0) {
    13641308                        return null;
     
    13731317         * @return
    13741318         */
    1375         public static Collection<Item> getCurrentItems()
    1376         {
     1319        public static Collection<Item> getCurrentItems() {
    13771320                return getCurrentItems(getCurrentItem());
    13781321        }
    13791322
    1380         public static Collection<Item> getCurrentItems(Item currentItem)
    1381         {
     1323        public static Collection<Item> getCurrentItems(Item currentItem) {
    13821324                Collection<Item> enclosure = getEnclosingLineEnds();
    1383                
     1325
    13841326                if (enclosure == null || enclosure.size() == 0) {
    13851327                        return null;
     
    13881330                Item firstItem = enclosure.iterator().next();
    13891331
    1390                 Collection<Item> enclosed = getItemsEnclosedBy(DisplayController.getCurrentFrame(), firstItem.getEnclosedShape());
     1332                Collection<Item> enclosed = getItemsEnclosedBy(DisplayController.getCurrentFrame(),
     1333                                firstItem.getEnclosedShape());
    13911334
    13921335                // Brook: enclosed widgets are to be fully enclosed, never partially
    13931336                /*
    1394                  * MIKE says: but doesn't this mean that widgets are treated differently
    1395                  * from ALL other object which only need to be partially enclosed to be
    1396                  * picked up
     1337                 * MIKE says: but doesn't this mean that widgets are treated differently from
     1338                 * ALL other object which only need to be partially enclosed to be picked up
    13971339                 */
    13981340                List<Widget> enclosedWidgets = new LinkedList<Widget>();
     
    14121354                                }
    14131355                        }
    1414                        
     1356
    14151357                        if (i instanceof WidgetCorner) {
    14161358                                if (!enclosedWidgets.contains(((WidgetCorner) i).getWidgetSource())) {
     
    14181360                                }
    14191361                        }
    1420                        
     1362
    14211363                        i.setHighlightMode(Item.HighlightMode.None);
    14221364                        i.setHighlightColorToDefault();
     
    14351377
    14361378        /**
    1437          * Gets the collection of Dot items that form the enclosure nearest to the current mouse position.
     1379         * Gets the collection of Dot items that form the enclosure nearest to the
     1380         * current mouse position.
    14381381         */
    1439         public static Collection<Item> getEnclosingLineEnds()
    1440         {
     1382        public static Collection<Item> getEnclosingLineEnds() {
    14411383                return getEnclosingLineEnds(new Point(DisplayController.getMouseX(), DisplayController.getMouseY()));
    14421384        }
    14431385
    14441386        /**
    1445          * Gets the collection of Dot items that form the enclosure nearest to the given position.
     1387         * Gets the collection of Dot items that form the enclosure nearest to the given
     1388         * position.
    14461389         */
    1447         public static Collection<Item> getEnclosingLineEnds(Point position)
    1448         {
     1390        public static Collection<Item> getEnclosingLineEnds(Point position) {
    14491391                // update enclosed shapes
    14501392                Frame current = DisplayController.getCurrentFrame();
     
    14841426                if (used.size() == 1) {
    14851427                        return used.get(0).getEnclosingDots();
    1486                 // otherwise, determine which polygon is closest to the cursor
     1428                        // otherwise, determine which polygon is closest to the cursor
    14871429                } else {
    14881430                        Collections.sort(used, new Comparator<Item>() {
     
    15031445
    15041446                                                if (i < p2.getPointCount()) {
    1505                                                         diff2 = Math.abs(p2.getPoint(i).getX() - mouseX)  + Math.abs(p2.getPoint(i).getY() - mouseY);
     1447                                                        diff2 = Math.abs(p2.getPoint(i).getX() - mouseX) + Math.abs(p2.getPoint(i).getY() - mouseY);
    15061448                                                }
    15071449
     
    15441486        // TODO Remove this method!!
    15451487        // Can just getItemsWithin be used?
    1546         public static Collection<Item> getItemsEnclosedBy(Frame frame, PolygonBounds poly)
    1547         {
     1488        public static Collection<Item> getItemsEnclosedBy(Frame frame, PolygonBounds poly) {
    15481489                Collection<Item> contained = frame.getItemsWithin(poly);
    15491490
     
    15701511                return results;
    15711512        }
     1513       
     1514        public static void CreateDefaultProfile(String profileFor, Frame profile) {
     1515                CreateDefaultProfile(profileFor, profile, null);
     1516        }
    15721517
    15731518        /**
    1574          * Fills the given Frame with default profile tags
     1519         * Copies the content from the default profile to the specified profile.
     1520         * @param profileFor Name of profile that is destination of copy.
     1521         * @param profile Profile being setup.
     1522         * @param specifiedTextSettings text settings to provide a default value for in the new profile
     1523         * @param specifiedGenericSettings generic settings to provide a default value for in the new profile
    15751524         */
    1576         public static void CreateDefaultProfile(String username, Frame profile)
    1577         {
    1578                 Text title = profile.getTitleItem();
    1579                 if (username.equals(UserSettings.DEFAULT_PROFILE_NAME)) {
     1525        public static void CreateDefaultProfile(String profileFor, Frame profile,
     1526                        Map<String, Setting> specifiedSettings) {
     1527                // If this is already the default profile then nothing (other than setting
     1528                // title) needs to be done.
     1529                Text titleItem = profile.getTitleItem();
     1530                Text title = titleItem;
     1531                if (!profileFor.equals(UserSettings.DEFAULT_PROFILE_NAME)) {
     1532                        // If this profile is not the default profile, copy it from the default profile
     1533                        // instead of generating a new profile
     1534                        // (this allows the possibility of modifying the default profile and having any
     1535                        // new profiles get those modifications)
     1536                        Frame defaultFrame = FrameIO.LoadProfile(UserSettings.DEFAULT_PROFILE_NAME);
     1537                        if (defaultFrame == null) {
     1538                                try {
     1539                                        // If we do not have a default to copy, create one.
     1540                                        defaultFrame = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME, null);
     1541                                } catch (InvalidFramesetNameException invalidNameEx) {
     1542                                        MessageBay.errorMessage("Failed to create default profile named: "
     1543                                                        + UserSettings.DEFAULT_PROFILE_NAME + ".  "
     1544                                                        + "Profile names must start and end with a letter and must contain only letters and numbers.");
     1545                                        return;
     1546                                } catch (ExistingFramesetException existingFramesetEx) {
     1547                                        MessageBay.errorMessage("Failed to create the desired default frameset: "
     1548                                                        + UserSettings.DEFAULT_PROFILE_NAME + ", "
     1549                                                        + "because it already exists.  This should never happen as we shouldn't be asking to create it if it already exists.");
     1550                                        return;
     1551                                }
     1552                        }
     1553
     1554                        MessageBay.suppressMessages(true);
     1555                        int lastNumber = FrameIO.getLastNumber(defaultFrame.getFramesetName());
     1556                        for (int i = 1; i <= lastNumber; i++) {
     1557                                // Load in next default, if it doesn't exist continue loop.
     1558                                defaultFrame = FrameIO.LoadFrame(defaultFrame.getFramesetName() + i);
     1559                                if (defaultFrame == null) {
     1560                                        continue;
     1561                                }
     1562
     1563                                // Create the next next (currently blank) profile frame.
     1564                                // If there is frame gaps in the default (say if there is no 4.exp but there is
     1565                                // a 5.exp) then retain those gaps.
     1566                                // This way copied relative links work.
     1567                                while (profile.getNumber() < defaultFrame.getNumber()) {
     1568                                        profile = FrameIO.CreateFrame(profile.getFramesetName(), null, null);
     1569                                }
     1570                                // Ensure we are working from a blank slate.
     1571                                profile.reset();
     1572                                profile.removeAllItems(profile.getAllItems());
     1573
     1574                                // For each item on defaultFrame:
     1575                                // 1. Set all items to be relatively linked so once copied their links correctly
     1576                                // point to the frame on the created profile rather than the default profile.
     1577                                // 2. Copy item from defaultFrame to the current profile frame being
     1578                                // constructed.
     1579                                // 3. Replace settings values of copied items with those specified in
     1580                                // specifiedSettings (if present)
     1581                                for (Item item : defaultFrame.getAllItems()) {
     1582                                        item.setRelativeLink();
     1583                                }
     1584                                profile.addAllItems(defaultFrame.getAllItems());
     1585                                if (i == 1 && titleItem != null) {
     1586                                        titleItem.setText(profileFor + "'s Profile");
     1587                                }
     1588                                String category = profile.getTitle();
     1589                                List<String> settingsKeys = null;
     1590                                if (specifiedSettings != null) {
     1591                                        settingsKeys = specifiedSettings.keySet().stream().filter(key ->
     1592                                                key.startsWith(category)).collect(Collectors.toList());
     1593                                }
     1594                                if (settingsKeys != null) {
     1595                                        for (String key: settingsKeys) {
     1596                                                Setting setting = specifiedSettings.get(key);
     1597                                                String name = setting.getName();
     1598                                                Text representation = setting.generateRepresentation(name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase(), profile.getFramesetName());
     1599                                                Collection<Text> canditates = profile.getTextItems();
     1600                                                canditates.removeIf(text -> !text.getText().startsWith(representation.getText().split(" ")[0]));
     1601                                                canditates.forEach(text -> {
     1602                                                        Point backupPos = text.getPosition();
     1603                                                        Item.DuplicateItem(representation, text);
     1604                                                        text.setText(representation.getText());
     1605                                                        text.setPosition(backupPos);
     1606                                                });
     1607                                        }
     1608                                }
     1609                                FrameIO.SaveFrame(profile);
     1610                        }
     1611                        MessageBay.suppressMessages(false);
     1612                } else {
    15801613                        title.setText("Default Profile Frame");
    1581                 } else {
    1582                         // if this profile is not the default profile, copy it from the default profile instead of generating a new profile
    1583                         // (this allows the possibility of modifying the default profile and having any new profiles get those modifications)
    1584                         Frame nextDefault = FrameIO.LoadProfile(UserSettings.DEFAULT_PROFILE_NAME);
    1585                         if (nextDefault == null) {
    1586                                 try {
    1587                                         nextDefault = FrameIO.CreateNewProfile(UserSettings.DEFAULT_PROFILE_NAME);
    1588                                 } catch (Exception e) {
    1589                                         // TODO tell the user that there was a problem creating the
    1590                                         // profile frame and close nicely
    1591                                         e.printStackTrace();
    1592                                 }
    1593                         }
    1594                         // load profile frame and set title correctly
    1595                         profile.reset();
    1596                         profile.removeAllItems(profile.getAllItems());
    1597                         // set relative link on all items so their links will correctly point to the page on the current profile rather than on the default profile
    1598                         for(Item i : nextDefault.getAllItems()) {
    1599                                 i.setRelativeLink();
    1600                         }
    1601                         profile.addAllItems(ItemUtils.CopyItems(nextDefault.getAllItems()));
    1602                         profile.setTitle(username + "'s Profile Frame");
    1603                         FrameIO.SaveFrame(profile);
    1604 
    1605                         Frame nextProfile = profile;
    1606                         MessageBay.suppressMessages(true);
    1607                         while((nextDefault = FrameIO.LoadNext(nextDefault)) != null) {
    1608                                 // in case there are gaps in the frame numbering of the default profile (e.g. if a user has edited it),
    1609                                 // we need to replicate those gaps in the copied profile so the links will work correctly
    1610                                 while(nextProfile.getNumber() < nextDefault.getNumber()) {
    1611                                         nextProfile = FrameIO.CreateFrame(profile.getFramesetName(), null, null);
    1612                                 }
    1613                                 // if the new profile has a frame number higher than the current frame number in the default profile,
    1614                                 // the new profile must already exist, so just exit
    1615                                 // (TODO: should we wipe the frames instead?)
    1616                                 if(nextProfile.getNumber() > nextDefault.getNumber()) {
    1617                                         break;
    1618                                 }
    1619                                 nextProfile.reset();
    1620                                 nextProfile.removeAllItems(nextProfile.getAllItems());
    1621                                 // set relative link on all items so their links will correctly point to the page on the current profile rather than on the default profile
    1622                                 for(Item i : nextDefault.getAllItems()) {
    1623                                         i.setRelativeLink();
    1624                                 }
    1625                                 nextProfile.addAllItems(ItemUtils.CopyItems(nextDefault.getAllItems()));
    1626                                 FrameIO.SaveFrame(nextProfile);
    1627                         }
    1628                         MessageBay.suppressMessages(false);
    1629 
    1630                         return;
    1631                 }
    1632 
    1633                 // int spacing = 50;
    1634                 final int intialYPos = 75;
    1635                 int xPos = 75;
    1636                 int yPos = intialYPos;
    1637 
    1638                 // yPos += spacing;
    1639                 // profile.addText(xPos, yPos, "@HomeFrame", null, profile.getName());
    1640                 // yPos += spacing;
    1641                 // String defaultFrameName = profile.getFramesetName() + "0";
    1642                 // profile.addText(xPos, yPos, "@DefaultFrame", null, defaultFrameName);
    1643                 // yPos += spacing;
    1644                 //
    1645                 // profile.addText(xPos, yPos, "@InitialWidth: "
    1646                 // + UserSettings.InitialWidth, null);
    1647                 // yPos += spacing;
    1648                 //
    1649                 // profile.addText(xPos, yPos, "@InitialHeight: "
    1650                 // + UserSettings.InitialHeight, null);
    1651                 // yPos += spacing;
    1652                 //
    1653                 // Text t = profile.addText(xPos, yPos, "@ItemTemplate", null);
    1654                 // t.setColor(null);
    1655                 //
    1656                 // yPos += spacing;
    1657                 // t = profile.addText(xPos, yPos, "@AnnotationTemplate", null);
    1658                 // t.setColor(Color.gray);
    1659                 //
    1660                 // yPos += spacing;
    1661                 // t = profile.addText(xPos, yPos, "@CommentTemplate", null);
    1662                 // t.setColor(Color.green.darker());
    1663                 //
    1664                 // yPos += spacing;
    1665                 // t = profile.addText(xPos, yPos, "@StatsTemplate", null);
    1666                 // t.setColor(Color.BLACK);
    1667                 // t.setBackgroundColor(new Color(0.9F, 0.9F, 0.9F));
    1668                 // t.setFamily(Text.MONOSPACED_FONT);
    1669                 // t.setSize(14);
    1670 
    1671                 Text t;
    1672 
    1673                 xPos = 300;
    1674                 // yPos = intialYPos + spacing;
    1675                 yPos = 100;
    1676 
    1677                 // Add documentation links
    1678                 File helpDirectory = new File(FrameIO.HELP_PATH);
    1679                 if (helpDirectory != null) {
    1680                         File[] helpFramesets = helpDirectory.listFiles();
    1681                         if (helpFramesets != null) {
    1682 
    1683                                 // Add the title for the help index
    1684                                 Text help = profile.addText(xPos, yPos, "@Expeditee Help", null);
    1685                                 help.setSize(25);
    1686                                 help.setFontStyle("Bold");
    1687                                 help.setFamily("SansSerif");
    1688                                 help.setColor(TemplateSettings.ColorWheel.get()[3]);
    1689 
    1690                                 xPos += 25;
    1691                                 System.out.println("Installing frameset: ");
    1692 
    1693                                 boolean first_item = true;
    1694 
    1695                                 for (File helpFrameset : helpFramesets) {
    1696                                         String framesetName = helpFrameset.getName();
    1697                                         if (!FrameIO.isValidFramesetName(framesetName)) {
    1698                                                 continue;
     1614                        int xPos = 300;
     1615                        int yPos = 100;
     1616                        Text t;
     1617                       
     1618                        // Add documentation links
     1619                        File helpDirectory = new File(FrameIO.HELP_PATH);
     1620                        if (helpDirectory != null) {
     1621                                File[] helpFramesets = helpDirectory.listFiles();
     1622                                if (helpFramesets != null) {
     1623
     1624                                        // Add the title for the help index
     1625                                        Text help = profile.addText(xPos, yPos, "@Expeditee Help", null);
     1626                                        help.setSize(25);
     1627                                        help.setFontStyle("Bold");
     1628                                        help.setFamily("SansSerif");
     1629                                        help.setColor(TemplateSettings.ColorWheel.get()[3]);
     1630
     1631                                        xPos += 25;
     1632                                        System.out.println("Installing frameset: ");
     1633
     1634                                        boolean first_item = true;
     1635                                        for (File helpFrameset : helpFramesets) {
     1636                                                String framesetName = helpFrameset.getName();
     1637                                                if (!FrameIO.isValidFramesetName(framesetName)) {
     1638                                                        continue;
     1639                                                }
     1640
     1641                                                if (first_item) {
     1642                                                        System.out.print("  " + framesetName);
     1643                                                        first_item = false;
     1644                                                } else {
     1645                                                        System.out.print(", " + framesetName);
     1646                                                }
     1647                                                System.out.flush();
     1648
     1649                                                Frame indexFrame = FrameIO.LoadFrame(framesetName + '1');
     1650                                                // Look through the folder for help index pages
     1651                                                if (indexFrame != null && ItemUtils.FindTag(indexFrame.getItems(), "@HelpIndex") != null) {
     1652                                                        // yPos += spacing;
     1653                                                        yPos += 30;
     1654                                                        t = profile.addText(xPos, yPos, '@' + indexFrame.getFramesetName(), null);
     1655                                                        t.setLink(indexFrame.getName());
     1656                                                        t.setColor(Colour.GREY);
     1657                                                }
    16991658                                        }
    1700 
    1701                                         if (first_item) {
    1702                                                 System.out.print("  " + framesetName);
    1703                                                 first_item = false;
    1704                                         }
    1705                                         else {
    1706                                                 System.out.print(", " + framesetName);
    1707                                         }
    1708                                         System.out.flush();
    1709 
    1710                                         Frame indexFrame = FrameIO.LoadFrame(framesetName + '1');
    1711                                         // Look through the folder for help index pages
    1712                                         if (indexFrame != null
    1713                                                         && ItemUtils.FindTag(indexFrame.getItems(),
    1714                                                                         "@HelpIndex") != null) {
    1715                                                 // yPos += spacing;
    1716                                                 yPos += 30;
    1717                                                 t = profile.addText(xPos, yPos,
    1718                                                                 '@' + indexFrame.getFramesetName(), null);
    1719                                                 t.setLink(indexFrame.getName());
    1720                                                 t.setColor(Colour.GREY);
    1721                                         }
    1722                                 }
    1723                                 System.out.println();
    1724                         }
    1725                 }
    1726 
    1727                 xPos = 50;
    1728                 yPos = 100;
    1729 
    1730                 // Populate Start Pages and Settings
    1731                 File framesetDirectory = new File(FrameIO.FRAME_PATH);
    1732 
    1733                 if (framesetDirectory.exists()) {
    1734                         File[] startpagesFramesets = framesetDirectory.listFiles();
    1735 
    1736                         if (startpagesFramesets != null) {
    1737                                 // Add Start Page title
    1738                                 Text templates = profile.addText(xPos, yPos, "@Start Pages",
    1739                                                 null);
    1740                                 templates.setSize(25);
    1741                                 templates.setFontStyle("Bold");
    1742                                 templates.setFamily("SansSerif");
    1743                                 templates.setColor(TemplateSettings.ColorWheel.get()[3]);
    1744 
    1745                                 xPos += 25;
    1746 
    1747                                 // Start Pages should be the first frame in its own frameset +
    1748                                 // frameset name should be present in FrameUtils.startPages[].
    1749                                 for (File startpagesFrameset : startpagesFramesets) {
    1750                                         String framesetName = startpagesFrameset.getName();
    1751 
    1752                                         // Only add link if frameset is a startpage
    1753                                         for (int i = 0; i < startPages.length; i++) {
    1754                                                 if (framesetName.equals(startPages[i])) {
    1755                                                         Frame indexFrame = FrameIO
    1756                                                                         .LoadFrame(framesetName + '1');
    1757 
    1758                                                         // Add start page link
    1759                                                         if (indexFrame != null) {
    1760                                                                 yPos += 30;
    1761                                                                 t = profile.addText(xPos, yPos,
    1762                                                                                 '@' + indexFrame.getFramesetName(),
    1763                                                                                 null);
    1764                                                                 t.setLink(indexFrame.getName());
    1765                                                                 t.setColor(Colour.GREY);
     1659                                        System.out.println();
     1660                                }
     1661                        }
     1662
     1663                        xPos = 50;
     1664                        yPos = 100;
     1665
     1666                        // Populate Start Pages and Settings
     1667                        File framesetDirectory = new File(FrameIO.FRAME_PATH);
     1668
     1669                        if (framesetDirectory.exists()) {
     1670                                File[] startpagesFramesets = framesetDirectory.listFiles();
     1671
     1672                                if (startpagesFramesets != null) {
     1673                                        // Add Start Page title
     1674                                        Text templates = profile.addText(xPos, yPos, "@Start Pages", null);
     1675                                        templates.setSize(25);
     1676                                        templates.setFontStyle("Bold");
     1677                                        templates.setFamily("SansSerif");
     1678                                        templates.setColor(TemplateSettings.ColorWheel.get()[3]);
     1679
     1680                                        xPos += 25;
     1681
     1682                                        // Start Pages should be the first frame in its own frameset +
     1683                                        // frameset name should be present in FrameUtils.startPages[].
     1684                                        for (File startpagesFrameset : startpagesFramesets) {
     1685                                                String framesetName = startpagesFrameset.getName();
     1686
     1687                                                // Only add link if frameset is a startpage
     1688                                                for (int i = 0; i < startPages.length; i++) {
     1689                                                        if (framesetName.equals(startPages[i])) {
     1690                                                                Frame indexFrame = FrameIO.LoadFrame(framesetName + '1');
     1691
     1692                                                                // Add start page link
     1693                                                                if (indexFrame != null) {
     1694                                                                        yPos += 30;
     1695                                                                        t = profile.addText(xPos, yPos, '@' + indexFrame.getFramesetName(), null);
     1696                                                                        t.setLink(indexFrame.getName());
     1697                                                                        t.setColor(Colour.GREY);
     1698                                                                }
    17661699                                                        }
    17671700                                                }
     
    17691702                                }
    17701703                        }
    1771                 }
    1772 
    1773                 FrameIO.SaveFrame(profile);
    1774 
    1775                 // Populate settings frameset
    1776                 Settings.Init();
    1777                 t = profile.addText(550, 100, "@Settings", null);
    1778                 t.setSize((float) 25.0);
    1779                 t.setFamily("SansSerif");
    1780                 t.setFontStyle("Bold");
    1781                 t.setColor(Colour.GREY);
    1782                 Settings.generateSettingsTree(t);
    1783 
    1784                 FrameIO.SaveFrame(profile);
    1785         }
    1786 
    1787         private static void checkTDFCItemWaiting(Frame currentFrame)
    1788         {
     1704
     1705                        FrameIO.SaveFrame(profile);
     1706
     1707                        // Populate settings frameset
     1708                        Settings.Init();
     1709                        t = profile.addText(550, 100, "@Settings", null);
     1710                        t.setSize((float) 25.0);
     1711                        t.setFamily("SansSerif");
     1712                        t.setFontStyle("Bold");
     1713                        t.setColor(Colour.GREY);
     1714                        Settings.generateSettingsTree(t);
     1715
     1716                        FrameIO.SaveFrame(profile);
     1717                }
     1718        }
     1719
     1720        private static void checkTDFCItemWaiting(Frame currentFrame) {
    17891721                Item tdfcItem = FrameUtils.getTdfcItem();
    17901722                // if there is a TDFC Item waiting
     
    18061738        }
    18071739
    1808         public static void setTdfcItem(Item _tdfcItem)
    1809         {
     1740        public static void setTdfcItem(Item _tdfcItem) {
    18101741                FrameUtils._tdfcItem = _tdfcItem;
    18111742        }
    18121743
    1813         public static Item getTdfcItem()
    1814         {
     1744        public static Item getTdfcItem() {
    18151745                return FrameUtils._tdfcItem;
    18161746        }
    18171747
    1818         public static void setLastEdited(Text lastEdited)
    1819         {
     1748        public static void setLastEdited(Text lastEdited) {
    18201749                // If the lastEdited is being changed then check if its @i
    18211750                Frame toReparse = null;
     
    18341763                                        // around it
    18351764                                        String text = LastEdited.getText();
    1836                                         if (text.startsWith("@i:")
    1837                                                         && !Character
    1838                                                         .isDigit(text.charAt(text.length() - 1))) {
    1839                                                 Collection<Item> enclosure = FrameUtils
    1840                                                                 .getEnclosingLineEnds(LastEdited.getPosition());
     1765                                        if (text.startsWith("@i:") && !Character.isDigit(text.charAt(text.length() - 1))) {
     1766                                                Collection<Item> enclosure = FrameUtils.getEnclosingLineEnds(LastEdited.getPosition());
    18411767                                                if (enclosure != null) {
    18421768                                                        for (Item i : enclosure) {
    18431769                                                                if (i.isLineEnd() && i.isEnclosed()) {
    1844                                                                         DisplayController.getCurrentFrame().removeAllItems(
    1845                                                                                         enclosure);
     1770                                                                        DisplayController.getCurrentFrame().removeAllItems(enclosure);
    18461771                                                                        AxisAlignedBoxBounds rect = i.getEnclosedBox();
    1847                                                                         LastEdited
    1848                                                                         .setText(LastEdited.getText()
    1849                                                                                         + " "
    1850                                                                                         + Math.round(rect
    1851                                                                                                         .getWidth()));
     1772                                                                        LastEdited.setText(LastEdited.getText() + " " + Math.round(rect.getWidth()));
    18521773                                                                        LastEdited.setPosition(rect.getTopLeft());
    18531774                                                                        LastEdited.setThickness(i.getThickness());
     
    18921813                }
    18931814        }
    1894 
     1815       
    18951816        /**
    1896          * Extracts files/folders from the assets/resources folder directly into
    1897          * ${PARENT_FOLDER} (~/.expeditee)
    1898          *
    1899          * @param force if true, resources will be extracted even if they have already been extracted before
     1817         * Extracts files/folders from assets/resources-public and assets/resources-private
     1818         * to {Expeditee Home}/resources-public and {Expeditee Home}/resources-private respectively.
     1819         * @param force  if true, resources will be extracted even ifthey have already been extracted before.
    19001820         */
    1901         public static void extractResources(boolean force)
    1902         {
    1903                 File check = new File(FrameIO.PARENT_FOLDER + ".res");
     1821        public static void extractResources(boolean force) {
     1822                // Extract private resources
     1823                Path resourcesPrivate = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-private");
     1824                extractResources("org/expeditee/assets/resources-private", resourcesPrivate, force);
    19041825               
    1905                 if(!force && check.exists()) {
     1826                // Extract public resources
     1827                Path resourcesPublic = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-public");
     1828                extractResources("org/expeditee/assets/resources-public", resourcesPublic, force);
     1829        }
     1830       
     1831        private static void extractResources(String source, Path destination, boolean force) {
     1832                // If resources have already been extracted, and we are not forcing the extraction, there is nothing to do.
     1833                if (!force && destination.resolve(".res").toFile().exists()) {
    19061834                        return;
    19071835                }
    19081836               
    1909                 System.out.println("Extracting/Installing resources:");
     1837                System.out.println("Extracting/Installing resources to: " + destination.getFileName());
    19101838               
    1911                 try     {
    1912                         check.getParentFile().mkdirs();
    1913                         check.createNewFile();
    1914 
    1915                         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    1916                         URL docURL = classLoader.getResource("org/expeditee/assets/resources");
    1917 
    1918                         // copy files from the jar file to the profile folder
    1919                         if (docURL.getProtocol().equals("jar")) {
    1920                                 JarURLConnection ju_connection=(JarURLConnection)docURL.openConnection();
    1921                                 JarFile jf =ju_connection.getJarFile();
     1839                // Create the destination
     1840                destination.getParent().toFile().mkdirs();
     1841               
     1842                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
     1843                URL resourceUrl = classLoader.getResource(source);
     1844                if (resourceUrl.getProtocol().equals("jar")) {
     1845                        try {
     1846                                JarURLConnection ju_connection = (JarURLConnection) resourceUrl.openConnection();
     1847                                JarFile jf = ju_connection.getJarFile();
    19221848                                Enumeration<JarEntry> jarEntries = jf.entries();
    1923                                 String res = "org/expeditee/assets/resources/";
    1924                                 int resLength = res.length();
    1925 
    1926                                 ZipEntry ze;
    1927 
    1928                                 while(jarEntries.hasMoreElements()) {
    1929                                         ze = jarEntries.nextElement();
    1930                                         if(!ze.getName().startsWith(res)) {
    1931                                                 continue;
    1932                                         }
    1933                                         File out = new File(FrameIO.PARENT_FOLDER + ze.getName().substring(resLength));
    1934                                         // System.out.println("Didn't crash here " + out.getPath());
    1935                                         //                                      if(out.exists()) {
    1936                                         //                                              continue;
    1937                                         //                                      }
    1938                                         if(ze.isDirectory()) {
    1939                                                 // System.out.println(out.getPath() + " IS DIRECTORY");
    1940                                                 out.mkdirs();
    1941                                                 continue;
    1942                                         }
    1943                                         FileOutputStream fOut = null;
    1944                                         InputStream fIn = null;
    1945                                         try {
    1946                                                 // System.out.println(out.getPath());
    1947                                                 fOut =  new FileOutputStream(out);
    1948                                                 fIn = classLoader.getResourceAsStream(ze.getName());
    1949                                                 byte[] bBuffer = new byte[1024];
    1950                                                 int nLen;
    1951                                                 while ((nLen = fIn.read(bBuffer)) > 0) {
    1952                                                         fOut.write(bBuffer, 0, nLen);
    1953                                                 }
    1954                                                 fOut.flush();
    1955                                         } catch (Exception e) {
    1956                                                 e.printStackTrace();
    1957                                         } finally {
    1958                                                 if(fOut != null) {
    1959                                                         fOut.close();
    1960                                                 }
    1961                                                 if(fIn != null) {
    1962                                                         fIn.close();
    1963                                                 }
    1964                                         }
    1965                                 }
    1966 
    1967                                 // Copy files from the source folder to the profile folder
    1968                         } else if (docURL.getProtocol().equals("bundleresource")) {
    1969                                 final URLConnection urlConnection = docURL.openConnection();
    1970                                 final Class<?> c = urlConnection.getClass();
    1971                                 final java.lang.reflect.Method toInvoke = c.getMethod("getFileURL");
    1972                                 final URL fileURL = (URL)toInvoke.invoke(urlConnection);
    1973                                 extractResourcesFromFolder(new File(fileURL.getPath()));
    1974                         } else {
    1975                                 File folder = new File(docURL.toURI().getPath());
    1976                                 extractResourcesFromFolder(folder);
    1977                         }
    1978                 }
    1979                 catch (Exception e) {
    1980                         e.printStackTrace();
    1981                 }
    1982         }
    1983 
    1984         private static void extractResourcesFromFolder(File folder) throws IOException
    1985         {
     1849                                extractFromJarFile(classLoader, jarEntries, source, destination);
     1850                        } catch (IOException e) {
     1851                                System.err.println("Error: FrameUtils::extractResources.  Exception whilst extracting resources from Jar File.  Message: " + e.getMessage());
     1852                        }
     1853                } else if (resourceUrl.getProtocol().equals("bundleresource")) {
     1854                        try {
     1855                                URLConnection urlConnection = resourceUrl.openConnection();
     1856                                Class<?> c = urlConnection.getClass();
     1857                                java.lang.reflect.Method toInvoke = c.getMethod("getFileURL");
     1858                                URL fileURL = (URL) toInvoke.invoke(urlConnection);
     1859                                extractResourcesFromFolder(new File(fileURL.getPath()), source, destination);
     1860                        } catch (IOException e) {
     1861                                System.err.println("Error: FrameUtils::extractResources.  Problem opening connection to bundleresource.  Message: " + e.getMessage());
     1862                        } catch (NoSuchMethodException e) {
     1863                                System.err.println("Error: FrameUtils::extractResources.  Unable to find method URLConnection::getFileURL.  Message: " + e.getMessage());
     1864                        } catch (InvocationTargetException e) {
     1865                                System.err.println("Error: FrameUtils::extractResources.  Problem invoking URLConnection::getFileURL.  Message: " + e.getMessage());
     1866                        } catch (IllegalAccessException e) {
     1867                                System.err.println("Error: FrameUtils::extractResources.  Problem invoking URLConnection::getFileURL.  Message: " + e.getMessage());
     1868                        }
     1869                } else {
     1870                        try {
     1871                                File folder = new File(resourceUrl.toURI().getPath());
     1872                                extractResourcesFromFolder(folder, source, destination);
     1873                        } catch (URISyntaxException e) {
     1874                                System.err.println("Error: FrameUtils::extractResources.  Problem converting URL to URI.  Message: " + e.getMessage());
     1875                        } catch (IOException e) {
     1876                                System.err.println("Error: FrameUtils::extractResources.  Exception whilst extracting resources from folder.  Message: " + e.getMessage());
     1877                        }
     1878                }
     1879               
     1880                // Create the .res file to signal completion
     1881                try {
     1882                        destination.resolve(".res").toFile().createNewFile();
     1883                } catch (IOException e) {
     1884                        System.err.println("Error: FrameUtils::extractResources.  Unable to create the .res file to flag that resources have been extracted.  Message: " + e.getMessage());
     1885                }
     1886        }
     1887
     1888        private static void extractFromJarFile(ClassLoader classLoader, Enumeration<JarEntry> jarEntries, String source, Path destination) throws IOException {
     1889                while (jarEntries.hasMoreElements()) {
     1890                        ZipEntry ze = jarEntries.nextElement();
     1891                        if (!ze.getName().startsWith(source)) {
     1892                                continue;
     1893                        }
     1894                        File out = destination.resolve(ze.getName().substring(source.length())).toFile();
     1895                        if (ze.isDirectory()) {
     1896                                out.mkdirs();
     1897                                continue;
     1898                        }
     1899                        FileOutputStream fOut = null;
     1900                        InputStream fIn = null;
     1901                        try {
     1902                                fOut = new FileOutputStream(out);
     1903                                fIn = classLoader.getResourceAsStream(ze.getName());
     1904                                byte[] bBuffer = new byte[1024];
     1905                                int nLen;
     1906                                while ((nLen = fIn.read(bBuffer)) > 0) {
     1907                                        fOut.write(bBuffer, 0, nLen);
     1908                                }
     1909                                fOut.flush();
     1910                        } catch (Exception e) {
     1911                                e.printStackTrace();
     1912                        } finally {
     1913                                if (fOut != null) {
     1914                                        fOut.close();
     1915                                }
     1916                                if (fIn != null) {
     1917                                        fIn.close();
     1918                                }
     1919                        }
     1920                }
     1921        }
     1922
     1923        private static void extractResourcesFromFolder(File folder, String source, Path destination) throws IOException {
    19861924                LinkedList<File> items = new LinkedList<File>();
    19871925                items.addAll(Arrays.asList(folder.listFiles()));
    19881926                LinkedList<File> files = new LinkedList<File>();
    1989                 String res = "org" + File.separator + "expeditee" + File.separator + "assets" + File.separator + "resources";
    1990                 int resLength = res.length();
    19911927
    19921928                while (items.size() > 0) {
    19931929                        File file = items.remove(0);
    1994                         if(file.isFile()) {
    1995                                 if(!file.getName().contains(".svn")) {
     1930                        if (file.isFile()) {
     1931                                if (!file.getName().contains(".svn")) {
    19961932                                        files.add(file);
    19971933                                }
     
    20031939                }
    20041940                for (File file : files) {
    2005                         System.out.println(file.getPath());
    2006                         File out = new File(FrameIO.PARENT_FOLDER + file.getPath().substring(file.getPath().indexOf(res) + resLength));
    2007                         //              if(out.exists()) {
    2008                         //                      continue;
    2009                         //              }
     1941                        String path = file.getPath();
     1942                        System.out.println(path);
     1943                        Path relativize = folder.toPath().relativize(Paths.get(file.getPath()));
     1944                        File out = destination.resolve(relativize).toFile();
    20101945                        copyFile(file, out, true);
    20111946                }
     
    20171952         * @throws IOException
    20181953         */
    2019         public static void copyFile(File src, File dst, boolean overWrite) throws IOException
    2020         {
    2021                 if(!overWrite && dst.exists()) {
     1954        public static void copyFile(File src, File dst, boolean overWrite) throws IOException {
     1955                if (!overWrite && dst.exists()) {
    20221956                        return;
    20231957                }
    2024                
     1958
    20251959                dst.getParentFile().mkdirs();
    20261960                FileOutputStream fOut = null;
     
    20391973                        e.printStackTrace();
    20401974                } finally {
    2041                         if(fOut != null) {
     1975                        if (fOut != null) {
    20421976                                fOut.close();
    20431977                        }
    2044                         if(fIn != null) {
     1978                        if (fIn != null) {
    20451979                                fIn.close();
    20461980                        }
     
    20481982        }
    20491983
    2050         public static Text getLastEdited()
    2051         {
     1984        public static Text getLastEdited() {
    20521985                return LastEdited;
    20531986        }
    20541987
    2055         public static Collection<Text> getCurrentTextItems()
    2056         {
     1988        public static Collection<Text> getCurrentTextItems() {
    20571989                Collection<Text> currentTextItems = new LinkedHashSet<Text>();
    20581990                Collection<Item> currentItems = getCurrentItems(null);
  • trunk/src/org/expeditee/importer/pdfImporter.java

    r1102 r1242  
    7777                }
    7878               
    79                 final String framesetPath = frameset.getPath()+name+File.separator;
     79                final String framesetPath = frameset.getFramesetPath();
    8080               
    8181                System.out.println("PATH = " + framesetPath);
  • trunk/src/org/expeditee/io/DefaultFrameReader.java

    r1232 r1242  
    8989                        _FrameTags.put('B', Frame.class.getMethod("setBackgroundColor", pColor));
    9090                        _FrameTags.put('K', Frame.class.getMethod("setEncryptionLabel", pString));
     91                        _FrameTags.put('T', Frame.class.getMethod("addToData", pString));
    9192
    9293                        // Note: As of 26/11/18 there are no unused letter item tags.  Use other characters.
  • trunk/src/org/expeditee/io/DefaultFrameWriter.java

    r1226 r1242  
    7878                        _FrameTags.put('B', Frame.class.getMethod("getBackgroundColor"));
    7979                        _FrameTags.put('K', Frame.class.getMethod("getEncryptionLabel"));
     80                        _FrameTags.put('T', Frame.class.getMethod("getData"));
    8081                       
    8182                        // Note: As of 26/11/18 there are no unused letter item tags.  Use other characters.
  • trunk/src/org/expeditee/io/ExpReader.java

    r1232 r1242  
    2929import org.expeditee.core.Point;
    3030import org.expeditee.gui.Frame;
     31import org.expeditee.gui.FrameIO;
    3132import org.expeditee.items.Constraint;
    3233import org.expeditee.items.Dot;
     
    213214                //newFrame.refreshItemPermissions();
    214215                _reader.close();
     216                FrameIO.setSavedProperties(newFrame);
    215217                newFrame.setChanged(false);
    216218
     
    344346                return -1;
    345347        }
     348       
     349        public static String redirectTo(String fullPath) {
     350                try {
     351                        BufferedReader reader = new BufferedReader(new FileReader(fullPath));
     352                        String next = "";
     353                        while (reader.ready() && !(next = reader.readLine()).equals("Z")) {
     354                                if (next.startsWith("REDIRECT:")) {
     355                                        String redirectTo = next.replace("REDIRECT:", "");
     356                                        reader.close();
     357                                        return redirectTo;
     358                                }
     359                        }
     360                        reader.close();
     361                } catch (Exception e) {
     362                }
     363                return null;
     364        }
    346365}
  • trunk/src/org/expeditee/io/HTMLWriter.java

    r1144 r1242  
    2828import org.expeditee.gio.EcosystemManager;
    2929import org.expeditee.gio.GraphicsManager;
    30 import org.expeditee.gio.swing.SwingMiscManager;
    3130import org.expeditee.gui.FrameIO;
    3231import org.expeditee.items.FramePicture;
     
    104103                        }
    105104                        if (filesFolder.equals("")) {
    106                                 filesFolder = "../" + FrameIO.IMAGES_FOLDER;
     105                                filesFolder = "../images/";
    107106                        }
    108107                }
  • trunk/src/org/expeditee/setting/ArraySetting.java

    r979 r1242  
    2121import java.util.Arrays;
    2222
     23import org.expeditee.core.Representable;
     24import org.expeditee.gui.Frame;
     25import org.expeditee.gui.FrameIO;
    2326import org.expeditee.items.Text;
    2427
     
    2831        protected T[] _value;
    2932       
    30         public ArraySetting(String tooltip, T[] value) {
    31                 super(tooltip);
     33        public ArraySetting(String tooltip, String name, T[] value) {
     34                super(tooltip, name);
    3235                _default = Arrays.copyOf(value, value.length);
    3336                _value = value;
     
    6265                _value = Arrays.copyOf(_default, _default.length);
    6366        }
    64 
     67       
     68        @Override
     69        public Text generateRepresentation(String label, String frameset) {
     70                Text t = new Text(label);
     71               
     72                if (_value.length > 0) {
     73                        Frame arrayFrame = FrameIO.CreateFrame(frameset, null, null);
     74                        arrayFrame.getTitleItem().delete();
     75                       
     76                        int x = 100;
     77                        int y = 100;
     78                        for (T v: _value) {
     79                                if (v == null) continue;
     80                                Text representation;
     81                                if (v instanceof Representable) {
     82                                        representation = ((Representable) v).generateRepresentation("Array Entry", "");
     83                                        representation.setPosition(x, y);
     84                                        representation.setID(arrayFrame.getNextItemID());
     85                                        arrayFrame.addItem(representation);
     86                                } else {
     87                                        representation = arrayFrame.addText(x, y, v.toString(), null);
     88                                }
     89                                y += representation.getBoundsHeight();
     90                        }
     91                        FrameIO.ForceSaveFrame(arrayFrame);
     92                        t.setLink(arrayFrame.getName());
     93                }
     94               
     95                return t;
     96        }
    6597}
  • trunk/src/org/expeditee/setting/BooleanSetting.java

    r919 r1242  
    2121public class BooleanSetting extends GenericSetting<Boolean> {
    2222
    23         public BooleanSetting(String tooltip, Boolean value) {
    24                 super(Boolean.class, tooltip, value);
     23        public BooleanSetting(String tooltip, String name, Boolean value) {
     24                super(Boolean.class, tooltip, name, value);
    2525        }
    2626}
  • trunk/src/org/expeditee/setting/FloatSetting.java

    r919 r1242  
    2121public class FloatSetting extends GenericSetting<Float> {
    2222
    23         public FloatSetting(String tooltip, Float value) {
    24                 super(Float.class, tooltip, value);
     23        public FloatSetting(String tooltip, String name, Float value) {
     24                super(Float.class, tooltip, name, value);
    2525        }
    2626}
  • trunk/src/org/expeditee/setting/FrameSetting.java

    r919 r1242  
    2424public abstract class FrameSetting extends Setting {
    2525
    26         public FrameSetting(String tooltip) {
    27                 super(tooltip);
     26        public FrameSetting(String tooltip, String name) {
     27                super(tooltip, name);
    2828        }
    2929       
     
    4545        }
    4646
     47        @Override
     48        public Text generateRepresentation(String label, String frameset) {
     49                Text t = new Text(label);
     50                return t;
     51        }
    4752}
  • trunk/src/org/expeditee/setting/FunctionSetting.java

    r919 r1242  
    2424public abstract class FunctionSetting extends Setting {
    2525       
    26         public FunctionSetting(String tooltip) {
    27                 super(tooltip);
     26        public FunctionSetting(String tooltip, String name) {
     27                super(tooltip, name);
    2828        }
    2929       
     
    4545                return false;
    4646        }
     47       
     48        @Override
     49        public Text generateRepresentation(String label, String frameset) {
     50                Text text = new Text(label + ": false");
     51                return text;
     52        }
    4753}
  • trunk/src/org/expeditee/setting/GenericSetting.java

    r1209 r1242  
    4343         * @param value Default value
    4444         */
    45         public GenericSetting(Class<T> type, String tooltip, T value) {
    46                 super(tooltip);
     45        public GenericSetting(Class<T> type, String tooltip, String name, T value) {
     46                super(tooltip, name);
    4747                _type = type;
    4848                _default = value;
     
    5353         * Instantiates a new setting with no default value
    5454         */
    55         public GenericSetting(Class<T> type, String tooltip) {
    56                 this(type, tooltip, (T) saneInitialValue(type));
     55        public GenericSetting(Class<T> type, String tooltip, String name) {
     56                this(type, tooltip, name, (T) saneInitialValue(type));
    5757        }
    5858       
     
    137137                _value = _default;
    138138        }
     139       
     140        @Override
     141        public Text generateRepresentation(String name, String frameset) {
     142                T value = get();
     143                Text t = new Text(name + ": " + (value == null ? "" : value));
     144                return t;
     145        }
    139146
    140147}
  • trunk/src/org/expeditee/setting/IntegerSetting.java

    r919 r1242  
    2121public class IntegerSetting extends GenericSetting<Integer> {
    2222
    23         public IntegerSetting(String tooltip, Integer value) {
    24                 super(Integer.class, tooltip, value);
     23        public IntegerSetting(String tooltip, String name, Integer value) {
     24                super(Integer.class, tooltip, name, value);
    2525        }
    2626}
  • trunk/src/org/expeditee/setting/ListSetting.java

    r919 r1242  
    2222import java.util.List;
    2323
     24import org.expeditee.core.Representable;
     25import org.expeditee.gui.Frame;
     26import org.expeditee.gui.FrameIO;
    2427import org.expeditee.items.Text;
    2528
     
    2932        protected List<T> _value;
    3033       
    31         public ListSetting(String tooltip, List<T> value) {
    32                 super(tooltip);
     34        public ListSetting(String tooltip, String name, List<T> value) {
     35                super(tooltip, name);
    3336                _default = new LinkedList<T>(value);
    3437                _value = value;
    3538        }
    3639       
    37         public ListSetting(String tooltip) {
    38                 this(tooltip, new LinkedList<T>());
     40        public ListSetting(String tooltip, String name) {
     41                this(tooltip, name, new LinkedList<T>());
    3942        }
    4043       
     
    5760        }
    5861
     62        @Override
     63        public Text generateRepresentation(String label, String frameset) {
     64                Text t = new Text(label);
     65               
     66                if (!_value.isEmpty()) {
     67                        Frame listFrame = FrameIO.CreateFrame(frameset, null, null);
     68                        listFrame.getTitleItem().delete();
     69                       
     70                        int x = 100;
     71                        int y = 100;
     72                        for (T v: _value) {
     73                                if (v == null) continue;
     74                                Text representation;
     75                                if (v instanceof Representable) {
     76                                        representation = ((Representable) v).generateRepresentation("List Entry", "");
     77                                        representation.setPosition(x, y);
     78                                        representation.setID(listFrame.getNextItemID());
     79                                        listFrame.addItem(representation);
     80                                } else {
     81                                        representation = listFrame.addText(x, y, v.toString(), null);
     82                                }
     83                                y += representation.getBoundsHeight();
     84                        }
     85                        FrameIO.ForceSaveFrame(listFrame);
     86                        t.setLink(listFrame.getName());
     87                }
     88               
     89                return t;
     90        }
    5991}
  • trunk/src/org/expeditee/setting/Setting.java

    r919 r1242  
    1919package org.expeditee.setting;
    2020
     21import org.expeditee.core.Representable;
    2122import org.expeditee.items.Text;
    2223
    23 public abstract class Setting {
     24public abstract class Setting implements Representable {
    2425       
    2526        private String _tooltip;
     27        private String _name;
    2628       
    27         public Setting(String tooltip) {
     29        public Setting(String tooltip, String name) {
    2830                this._tooltip = tooltip;
     31                this._name = name;
    2932        }
    3033       
    3134        public final String getTooltip() {
    3235                return _tooltip;
     36        }
     37       
     38        public final String getName() {
     39                return _name;
    3340        }
    3441       
  • trunk/src/org/expeditee/setting/StringSetting.java

    r919 r1242  
    2222
    2323        public StringSetting(String tooltip, String value) {
    24                 super(String.class, tooltip, value);
     24                super(String.class, tooltip, value, value);
    2525        }
    2626}
  • trunk/src/org/expeditee/setting/TextSetting.java

    r919 r1242  
    2323public abstract class TextSetting extends GenericSetting<Text> {
    2424
    25         public TextSetting(String tooltip) {
    26                 super(Text.class, tooltip, null);
     25        public TextSetting(String tooltip, String name) {
     26                super(Text.class, tooltip, name, null);
    2727                _default = generateText();
    2828                _value = _default;
     
    4141       
    4242        public abstract Text generateText();
     43       
     44        public Text generateRepresentation(String label, String frameset) {
     45                return get();
     46        }
    4347
    4448}
  • trunk/src/org/expeditee/setting/VariableSetting.java

    r919 r1242  
    2121public abstract class VariableSetting extends Setting {
    2222       
    23         public VariableSetting(String tooltip) {
    24                 super(tooltip);
     23        public VariableSetting(String tooltip, String name) {
     24                super(tooltip, name);
    2525        }
    2626       
  • trunk/src/org/expeditee/settings/Settings.java

    r1121 r1242  
    2222import java.lang.reflect.Method;
    2323import java.util.HashMap;
     24import java.util.Iterator;
    2425import java.util.LinkedList;
    2526import java.util.List;
     
    3233import org.expeditee.items.widgets.Password;
    3334import org.expeditee.reflection.PackageLoader;
    34 import org.expeditee.setting.GenericSetting;
    3535import org.expeditee.setting.Setting;
    3636import org.expeditee.setting.VariableSetting;
     
    229229        }
    230230       
    231         /** Generates settings tree */
    232         private static void generateSettingsTree(String page, Text text)
    233         {
    234                 FrameCreator frames = new FrameCreator(text.getParentOrCurrentFrame().getFramesetName(), text.getParentOrCurrentFrame().getPath(), page, false, false);
    235                 // Frame frame = FrameIO.CreateFrame(text.getParentOrCurrentFrame().getFramesetName(), page, null);
     231        private static void generateSettingsTree(String page, Text text) {
     232                Frame parent = text.getParentOrCurrentFrame();
     233                FrameCreator frames = new FrameCreator(parent.getFramesetName(), parent.getPath(), page, false, false);
    236234                text.setLink(frames.getName());
    237235               
    238                 // add subpages of the current page
    239                 for(String k : _pages.keySet()) {
    240                         if(k.startsWith(page.toLowerCase()) && !k.equals(page)) {
     236                // Add subpages of the current page by recursing
     237                for (String k: _pages.keySet()) {
     238                        if (k.startsWith(page.toLowerCase()) && !k.equals(page)) {
    241239                                String name = k.substring(page.length() + 1);
    242                                 if(name.indexOf('.') != -1) {
     240                                if (name.indexOf('.') != -1) {
    243241                                        continue;
    244242                                }
     
    248246                }
    249247               
     248                // Start building current page
    250249                frames.setLastY(frames.getLastY() + 20);
    251                
    252                 // add settings of the current page
     250                //      Add Settings of the current page
    253251                PageDescriptor pd = _pages.get(page);
    254                 if(pd != null) {
    255                         for(String str : pd.orderedEntries) {
    256                                 String key = str.toLowerCase();
    257                                 Setting s = pd.settings.get(key);
    258                                 if(s == null) {
     252                if (pd == null) {
     253                        frames.save();
     254                        return;
     255                }
     256               
     257               
     258                Iterator<String> keys = pd.orderedEntries.stream().map(t -> t.toLowerCase()).iterator();
     259                while(keys.hasNext()) {
     260                        String key = keys.next();
     261                        Setting setting = pd.settings.get(key);
     262                        if (setting == null) {
     263                                continue;
     264                        }
     265                       
     266                        // Keep track of were we are placing items on Frames.
     267                        int x = 0, y = 0;
     268                       
     269                        if (key.equals("pass")) {
     270                                // Special case for Password widgets
     271                                Text passwordWidgetText = frames.addText("iw: org.expeditee.items.widgets.Passwsord", null, null, null, false);
     272                                Password pw = new Password(passwordWidgetText, null);
     273                                pw.setPassword("");
     274                                frames.getCurrentFrame().removeItem(passwordWidgetText);
     275                                frames.getCurrentFrame().addAllItems(pw.getItems());
     276                                x = passwordWidgetText.getX() + passwordWidgetText.getBoundsWidth();
     277                                y = passwordWidgetText.getY();
     278                        } else {
     279                                // Determine the content for a setting label.
     280                                String name = key.substring(0, 1).toUpperCase() + key.substring(1);
     281                               
     282                                // Construct and add text representation for setting. 
     283                                // If a setting has no initialised value then it is not included.
     284                                Text settingRepresentation = setting.generateRepresentation(name, frames.getCurrentFrame().getFramesetName()).copy();
     285                                if (settingRepresentation.getBounds() == null) {
    259286                                        continue;
    260287                                }
    261                                 String name = str.substring(0, 1).toUpperCase() + str.substring(1);
    262                                 String value = "";
    263                                 if(s instanceof GenericSetting && ((GenericSetting<?>) s).isPrimitive()) {
    264                                         if(((GenericSetting<?>) s).get() != null) {
    265                                                 value = ": " + ((GenericSetting<?>) s).get();
    266                                         } else {
    267                                                 value = ": ";
    268                                         }
    269                                 }
    270                                 int x = 0, y = 0;
    271                                 Text t;
    272                                 if(key.equals("pass")) {
    273                                         t = frames.addText("iw: org.expeditee.items.widgets.Password", null, null, null, false);
    274                                         Password pw = new Password(t, null);
    275                                         pw.setPassword((String) value);
    276                                         frames.getCurrentFrame().removeItem(t);
    277                                         frames.getCurrentFrame().addAllItems(pw.getItems());
    278                                         x = pw.getX() + pw.getWidth();
    279                                         y = pw.getY();
    280                                 } else {
    281                                         if(s instanceof GenericSetting && ((GenericSetting<?>) s).getType().equals(Text.class)) {
    282                                         t = (Text) ((GenericSetting<?>)s).get();
    283                                         if(t == null) {
    284                                                 System.err.println("Failed to get Text setting \"" + str + "\"");
    285                                                 continue;
    286                                         }
    287                                         t = t.copy();
    288                                         t.setID(frames.getCurrentFrame().getNextItemID());
    289                                         t.setText(name);
    290                                         frames.addItem(t, false);
    291                                 } else {
    292                                         t = frames.addText(name + value, null, null, null, false);
    293                                 }
    294                                         x = t.getX() + t.getBoundsWidth();
    295                                         y = t.getY();
    296                                 }
    297                                 x = Math.max(250, x + 20);
    298                                 Text tt = frames.getCurrentFrame().addText(x, y, "// " + s.getTooltip(), null);
    299                                 // rebuild to get the correct height since setWidth() doesn't immediately rebuild
    300                                 tt.rebuild(true);
    301                                 if(tt.getY() + tt.getBoundsHeight() > frames.getLastY()) {
    302                                         frames.setLastY(tt.getY() + tt.getBoundsHeight());
    303                                 }
     288                                settingRepresentation.setID(frames.getCurrentFrame().getNextItemID());
     289                                frames.addItem(settingRepresentation, false);                           
     290                                x = settingRepresentation.getX() + settingRepresentation.getBoundsWidth();
     291                                y = settingRepresentation.getY();
     292                        }
     293                       
     294                        x = Math.max(250, x + 20);
     295                        // Add tooltip for setting
     296                        Text tooltip = frames.getCurrentFrame().addText(x, y, "// " + setting.getTooltip(), null);
     297                        tooltip.rebuild(true);
     298                        if (tooltip.getY() + tooltip.getBoundsHeight() > frames.getLastY()) {
     299                                frames.setLastY(tooltip.getY() + tooltip.getBoundsHeight());
    304300                        }
    305301                }
    306302               
    307303                frames.save();
    308                 //FrameIO.SaveFrame(frame);
    309304        }
    310305}
  • trunk/src/org/expeditee/settings/UserSettings.java

    r1227 r1242  
    2222import java.io.FileNotFoundException;
    2323import java.io.IOException;
     24import java.nio.file.Paths;
    2425import java.util.ArrayList;
    25 import java.util.Collection;
    2626import java.util.LinkedList;
    2727import java.util.List;
     
    3434import org.expeditee.gui.FrameUtils;
    3535import org.expeditee.gui.MessageBay;
    36 import org.expeditee.items.Item;
    3736import org.expeditee.items.Text;
    3837import org.expeditee.setting.BooleanSetting;
     
    5352       
    5453        public static String DEFAULT_PROFILE_NAME = "default";
    55        
    56         public static final IntegerSetting Gravity = new IntegerSetting("Distance the cursor has to be from a text item to select the text item", 3);
     54         
     55        public static Boolean multiUserMode;
     56       
     57        public static final IntegerSetting Gravity = new IntegerSetting("Distance the cursor has to be from a text item to select the text item", "Gravity", 3);
    5758       
    5859        public static final StringSetting StartFrame = new StringSetting("The frame to go to when Expeditee is started (defaults to the profile frame)", null);
     
    8283                }
    8384        };
    84         public static final IntegerSetting InitialWidth = new IntegerSetting("Initial width of Expeditee window", 1024);
    85        
    86         public static final IntegerSetting InitialHeight = new IntegerSetting("Initial height of Expeditee window", 768);
     85        public static final IntegerSetting InitialWidth = new IntegerSetting("Initial width of Expeditee window", "InitialWidth", 1024);
     86       
     87        public static final IntegerSetting InitialHeight = new IntegerSetting("Initial height of Expeditee window", "InitialHeight", 768);
    8788       
    8889        /*
     
    9091         */
    9192       
    92         public static final FloatSetting ScaleFactor = new FloatSetting("Scale Factor for drawing (TODO: does this even do anything?)", 1F);
    93        
    94         public static final FloatSetting FormatSpacingMin = new FloatSetting("Minimum spacing ratio", null);
    95        
    96         public static final FloatSetting FormatSpacingMax = new FloatSetting("Maximum spacing ratio", null);
    97 
    98         public static final IntegerSetting LineStraightenThreshold = new IntegerSetting("Threshold for straightening a line (TODO: does this even do anything?)", 15);
    99 
    100         public static final IntegerSetting NoOpThreshold = new IntegerSetting("Distance the cursor may be dragged before Gestures must be reinterpreted.  E.g. Copy becomes range.", 10);
    101        
    102         public static final IntegerSetting TitlePosition = new IntegerSetting("Position of title item in frame (TODO: find whether this is x-offset or y-offset)", 150);
    103        
    104         public static final StringSetting ProfileName = new StringSetting("Profile name", FrameIO.ConvertToValidFramesetName(System.getProperty("user.name"))) {
     93        public static final FloatSetting ScaleFactor = new FloatSetting("Scale Factor for drawing (TODO: does this even do anything?)", "ScaleFactor", 1F);
     94       
     95        public static final FloatSetting FormatSpacingMin = new FloatSetting("Minimum spacing ratio", "FormatSpacingMin", null);
     96       
     97        public static final FloatSetting FormatSpacingMax = new FloatSetting("Maximum spacing ratio", "FormatSpacingMax", null);
     98
     99        public static final IntegerSetting LineStraightenThreshold = new IntegerSetting("Threshold for straightening a line (TODO: does this even do anything?)", "LineStraightenThreshold", 15);
     100
     101        public static final IntegerSetting NoOpThreshold = new IntegerSetting("Distance the cursor may be dragged before Gestures must be reinterpreted.  E.g. Copy becomes range.", "NoOpThreshold", 10);
     102       
     103        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);
     104       
     105        public static final StringSetting ProfileName = new StringSetting("Profile name", FrameIO.ConvertToValidFramesetName(System.getProperty("user.name")));
     106       
     107        public static final StringSetting UserName = new StringSetting("User name", ProfileName.get());
    105108               
    106                 /** Commit the change to the appropriate frame */
    107                 public void set(String value) {
    108                         super.set(value);
    109                         commitToSettingsFrameItem(value, "ProfileName:");
    110                 };
    111                
    112                 /** If authenticated, then resetting ProfileName should not do anything. */
    113                 public void reset() {
    114                         if (!Authenticated.get()) {
    115                                 super.reset();
    116                         }
    117                 };
    118         };
    119        
    120         public static final StringSetting UserName = new StringSetting("User name", ProfileName.get()) {
    121                 /** Commit the change to the appropriate frame */
    122                 public void set(String value) {
    123                         super.set(value);
    124                         commitToSettingsFrameItem(value, "UserName:");
    125                 };
    126                
    127                 /** If authenticated, then resetting UserName should not do anything. */
    128                 public void reset() {
    129                         if (!Authenticated.get()) {
    130                                 super.reset();
    131                         }
    132                 };
    133         };
    134                
    135         public static final BooleanSetting AntiAlias = new BooleanSetting("Whether anti-aliasing should be enabled", false);
    136 
    137         public static final BooleanSetting LineHighlight = new BooleanSetting("Whether lines should be highlighted", false);
    138 
    139         public static final BooleanSetting Logging = new BooleanSetting("Whether logging should be enabled", false);
    140 
    141         public static final BooleanSetting LogStats = new BooleanSetting("Whether stats should be logged", true);
    142 
    143         public static final BooleanSetting Threading = new BooleanSetting("Whether threading should be enabled", true);
    144 
    145         public static final BooleanSetting Authenticated = new BooleanSetting("Whether the current user is authenticated", false) {
    146                 public void set(Boolean value) {
    147                         super.set(value);
    148                         commitToSettingsFrameItem(value, "Authenticated:");
    149                 }
    150                
    151                 // Authenticated must be maintained rather than rely on default value.
    152                 public void reset() {};
    153                
    154                 public boolean setSetting(Text text) {
    155                         return super.setSetting(text);
    156                 };
    157         };
    158        
     109        public static final BooleanSetting AntiAlias = new BooleanSetting("Whether anti-aliasing should be enabled", "AntiAlias", false);
     110
     111        public static final BooleanSetting LineHighlight = new BooleanSetting("Whether lines should be highlighted", "LineHighlight", false);
     112
     113        public static final BooleanSetting Logging = new BooleanSetting("Whether logging should be enabled", "Logging", false);
     114
     115        public static final BooleanSetting LogStats = new BooleanSetting("Whether stats should be logged", "LogStats", true);
     116
     117        public static final BooleanSetting Threading = new BooleanSetting("Whether threading should be enabled", "Threading", true);
     118
    159119        /*
    160120         * Frames
     
    167127         * Other
    168128         */
    169         public static final ListSetting<Text> Style = new ListSetting<Text>("Set the style (TODO: what does this do?)") {               
     129        public static final ListSetting<Text> Style = new ListSetting<Text>("Set the style (TODO: what does this do?)", "Style") {             
    170130                @Override
    171131                public boolean setSetting(Text text) {
     
    196156        };
    197157       
    198         public static final FunctionSetting SpellChecker = new FunctionSetting("Enables the dictionary with the default dictionary") {
     158        public static final FunctionSetting SpellChecker = new FunctionSetting("Enables the dictionary with the default dictionary", "SpellChecker") {
    199159                @Override
    200160                public void run() {
     
    208168                }
    209169        };
    210         public static final FrameSetting Spelling = new FrameSetting("Enables the dictionary and adds the items in the child frame to the dictionary") {
     170        public static final FrameSetting Spelling = new FrameSetting("Enables the dictionary and adds the items in the child frame to the dictionary", "Spelling") {
    211171                @Override
    212172                public void run(Frame frame) {
     
    219179        };
    220180       
    221         public static final FrameSetting GreenstoneSettings = new FrameSetting("Greenstone settings (TODO: What are these for?)") {
     181        public static final FrameSetting GreenstoneSettings = new FrameSetting("Greenstone settings (TODO: What are these for?)", "GreenstoneSettings") {
    222182                @Override
    223183                public void run(Frame frame) {
     
    226186        };
    227187       
    228         public static final FrameSetting Reminders = new FrameSetting("Reminders (TODO: What are these for?)") {
     188        public static final FrameSetting Reminders = new FrameSetting("Reminders (TODO: What are these for?)", "Reminders") {
    229189                @Override
    230190                public void run(Frame frame) {
     
    233193        };
    234194       
    235         public static final FrameSetting MailSettings = new FrameSetting("Mail Settings (TODO: How does this work?)") {
     195        public static final FrameSetting MailSettings = new FrameSetting("Mail Settings (TODO: How does this work?)", "MailSettings") {
    236196                @Override
    237197                public void run(Frame frame) {
     
    242202        // add default values
    243203        static {
     204                // Are we in the new regime or the old regime?
     205                File resFile = Paths.get(getDesiredExpediteeHome()).resolve(".res").toFile();
     206                File resourcesPrivateFile = Paths.get(getDesiredExpediteeHome() + "resources-private" + File.separator).toFile();
     207                if (resourcesPrivateFile.exists()) {
     208                        // If resources-private exists than this is a good sign we have new regime available.
     209                        multiUserMode = Boolean.TRUE;
     210                } else if (resFile.exists()) {
     211                        // If we do not, but do have the .res file then this is a good sign we are in old regime.
     212                        multiUserMode = Boolean.FALSE;
     213                } else {
     214                        // If we have neither then we are unpacking and therefore will have new regime available once unpacked.
     215                        multiUserMode = Boolean.TRUE;
     216                }
     217               
    244218                setupDefaultFolders();
    245219        }
    246 
    247         public static void setupDefaultFolders() {
    248                 String expeditee_home = System.getProperty("expeditee.home");
    249                 if (expeditee_home != null) {
    250                     FrameIO.changeParentFolder(expeditee_home + File.separator);
    251                 } else {
    252                     FrameIO.changeParentFolder(getSaveLocation());
    253                 }
     220               
     221        public static void setupDefaultFolders() {             
     222                FrameIO.changeParentFolder(getDesiredExpediteeHome());
    254223         
    255224                FolderSettings.FrameDirs.get().clear();
     
    258227        }
    259228
     229        private static String getDesiredExpediteeHome() {
     230                String homeProperty = System.getProperty("expeditee.home");
     231                String expeditee_home = homeProperty == null ? getSaveLocation() : homeProperty + File.separator;
     232                return expeditee_home;
     233        }
     234
    260235        public static void appendDefaultFolders() {
    261                 FolderSettings.FrameDirs.get().add(FrameIO.FRAME_PATH);
    262                 FolderSettings.FrameDirs.get().add(FrameIO.PUBLIC_PATH);
    263                 FolderSettings.FrameDirs.get().add(FrameIO.PROFILE_PATH);
    264                 FolderSettings.FrameDirs.get().add(FrameIO.HELP_PATH);
    265                 FolderSettings.FrameDirs.get().add(FrameIO.MESSAGES_PATH);
    266                 FolderSettings.FrameDirs.get().add(FrameIO.SHARED_BY_ME_FRAMESETS);
    267                 FolderSettings.FrameDirs.get().add(FrameIO.SHARED_WITH_ME_FRAMESETS);
    268                 FolderSettings.FrameDirs.setDefault(FolderSettings.FrameDirs.get());
    269                 FolderSettings.ImageDirs.get().add(FrameIO.IMAGES_PATH);
    270                 FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
     236                if (multiUserMode) {
     237                        // The comments here explain how things have changed with the new regime.
     238                        // FrameDirs
     239                        // 1. PROFILE_PATH                                      Still points to same place.
     240                        // 2. SHARED_FRAMESETS_PATH                     Still points to same place. (encryption stops just anyone reading it)
     241                        // 3. framesets-<username>                      Generated on user account creation and must be refreshed on user switching.  Also gives access to tutorial stuffs.
     242                        // 4. FRAME_PATH                                        <expeditee-home>\resources-public\framesets.
     243                        // 5. HELP_PUBLIC_PATH                          <expeditee-home>\resources-public\documentation.
     244                        // 6. MESSAGES_PATH                                     Still points to same place.  Should these be per user and encrypted?
     245                        // 7. PUBLIC_PATH                                       Still points to same place.  Kept for compatibility.
     246                        FolderSettings.FrameDirs.get().add(FrameIO.PROFILE_PATH);
     247                        FolderSettings.FrameDirs.get().add(FrameIO.FRAME_PRIVATE_PATH);
     248                        FolderSettings.FrameDirs.get().add(FrameIO.SHARED_FRAMESETS_PATH);
     249                        FolderSettings.FrameDirs.get().add(FrameIO.FRAME_PATH);
     250                        FolderSettings.FrameDirs.get().add(FrameIO.RESOURCES_PATH);
     251                        FolderSettings.FrameDirs.get().add(FrameIO.MESSAGES_PATH);
     252                        FolderSettings.FrameDirs.get().add(FrameIO.PUBLIC_PATH);
     253                        FolderSettings.FrameDirs.setDefault(FolderSettings.FrameDirs.get());
     254                                               
     255                        // ImageDirs
     256                        // 1. resources-<username>\images       Generated on user account creation and must be refreshed on user switching.
     257                        // 2. IMAGES_PATH                                       <expeditee-home>\resources-public\images
     258                        FolderSettings.ImageDirs.get().add(FrameIO.IMAGES_PRIVATE_PATH);
     259                        FolderSettings.ImageDirs.get().add(FrameIO.IMAGES_PATH);
     260                        FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
     261                } else {
     262                        FolderSettings.FrameDirs.get().add(FrameIO.FRAME_PATH);
     263                        FolderSettings.FrameDirs.get().add(FrameIO.PUBLIC_PATH);
     264                        FolderSettings.FrameDirs.get().add(FrameIO.PROFILE_PATH);
     265                        FolderSettings.FrameDirs.get().add(FrameIO.HELP_PATH);
     266                        FolderSettings.FrameDirs.get().add(FrameIO.MESSAGES_PATH);
     267                        FolderSettings.FrameDirs.setDefault(FolderSettings.FrameDirs.get());
     268                        FolderSettings.ImageDirs.get().add(FrameIO.IMAGES_PATH);
     269                        FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
     270                }
    271271        }
    272272
     
    291291                }
    292292        }
    293        
    294         private static void commitToSettingsFrameItem(Object value, String contentMatch) {
    295                 String profileName = UserSettings.UserName.get();
    296                 int lastNumber = FrameIO.getLastNumber(profileName);
    297                 for (int i = 1; i <= lastNumber; i++) {
    298                         Frame frame = FrameIO.LoadFrame(profileName + i);
    299                         if (frame != null) {
    300                                 Collection<Item> items = frame.getAllItems();
    301                                 boolean found = false;
    302                                 for (Item item: items) {
    303                                         if (item.getText().startsWith(contentMatch)) {
    304                                                 item.setText(contentMatch + " " + value);
    305                                         }
    306                                 }
    307                                 if (found) { break; }
    308                         }
    309                 }
    310         }
    311293}
  • trunk/src/org/expeditee/settings/audio/AudioSettings.java

    r1050 r1242  
    1919package org.expeditee.settings.audio;
    2020
    21 import org.expeditee.items.Text;
    22 import org.expeditee.setting.BooleanSetting;
    2321import org.expeditee.setting.IntegerSetting;
    24 import org.expeditee.setting.StringSetting;
    2522
    2623/**
     
    3229        public static final int PLAYBACK_CLOCK_RESOLUTION = 50;
    3330               
    34         public static final IntegerSetting PlaybackClockResolution = new IntegerSetting("Clock resolution (in milliseconds) for graphical updates when playing audio", 50);
     31        public static final IntegerSetting PlaybackClockResolution = new IntegerSetting("Clock resolution (in milliseconds) for graphical updates when playing audio", "PlaybackClockResolution", 50);
    3532
    3633}
  • trunk/src/org/expeditee/settings/experimental/ExperimentalFeatures.java

    r1051 r1242  
    2323public class ExperimentalFeatures {
    2424
    25         public static final BooleanSetting AutoWrap = new BooleanSetting("Enable auto wrapping of text", false);
     25        public static final BooleanSetting AutoWrap = new BooleanSetting("Enable auto wrapping of text", "AutoWrap", false);
    2626       
    27         public static final BooleanSetting FrameZoom = new BooleanSetting("Enable zooming in and out of frame using F1/F2 or else shift with click-wheel", false);
     27        public static final BooleanSetting FrameZoom = new BooleanSetting("Enable zooming in and out of frame using F1/F2 or else shift with click-wheel", "FrameZoom", false);
    2828       
    29         public static final BooleanSetting FrameZoomAroundCursor = new BooleanSetting("If true, Frame Zooming uses the location of the mouse cursor as the central point to zoom in/out.", false);
     29        public static final BooleanSetting FrameZoomAroundCursor = new BooleanSetting("If true, Frame Zooming uses the location of the mouse cursor as the central point to zoom in/out.", "FrameZoomAroundCursor", false);
    3030       
    31         public static final BooleanSetting MousePan = new BooleanSetting("Enable panning of the frame by shift-click and dragging the mouse", false);
     31        public static final BooleanSetting MousePan = new BooleanSetting("Enable panning of the frame by shift-click and dragging the mouse", "MousePan", false);
    3232       
    3333}
  • trunk/src/org/expeditee/settings/exploratorysearch/ExploratorySearchSettings.java

    r919 r1242  
    1919package org.expeditee.settings.exploratorysearch;
    2020
    21 import org.expeditee.items.Text;
    2221import org.expeditee.setting.BooleanSetting;
    2322import org.expeditee.setting.IntegerSetting;
    24 import org.expeditee.setting.StringSetting;
    2523
    2624/**
     
    3432        public static final int BROWSER_VERT_OFFSET = 50;
    3533       
    36         public static final BooleanSetting BrowserFullScreen = new BooleanSetting("Start Exploratory Search browser in fullscreen", true);
     34        public static final BooleanSetting BrowserFullScreen = new BooleanSetting("Start Exploratory Search browser in fullscreen", "BrowserFullScreen", true);
    3735       
    38         public static final IntegerSetting BrowserDefaultWidth = new IntegerSetting("Default Browser width", 800);
     36        public static final IntegerSetting BrowserDefaultWidth = new IntegerSetting("Default Browser width", "BrowserDefaultWidth", 800);
    3937       
    40         public static final IntegerSetting BrowserDefaultHeight = new IntegerSetting("Default Browser height", 600);
     38        public static final IntegerSetting BrowserDefaultHeight = new IntegerSetting("Default Browser height"," BrowserDefaultHeight",600);
    4139       
    42         public static final IntegerSetting BrowserLeftMargin = new IntegerSetting("Size of left hand margin for Browser", 0);
     40        public static final IntegerSetting BrowserLeftMargin = new IntegerSetting("Size of left hand margin for Browser","BrowserLeftMargin", 0);
    4341       
    44         public static final IntegerSetting BrowserRightMargin = new IntegerSetting("Size of right hand margin for Browser", 0);
     42        public static final IntegerSetting BrowserRightMargin = new IntegerSetting("Size of right hand margin for Browser", "BrowserRightMargin", 0);
    4543       
    46         public static final IntegerSetting BrowserTopMargin = new IntegerSetting("Size of Top margin for Browser", 0);
     44        public static final IntegerSetting BrowserTopMargin = new IntegerSetting("Size of Top margin for Browser", "BrowserTopMargin", 0);
    4745       
    48         public static final IntegerSetting BrowserBottomMargin = new IntegerSetting("Size of bottom margin for Browser", 0);
     46        public static final IntegerSetting BrowserBottomMargin = new IntegerSetting("Size of bottom margin for Browser", "BrowserBottomMargin", 0);
    4947}
  • trunk/src/org/expeditee/settings/folders/FolderSettings.java

    r919 r1242  
    2525import org.expeditee.setting.ListSetting;
    2626import org.expeditee.setting.Setting;
    27 import org.expeditee.settings.UserSettings;
    2827
    2928public class FolderSettings {
    3029
    31         public static final ListSetting<String> FrameDirs = new ListSetting<String>("Directories to look in for frames") {
     30        public static final ListSetting<String> FrameDirs = new ListSetting<String>("Directories to look in for frames", "FrameDirs") {
    3231                @Override
    3332                public boolean setSetting(Text text) {
     
    3635                }
    3736        };
    38         public static final Setting FramesetDir = new Setting("Adds a directory to look in for frames") {
     37        public static final Setting FramesetDir = new Setting("Adds a directory to look in for frames", "FramesetDir") {
    3938                @Override
    4039                public boolean setSetting(Text text) {
     
    5251                return false;
    5352                }
     53               
     54                @Override
     55                public Text generateRepresentation(String label, String frameset) {
     56                        Text t = new Text(label);
     57                        return t;
     58                }
    5459        };
    5560
    56         public static ListSetting<String> ImageDirs = new ListSetting<String>("Directories to look in for images") {
     61        public static ListSetting<String> ImageDirs = new ListSetting<String>("Directories to look in for images", "ImageDirs") {
    5762                @Override
    5863                public boolean setSetting(Text text) {
     
    6166                }
    6267        };
    63         public static final Setting ImageDir = new Setting("Adds a directory to look in for images") {
     68        public static final Setting ImageDir = new Setting("Adds a directory to look in for images", "ImageDir") {
    6469                @Override
    6570                public boolean setSetting(Text text) {
     
    7782                return false;
    7883                }
     84               
     85                @Override
     86                public Text generateRepresentation(String label, String frameset) {
     87                        Text t = new Text(label);
     88                        return t;
     89                }
    7990        };
    8091       
    81         public static final Setting LogDir = new Setting("Set the directory to save logs") {
     92        public static final Setting LogDir = new Setting("Set the directory to save logs", "LogDir") {
    8293                @Override
    8394                public boolean setSetting(Text text) {
     
    91102                return true;
    92103                }
     104               
     105                @Override
     106                public Text generateRepresentation(String label, String frameset) {
     107                        Text t = new Text(label);
     108                        return t;
     109                }
    93110        };
    94111}
  • trunk/src/org/expeditee/settings/legacy/LegacyFeatures.java

    r1195 r1242  
    44
    55public class LegacyFeatures {
    6         public static final BooleanSetting UseLegacyActionArgumentMapping = new BooleanSetting("Legacy action argument mapping does not allow for the possibility of actions being passed both floating content and the action item.", false);
     6        public static final BooleanSetting UseLegacyActionArgumentMapping =
     7                        new BooleanSetting("Legacy action argument mapping does not allow for the possibility of actions being passed both floating content and the action item.", "UseLegacyActionArgumentMapping", false);
    78}
  • trunk/src/org/expeditee/settings/network/NetworkSettings.java

    r919 r1242  
    3333        public static final StringSetting HomePage = new StringSetting("The home page for the JfxBrowser", "https://duckduckgo.com");
    3434       
    35         public static final IntegerSetting FrameShareTimeout = new IntegerSetting("Timeout for FrameShare socket, in milliseconds", 1000);
     35        public static final IntegerSetting FrameShareTimeout = new IntegerSetting("Timeout for FrameShare socket, in milliseconds", "FrameShareTimeout", 1000);
    3636       
    37         public static final FrameSetting FrameShare = new FrameSetting("Enable accessing remote frames") {
     37        public static final FrameSetting FrameShare = new FrameSetting("Enable accessing remote frames", "FrameShare") {
    3838                @Override
    3939                public void run(Frame frame) {
  • trunk/src/org/expeditee/settings/templates/TemplateSettings.java

    r1102 r1242  
    4242        };
    4343       
    44         public static final FrameSetting CursorFrame = new FrameSetting("Items on this frame will be used as the cursor (clearing the frame or removing the link will default back to a normal cursor)") {
     44        public static final FrameSetting CursorFrame = new FrameSetting("Items on this frame will be used as the cursor (clearing the frame or removing the link will default back to a normal cursor)", "CursorFrame") {
    4545                @Override
    4646                public void run(Frame frame) {
     
    5555       
    5656        public static final ArraySetting<Colour> ColorWheel = new ArraySetting<Colour>("The colours of items in the child frame are used to populate the colour wheel",
    57                         new Colour[] { Colour.BLACK, Colour.RED, Colour.BLUE, Item.GREEN, Colour.MAGENTA, Colour.YELLOW.darker(), Colour.WHITE }) {
     57                        "ColorWheel", new Colour[] { Colour.BLACK, Colour.RED, Colour.BLUE, Item.GREEN, Colour.MAGENTA, Colour.YELLOW.darker(), Colour.WHITE }) {
    5858                @Override
    5959                public boolean setSetting(Text text) {
     
    6868       
    6969        public static final ArraySetting<Colour> FillColorWheel = new ArraySetting<Colour>("The colours of items in the child frame are used to populate the colour wheel",
    70                         new Colour[] { Colour.FromRGB255(255, 150, 150), Colour.FromRGB255(150, 150, 255), Colour.FromRGB255(150, 255, 150),
     70                        "FillColorWheel", new Colour[] { Colour.FromRGB255(255, 150, 150), Colour.FromRGB255(150, 150, 255), Colour.FromRGB255(150, 255, 150),
    7171                        Colour.FromRGB255(255, 150, 255), Colour.FromRGB255(255, 255, 100), Colour.WHITE, Colour.BLACK }) {
    7272                @Override
     
    8282       
    8383        public static final ArraySetting<Colour> BackgroundColorWheel = new ArraySetting<Colour>("The colours of items in the child frame are used to populate the colour wheel",
     84                        "BackgroundColorWheel",
    8485                        new Colour[] { Colour.FromRGB255(235, 235, 235), Colour.FromRGB255(225, 225, 255), Colour.FromRGB255(195, 255, 255),
    8586                                        Colour.FromRGB255(225, 255, 225), Colour.FromRGB255(255, 255, 195), Colour.FromRGB255(255, 225, 225),
     
    9697        };
    9798       
    98         public static final TextSetting ItemTemplate = new TextSetting("Template for normal text items") {
     99        public static final TextSetting ItemTemplate = new TextSetting("Template for normal text items", "ItemTemplate") {
    99100                @Override
    100101                public Text generateText() {
     
    102103                }
    103104        };
    104         public static final TextSetting AnnotationTemplate = new TextSetting("Template for annotation text items") {
     105        public static final TextSetting AnnotationTemplate = new TextSetting("Template for annotation text items", "AnnotationTemplate") {
    105106                @Override
    106107                public Text generateText() {
     
    111112        };
    112113
    113         public static final TextSetting CommentTemplate = new TextSetting("Template for code comment text items") {
     114        public static final TextSetting CommentTemplate = new TextSetting("Template for code comment text items", "CommentTemplate") {
    114115                @Override
    115116                public Text generateText() {
     
    120121        };
    121122
    122         public static final TextSetting StatTemplate = new TextSetting("Template for statistics (e.g. extracted attributes) text items") {
     123        public static final TextSetting StatTemplate = new TextSetting("Template for statistics (e.g. extracted attributes) text items", "StatTemplate") {
    123124                @Override
    124125                public Text generateText() {
     
    132133        };
    133134       
    134         public static final TextSetting TitleTemplate = new TextSetting("Template for Title text item") {
     135        public static final TextSetting TitleTemplate = new TextSetting("Template for Title text item", "TitleTemplate") {
    135136                @Override
    136137                public Text generateText() {
     
    145146        };
    146147       
    147         public static final TextSetting DotTemplate = new TextSetting("Template for dot items") {
     148        public static final TextSetting DotTemplate = new TextSetting("Template for dot items", "DotTemplate") {
    148149                @Override
    149150                public Text generateText() {
     
    152153        };
    153154       
    154         public static final TextSetting TooltipTemplate = new TextSetting("Template for tooltips") {
     155        public static final TextSetting TooltipTemplate = new TextSetting("Template for tooltips", "TooltipTemplate") {
    155156                @Override
    156157                public Text generateText() {
Note: See TracChangeset for help on using the changeset viewer.