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.util.Vote;
022
023 /**
024 * @author Andres Almiray
025 * @since 2.0.0
026 */
027 public class TextInputContentAdapter implements GriffonPivotAdapter, org.apache.pivot.wtk.TextInputContentListener {
028 private CallableWithArgs<Void> textChanged;
029 private CallableWithArgs<Vote> previewInsertText;
030 private CallableWithArgs<Void> textInserted;
031 private CallableWithArgs<Void> insertTextVetoed;
032 private CallableWithArgs<Vote> previewRemoveText;
033 private CallableWithArgs<Void> textRemoved;
034 private CallableWithArgs<Void> removeTextVetoed;
035
036 public CallableWithArgs<Void> getTextChanged() {
037 return this.textChanged;
038 }
039
040 public CallableWithArgs<Vote> getPreviewInsertText() {
041 return this.previewInsertText;
042 }
043
044 public CallableWithArgs<Void> getTextInserted() {
045 return this.textInserted;
046 }
047
048 public CallableWithArgs<Void> getInsertTextVetoed() {
049 return this.insertTextVetoed;
050 }
051
052 public CallableWithArgs<Vote> getPreviewRemoveText() {
053 return this.previewRemoveText;
054 }
055
056 public CallableWithArgs<Void> getTextRemoved() {
057 return this.textRemoved;
058 }
059
060 public CallableWithArgs<Void> getRemoveTextVetoed() {
061 return this.removeTextVetoed;
062 }
063
064
065 public void setTextChanged(CallableWithArgs<Void> textChanged) {
066 this.textChanged = textChanged;
067 }
068
069 public void setPreviewInsertText(CallableWithArgs<Vote> previewInsertText) {
070 this.previewInsertText = previewInsertText;
071 }
072
073 public void setTextInserted(CallableWithArgs<Void> textInserted) {
074 this.textInserted = textInserted;
075 }
076
077 public void setInsertTextVetoed(CallableWithArgs<Void> insertTextVetoed) {
078 this.insertTextVetoed = insertTextVetoed;
079 }
080
081 public void setPreviewRemoveText(CallableWithArgs<Vote> previewRemoveText) {
082 this.previewRemoveText = previewRemoveText;
083 }
084
085 public void setTextRemoved(CallableWithArgs<Void> textRemoved) {
086 this.textRemoved = textRemoved;
087 }
088
089 public void setRemoveTextVetoed(CallableWithArgs<Void> removeTextVetoed) {
090 this.removeTextVetoed = removeTextVetoed;
091 }
092
093
094 public void textChanged(org.apache.pivot.wtk.TextInput arg0) {
095 if (textChanged != null) {
096 textChanged.call(arg0);
097 }
098 }
099
100 public org.apache.pivot.util.Vote previewInsertText(org.apache.pivot.wtk.TextInput arg0, java.lang.CharSequence arg1, int arg2) {
101 if (previewInsertText != null) {
102 return previewInsertText.call(arg0, arg1, arg2);
103 }
104 return Vote.APPROVE;
105 }
106
107 public void textInserted(org.apache.pivot.wtk.TextInput arg0, int arg1, int arg2) {
108 if (textInserted != null) {
109 textInserted.call(arg0, arg1, arg2);
110 }
111 }
112
113 public void insertTextVetoed(org.apache.pivot.wtk.TextInput arg0, org.apache.pivot.util.Vote arg1) {
114 if (insertTextVetoed != null) {
115 insertTextVetoed.call(arg0, arg1);
116 }
117 }
118
119 public org.apache.pivot.util.Vote previewRemoveText(org.apache.pivot.wtk.TextInput arg0, int arg1, int arg2) {
120 if (previewRemoveText != null) {
121 return previewRemoveText.call(arg0, arg1, arg2);
122 }
123 return Vote.APPROVE;
124 }
125
126 public void textRemoved(org.apache.pivot.wtk.TextInput arg0, int arg1, int arg2) {
127 if (textRemoved != null) {
128 textRemoved.call(arg0, arg1, arg2);
129 }
130 }
131
132 public void removeTextVetoed(org.apache.pivot.wtk.TextInput arg0, org.apache.pivot.util.Vote arg1) {
133 if (removeTextVetoed != null) {
134 removeTextVetoed.call(arg0, arg1);
135 }
136 }
137
138 }
|