TextInputContentAdapter.java
001 /*
002  * Copyright 2008-2014 the original author or authors.
003  *
004  * Licensed under the Apache License, Version 2.0 (the "License");
005  * you may not use this file except in compliance with the License.
006  * You may obtain a copy of the License at
007  *
008  *     http://www.apache.org/licenses/LICENSE-2.0
009  *
010  * Unless required by applicable law or agreed to in writing, software
011  * distributed under the License is distributed on an "AS IS" BASIS,
012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013  * See the License for the specific language governing permissions and
014  * limitations under the License.
015  */
016 package griffon.pivot.support.adapters;
017 
018 import griffon.core.CallableWithArgs;
019 import org.apache.pivot.util.Vote;
020 
021 /**
022  @author Andres Almiray
023  @since 2.0.0
024  */
025 public class TextInputContentAdapter implements GriffonPivotAdapter, org.apache.pivot.wtk.TextInputContentListener {
026     private CallableWithArgs<Void> textChanged;
027     private CallableWithArgs<Vote> previewInsertText;
028     private CallableWithArgs<Void> textInserted;
029     private CallableWithArgs<Void> insertTextVetoed;
030     private CallableWithArgs<Vote> previewRemoveText;
031     private CallableWithArgs<Void> textRemoved;
032     private CallableWithArgs<Void> removeTextVetoed;
033 
034     public CallableWithArgs<Void> getTextChanged() {
035         return this.textChanged;
036     }
037 
038     public CallableWithArgs<Vote> getPreviewInsertText() {
039         return this.previewInsertText;
040     }
041 
042     public CallableWithArgs<Void> getTextInserted() {
043         return this.textInserted;
044     }
045 
046     public CallableWithArgs<Void> getInsertTextVetoed() {
047         return this.insertTextVetoed;
048     }
049 
050     public CallableWithArgs<Vote> getPreviewRemoveText() {
051         return this.previewRemoveText;
052     }
053 
054     public CallableWithArgs<Void> getTextRemoved() {
055         return this.textRemoved;
056     }
057 
058     public CallableWithArgs<Void> getRemoveTextVetoed() {
059         return this.removeTextVetoed;
060     }
061 
062 
063     public void setTextChanged(CallableWithArgs<Void> textChanged) {
064         this.textChanged = textChanged;
065     }
066 
067     public void setPreviewInsertText(CallableWithArgs<Vote> previewInsertText) {
068         this.previewInsertText = previewInsertText;
069     }
070 
071     public void setTextInserted(CallableWithArgs<Void> textInserted) {
072         this.textInserted = textInserted;
073     }
074 
075     public void setInsertTextVetoed(CallableWithArgs<Void> insertTextVetoed) {
076         this.insertTextVetoed = insertTextVetoed;
077     }
078 
079     public void setPreviewRemoveText(CallableWithArgs<Vote> previewRemoveText) {
080         this.previewRemoveText = previewRemoveText;
081     }
082 
083     public void setTextRemoved(CallableWithArgs<Void> textRemoved) {
084         this.textRemoved = textRemoved;
085     }
086 
087     public void setRemoveTextVetoed(CallableWithArgs<Void> removeTextVetoed) {
088         this.removeTextVetoed = removeTextVetoed;
089     }
090 
091 
092     public void textChanged(org.apache.pivot.wtk.TextInput arg0) {
093         if (textChanged != null) {
094             textChanged.call(arg0);
095         }
096     }
097 
098     public org.apache.pivot.util.Vote previewInsertText(org.apache.pivot.wtk.TextInput arg0, java.lang.CharSequence arg1, int arg2) {
099         if (previewInsertText != null) {
100             return previewInsertText.call(arg0, arg1, arg2);
101         }
102         return Vote.APPROVE;
103     }
104 
105     public void textInserted(org.apache.pivot.wtk.TextInput arg0, int arg1, int arg2) {
106         if (textInserted != null) {
107             textInserted.call(arg0, arg1, arg2);
108         }
109     }
110 
111     public void insertTextVetoed(org.apache.pivot.wtk.TextInput arg0, org.apache.pivot.util.Vote arg1) {
112         if (insertTextVetoed != null) {
113             insertTextVetoed.call(arg0, arg1);
114         }
115     }
116 
117     public org.apache.pivot.util.Vote previewRemoveText(org.apache.pivot.wtk.TextInput arg0, int arg1, int arg2) {
118         if (previewRemoveText != null) {
119             return previewRemoveText.call(arg0, arg1, arg2);
120         }
121         return Vote.APPROVE;
122     }
123 
124     public void textRemoved(org.apache.pivot.wtk.TextInput arg0, int arg1, int arg2) {
125         if (textRemoved != null) {
126             textRemoved.call(arg0, arg1, arg2);
127         }
128     }
129 
130     public void removeTextVetoed(org.apache.pivot.wtk.TextInput arg0, org.apache.pivot.util.Vote arg1) {
131         if (removeTextVetoed != null) {
132             removeTextVetoed.call(arg0, arg1);
133         }
134     }
135 
136 }