NodeAdapter.java
001 /*
002  * SPDX-License-Identifier: Apache-2.0
003  *
004  * Copyright 2008-2017 the original author or authors.
005  *
006  * Licensed under the Apache License, Version 2.0 (the "License");
007  * you may not use this file except in compliance with the License.
008  * You may obtain a copy of the License at
009  *
010  *     http://www.apache.org/licenses/LICENSE-2.0
011  *
012  * Unless required by applicable law or agreed to in writing, software
013  * distributed under the License is distributed on an "AS IS" BASIS,
014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015  * See the License for the specific language governing permissions and
016  * limitations under the License.
017  */
018 package griffon.pivot.support.adapters;
019 
020 import griffon.core.CallableWithArgs;
021 import org.apache.pivot.wtk.text.Node;
022 
023 /**
024  @author Andres Almiray
025  @since 2.0.0
026  */
027 public class NodeAdapter implements GriffonPivotAdapter, org.apache.pivot.wtk.text.NodeListener {
028     private CallableWithArgs<Void> rangeInserted;
029     private CallableWithArgs<Void> rangeRemoved;
030     private CallableWithArgs<Void> nodeInserted;
031     private CallableWithArgs<Void> nodesRemoved;
032     private CallableWithArgs<Void> offsetChanged;
033     private CallableWithArgs<Void> parentChanged;
034 
035     public CallableWithArgs<Void> getRangeInserted() {
036         return this.rangeInserted;
037     }
038 
039     public CallableWithArgs<Void> getRangeRemoved() {
040         return this.rangeRemoved;
041     }
042 
043     public CallableWithArgs<Void> getNodeInserted() {
044         return this.nodeInserted;
045     }
046 
047     public CallableWithArgs<Void> getNodesRemoved() {
048         return this.nodesRemoved;
049     }
050 
051     public CallableWithArgs<Void> getOffsetChanged() {
052         return this.offsetChanged;
053     }
054 
055     public CallableWithArgs<Void> getParentChanged() {
056         return this.parentChanged;
057     }
058 
059 
060     public void setRangeInserted(CallableWithArgs<Void> rangeInserted) {
061         this.rangeInserted = rangeInserted;
062     }
063 
064     public void setRangeRemoved(CallableWithArgs<Void> rangeRemoved) {
065         this.rangeRemoved = rangeRemoved;
066     }
067 
068     public void setNodeInserted(CallableWithArgs<Void> nodeInserted) {
069         this.nodeInserted = nodeInserted;
070     }
071 
072     public void setNodesRemoved(CallableWithArgs<Void> nodesRemoved) {
073         this.nodesRemoved = nodesRemoved;
074     }
075 
076     public void setOffsetChanged(CallableWithArgs<Void> offsetChanged) {
077         this.offsetChanged = offsetChanged;
078     }
079 
080     public void setParentChanged(CallableWithArgs<Void> parentChanged) {
081         this.parentChanged = parentChanged;
082     }
083 
084 
085     public void rangeInserted(org.apache.pivot.wtk.text.Node arg0, int arg1, int arg2) {
086         if (rangeInserted != null) {
087             rangeInserted.call(arg0, arg1, arg2);
088         }
089     }
090 
091     public void rangeRemoved(org.apache.pivot.wtk.text.Node arg0, int arg1, int arg2) {
092         if (rangeRemoved != null) {
093             rangeRemoved.call(arg0, arg1, arg2);
094         }
095     }
096 
097     public void nodeInserted(org.apache.pivot.wtk.text.Node arg0, int arg1) {
098         if (nodeInserted != null) {
099             nodeInserted.call(arg0, arg1);
100         }
101     }
102 
103     public void nodesRemoved(org.apache.pivot.wtk.text.Node arg0, org.apache.pivot.collections.Sequence<Node> arg1, int arg2) {
104         if (nodesRemoved != null) {
105             nodesRemoved.call(arg0, arg1, arg2);
106         }
107     }
108 
109     public void offsetChanged(org.apache.pivot.wtk.text.Node arg0, int arg1) {
110         if (offsetChanged != null) {
111             offsetChanged.call(arg0, arg1);
112         }
113     }
114 
115     public void parentChanged(org.apache.pivot.wtk.text.Node arg0, org.apache.pivot.wtk.text.Element arg1) {
116         if (parentChanged != null) {
117             parentChanged.call(arg0, arg1);
118         }
119     }
120 
121 }