1 package org.catacomb.druid.gui.base; 2 3 4 import org.catacomb.druid.gui.edit.Effect; 5 import org.catacomb.interlish.structure.Ablable; 6 import org.catacomb.report.E; 7 8 9 10 11 public class DruAbleEffect extends Effect { 12 13 14 boolean enabledState; 15 16 String enabledValue; 17 18 19 public DruAbleEffect(String tgt, boolean b, String s) { 20 super(tgt); 21 enabledState = b; 22 enabledValue = s; 23 } 24 25 26 27 public void apply(String s) { 28 Object tgt = getTarget(); 29 30 if (tgt instanceof Ablable) { 31 if (s != null && s.equals(enabledValue)) { 32 ((Ablable)tgt).able(true); 33 } else { 34 ((Ablable)tgt).able(false); 35 } 36 37 38 } else { 39 E.error("must have ableable component, not " + tgt); 40 } 41 42 } 43 44 public void apply(boolean b) { 45 Object tgt = getTarget(); 46 47 if (tgt instanceof Ablable) { 48 if (b == enabledState) { 49 ((Ablable)tgt).able(true); 50 } else { 51 ((Ablable)tgt).able(false); 52 } 53 54 55 } else { 56 E.error("must have ableable component, not " + tgt); 57 } 58 59 } 60 61 }