source: trunk/src/org/expeditee/setting/FunctionSetting.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: 663 bytes
Line 
1package org.expeditee.setting;
2
3import org.expeditee.gui.AttributeValuePair;
4import org.expeditee.items.Text;
5
6public abstract class FunctionSetting extends Setting {
7
8 public FunctionSetting(String tooltip) {
9 super(tooltip);
10 }
11
12 /**
13 * The code to run
14 * Must be overridden
15 */
16 protected abstract void run();
17
18 /**
19 * runs the setting specific code if the text item has a value of true
20 */
21 public boolean setSetting(Text text) {
22 AttributeValuePair avp = new AttributeValuePair(text.getText(), false);
23 if(avp.getValue() != null && avp.getValue().trim().length() != 0 && avp.getBooleanValue()) {
24 run();
25 return true;
26 }
27 return false;
28 }
29}
Note: See TracBrowser for help on using the repository browser.