summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/StringFieldEditorDialog.java
blob: d027cd8024d5eb756af18cce11f938c15bd2042f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package NET.worlds.scape;

class StringFieldEditorDialog extends FieldEditorDialog {
   Property property;

   StringFieldEditorDialog(EditTile parent, String title, Property property) {
      super(parent, title);
      this.property = property;
      this.ready();
   }

   @Override
   protected String getValue() {
      String s = (String)this.property.get();
      return s != null ? s : "";
   }

   @Override
   protected boolean setValue(String text) {
      if (text.length() == 0) {
         if (!this.property.canSetNull()) {
            return false;
         }

         text = null;
      }

      this.parent.addUndoableSet(this.property, text);
      return true;
   }
}