source: trunk/src/org/expeditee/setting/ListSetting.java@ 655

Last change on this file since 655 was 655, checked in by jts21, 10 years ago

Switch to using specialised objects for settings so they make more a bit more sense (now each setting is a single object instead of multiple, and setter functions and default values are less hackish)
Also added tooltips (help strings) to settings, will need to add a way of displaying these (maybe add the idea of a tooltip which is a text item which only appears when hovering over another item?)
Converted all settings over to new format, everything seems to be working fine

File size: 745 bytes
Line 
1package org.expeditee.setting;
2
3import java.util.LinkedList;
4import java.util.List;
5
6import org.expeditee.items.Text;
7
8public abstract class ListSetting<T> extends VariableSetting {
9
10 protected final List<T> _default;
11 protected List<T> _value;
12
13 public ListSetting(String tooltip, List<T> value) {
14 super(tooltip);
15 _default = new LinkedList<T>(value);
16 _value = value;
17 _hasDefault = true;
18 }
19
20 public ListSetting(String tooltip) {
21 this(tooltip, new LinkedList<T>());
22 _hasDefault = false;
23 }
24
25 public List<T> get() {
26 return _value;
27 }
28
29 public void set(List<T> value) {
30 _value = value;
31 }
32
33 public abstract boolean setSetting(Text text);
34
35 public void reset() {
36 if(!_hasDefault) {
37 return;
38 }
39 _value = _default;
40 }
41
42}
Note: See TracBrowser for help on using the repository browser.