[919] | 1 | /**
|
---|
| 2 | * UserSettings.java
|
---|
| 3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
| 4 | *
|
---|
| 5 | * This program is free software: you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of the GNU General Public License as published by
|
---|
| 7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 8 | * (at your option) any later version.
|
---|
| 9 | *
|
---|
| 10 | * This program is distributed in the hope that it will be useful,
|
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | * GNU General Public License for more details.
|
---|
| 14 | *
|
---|
| 15 | * You should have received a copy of the GNU General Public License
|
---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | */
|
---|
| 18 |
|
---|
[570] | 19 | package org.expeditee.settings;
|
---|
[4] | 20 |
|
---|
| 21 | import java.io.File;
|
---|
[572] | 22 | import java.io.FileNotFoundException;
|
---|
| 23 | import java.io.IOException;
|
---|
[1242] | 24 | import java.nio.file.Paths;
|
---|
[572] | 25 | import java.util.ArrayList;
|
---|
[4] | 26 | import java.util.LinkedList;
|
---|
| 27 | import java.util.List;
|
---|
| 28 |
|
---|
[572] | 29 | import org.expeditee.agents.SearchGreenstone;
|
---|
| 30 | import org.expeditee.agents.mail.MailSession;
|
---|
| 31 | import org.expeditee.agents.wordprocessing.JSpellChecker;
|
---|
[1287] | 32 | import org.expeditee.auth.AuthenticatorBrowser;
|
---|
[571] | 33 | import org.expeditee.gui.Frame;
|
---|
[570] | 34 | import org.expeditee.gui.FrameIO;
|
---|
[571] | 35 | import org.expeditee.gui.FrameUtils;
|
---|
[572] | 36 | import org.expeditee.gui.MessageBay;
|
---|
[4] | 37 | import org.expeditee.items.Text;
|
---|
[666] | 38 | import org.expeditee.setting.BooleanSetting;
|
---|
| 39 | import org.expeditee.setting.FloatSetting;
|
---|
[655] | 40 | import org.expeditee.setting.FrameSetting;
|
---|
| 41 | import org.expeditee.setting.FunctionSetting;
|
---|
[666] | 42 | import org.expeditee.setting.IntegerSetting;
|
---|
[655] | 43 | import org.expeditee.setting.ListSetting;
|
---|
[666] | 44 | import org.expeditee.setting.StringSetting;
|
---|
[778] | 45 | import org.expeditee.settings.folders.FolderSettings;
|
---|
[4] | 46 |
|
---|
| 47 | /**
|
---|
| 48 | * Central class to contain all values that can be set by the user on their
|
---|
| 49 | * profile frame. These values should be updated only by
|
---|
| 50 | * FrameUtils.ParseProfile.
|
---|
| 51 | */
|
---|
| 52 | public abstract class UserSettings {
|
---|
[348] | 53 |
|
---|
[1213] | 54 | public static String DEFAULT_PROFILE_NAME = "default";
|
---|
[1242] | 55 |
|
---|
[1244] | 56 | public static Boolean PublicAndPrivateResources;
|
---|
[289] | 57 |
|
---|
[1242] | 58 | public static final IntegerSetting Gravity = new IntegerSetting("Distance the cursor has to be from a text item to select the text item", "Gravity", 3);
|
---|
[717] | 59 |
|
---|
[732] | 60 | public static final StringSetting StartFrame = new StringSetting("The frame to go to when Expeditee is started (defaults to the profile frame)", null);
|
---|
| 61 |
|
---|
[572] | 62 | /*
|
---|
[717] | 63 | * Stuff that goes first
|
---|
| 64 | */
|
---|
| 65 | public static final StringSetting HomeFrame = new StringSetting("The home frame", null) {
|
---|
| 66 | @Override
|
---|
| 67 | public boolean setSetting(Text text) {
|
---|
| 68 | if(text.getText().indexOf(':') == -1 || !text.hasLink()) {
|
---|
[1213] | 69 | text.setLink(UserSettings.ProfileName.get() + "1");
|
---|
| 70 | //text.setLink(FrameIO.LoadProfile(UserSettings.ProfileName.get()).getName());
|
---|
[717] | 71 | }
|
---|
| 72 | String first = FrameUtils.getLink(text, UserSettings.HomeFrame.get());
|
---|
[1244] | 73 | // do not use non-existent frames as the first frame
|
---|
[717] | 74 | if (FrameIO.isValidFrameName(first)) {
|
---|
| 75 | _value = first;
|
---|
| 76 | }
|
---|
| 77 | // warn the user
|
---|
| 78 | else {
|
---|
| 79 | // MessageBay.warningMessage("Home frame: " + first
|
---|
| 80 | // + " is not a valid frame.");
|
---|
| 81 | _value = FrameIO.LoadProfile(UserSettings.ProfileName.get()).getName();
|
---|
| 82 | }
|
---|
| 83 | return true;
|
---|
| 84 | }
|
---|
| 85 | };
|
---|
[1242] | 86 | public static final IntegerSetting InitialWidth = new IntegerSetting("Initial width of Expeditee window", "InitialWidth", 1024);
|
---|
[717] | 87 |
|
---|
[1242] | 88 | public static final IntegerSetting InitialHeight = new IntegerSetting("Initial height of Expeditee window", "InitialHeight", 768);
|
---|
[717] | 89 |
|
---|
| 90 | /*
|
---|
[572] | 91 | * General settings (no setter functions)
|
---|
| 92 | */
|
---|
[289] | 93 |
|
---|
[1242] | 94 | public static final FloatSetting ScaleFactor = new FloatSetting("Scale Factor for drawing (TODO: does this even do anything?)", "ScaleFactor", 1F);
|
---|
[655] | 95 |
|
---|
[1242] | 96 | public static final FloatSetting FormatSpacingMin = new FloatSetting("Minimum spacing ratio", "FormatSpacingMin", null);
|
---|
[655] | 97 |
|
---|
[1242] | 98 | public static final FloatSetting FormatSpacingMax = new FloatSetting("Maximum spacing ratio", "FormatSpacingMax", null);
|
---|
[4] | 99 |
|
---|
[1242] | 100 | public static final IntegerSetting LineStraightenThreshold = new IntegerSetting("Threshold for straightening a line (TODO: does this even do anything?)", "LineStraightenThreshold", 15);
|
---|
[4] | 101 |
|
---|
[1242] | 102 | 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);
|
---|
[74] | 103 |
|
---|
[1242] | 104 | 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);
|
---|
[1272] | 105 |
|
---|
| 106 | public static final StringSetting UserName = new StringSetting("Profile name", FrameIO.ConvertToValidFramesetName(System.getProperty("user.name")));
|
---|
[4] | 107 |
|
---|
[1272] | 108 | public static final StringSetting ProfileName = new StringSetting("Profile name", UserName.get());
|
---|
[1213] | 109 |
|
---|
[1242] | 110 | public static final BooleanSetting AntiAlias = new BooleanSetting("Whether anti-aliasing should be enabled", "AntiAlias", false);
|
---|
[572] | 111 |
|
---|
[1242] | 112 | public static final BooleanSetting LineHighlight = new BooleanSetting("Whether lines should be highlighted", "LineHighlight", false);
|
---|
[572] | 113 |
|
---|
[1242] | 114 | public static final BooleanSetting Logging = new BooleanSetting("Whether logging should be enabled", "Logging", false);
|
---|
[572] | 115 |
|
---|
[1242] | 116 | public static final BooleanSetting LogStats = new BooleanSetting("Whether stats should be logged", "LogStats", true);
|
---|
[572] | 117 |
|
---|
[1242] | 118 | public static final BooleanSetting Threading = new BooleanSetting("Whether threading should be enabled", "Threading", true);
|
---|
[1213] | 119 |
|
---|
[572] | 120 | /*
|
---|
| 121 | * Frames
|
---|
| 122 | */
|
---|
[666] | 123 | public static final StringSetting StatisticsFrameset = new StringSetting("The statistics frameset", null);
|
---|
[4] | 124 |
|
---|
[666] | 125 | public static final StringSetting MenuFrame = new StringSetting("The menu frame", null);
|
---|
[572] | 126 |
|
---|
| 127 | /*
|
---|
| 128 | * Other
|
---|
| 129 | */
|
---|
[1242] | 130 | public static final ListSetting<Text> Style = new ListSetting<Text>("Set the style (TODO: what does this do?)", "Style") {
|
---|
[655] | 131 | @Override
|
---|
| 132 | public boolean setSetting(Text text) {
|
---|
| 133 | Frame child = text.getChild();
|
---|
| 134 | if (child == null) {
|
---|
| 135 | _value = new LinkedList<Text>();
|
---|
| 136 | return true;
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | List<Text> style = new ArrayList<Text>(8);
|
---|
| 141 | for (int i = 0; i < 10; i++) {
|
---|
| 142 | style.add(null);
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | for (Text t : child.getBodyTextItems(false)) {
|
---|
| 146 | String type = t.getText();
|
---|
| 147 | char lastChar = type.charAt(type.length() - 1);
|
---|
| 148 | if (Character.isDigit(lastChar)) {
|
---|
| 149 | style.set(lastChar - '0', t);
|
---|
| 150 | } else {
|
---|
| 151 | style.set(0, t);
|
---|
| 152 | }
|
---|
| 153 | }
|
---|
| 154 | _value = style;
|
---|
| 155 | return true;
|
---|
[639] | 156 | }
|
---|
[655] | 157 | };
|
---|
[572] | 158 |
|
---|
[1242] | 159 | public static final FunctionSetting SpellChecker = new FunctionSetting("Enables the dictionary with the default dictionary", "SpellChecker") {
|
---|
[655] | 160 | @Override
|
---|
| 161 | public void run() {
|
---|
| 162 | try {
|
---|
[641] | 163 | JSpellChecker.create();
|
---|
| 164 | } catch (FileNotFoundException e) {
|
---|
[655] | 165 | MessageBay.errorMessage("Could not find dictionary: " + e.getMessage());
|
---|
[641] | 166 | } catch (IOException e) {
|
---|
| 167 | e.printStackTrace();
|
---|
| 168 | }
|
---|
[572] | 169 | }
|
---|
[655] | 170 | };
|
---|
[1242] | 171 | public static final FrameSetting Spelling = new FrameSetting("Enables the dictionary and adds the items in the child frame to the dictionary", "Spelling") {
|
---|
[655] | 172 | @Override
|
---|
| 173 | public void run(Frame frame) {
|
---|
| 174 | try {
|
---|
| 175 | JSpellChecker.create(frame);
|
---|
| 176 | } catch (Exception e) {
|
---|
| 177 | e.printStackTrace();
|
---|
| 178 | }
|
---|
[641] | 179 | }
|
---|
[655] | 180 | };
|
---|
[572] | 181 |
|
---|
[1242] | 182 | public static final FrameSetting GreenstoneSettings = new FrameSetting("Greenstone settings (TODO: What are these for?)", "GreenstoneSettings") {
|
---|
[655] | 183 | @Override
|
---|
| 184 | public void run(Frame frame) {
|
---|
| 185 | SearchGreenstone.init(frame);
|
---|
| 186 | }
|
---|
| 187 | };
|
---|
[572] | 188 |
|
---|
[1242] | 189 | public static final FrameSetting Reminders = new FrameSetting("Reminders (TODO: What are these for?)", "Reminders") {
|
---|
[655] | 190 | @Override
|
---|
| 191 | public void run(Frame frame) {
|
---|
| 192 | org.expeditee.gui.Reminders.init(frame);
|
---|
[642] | 193 | }
|
---|
[655] | 194 | };
|
---|
[572] | 195 |
|
---|
[1242] | 196 | public static final FrameSetting MailSettings = new FrameSetting("Mail Settings (TODO: How does this work?)", "MailSettings") {
|
---|
[655] | 197 | @Override
|
---|
| 198 | public void run(Frame frame) {
|
---|
| 199 | MailSession.init(frame);
|
---|
[642] | 200 | }
|
---|
[655] | 201 | };
|
---|
[761] | 202 |
|
---|
[4] | 203 | // add default values
|
---|
[355] | 204 | static {
|
---|
[1242] | 205 | // Are we in the new regime or the old regime?
|
---|
[1244] | 206 | File resFile = Paths.get(getExpediteeHome()).resolve(".res").toFile();
|
---|
| 207 | File resourcesPrivateFile = Paths.get(getExpediteeHome() + "resources-private" + File.separator).toFile();
|
---|
[1242] | 208 | if (resourcesPrivateFile.exists()) {
|
---|
[1244] | 209 | // If resources-private exists then this is a good sign we have new regime available.
|
---|
| 210 | PublicAndPrivateResources = Boolean.TRUE;
|
---|
[1330] | 211 | } else if (resFile.exists()) {
|
---|
[1242] | 212 | // If we do not, but do have the .res file then this is a good sign we are in old regime.
|
---|
[1244] | 213 | PublicAndPrivateResources = Boolean.FALSE;
|
---|
[1330] | 214 | } else {
|
---|
[1242] | 215 | // If we have neither then we are unpacking and therefore will have new regime available once unpacked.
|
---|
[1244] | 216 | PublicAndPrivateResources = Boolean.TRUE;
|
---|
[1242] | 217 | }
|
---|
| 218 |
|
---|
[946] | 219 | setupDefaultFolders();
|
---|
| 220 | }
|
---|
[1242] | 221 |
|
---|
[1244] | 222 | public static void setupDefaultFolders() {
|
---|
| 223 | String expeditee_home = getExpediteeHome();
|
---|
| 224 |
|
---|
| 225 | FrameIO.changeParentAndSubFolders(expeditee_home);
|
---|
| 226 |
|
---|
[946] | 227 | FolderSettings.FrameDirs.get().clear();
|
---|
| 228 | FolderSettings.ImageDirs.get().clear();
|
---|
[1244] | 229 | FolderSettings.AudioDirs.get().clear();
|
---|
[946] | 230 | appendDefaultFolders();
|
---|
[1244] | 231 |
|
---|
[946] | 232 | }
|
---|
| 233 |
|
---|
[1244] | 234 | private static String getExpediteeHome() {
|
---|
| 235 | String home_property = System.getProperty("expeditee.home");
|
---|
| 236 | String expeditee_home = (home_property != null) ? home_property + File.separator : getSaveLocation();
|
---|
[1242] | 237 | return expeditee_home;
|
---|
| 238 | }
|
---|
[1328] | 239 |
|
---|
[946] | 240 | public static void appendDefaultFolders() {
|
---|
[1328] | 241 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PUBLIC_PATH);
|
---|
| 242 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.TRASH_PATH);
|
---|
| 243 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PROFILE_PATH);
|
---|
| 244 |
|
---|
| 245 | if (PublicAndPrivateResources) {
|
---|
| 246 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.HELP_PATH);
|
---|
| 247 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.HELP_PRIVATE_PATH);
|
---|
| 248 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PATH);
|
---|
[1244] | 249 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PRIVATE_PATH);
|
---|
| 250 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MESSAGES_PATH);
|
---|
[1328] | 251 | if (AuthenticatorBrowser.isAuthenticated()) {
|
---|
| 252 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.SHARED_FRAMESETS_PATH);
|
---|
[1360] | 253 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MAIL_PATH);
|
---|
[1328] | 254 | }
|
---|
[1242] | 255 | FolderSettings.FrameDirs.setDefault(FolderSettings.FrameDirs.get());
|
---|
[1328] | 256 |
|
---|
| 257 | FolderSettings.ImageDirs.addAbsoluteDir(FrameIO.IMAGES_PATH);
|
---|
[1245] | 258 | FolderSettings.ImageDirs.addAbsoluteDir(FrameIO.IMAGES_PRIVATE_PATH);
|
---|
[1242] | 259 | FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
|
---|
[1244] | 260 |
|
---|
[1328] | 261 | FolderSettings.AudioDirs.addAbsoluteDir(FrameIO.AUDIO_PATH);
|
---|
[1245] | 262 | FolderSettings.AudioDirs.addAbsoluteDir(FrameIO.AUDIO_PRIVATE_PATH);
|
---|
[1244] | 263 | FolderSettings.AudioDirs.setDefault(FolderSettings.AudioDirs.get());
|
---|
[1242] | 264 | } else {
|
---|
[1328] | 265 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.HELP_PATH);
|
---|
[1244] | 266 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PATH);
|
---|
| 267 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MESSAGES_PATH);
|
---|
[1328] | 268 | if (AuthenticatorBrowser.isAuthenticated()) {
|
---|
| 269 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.SHARED_FRAMESETS_PATH);
|
---|
[1360] | 270 | FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MAIL_PATH);
|
---|
[1328] | 271 | }
|
---|
[1242] | 272 | FolderSettings.FrameDirs.setDefault(FolderSettings.FrameDirs.get());
|
---|
[1328] | 273 |
|
---|
[1245] | 274 | FolderSettings.ImageDirs.addAbsoluteDir(FrameIO.IMAGES_PATH);
|
---|
[1242] | 275 | FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
|
---|
[1244] | 276 |
|
---|
[1245] | 277 | FolderSettings.AudioDirs.addAbsoluteDir(FrameIO.AUDIO_PATH);
|
---|
[1244] | 278 | FolderSettings.AudioDirs.setDefault(FolderSettings.AudioDirs.get());
|
---|
[1242] | 279 | }
|
---|
[4] | 280 | }
|
---|
| 281 |
|
---|
[1328] | 282 | // public static void appendDefaultFolders() {
|
---|
| 283 | // if (PublicAndPrivateResources && AuthenticatorBrowser.isAuthenticated()) {
|
---|
| 284 | // // The comments here explain how things have changed with the new regime.
|
---|
| 285 | // // FrameDirs
|
---|
| 286 | // // 1. PROFILE_PATH Still points to same place.
|
---|
| 287 | // // 2. SHARED_FRAMESETS_PATH Still points to same place. (encryption stops just anyone reading it)
|
---|
| 288 | // // 3. framesets-<username> Generated on user account creation and must be refreshed on user switching. Also gives access to tutorial stuffs.
|
---|
| 289 | // // 4. FRAME_PATH <expeditee-home>\resources-public\framesets.
|
---|
| 290 | // // 5. HELP_PUBLIC_PATH <expeditee-home>\resources-public\documentation.
|
---|
| 291 | // // 6. MESSAGES_PATH Still points to same place. Should these be per user and encrypted?
|
---|
| 292 | // // 7. PUBLIC_PATH Still points to same place. Kept for compatibility.
|
---|
| 293 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PROFILE_PATH);
|
---|
| 294 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PRIVATE_PATH);
|
---|
| 295 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.SHARED_FRAMESETS_PATH);
|
---|
| 296 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PATH);
|
---|
| 297 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.RESOURCES_PATH);
|
---|
| 298 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MESSAGES_PATH);
|
---|
| 299 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PUBLIC_PATH);
|
---|
| 300 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.HELP_PRIVATE_PATH);
|
---|
| 301 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MAIL_PATH);
|
---|
| 302 | // FolderSettings.FrameDirs.setDefault(FolderSettings.FrameDirs.get());
|
---|
| 303 | //
|
---|
| 304 | // // ImageDirs
|
---|
| 305 | // // 1. resources-<username>\images Generated on user account creation and must be refreshed on user switching.
|
---|
| 306 | // // 2. IMAGES_PATH <expeditee-home>\resources-public\images
|
---|
| 307 | // FolderSettings.ImageDirs.addAbsoluteDir(FrameIO.IMAGES_PRIVATE_PATH);
|
---|
| 308 | // FolderSettings.ImageDirs.addAbsoluteDir(FrameIO.IMAGES_PATH);
|
---|
| 309 | // FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
|
---|
| 310 | //
|
---|
| 311 | // FolderSettings.AudioDirs.addAbsoluteDir(FrameIO.AUDIO_PRIVATE_PATH);
|
---|
| 312 | // FolderSettings.AudioDirs.addAbsoluteDir(FrameIO.AUDIO_PATH);
|
---|
| 313 | // FolderSettings.AudioDirs.setDefault(FolderSettings.AudioDirs.get());
|
---|
| 314 | // } else {
|
---|
| 315 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PATH);
|
---|
| 316 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PUBLIC_PATH);
|
---|
| 317 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.PROFILE_PATH);
|
---|
| 318 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.HELP_PATH);
|
---|
| 319 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.MESSAGES_PATH);
|
---|
| 320 | // if (FrameIO.FRAME_PRIVATE_PATH != null) {
|
---|
| 321 | // FolderSettings.FrameDirs.addAbsoluteDir(FrameIO.FRAME_PRIVATE_PATH);
|
---|
| 322 | // }
|
---|
| 323 | // FolderSettings.FrameDirs.setDefault(FolderSettings.FrameDirs.get());
|
---|
| 324 | //
|
---|
| 325 | // FolderSettings.ImageDirs.addAbsoluteDir(FrameIO.IMAGES_PATH);
|
---|
| 326 | // FolderSettings.ImageDirs.setDefault(FolderSettings.ImageDirs.get());
|
---|
| 327 | //
|
---|
| 328 | // FolderSettings.AudioDirs.addAbsoluteDir(FrameIO.AUDIO_PATH);
|
---|
| 329 | // FolderSettings.AudioDirs.setDefault(FolderSettings.AudioDirs.get());
|
---|
| 330 | // }
|
---|
| 331 | // }
|
---|
| 332 |
|
---|
[4] | 333 | /**
|
---|
[504] | 334 | * Find the appropriate directory to store application settings in for
|
---|
| 335 | * the current OS.
|
---|
| 336 | * This has only been tested on Linux so far, so if it doesn't work it
|
---|
| 337 | * may need to be modified or reverted. Should return:
|
---|
| 338 | * Linux: ~/.expeditee
|
---|
| 339 | * Windows: %appdata%\.expeditee
|
---|
| 340 | * Mac: ~/Library/Application\ Support/.expeditee
|
---|
| 341 | * @return the path to store expeditee's settings
|
---|
[4] | 342 | */
|
---|
[504] | 343 | public static String getSaveLocation() {
|
---|
| 344 | String OS=System.getProperty("os.name").toLowerCase();
|
---|
[768] | 345 | if(OS.indexOf("win")>=0) { //windoze
|
---|
[504] | 346 | return System.getenv("APPDATA")+File.separator+".expeditee"+File.separator;
|
---|
[768] | 347 | } else if(OS.indexOf("mac")>=0) { //mac
|
---|
[504] | 348 | return System.getProperty("user.home")+File.separator+"Library"+File.separator+"Application Support"+File.separator+".expeditee"+File.separator;
|
---|
| 349 | } else { //linux or other
|
---|
| 350 | return System.getProperty("user.home")+File.separator+".expeditee"+File.separator;
|
---|
[4] | 351 | }
|
---|
| 352 | }
|
---|
| 353 | }
|
---|