View Javadoc

1   package com.melloware.jukes.gui.view.validation;
2   
3   import com.jgoodies.uif.action.ActionManager;
4   import com.jgoodies.validation.ValidationResult;
5   import com.melloware.jukes.db.orm.Artist;
6   import com.melloware.jukes.gui.tool.Actions;
7   
8   /**
9    * Provides all models to bind an artist editor to its domain model,
10   * an instance of {@link Artist}.
11   * <p>
12   * Copyright (c) 1999-2007 Melloware, Inc. <http://www.melloware.com>
13   * @author Emil A. Lefkof III <info@melloware.com>
14   * @version 4.0
15   */
16  public final class ArtistValidationModel
17      extends AbstractValidationModel {
18      
19  	private static final String[] VALIDATION_PROPERTIES = { Artist.PROPERTYNAME_NAME, Artist.PROPERTYNAME_NOTES };
20      /**
21  	 * Constuctor that takes an Artist object.
22  	 * <p>
23  	 * @param aArtist the domain object
24  	 */
25  	public ArtistValidationModel(Artist aArtist) {
26  		super(aArtist);
27  	}
28  
29  	protected void updateValidationResult() {
30          Artist artist = (Artist)getBean();
31          ValidationResult result = new ArtistValidator(artist).validate();
32          validationResultModel.setResult(result);
33      }
34  	
35  	/**
36       * Turns the buttons on this editor on or off based on state of the 
37       * underlying ORM object.  If it is modified turn these on.
38       * <p>
39       * @param enabled true to enable false to disable
40       */
41      public void updateButtonState(boolean enabled) {
42      	this.dirty = enabled;
43      	ActionManager.get(Actions.COMMIT_ID).setEnabled(enabled);
44      	ActionManager.get(Actions.ROLLBACK_ID).setEnabled(enabled);
45      	ActionManager.get(Actions.DELETE_ID).setEnabled(enabled);
46      }
47  
48  	/* (non-Javadoc)
49  	 * @see com.melloware.jukes.gui.view.validation.AbstractValidationModel#gtePropertiesToCheck()
50  	 */
51  	protected String[] getPropertiesToCheck() {
52  		return VALIDATION_PROPERTIES;
53  	}
54  
55  	
56  
57  }