source: src/main/java/genius/gui/panels/TextModel.java@ 346

Last change on this file since 346 was 1, checked in by Wouter Pasman, 6 years ago

Initial import : Genius 9.0.0

File size: 673 bytes
Line 
1package genius.gui.panels;
2
3import genius.core.listener.DefaultListenable;
4import genius.core.misc.StringUtils;
5
6/**
7 * Model behind a text field. Listeners receive the new string value as object.
8 *
9 */
10public class TextModel extends DefaultListenable<String> {
11 private String text;
12
13 public TextModel(String initial) {
14 this.text = initial;
15 }
16
17 public void setText(String newvalue) {
18 if (!text.equals(newvalue)) {
19 text = newvalue;
20 notifyChange(text);
21 }
22 }
23
24 public String getText() {
25 return text;
26 }
27
28 /**
29 * Tries to automatically increment the version nr at end of the text.
30 */
31 public void increment() {
32 setText(StringUtils.increment(text));
33 }
34
35}
Note: See TracBrowser for help on using the repository browser.