summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/FloatFieldEditorDialog.java
blob: 7ad36cc52ebf3a86b1dda72409133864c5306139 (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
32
33
34
package NET.worlds.scape;

class FloatFieldEditorDialog extends FieldEditorDialog {
   Property property;
   FloatPropertyEditor limits;

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

   @Override
   protected String getValue() {
      return "" + this.property.get();
   }

   @Override
   protected boolean setValue(String text) {
      if (text.length() != 0) {
         try {
            Float val = Float.valueOf(text);
            if (!this.limits.rangeLimits || val >= this.limits.minVal && val <= this.limits.maxVal) {
               this.parent.addUndoableSet(this.property, val);
               return true;
            }
         } catch (NumberFormatException var3) {
         }
      }

      return false;
   }
}