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: SwingDummyModel.java,v 1.11 2002/09/12 18:26:54 ludovicc Exp $ 37 */ 38 package test.view.swing; 39 40 41 import java.util.ArrayList; 42 import java.util.HashSet; 43 import javax.swing.ImageIcon; 44 import org.apache.commons.logging.Log; 45 import org.apache.commons.logging.LogFactory; 46 import org.scopemvc.core.Selector; 47 import org.scopemvc.model.basic.BasicModel; 48 import org.scopemvc.model.collection.ListModel; 49 50 /*** 51 * <P> 52 * 53 * </P> 54 * 55 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net">Steve Meyfroidt</A> 56 * @created 10 September 2002 57 * @version $Revision: 1.11 $ $Date: 2002/09/12 18:26:54 $ 58 */ 59 public final class SwingDummyModel extends BasicModel { 60 61 private static final Log LOG = LogFactory.getLog(SwingDummyModel.class); 62 63 private static final ImageIcon ICON = new ImageIcon(); 64 65 // --------------------- Some actions ----------------------- 66 67 boolean doneAction1; 68 int action2; 69 70 private String stringProperty = "sp"; 71 private String readOnlyStringProperty = "rosp"; 72 private int intProperty = 1; 73 private Integer intProperty2 = new Integer(1); 74 private int invalidIntProperty = 0; 75 private boolean booleanProperty = false; 76 private Boolean booleanProperty1 = Boolean.FALSE; 77 78 private String[] stringIndexedProperty = {"sip0", "sip1"}; 79 private String[] hiddenStringIndexedProperty = {"hsip0", "hsip1"}; 80 private ArrayList stringNonIndexedProperty = new ArrayList(); 81 private String[] stringNonIndexedProperty2 = new String[2]; 82 83 private HashSet selections; 84 85 private SwingDummyModel subModel; 86 87 private ListModel subModels; 88 89 /*** 90 * Constructor for the SwingDummyModel object 91 */ 92 public SwingDummyModel() { 93 stringNonIndexedProperty.add("snip0"); 94 stringNonIndexedProperty.add("snip1"); 95 stringNonIndexedProperty2[0] = "snip20"; 96 stringNonIndexedProperty2[1] = "snip21"; 97 } 98 99 100 /*** 101 * Constructor for the SwingDummyModel object 102 * 103 * @param inString TODO: Describe the Parameter 104 * @param inInt TODO: Describe the Parameter 105 */ 106 public SwingDummyModel(String inString, int inInt) { 107 this(); 108 setStringProperty(inString); 109 setIntProperty(inInt); 110 } 111 112 113 /*** 114 * Gets the string property 115 * 116 * @return The stringProperty value 117 */ 118 public String getStringProperty() { 119 return stringProperty; 120 } 121 122 123 /*** 124 * Gets the int property 125 * 126 * @return The intProperty value 127 */ 128 public int getIntProperty() { 129 return intProperty; 130 } 131 132 133 /*** 134 * Gets the int property2 135 * 136 * @return The intProperty2 value 137 */ 138 public Integer getIntProperty2() { 139 return intProperty2; 140 } 141 142 143 /*** 144 * Gets the invalid int property 145 * 146 * @return The invalidIntProperty value 147 */ 148 public int getInvalidIntProperty() { 149 return invalidIntProperty; 150 } 151 152 153 /*** 154 * Gets the read only int property 155 * 156 * @return The readOnlyIntProperty value 157 */ 158 public int getReadOnlyIntProperty() { 159 return 70; 160 } 161 162 163 /*** 164 * Gets the boolean property 165 * 166 * @return The booleanProperty value 167 */ 168 public boolean getBooleanProperty() { 169 return booleanProperty; 170 } 171 172 173 /*** 174 * Gets the boolean property1 175 * 176 * @return The booleanProperty1 value 177 */ 178 public Boolean getBooleanProperty1() { 179 return booleanProperty1; 180 } 181 182 183 /*** 184 * Gets the boolean read only property 185 * 186 * @return The booleanReadOnlyProperty value 187 */ 188 public boolean getBooleanReadOnlyProperty() { 189 return true; 190 } 191 192 193 /*** 194 * Gets the invalid boolean property 195 * 196 * @return The invalidBooleanProperty value 197 */ 198 public boolean getInvalidBooleanProperty() { 199 return false; 200 } 201 202 203 /*** 204 * Gets the string indexed property 205 * 206 * @return The stringIndexedProperty value 207 */ 208 public String[] getStringIndexedProperty() { 209 return stringIndexedProperty; 210 } 211 212 213 /*** 214 * Gets the string indexed property 215 * 216 * @param inIndex TODO: Describe the Parameter 217 * @return The stringIndexedProperty value 218 */ 219 public String getStringIndexedProperty(int inIndex) { 220 return stringIndexedProperty[inIndex]; 221 } 222 223 224 /*** 225 * Gets the hidden string indexed property 226 * 227 * @param inIndex TODO: Describe the Parameter 228 * @return The hiddenStringIndexedProperty value 229 */ 230 public String getHiddenStringIndexedProperty(int inIndex) { 231 return hiddenStringIndexedProperty[inIndex]; 232 } 233 234 235 /*** 236 * Gets the hidden string indexed property size 237 * 238 * @return The hiddenStringIndexedPropertySize value 239 */ 240 public int getHiddenStringIndexedPropertySize() { 241 return hiddenStringIndexedProperty.length; 242 } 243 244 245 /*** 246 * Gets the string non indexed property 247 * 248 * @return The stringNonIndexedProperty value 249 */ 250 public ArrayList getStringNonIndexedProperty() { 251 return stringNonIndexedProperty; 252 } 253 254 /*** 255 * Gets the string non indexed property 256 * 257 * @param inIndex TODO: Describe the Parameter 258 * @return The stringNonIndexedProperty value 259 */ 260 public String getStringNonIndexedProperty(int inIndex) { 261 return (String) getStringNonIndexedProperty().get(inIndex); 262 } 263 264 265 /*** 266 * Gets the string non indexed property2 267 * 268 * @return The stringNonIndexedProperty2 value 269 */ 270 public String[] getStringNonIndexedProperty2() { 271 return stringNonIndexedProperty2; 272 } 273 274 275 /*** 276 * Gets the read only string property 277 * 278 * @return The readOnlyStringProperty value 279 */ 280 public String getReadOnlyStringProperty() { 281 return readOnlyStringProperty; 282 } 283 284 285 /*** 286 * Gets the sub model 287 * 288 * @return The subModel value 289 */ 290 public SwingDummyModel getSubModel() { 291 return subModel; 292 } 293 294 /*** 295 * Gets the icon property 296 * 297 * @return The iconProperty value 298 */ 299 public ImageIcon getIconProperty() { 300 return ICON; 301 } 302 303 304 /*** 305 * Gets the selections 306 * 307 * @return The selections value 308 */ 309 public HashSet getSelections() { 310 return selections; 311 } 312 313 314 /*** 315 * Gets the sub models 316 * 317 * @return The subModels value 318 */ 319 public ListModel getSubModels() { 320 return subModels; 321 } 322 323 324 /*** 325 * Sets the string property 326 * 327 * @param inString The new stringProperty value 328 */ 329 public void setStringProperty(String inString) { 330 if ("Illegal".equals(inString)) { 331 throw new IllegalArgumentException(); 332 } 333 stringProperty = inString; 334 fireModelChange(VALUE_CHANGED, Selector.fromString("stringProperty")); 335 } 336 337 338 /*** 339 * Sets the int property 340 * 341 * @param inInt The new intProperty value 342 */ 343 public void setIntProperty(int inInt) { 344 intProperty = inInt; 345 fireModelChange(VALUE_CHANGED, Selector.fromString("intProperty")); 346 } 347 348 349 /*** 350 * Sets the int property2 351 * 352 * @param inInt The new intProperty2 value 353 */ 354 public void setIntProperty2(Integer inInt) { 355 intProperty2 = inInt; 356 fireModelChange(VALUE_CHANGED, Selector.fromString("intProperty2")); 357 } 358 359 360 /*** 361 * Sets the invalid int property 362 * 363 * @param inInt The new invalidIntProperty value 364 */ 365 public void setInvalidIntProperty(int inInt) { 366 if (inInt > 50) { 367 throw new IllegalArgumentException(); 368 } 369 invalidIntProperty = inInt; 370 fireModelChange(VALUE_CHANGED, Selector.fromString("invalidIntProperty")); 371 } 372 373 374 /*** 375 * Sets the boolean property 376 * 377 * @param inValue The new booleanProperty value 378 */ 379 public void setBooleanProperty(boolean inValue) { 380 booleanProperty = inValue; 381 fireModelChange(VALUE_CHANGED, Selector.fromString("booleanProperty")); 382 } 383 384 385 /*** 386 * Sets the boolean property1 387 * 388 * @param inValue The new booleanProperty1 value 389 */ 390 public void setBooleanProperty1(Boolean inValue) { 391 booleanProperty1 = inValue; 392 fireModelChange(VALUE_CHANGED, Selector.fromString("booleanProperty1")); 393 } 394 395 396 /*** 397 * Sets the invalid boolean property 398 * 399 * @param inValue The new invalidBooleanProperty value 400 */ 401 public void setInvalidBooleanProperty(boolean inValue) { 402 if (inValue) { 403 throw new IllegalArgumentException(); 404 } 405 fireModelChange(VALUE_CHANGED, Selector.fromString("invalidBooleanProperty")); 406 } 407 408 409 /*** 410 * Sets the string indexed property 411 * 412 * @param inStrings The new stringIndexedProperty value 413 */ 414 public void setStringIndexedProperty(String[] inStrings) { 415 stringIndexedProperty = inStrings; 416 } 417 418 419 /*** 420 * Sets the string indexed property 421 * 422 * @param inIndex The new stringIndexedProperty value 423 * @param inString The new stringIndexedProperty value 424 */ 425 public void setStringIndexedProperty(int inIndex, String inString) { 426 stringIndexedProperty[inIndex] = inString; 427 } 428 429 430 /*** 431 * Sets the hidden string indexed property 432 * 433 * @param inIndex The new hiddenStringIndexedProperty value 434 * @param inString The new hiddenStringIndexedProperty value 435 */ 436 public void setHiddenStringIndexedProperty(int inIndex, String inString) { 437 hiddenStringIndexedProperty[inIndex] = inString; 438 } 439 440 /*** 441 * Sets the string non indexed property 442 * 443 * @param inList The new stringNonIndexedProperty value 444 */ 445 public void setStringNonIndexedProperty(ArrayList inList) { 446 stringNonIndexedProperty = inList; 447 fireModelChange(VALUE_CHANGED, Selector.fromString("stringNonIndexedProperty")); 448 } 449 450 451 /*** 452 * Sets the string non indexed property2 453 * 454 * @param inArray The new stringNonIndexedProperty2 value 455 */ 456 public void setStringNonIndexedProperty2(String[] inArray) { 457 stringNonIndexedProperty2 = inArray; 458 } 459 460 461 /*** 462 * Sets the sub model 463 * 464 * @param inModel The new subModel value 465 */ 466 public void setSubModel(SwingDummyModel inModel) { 467 unlistenOldSubmodel(Selector.fromString("subModel")); 468 subModel = inModel; 469 listenNewSubmodel(Selector.fromString("subModel")); 470 fireModelChange(VALUE_CHANGED, Selector.fromString("subModel")); 471 } 472 473 474 /*** 475 * Sets the selections 476 * 477 * @param inHash The new selections value 478 */ 479 public void setSelections(HashSet inHash) { 480 selections = inHash; 481 fireModelChange(VALUE_CHANGED, Selector.fromString("selections")); 482 } 483 484 485 /*** 486 * Sets the sub models 487 * 488 * @param inList The new subModels value 489 */ 490 public void setSubModels(ListModel inList) { 491 subModels = inList; 492 fireModelChange(VALUE_CHANGED, Selector.fromString("subModels")); 493 } 494 495 496 /*** 497 * TODO: document the method 498 */ 499 public void initSubModels() { 500 subModels = new ListModel(); 501 subModels.add(new SwingDummyModel("a", 1)); 502 subModels.add(new SwingDummyModel("b", 2)); 503 subModels.add(new SwingDummyModel("c", 3)); 504 } 505 506 507 /*** 508 * TODO: document the method 509 */ 510 public void action1() { 511 doneAction1 = true; 512 } 513 514 515 /*** 516 * TODO: document the method 517 * 518 * @param inParameter TODO: Describe the Parameter 519 */ 520 public void action2(int inParameter) { 521 action2 = inParameter; 522 } 523 524 525 /*** 526 * TODO: document the method 527 * 528 * @param inParameter TODO: Describe the Parameter 529 * @return TODO: Describe the Return Value 530 */ 531 public long action3(long inParameter) { 532 return inParameter; 533 } 534 } 535

This page was automatically generated by Maven