AbstractVetoable.java
01 /*
02  * Copyright 2012-2013 the original author or authors.
03  *
04  * Licensed under the Apache License, Version 2.0 (the "License");
05  * you may not use this file except in compliance with the License.
06  * You may obtain a copy of the License at
07  *
08  *      http://www.apache.org/licenses/LICENSE-2.0
09  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package org.codehaus.griffon.runtime.core;
18 
19 import griffon.core.Vetoable;
20 
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyVetoException;
23 import java.beans.VetoableChangeListener;
24 import java.beans.VetoableChangeSupport;
25 
26 /**
27  @author Andres Almiray
28  @since 1.2.0
29  */
30 public class AbstractVetoable extends AbstractObservable implements Vetoable {
31     protected VetoableChangeSupport vcs;
32 
33     public AbstractVetoable() {
34         vcs = new VetoableChangeSupport(this);
35     }
36 
37     public void addVetoableChangeListener(VetoableChangeListener listener) {
38         vcs.addVetoableChangeListener(listener);
39     }
40 
41     public void removeVetoableChangeListener(VetoableChangeListener listener) {
42         vcs.removeVetoableChangeListener(listener);
43     }
44 
45     public VetoableChangeListener[] getVetoableChangeListeners() {
46         return vcs.getVetoableChangeListeners();
47     }
48 
49     public void addVetoableChangeListener(String propertyName, VetoableChangeListener listener) {
50         vcs.addVetoableChangeListener(propertyName, listener);
51     }
52 
53     public void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener) {
54         vcs.removeVetoableChangeListener(propertyName, listener);
55     }
56 
57     public VetoableChangeListener[] getVetoableChangeListeners(String propertyName) {
58         return vcs.getVetoableChangeListeners(propertyName);
59     }
60 
61     protected void fireVetoableChange(PropertyChangeEvent eventthrows PropertyVetoException {
62         vcs.fireVetoableChange(event);
63     }
64 
65     protected void fireVetoableChange(String propertyName, Object oldValue, Object newValuethrows PropertyVetoException {
66         vcs.fireVetoableChange(propertyName, oldValue, newValue);
67     }
68 }