source: trunk/src/org/expeditee/gui/UserSettings.java@ 247

Last change on this file since 247 was 247, checked in by ra33, 16 years ago

Added more import and mail stuff... including text importer

File size: 3.0 KB
Line 
1package org.expeditee.gui;
2
3import java.io.File;
4import java.net.URL;
5import java.util.LinkedList;
6import java.util.List;
7
8import org.expeditee.items.Text;
9
10/**
11 * Central class to contain all values that can be set by the user on their
12 * profile frame. These values should be updated only by
13 * FrameUtils.ParseProfile.
14 */
15public abstract class UserSettings {
16
17 public static int Gravity = 3;
18
19 public static int LineStraightenThreshold = 15;
20
21 public static int NoOpThreshold = 60;
22
23 public static int TitlePosition = 150;
24
25 public static int InitialWidth = 1024;
26
27 public static int InitialHeight = 768;
28
29 public static String Username;
30
31 public static String DefaultFrame = null;
32
33 public static String MenuFrame = null;
34
35 public static String FirstFrame = null;
36
37 public static List<String> FrameDirs = new LinkedList<String>();
38
39 public static List<String> ImageDirs = new LinkedList<String>();
40
41 public static boolean AntiAlias = false;
42
43 public static boolean LineHighlight = false;
44
45 public static boolean Logging = false;
46
47 public static boolean LogStats = true;
48
49 public static boolean Threading = true;
50
51 public static Text ItemTemplate = new Text("@ItemTemplate");
52
53 public static Text DotTemplate = new Text("@DotTemplate");
54
55 public static Text AnnotationTemplate = null;
56
57 public static Text CodeCommentTemplate = null;
58
59 public static Text TitleTemplate = null;
60
61 public static Text StatTemplate = null;
62
63 // add default values
64 public static void Init() {
65 String jarPath = getJarLocation();
66 if (jarPath != null)
67 FrameIO.changeParentFolder(jarPath);
68 else
69 FrameIO.changeParentFolder("." + File.separator + "expeditee"
70 + File.separator);
71
72 UserSettings.FrameDirs.add(FrameIO.FRAME_PATH);
73 UserSettings.FrameDirs.add(FrameIO.PROFILE_PATH);
74 UserSettings.FrameDirs.add(FrameIO.HELP_PATH);
75 UserSettings.ImageDirs.add(FrameIO.IMAGES_PATH);
76 }
77
78 /**
79 * Find where abouts the Jar is located that is running expeditee. The
80 * reason for this was so that the framesets could be stored in the same
81 * location as the jar file for now. Using the current directory fails to
82 * achieve this as the current directory not the same as the directory the
83 * jar is stored in if the user double clicks on the jar file in Linux or
84 * runs the jar from the command line from another directory.
85 *
86 * @return
87 */
88 public static String getJarLocation() {
89 // Get a File object for the package
90 File directory = null;
91
92 ClassLoader cld = Thread.currentThread().getContextClassLoader();
93 URL resource = cld.getResource("org");
94 directory = new File(resource.getFile());
95
96 int splitPoint = directory.getPath().indexOf('!');
97 if (splitPoint > 0) {
98 String jarName = directory.getPath().substring("file:".length(),
99 splitPoint);
100 // Windows HACK
101 if (jarName.indexOf(":") >= 0)
102 jarName = jarName.substring(1);
103
104 if (jarName.indexOf("%20") > 0) {
105 jarName = jarName.replace("%20", " ");
106 }
107
108 int lastFileSeparator = jarName.lastIndexOf(File.separator);
109 return jarName.substring(0, lastFileSeparator + 1);
110 }
111 return null;
112 }
113}
Note: See TracBrowser for help on using the repository browser.