1 16 package org.apache.cocoon.forms.formmodel; 17 18 import org.apache.commons.lang.enums.ValuedEnum; 19 20 28 public class WidgetState extends ValuedEnum { 29 30 private static final int ACTIVE_VALUE = 4; 31 32 private static final int DISABLED_VALUE = 3; 33 34 private static final int OUTPUT_VALUE = 2; 35 36 private static final int INVISIBLE_VALUE = 1; 37 38 42 public static final WidgetState ACTIVE = new WidgetState("active", ACTIVE_VALUE); 43 44 48 public static final WidgetState DISABLED = new WidgetState("disabled", DISABLED_VALUE); 49 50 54 public static final WidgetState OUTPUT = new WidgetState("output", OUTPUT_VALUE); 55 56 59 public static final WidgetState INVISIBLE = new WidgetState("invisible", INVISIBLE_VALUE); 60 61 64 private WidgetState(String name, int value) { 65 super(name, value); 66 } 67 68 76 public static WidgetState stateForName(String name) { 77 return (WidgetState) getEnum(WidgetState.class, name); 78 } 79 80 88 public static WidgetState strictest(WidgetState one, WidgetState two) { 89 return (one.getValue() < two.getValue()) ? one : two; 90 } 91 92 99 public boolean stricterThan(WidgetState other) { 100 return this.getValue() < other.getValue(); 101 } 102 103 108 public boolean isAcceptingInputs() { 109 return this.getValue() == ACTIVE_VALUE; 110 } 111 112 117 public boolean isDisplayingValues() { 118 return this.getValue() > INVISIBLE_VALUE; 119 } 120 121 126 public boolean isValidatingValues() { 127 return this.getValue() == ACTIVE_VALUE; 128 } 129 130 148 } 149 | Popular Tags |