View Javadoc
1 /* 2 * Scope: a generic MVC framework. 3 * Copyright (c) 2000-2002, The Scope team 4 * All rights reserved. 5 * 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * Neither the name "Scope" nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 * 36 * $Id: BasicTestModel.java,v 1.5 2002/09/05 15:41:46 ludovicc Exp $ 37 */ 38 package test.model.basic; 39 40 41 import org.scopemvc.core.ModelChangeEvent; 42 import org.scopemvc.core.Selector; 43 import org.scopemvc.model.basic.BasicModel; 44 import org.scopemvc.model.beans.DynamicReadOnly; 45 46 /*** 47 * <P> 48 * 49 * </P> 50 * 51 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net">Steve Meyfroidt</A> 52 * @created 05 September 2002 53 * @version $Revision: 1.5 $ $Date: 2002/09/05 15:41:46 $ 54 */ 55 public class BasicTestModel extends BasicModel implements DynamicReadOnly { 56 57 /*** 58 * TODO: describe of the Field 59 */ 60 public static Selector NAME = Selector.fromString("name"); 61 /*** 62 * TODO: describe of the Field 63 */ 64 public static Selector SUB_MODEL = Selector.fromString("subModel"); 65 /*** 66 * TODO: describe of the Field 67 */ 68 public static Selector INT_PROPERTY = Selector.fromString("intProperty"); 69 /*** 70 * TODO: describe of the Field 71 */ 72 public static Selector LONG_PROPERTY = Selector.fromString("longProperty"); 73 /*** 74 * TODO: describe of the Field 75 */ 76 public static Selector BOOLEAN_PROPERTY = Selector.fromString("booleanProperty"); 77 /*** 78 * TODO: describe of the Field 79 */ 80 public static Selector READ_ONLY_PROPERTY = Selector.fromString("readOnlyProperty"); 81 82 private String name; 83 private BasicTestModel subModel; 84 private int intProperty; 85 private long longProperty; 86 private boolean booleanProperty; 87 88 private boolean nameReadOnly; 89 90 91 /*** 92 * Constructor for the BasicTestModel object 93 * 94 * @param inName TODO: Describe the Parameter 95 */ 96 public BasicTestModel(String inName) { 97 setName(inName); 98 } 99 100 101 /*** 102 * Gets the name 103 * 104 * @return The name value 105 */ 106 public String getName() { 107 return name; 108 } 109 110 111 /*** 112 * Gets the sub model 113 * 114 * @return The subModel value 115 */ 116 public BasicTestModel getSubModel() { 117 return subModel; 118 } 119 120 121 /*** 122 * Gets the property read only 123 * 124 * @param inSelector TODO: Describe the Parameter 125 * @return The propertyReadOnly value 126 */ 127 public boolean isPropertyReadOnly(Selector inSelector) { 128 if (inSelector.equals(NAME) && nameReadOnly) { 129 return true; 130 } 131 return false; 132 } 133 134 /*** 135 * Gets the int property 136 * 137 * @return The intProperty value 138 */ 139 public int getIntProperty() { 140 return intProperty; 141 } 142 143 /*** 144 * Gets the long property 145 * 146 * @return The longProperty value 147 */ 148 public long getLongProperty() { 149 return longProperty; 150 } 151 152 /*** 153 * Gets the boolean property 154 * 155 * @return The booleanProperty value 156 */ 157 public boolean getBooleanProperty() { 158 return booleanProperty; 159 } 160 161 162 /*** 163 * Gets the read only property 164 * 165 * @return The readOnlyProperty value 166 */ 167 public int getReadOnlyProperty() { 168 return 0; 169 } 170 171 172 /*** 173 * Sets the name 174 * 175 * @param inName The new name value 176 */ 177 public void setName(String inName) { 178 name = inName; 179 fireModelChange(ModelChangeEvent.VALUE_CHANGED, NAME); 180 } 181 182 183 /*** 184 * Sets the sub model 185 * 186 * @param inSubModel The new subModel value 187 */ 188 public void setSubModel(BasicTestModel inSubModel) { 189 unlistenOldSubmodel(SUB_MODEL); 190 subModel = inSubModel; 191 listenNewSubmodel(SUB_MODEL); 192 fireModelChange(ModelChangeEvent.VALUE_CHANGED, SUB_MODEL); 193 } 194 195 196 /*** 197 * Sets the int property 198 * 199 * @param inValue The new intProperty value 200 */ 201 public void setIntProperty(int inValue) { 202 intProperty = inValue; 203 fireModelChange(ModelChangeEvent.VALUE_CHANGED, INT_PROPERTY); 204 } 205 206 207 /*** 208 * Sets the long property 209 * 210 * @param inValue The new longProperty value 211 */ 212 public void setLongProperty(long inValue) { 213 longProperty = inValue; 214 fireModelChange(ModelChangeEvent.VALUE_CHANGED, LONG_PROPERTY); 215 } 216 217 218 /*** 219 * Sets the boolean property 220 * 221 * @param inValue The new booleanProperty value 222 */ 223 public void setBooleanProperty(boolean inValue) { 224 booleanProperty = inValue; 225 fireModelChange(ModelChangeEvent.VALUE_CHANGED, BOOLEAN_PROPERTY); 226 } 227 228 229 /*** 230 * TODO: document the method 231 */ 232 public void activate() { 233 makeActive(true); 234 } 235 236 237 /*** 238 * TODO: document the method 239 */ 240 public void deactivate() { 241 makeActive(false); 242 } 243 244 245 /*** 246 * TODO: document the method 247 * 248 * @param inReadOnly TODO: Describe the Parameter 249 */ 250 public void makeNameReadOnly(boolean inReadOnly) { 251 nameReadOnly = inReadOnly; 252 fireModelChange(ModelChangeEvent.ACCESS_CHANGED, NAME); 253 } 254 255 256 /*** 257 * TODO: document the method 258 * 259 * @return TODO: Describe the Return Value 260 */ 261 public String toString() { 262 return "BasicTestModel name(" + name + ")"; 263 } 264 } 265

This page was automatically generated by Maven