Changeset 1244 for trunk/src/org/expeditee/gui
- Timestamp:
- 03/17/19 22:29:23 (5 years ago)
- Location:
- trunk/src/org/expeditee/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/Browser.java
r1242 r1244 22 22 import java.io.IOException; 23 23 import java.net.Authenticator; 24 import java.nio.file.Path; 24 25 import java.security.KeyStoreException; 25 26 import java.security.NoSuchAlgorithmException; … … 148 149 public static boolean _hasExited = false; 149 150 151 public static String USER_NOBODY = "nobody"; 152 150 153 /** A flag which is set once the application is exiting. */ 151 154 protected boolean _isExiting = false; … … 154 157 155 158 private static String _startFrame = null; 159 156 160 157 161 /** … … 162 166 public static void main(String[] args) 163 167 { 168 if (Boolean.getBoolean("auth")) { 169 String starting_user_name = System.getProperty("user.name"); 170 System.setProperty("startinguser.name", starting_user_name); 171 System.setProperty("user.name", USER_NOBODY); 172 } 173 164 174 // Parse the starting frame command-line argument 165 175 if(args.length > 0) { … … 261 271 Frame userProfile = loadProfiles(); 262 272 273 if (!Boolean.getBoolean("auth")) { 274 String userName = UserSettings.ProfileName.get(); 275 FrameIO.setupPersonalResources(userName); 276 } 263 277 // Listen for save status to display during and after runtime 264 278 EntitySaveManager.getInstance().addSaveStateChangedEventListener(this); -
trunk/src/org/expeditee/gui/DisplayController.java
r1216 r1244 68 68 RIGHT 69 69 } 70 70 71 // To help title calculations on frame 72 public static final int MINIMUM_FRAME_WIDTH = 512; 73 71 74 /** Convenience definition of TwinFramesSide.LEFT. */ 72 75 public static final TwinFramesSide LEFT = TwinFramesSide.LEFT; -
trunk/src/org/expeditee/gui/FrameIO.java
r1242 r1244 33 33 import java.io.Writer; 34 34 import java.nio.channels.FileChannel; 35 import java.nio.file.Files; 36 import java.nio.file.Path; 35 37 import java.nio.file.Paths; 36 38 import java.sql.Time; … … 43 45 import java.util.stream.Collectors; 44 46 47 import org.apollo.gui.IChangeParentAndSubFolders; 48 import org.apollo.io.AudioPathManager; 45 49 import org.expeditee.actions.Actions; 46 50 import org.expeditee.agents.ExistingFramesetException; … … 81 85 * 82 86 */ 87 88 83 89 public class FrameIO { 84 90 85 91 private static final char FRAME_NAME_LAST_CHAR = 'A'; 86 87 public static void changeParentFolder(String newFolder) {88 // Partial Paths.89 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.94 PUBLIC_PATH = PARENT_FOLDER + "public" + File.separator;95 MESSAGES_PATH = PARENT_FOLDER + "messages" + File.separator;96 TRASH_PATH = PARENT_FOLDER + "trash" + File.separator;97 HELP_PATH = PARENT_FOLDER + "documentation" + File.separator;98 PROFILE_PATH = PARENT_FOLDER + "profiles" + File.separator;99 EXPORTS_DIR = PARENT_FOLDER + "exports" + File.separator;100 STATISTICS_DIR = PARENT_FOLDER + "statistics" + File.separator;101 LOGS_DIR = PARENT_FOLDER + "logs" + File.separator;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 paths122 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 92 135 93 // The parent path that all others are relative to. Also referred to as Expeditee Home. … … 142 100 public static String MESSAGES_PATH; 143 101 public static String IMAGES_PATH; 102 public static String AUDIO_PATH; 144 103 public static String PUBLIC_PATH; 145 104 public static String TRASH_PATH; … … 159 118 public static String FRAME_PRIVATE_PATH; 160 119 public static String IMAGES_PRIVATE_PATH; 120 public static String AUDIO_PRIVATE_PATH; 161 121 162 122 // Paths used only by old regime. … … 175 135 176 136 private static final String INF_FILENAME = "frame.inf"; 137 138 public static void changeParentAndSubFolders(String newFolder) { 139 // Partial Paths. 140 PARENT_FOLDER = newFolder; 141 142 String resourcesPublicPath = PARENT_FOLDER + "resources-public" + File.separator; 143 144 // Standard paths. 145 PUBLIC_PATH = PARENT_FOLDER + "public" + File.separator; 146 MESSAGES_PATH = PARENT_FOLDER + "messages" + File.separator; 147 TRASH_PATH = PARENT_FOLDER + "trash" + File.separator; 148 HELP_PATH = PARENT_FOLDER + "documentation" + File.separator; 149 PROFILE_PATH = PARENT_FOLDER + "profiles" + File.separator; 150 EXPORTS_DIR = PARENT_FOLDER + "exports" + File.separator; 151 STATISTICS_DIR = PARENT_FOLDER + "statistics" + File.separator; 152 LOGS_DIR = PARENT_FOLDER + "logs" + File.separator; 153 154 155 // Conditional paths 156 if (UserSettings.PublicAndPrivateResources) { 157 // Work with a system of public and private folders 158 159 FONT_PATH = resourcesPublicPath + "fonts" + File.separator; 160 DICT_PATH = resourcesPublicPath + "dict" + File.separator; 161 IMAGES_PATH = resourcesPublicPath + "images" + File.separator; 162 AUDIO_PATH = resourcesPublicPath + "audio" + File.separator; 163 FRAME_PATH = resourcesPublicPath + "framesets" + File.separator; 164 } 165 else { 166 FONT_PATH = PARENT_FOLDER + "fonts" + File.separator; 167 DICT_PATH = PARENT_FOLDER + "dict" + File.separator; 168 IMAGES_PATH = PARENT_FOLDER + "images" + File.separator; 169 AUDIO_PATH = PARENT_FOLDER + "audio" + File.separator; 170 FRAME_PATH = PARENT_FOLDER + "framesets" + File.separator; 171 } 172 173 if (!UserSettings.PublicAndPrivateResources || System.getProperty("user.name").equals(Browser.USER_NOBODY)) { 174 175 if (System.getProperty("user.name").equals(Browser.USER_NOBODY)) { 176 System.err.println("**** FrameIO::changeParentAndSubFolders(): Not setting subfolders for user '"+Browser.USER_NOBODY+"'"); 177 } 178 179 // If we are using the old regime, or user.name set to Browser.USER_NOBODY 180 // => then these paths should not be used. 181 RESOURCES_PATH = null; 182 SHARED_FRAMESETS_PATH = null; 183 RESOURCES_PRIVATE = null; 184 FRAME_PRIVATE_PATH = null; 185 IMAGES_PRIVATE_PATH = null; 186 AUDIO_PRIVATE_PATH = null; 187 CONTACTS_PATH = null; 188 } 189 else { 190 String resourcesPrivateIndividualPath = PARENT_FOLDER + "resources-" + UserSettings.UserName.get() + File.separator; 191 192 RESOURCES_PATH = resourcesPublicPath + "documentation" + File.separator; 193 SHARED_FRAMESETS_PATH = resourcesPrivateIndividualPath + "framesets-shared" + File.separator; 194 195 RESOURCES_PRIVATE = PARENT_FOLDER + "resources-private" + File.separator; 196 FRAME_PRIVATE_PATH = resourcesPrivateIndividualPath + "framesets" + File.separator; 197 IMAGES_PRIVATE_PATH = resourcesPrivateIndividualPath + "images" + File.separator; 198 AUDIO_PRIVATE_PATH = resourcesPrivateIndividualPath + "audio" + File.separator; 199 CONTACTS_PATH = resourcesPrivateIndividualPath + "contacts" + File.separator; 200 } 201 202 203 System.err.println("**** FrameIO::changeParentAndSubFolder(): Calling AudioPathManger.changeParentAndSubFolder()"); 204 AudioPathManager.changeParentAndSubFolders(newFolder); 205 } 177 206 178 207 // All methods are static, this should not be instantiated … … 341 370 loaded = LoadKnownPath(knownPath, framename); 342 371 } else { 343 List<String> directoriesToSearch = FolderSettings.FrameDirs.get ();372 List<String> directoriesToSearch = FolderSettings.FrameDirs.getAbsoluteDirs(); 344 373 345 374 if (Authenticator.Authenticated) { … … 378 407 StringBuffer list = new StringBuffer(); 379 408 380 for (String path : FolderSettings.FrameDirs.get ()) {409 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 381 410 File files = new File(path); 382 411 if (!files.exists()) { … … 466 495 } 467 496 468 for (String path : FolderSettings.FrameDirs.get ()) {497 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 469 498 if (getFrameFullPathName(path, frameName) != null) { 470 499 return true; … … 478 507 String fullPath = null; 479 508 if (path == null) { 480 for (String possiblePath : FolderSettings.FrameDirs.get ()) {509 for (String possiblePath : FolderSettings.FrameDirs.getAbsoluteDirs()) { 481 510 fullPath = getFrameFullPathName(possiblePath, frameName); 482 511 if (fullPath != null) { … … 879 908 if (!DisplayController.isTwinFramesOn() && !Justification.center.equals(((Text)titleItem).getJustification())) { 880 909 if ((titleItem.getX() + 1) < template.getNameItem().getX()) { 881 while (titleItem.getSize() > Text.MINIMUM_FONT_SIZE 882 && titleItem.getBoundsWidth() + titleItem.getX() > template 883 .getNameItem().getX()) { 910 int title_item_xr = titleItem.getX() + titleItem.getBoundsWidth(); // should really be '... -1' 911 int frame_name_xl = template.getNameItem().getX(); 912 if (frame_name_xl < DisplayController.MINIMUM_FRAME_WIDTH) { 913 frame_name_xl = DisplayController.MINIMUM_FRAME_WIDTH; 914 } 915 916 while ((titleItem.getSize() > Text.MINIMUM_FONT_SIZE) && title_item_xr > frame_name_xl) { 884 917 titleItem.setSize(titleItem.getSize() - 1); 918 System.err.println("**** shrunk titleItem: " + titleItem + " to font size: " + titleItem.getSize()); 885 919 } 886 920 } else { … … 1544 1578 public static Boolean canAccessFrameset(String framesetName) { 1545 1579 framesetName = framesetName.toLowerCase(); 1546 for (String path : FolderSettings.FrameDirs.get ()) {1580 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 1547 1581 if ((new File(path + framesetName)).exists()) { 1548 1582 return true; … … 1685 1719 1686 1720 // Search all the available directories for the directory 1687 for (String path : FolderSettings.FrameDirs.get ()) {1721 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 1688 1722 String source = path + framesetName.toLowerCase() + File.separator; 1689 1723 File framesetDirectory = new File(source); … … 1730 1764 // search through all the directories to find the frameset we are 1731 1765 // copying 1732 for (String path : FolderSettings.FrameDirs.get ()) {1766 for (String path : FolderSettings.FrameDirs.getAbsoluteDirs()) { 1733 1767 String source = path + framesetToCopy.toLowerCase() 1734 1768 + File.separator; … … 1890 1924 toSave.setActiveTime(activeTime); 1891 1925 } 1926 1927 public static Path setupPersonalResources(String username) 1928 { 1929 Path personalResources = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-" + username); 1930 personalResources.toFile().mkdir(); 1931 File[] globalResourcesToCopy = Paths.get(FrameIO.RESOURCES_PRIVATE).toFile().listFiles(); 1932 1933 try { 1934 for (File toCopy: globalResourcesToCopy) { 1935 Path p = Paths.get(toCopy.getAbsolutePath()); 1936 if (!p.getFileName().toString().equals(".res") && !p.getFileName().toString().equals("about")) { 1937 copyFileTree(p.toAbsolutePath(), personalResources.resolve(p.getFileName())); 1938 } 1939 } 1940 } 1941 catch (IOException e) { 1942 e.printStackTrace(); 1943 personalResources = null; 1944 } 1945 1946 return personalResources; 1947 } 1948 1949 private static void copyFileTree(Path source, Path target) throws IOException { 1950 Files.copy(source, target); 1951 if (source.toFile().isDirectory()) { 1952 File[] files = source.toFile().listFiles(); 1953 for (File file: files) { 1954 Path asPath = Paths.get(file.getAbsolutePath()); 1955 copyFileTree(asPath, target.resolve(asPath.getFileName())); 1956 } 1957 } 1958 } 1892 1959 } -
trunk/src/org/expeditee/gui/FrameUtils.java
r1242 r1244 1090 1090 Logger.Log(e); 1091 1091 e.printStackTrace(); 1092 MessageBay.warningMessage("Exception occured when loading " + i.getClass().getSimpleName() + "(ID: " 1093 + i.getID() + ") " + e.getMessage() != null ? e.getMessage() : ""); 1092 System.err.println("**** Have temporarily supressed MessageBay call, as resulted in infinite recursion"); 1093 //MessageBay.warningMessage("Exception occured when loading " + i.getClass().getSimpleName() + "(ID: " 1094 // + i.getID() + ") " + e.getMessage() != null ? e.getMessage() : ""); 1094 1095 } 1095 1096 } … … 1820 1821 */ 1821 1822 public static void extractResources(boolean force) { 1822 // Extract private resources1823 Path resourcesPrivate = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-private");1824 extractResources("org/expeditee/assets/resources-private", resourcesPrivate, force);1825 1823 1826 // Extract public resources 1827 Path resourcesPublic = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-public"); 1828 extractResources("org/expeditee/assets/resources-public", resourcesPublic, force); 1824 if (UserSettings.PublicAndPrivateResources) { 1825 // Extract private resources 1826 Path resourcesPrivate = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-private"); 1827 extractResources("org/expeditee/assets/resources-private", resourcesPrivate, force); 1828 1829 // Extract public resources 1830 Path resourcesPublic = Paths.get(FrameIO.PARENT_FOLDER).resolve("resources-public"); 1831 extractResources("org/expeditee/assets/resources-public", resourcesPublic, force); 1832 } 1829 1833 } 1830 1834
Note:
See TracChangeset
for help on using the changeset viewer.