| /* |
| * Copyright 2000-2014 JetBrains s.r.o. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| package standardDsls |
| |
| def vetoableMethods = { |
| method name: "addVetoableChangeListener", |
| type: "void", |
| params: [propertyName: "java.lang.String", |
| listener: "java.beans.VetoableChangeListener"], |
| doc: """ |
| Add a VetoableChangeListener for a specific property. The listener will be invoked only when a call on |
| fireVetoableChange names that specific property. The same listener object may be added more than once. |
| For each property, the listener will be invoked the number of times it was added for that property. If |
| propertyName or listener is null, no exception is thrown and no action is taken. |
| @param propertyName The name of the property to listen on. |
| @param listener The VetoableChangeListener to be added""" |
| |
| method name: "addVetoableChangeListener", |
| type: "void", |
| params: [listener: "java.beans.VetoableChangeListener"], |
| doc: """ |
| Add a VetoableListener to the listener list. The listener is registered for all properties. The same listener |
| object may beadded more than once, and will be called as many times as it is added. If listener is null, no |
| exception is thrown and no action is taken. |
| @param listener The VetoableChangeListener to be added""" |
| |
| method name: "removeVetoableChangeListener", |
| type: "void", |
| params: [propertyName: "java.lang.String", |
| listener: "java.beans.VetoableChangeListener"], |
| doc: """ |
| Remove a VetoableChangeListener for a specific property. If listener was added more than once to the same event |
| source for the specified property, it will be notified one less time after being removed. If propertyName is null, |
| no exception is thrown and no action is taken. If listener is null, or was never added for the specified property, |
| no exception is thrown and no action is taken. |
| @param propertyName The name of the property that was listened on. |
| @param listener The VetoableChangeListener to be removed""" |
| |
| method name: "removeVetoableChangeListener", |
| type: "void", |
| params: [listener: "java.beans.VetoableChangeListener"], |
| doc: """ |
| Remove a VetoableChangeListener from the listener list. This removes a VetoableChangeListener that was registered |
| for all properties. If listener was added more than once to the same event source, it will be notified one less |
| time after being removed. If listener is null, or was never added, no exception is thrown and no action is taken. |
| @param listener The VetoableChangeListener to be removed""" |
| |
| method name: "fireVetoableChange", |
| type: "void", |
| params: [propertyName: "java.lang.String", oldValue: "java.lang.Object", newValue: "java.lang.Object"], |
| doc: """ |
| Report a vetoable property update to any registered listeners. If anyone vetos the change, then fire a new event |
| reverting everyone to the old value and then rethrow the PropertyVetoException. |
| No event is fired if old and new are equal and non-null. |
| @param propertyName The programmatic name of the property that is about to change.. |
| @param oldValue The old value of the property. |
| @param newValue The new value of the property. """ |
| |
| method name: "getVetoableChangeListeners", |
| type: "java.beans.VetoableChangeListener[]", |
| doc: """ |
| Returns the list of VetoableChangeListeners. If named vetoable change listeners were added, then VetoableChangeListenerProxy |
| wrappers will returned. |
| @return List of VetoableChangeListeners and VetoableChangeListenerProxys if named property change listeners were added.""" |
| |
| method name: "getVetoableChangeListeners", |
| type: "java.beans.VetoableChangeListener[]", |
| params: [propertyName: "java.lang.String"], |
| doc: """ |
| Returns an array of all the listeners which have been associated with the named property. |
| @param propertyName The name of the property being listened to |
| @return all the VetoableChangeListeners associated with the named property. If no such listeners have been added, or if |
| propertyName is null, an empty array is returned.""" |
| } |
| |
| contributor(ctype:hasField(hasAnnotation("groovy.beans.Vetoable"))) { |
| if (psiClass?.fields?.find {it.hasAnnotation("groovy.beans.Vetoable")}) { |
| vetoableMethods.delegate = delegate |
| vetoableMethods.resolveStrategy = Closure.DELEGATE_FIRST |
| vetoableMethods() |
| } |
| } |