- Timestamp:
- 01/08/14 12:29:24 (10 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 5 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/setting/GenericSetting.java
r656 r666 12 12 * @param <T> type of the setting 13 13 */ 14 public class GenericSetting<T> extends VariableSetting {14 public abstract class GenericSetting<T> extends VariableSetting { 15 15 16 16 protected final Class<T> _type; 17 protected finalT _default;17 protected T _default; 18 18 protected T _value; 19 19 … … 31 31 _default = value; 32 32 _value = value; 33 _hasDefault = true;34 33 } 35 34 … … 39 38 public GenericSetting(Class<T> type, String tooltip) { 40 39 this(type, tooltip, (T) saneInitialValue(type)); 41 _hasDefault = false;42 40 } 43 41 … … 112 110 } 113 111 112 public void setDefault(T value) { 113 _default = value; 114 } 115 114 116 /** 115 117 * Reset the value back to the default, if a default value was specified 116 118 */ 117 119 public void reset() { 118 if(!_hasDefault) { 119 return; 120 } 121 if(_default instanceof Text) { 122 int id = ((Item) _value).getID(); 123 if(id < 0) { 124 if(((Item) _value).getParentOrCurrentFrame() != null) { 125 id = ((Item) _value).getParentOrCurrentFrame().getNextItemID(); 126 } else { 127 id = 0; 128 } 129 } 130 _value = (T) ((Text) _default).copy(); 131 ((Item) _value).setID(id); 132 } else { 133 _value = _default; 134 } 120 _value = _default; 135 121 } 136 122 -
trunk/src/org/expeditee/setting/ListSetting.java
r655 r666 8 8 public abstract class ListSetting<T> extends VariableSetting { 9 9 10 protected finalList<T> _default;10 protected List<T> _default; 11 11 protected List<T> _value; 12 12 … … 15 15 _default = new LinkedList<T>(value); 16 16 _value = value; 17 _hasDefault = true;18 17 } 19 18 20 19 public ListSetting(String tooltip) { 21 20 this(tooltip, new LinkedList<T>()); 22 _hasDefault = false;23 21 } 24 22 … … 33 31 public abstract boolean setSetting(Text text); 34 32 33 public void setDefault(List<T> value) { 34 _default = new LinkedList<T>(value); 35 } 36 35 37 public void reset() { 36 if(!_hasDefault) { 37 return; 38 } 39 _value = _default; 38 _value = new LinkedList<T>(_default); 40 39 } 41 40 -
trunk/src/org/expeditee/setting/VariableSetting.java
r655 r666 2 2 3 3 public abstract class VariableSetting extends Setting { 4 5 protected boolean _hasDefault;6 4 7 5 public VariableSetting(String tooltip) { … … 9 7 } 10 8 11 public boolean hasDefault() {12 return _hasDefault;13 }14 15 9 public abstract void reset(); 16 10 -
trunk/src/org/expeditee/settings/Settings.java
r658 r666 29 29 private final HashMap<String, Setting> settings = new HashMap<String, Setting>(); 30 30 private final List<String> orderedEntries = new LinkedList<String>(); 31 private final List<VariableSetting> hasDefault = new LinkedList<VariableSetting>();31 private final List<VariableSetting> settingsList = new LinkedList<VariableSetting>(); 32 32 private final Method onParsed; 33 33 … … 43 43 Setting s = (Setting) f.get(null); 44 44 settings.put(f.getName().toLowerCase(), s); 45 if(s instanceof VariableSetting && ((VariableSetting) s).hasDefault()) {46 hasDefault.add((VariableSetting) s);45 if(s instanceof VariableSetting) { 46 settingsList.add((VariableSetting) s); 47 47 } 48 48 orderedEntries.add(f.getName()); … … 108 108 return; 109 109 } 110 List<VariableSetting> toDefault = new LinkedList<VariableSetting>(pd. hasDefault);110 List<VariableSetting> toDefault = new LinkedList<VariableSetting>(pd.settingsList); 111 111 // set the fields 112 112 for (Text t : text.getChild().getBodyTextItems(true)) { -
trunk/src/org/expeditee/settings/UserSettings.java
r664 r666 22 22 import org.expeditee.items.ItemUtils; 23 23 import org.expeditee.items.Text; 24 import org.expeditee.setting.BooleanSetting; 25 import org.expeditee.setting.FloatSetting; 24 26 import org.expeditee.setting.FrameSetting; 25 27 import org.expeditee.setting.FunctionSetting; 26 import org.expeditee.setting. GenericSetting;28 import org.expeditee.setting.IntegerSetting; 27 29 import org.expeditee.setting.ListSetting; 28 30 import org.expeditee.setting.Setting; 31 import org.expeditee.setting.StringSetting; 32 import org.expeditee.setting.TextSetting; 29 33 30 34 /** … … 41 45 */ 42 46 43 public static final GenericSetting<Float> ScaleFactor = new GenericSetting<Float>(Float.class,"Scale Factor for drawing (TODO: does this even do anything?)", 1F);44 45 public static final GenericSetting<Float> FormatSpacingMin = new GenericSetting<Float>(Float.class,"Minimum spacing ratio", null);46 47 public static final GenericSetting<Float> FormatSpacingMax = new GenericSetting<Float>(Float.class,"Maximum spacing ratio", null);48 49 public static final GenericSetting<Integer> Gravity = new GenericSetting<Integer>(Integer.class,"Distance the cursor has to be from a text item to select the text item", 3);50 51 public static final GenericSetting<Integer> LineStraightenThreshold = new GenericSetting<Integer>(Integer.class,"Threshold for straightening a line (TODO: does this even do anything?)", 15);52 53 public static final GenericSetting<Integer> NoOpThreshold = new GenericSetting<Integer>(Integer.class,"Distance the cursor may be dragged while clicking before the operation is cancelled", 60);54 55 public static final GenericSetting<Integer> TitlePosition = new GenericSetting<Integer>(Integer.class,"Position of title item in frame (TODO: find whether this is x-offset or y-offset)", 150);56 57 public static final GenericSetting<Integer> InitialWidth = new GenericSetting<Integer>(Integer.class,"Initial width of Expeditee window", 1024);58 59 public static final GenericSetting<Integer> InitialHeight = new GenericSetting<Integer>(Integer.class,"Initial height of Expeditee window", 768);60 61 public static final GenericSetting<String> ProfileName = new GenericSetting<String>(String.class,"Profile name", FrameIO.ConvertToValidFramesetName(System.getProperty("user.name")));62 63 public static final GenericSetting<String> UserName = new GenericSetting<String>(String.class,"User name", ProfileName.get());64 65 public static final GenericSetting<Boolean> AntiAlias = new GenericSetting<Boolean>(Boolean.class,"Whether anti-aliasing should be enabled", false);66 67 public static final GenericSetting<Boolean> LineHighlight = new GenericSetting<Boolean>(Boolean.class,"Whether lines should be highlighted", false);68 69 public static final GenericSetting<Boolean> Logging = new GenericSetting<Boolean>(Boolean.class,"Whether logging should be enabled", false);70 71 public static final GenericSetting<Boolean> LogStats = new GenericSetting<Boolean>(Boolean.class,"Whether stats should be logged", true);72 73 public static final GenericSetting<Boolean> Threading = new GenericSetting<Boolean>(Boolean.class,"Whether threading should be enabled", true);47 public static final FloatSetting ScaleFactor = new FloatSetting("Scale Factor for drawing (TODO: does this even do anything?)", 1F); 48 49 public static final FloatSetting FormatSpacingMin = new FloatSetting("Minimum spacing ratio", null); 50 51 public static final FloatSetting FormatSpacingMax = new FloatSetting("Maximum spacing ratio", null); 52 53 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 final IntegerSetting LineStraightenThreshold = new IntegerSetting("Threshold for straightening a line (TODO: does this even do anything?)", 15); 56 57 public static final IntegerSetting NoOpThreshold = new IntegerSetting("Distance the cursor may be dragged while clicking before the operation is cancelled", 60); 58 59 public static final IntegerSetting TitlePosition = new IntegerSetting("Position of title item in frame (TODO: find whether this is x-offset or y-offset)", 150); 60 61 public static final IntegerSetting InitialWidth = new IntegerSetting("Initial width of Expeditee window", 1024); 62 63 public static final IntegerSetting InitialHeight = new IntegerSetting("Initial height of Expeditee window", 768); 64 65 public static final StringSetting ProfileName = new StringSetting("Profile name", FrameIO.ConvertToValidFramesetName(System.getProperty("user.name"))); 66 67 public static final StringSetting UserName = new StringSetting("User name", ProfileName.get()); 68 69 public static final BooleanSetting AntiAlias = new BooleanSetting("Whether anti-aliasing should be enabled", false); 70 71 public static final BooleanSetting LineHighlight = new BooleanSetting("Whether lines should be highlighted", false); 72 73 public static final BooleanSetting Logging = new BooleanSetting("Whether logging should be enabled", false); 74 75 public static final BooleanSetting LogStats = new BooleanSetting("Whether stats should be logged", true); 76 77 public static final BooleanSetting Threading = new BooleanSetting("Whether threading should be enabled", true); 74 78 75 79 … … 77 81 * Frames 78 82 */ 79 public static final GenericSetting<String> DefaultFrame = new GenericSetting<String>(String.class,"The default frame", null) {83 public static final StringSetting DefaultFrame = new StringSetting("The default frame", null) { 80 84 @Override 81 85 public boolean setSetting(Text text) { … … 85 89 }; 86 90 87 public static final GenericSetting<String> StatisticsFrameset = new GenericSetting<String>(String.class,"The statistics frameset", null);88 89 public static final GenericSetting<String> MenuFrame = new GenericSetting<String>(String.class,"The menu frame", null);90 91 public static final GenericSetting<String> HomeFrame = new GenericSetting<String>(String.class,"The home frame", null) {91 public static final StringSetting StatisticsFrameset = new StringSetting("The statistics frameset", null); 92 93 public static final StringSetting MenuFrame = new StringSetting("The menu frame", null); 94 95 public static final StringSetting HomeFrame = new StringSetting("The home frame", null) { 92 96 @Override 93 97 public boolean setSetting(Text text) { … … 180 184 * Templates 181 185 */ 182 public static final GenericSetting<Text> TitleTemplate = new GenericSetting<Text>(Text.class, "Template for Title text item"); 183 184 public static final GenericSetting<Text> ItemTemplate = new GenericSetting<Text>(Text.class, "Template for normal text items", new Text("@ItemTemplate")) { 185 @Override 186 public boolean setSetting(Text text) { 187 _value = text.getTemplateForm(); 188 return true; 189 } 190 }; 191 192 public static final GenericSetting<Text> DotTemplate = new GenericSetting<Text>(Text.class, "Template for dot items", new Text("@DotTemplate")) { 193 @Override 194 public boolean setSetting(Text text) { 195 _value = text.getTemplateForm(); 196 return true; 197 } 198 }; 199 200 private static final Text annotationTemplate() { 201 Text t = new Text("@AnnotationTemplate"); 202 t.setColor(Color.gray); 203 return t; 204 } 205 public static final GenericSetting<Text> AnnotationTemplate = new GenericSetting<Text>(Text.class, "Template for annotation text items", annotationTemplate()) { 206 @Override 207 public boolean setSetting(Text text) { 208 _value = text.getTemplateForm(); 209 return true; 210 } 211 }; 212 213 private static final Text codeCommentTemplate() { 214 Text t = new Text("@CommentTemplate"); 215 t.setColor(Color.green.darker()); 216 return t; 217 } 218 public static final GenericSetting<Text> CodeCommentTemplate = new GenericSetting<Text>(Text.class, "Template for code comment text items", codeCommentTemplate()) { 219 @Override 220 public boolean setSetting(Text text) { 221 _value = text.getTemplateForm(); 222 return true; 223 } 224 }; 225 226 private static final Text statTemplate() { 227 Text t = new Text("@StatsTemplate"); 228 t.setColor(Color.BLACK); 229 t.setBackgroundColor(new Color(0.9F, 0.9F, 0.9F)); 230 t.setFamily(Text.MONOSPACED_FONT); 231 t.setSize(14); 232 return t; 233 } 234 public static final GenericSetting<Text> StatTemplate = new GenericSetting<Text>(Text.class, "Template for statistics (e.g. extracted attributes) text items", statTemplate()) { 235 @Override 236 public boolean setSetting(Text text) { 237 _value = text.getTemplateForm(); 238 return true; 239 } 240 }; 241 242 private static final Text tooltipTemplate() { 243 Text t = new Text("@StatsTemplate"); 244 t.setColor(Color.BLACK); 245 t.setBackgroundColor(new Color(0.7F, 0.7F, 0.9F)); 246 // t.setFamily(Text.MONOSPACED_FONT); 247 t.setSize(14); 248 return t; 249 } 250 public static final GenericSetting<Text> TooltipTemplate = new GenericSetting<Text>(Text.class, "Template for tooltips", tooltipTemplate()) { 251 @Override 252 public boolean setSetting(Text text) { 253 _value = text.getTemplateForm(); 254 return true; 186 public static final TextSetting TitleTemplate = new TextSetting("Template for Title text item") { 187 @Override 188 public Text generateText() { 189 return null; 190 } 191 }; 192 193 public static final TextSetting ItemTemplate = new TextSetting("Template for normal text items") { 194 @Override 195 public boolean setSetting(Text text) { 196 _value = text.getTemplateForm(); 197 return true; 198 } 199 200 @Override 201 public Text generateText() { 202 return new Text("@ItemTemplate"); 203 } 204 }; 205 206 public static final TextSetting DotTemplate = new TextSetting("Template for dot items") { 207 @Override 208 public boolean setSetting(Text text) { 209 _value = text.getTemplateForm(); 210 return true; 211 } 212 213 @Override 214 public Text generateText() { 215 return new Text("@DotTemplate"); 216 } 217 }; 218 219 public static final TextSetting AnnotationTemplate = new TextSetting("Template for annotation text items") { 220 @Override 221 public boolean setSetting(Text text) { 222 _value = text.getTemplateForm(); 223 return true; 224 } 225 @Override 226 public Text generateText() { 227 Text t = new Text("@AnnotationTemplate"); 228 t.setColor(Color.gray); 229 return t; 230 } 231 }; 232 233 public static final TextSetting CodeCommentTemplate = new TextSetting("Template for code comment text items") { 234 @Override 235 public boolean setSetting(Text text) { 236 _value = text.getTemplateForm(); 237 return true; 238 } 239 @Override 240 public Text generateText() { 241 Text t = new Text("@CommentTemplate"); 242 t.setColor(Color.green.darker()); 243 return t; 244 } 245 }; 246 247 public static final TextSetting StatTemplate = new TextSetting("Template for statistics (e.g. extracted attributes) text items") { 248 @Override 249 public boolean setSetting(Text text) { 250 _value = text.getTemplateForm(); 251 return true; 252 } 253 @Override 254 public Text generateText() { 255 Text t = new Text("@StatsTemplate"); 256 t.setColor(Color.BLACK); 257 t.setBackgroundColor(new Color(0.9F, 0.9F, 0.9F)); 258 t.setFamily(Text.MONOSPACED_FONT); 259 t.setSize(14); 260 return t; 261 } 262 }; 263 264 public static final TextSetting TooltipTemplate = new TextSetting("Template for tooltips") { 265 @Override 266 public boolean setSetting(Text text) { 267 _value = text.getTemplateForm(); 268 return true; 269 } 270 @Override 271 public Text generateText() { 272 Text t = new Text("@StatsTemplate"); 273 t.setColor(Color.BLACK); 274 t.setBackgroundColor(new Color(0.7F, 0.7F, 0.9F)); 275 // t.setFamily(Text.MONOSPACED_FONT); 276 t.setSize(14); 277 return t; 255 278 } 256 279 }; … … 382 405 UserSettings.FrameDirs.get().add(FrameIO.PROFILE_PATH); 383 406 UserSettings.FrameDirs.get().add(FrameIO.HELP_PATH); 407 UserSettings.FrameDirs.get().add(FrameIO.MESSAGES_PATH); 408 UserSettings.FrameDirs.setDefault(UserSettings.FrameDirs.get()); 384 409 UserSettings.ImageDirs.get().add(FrameIO.IMAGES_PATH); 385 UserSettings. FrameDirs.get().add(FrameIO.MESSAGES_PATH);410 UserSettings.ImageDirs.setDefault(UserSettings.ImageDirs.get()); 386 411 } 387 412 -
trunk/src/org/expeditee/settings/experimental/ExperimentalFeatures.java
r655 r666 1 1 package org.expeditee.settings.experimental; 2 2 3 import org.expeditee.setting. GenericSetting;3 import org.expeditee.setting.BooleanSetting; 4 4 5 5 public class ExperimentalFeatures { 6 6 7 public static final GenericSetting<Boolean> AutoWrap = new GenericSetting<Boolean>(Boolean.class,"Enable auto wrapping of text", false);7 public static final BooleanSetting AutoWrap = new BooleanSetting("Enable auto wrapping of text", false); 8 8 9 public static final GenericSetting<Boolean> MousePan = new GenericSetting<Boolean>(Boolean.class,"Enable panning of the frame by shift-click and dragging the mouse", false);9 public static final BooleanSetting MousePan = new BooleanSetting("Enable panning of the frame by shift-click and dragging the mouse", false); 10 10 11 11 } -
trunk/src/org/expeditee/settings/network/NetworkSettings.java
r655 r666 4 4 import org.expeditee.gui.Frame; 5 5 import org.expeditee.items.Text; 6 import org.expeditee.network.FrameShare;7 6 import org.expeditee.setting.FrameSetting; 8 import org.expeditee.setting. GenericSetting;7 import org.expeditee.setting.StringSetting; 9 8 10 9 public abstract class NetworkSettings { 11 10 12 11 // The URL to prepend to web searches 13 public static final GenericSetting<String> SearchEngine = new GenericSetting<String>(String.class,"The search engine for the JfxBrowser", "https://duckduckgo.com/?q=");12 public static final StringSetting SearchEngine = new StringSetting("The search engine for the JfxBrowser", "https://duckduckgo.com/?q="); 14 13 15 public static final GenericSetting<String> HomePage = new GenericSetting<String>(String.class,"The home page for the JfxBrowser", "https://duckduckgo.com");14 public static final StringSetting HomePage = new StringSetting("The home page for the JfxBrowser", "https://duckduckgo.com"); 16 15 17 16 public static final FrameSetting FrameShare = new FrameSetting("Enable accessing remote frames") { -
trunk/src/org/expeditee/settings/network/proxy/ProxySettings.java
r655 r666 9 9 import org.expeditee.items.widgets.WidgetCorner; 10 10 import org.expeditee.items.widgets.WidgetEdge; 11 import org.expeditee.setting. GenericSetting;11 import org.expeditee.setting.StringSetting; 12 12 13 13 public abstract class ProxySettings { 14 14 15 public static final GenericSetting<String> Host = new GenericSetting<String>(String.class,"The host for the proxy", null);16 public static final GenericSetting<String> Port = new GenericSetting<String>(String.class,"The port for the proxy (e.g. port 80)", "80");17 public static final GenericSetting<String> User = new GenericSetting<String>(String.class,"Your username for the proxy", null);18 public static final GenericSetting<String> Pass = new GenericSetting<String>(String.class,"Your password for the proxy", null);15 public static final StringSetting Host = new StringSetting("The host for the proxy", null); 16 public static final StringSetting Port = new StringSetting("The port for the proxy (e.g. port 80)", "80"); 17 public static final StringSetting User = new StringSetting("Your username for the proxy", null); 18 public static final StringSetting Pass = new StringSetting("Your password for the proxy", null); 19 19 20 20 public static void onParsed(Text text) {
Note:
See TracChangeset
for help on using the changeset viewer.