Author: rwhitcomb Date: Wed Dec 6 01:00:53 2017 New Revision: 1817255 URL: http://svn.apache.org/viewvc?rev=1817255&view=rev Log: PIVOT-1011: Move the multiple ListenerList subclasses out of TextInput and into their respective interface classes (alongside any Adapter classes that are needed). Rename the class references in TextInput itself.
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputBindingListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputSelectionListener.java Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java?rev=1817255&r1=1817254&r2=1817255&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java Wed Dec 6 01:00:53 2017 @@ -108,124 +108,6 @@ public class TextInput extends Component } } - private static class TextInputListenerList extends ListenerList<TextInputListener> implements - TextInputListener { - @Override - public void textSizeChanged(TextInput textInput, int previousTextSize) { - forEach(listener -> listener.textSizeChanged(textInput, previousTextSize)); - } - - @Override - public void maximumLengthChanged(TextInput textInput, int previousMaximumLength) { - forEach(listener -> listener.maximumLengthChanged(textInput, previousMaximumLength)); - } - - @Override - public void passwordChanged(TextInput textInput) { - forEach(listener -> listener.passwordChanged(textInput)); - } - - @Override - public void promptChanged(TextInput textInput, String previousPrompt) { - forEach(listener -> listener.promptChanged(textInput, previousPrompt)); - } - - @Override - public void textValidatorChanged(TextInput textInput, Validator previousValidator) { - forEach(listener -> listener.textValidatorChanged(textInput, previousValidator)); - } - - @Override - public void strictValidationChanged(TextInput textInput) { - forEach(listener -> listener.strictValidationChanged(textInput)); - } - - @Override - public void textValidChanged(TextInput textInput) { - forEach(listener -> listener.textValidChanged(textInput)); - } - - @Override - public void editableChanged(TextInput textInput) { - forEach(listener -> listener.editableChanged(textInput)); - } - } - - private static class TextInputContentListenerList extends - ListenerList<TextInputContentListener> implements TextInputContentListener { - @Override - public Vote previewInsertText(TextInput textInput, CharSequence text, int index) { - VoteResult result = new VoteResult(); - - forEach(listener -> result.tally(listener.previewInsertText(textInput, text, index))); - - return result.get(); - } - - @Override - public void insertTextVetoed(TextInput textInput, Vote reason) { - forEach(listener -> listener.insertTextVetoed(textInput, reason)); - } - - @Override - public void textInserted(TextInput textInput, int index, int count) { - forEach(listener -> listener.textInserted(textInput, index, count)); - } - - @Override - public Vote previewRemoveText(TextInput textInput, int index, int count) { - VoteResult result = new VoteResult(); - - forEach(listener -> result.tally(listener.previewRemoveText(textInput, index, count))); - - return result.get(); - } - - @Override - public void removeTextVetoed(TextInput textInput, Vote reason) { - forEach(listener -> listener.removeTextVetoed(textInput, reason)); - } - - @Override - public void textRemoved(TextInput textInput, int index, int count) { - forEach(listener -> listener.textRemoved(textInput, index, count)); - } - - @Override - public void textChanged(TextInput textInput) { - forEach(listener -> listener.textChanged(textInput)); - } - } - - private static class TextInputSelectionListenerList extends - ListenerList<TextInputSelectionListener> implements TextInputSelectionListener { - @Override - public void selectionChanged(TextInput textInput, int previousSelectionStart, - int previousSelectionLength) { - forEach(listener -> listener.selectionChanged(textInput, previousSelectionStart, - previousSelectionLength)); - } - } - - private static class TextInputBindingListenerList extends - ListenerList<TextInputBindingListener> implements TextInputBindingListener { - @Override - public void textKeyChanged(TextInput textInput, String previousTextKey) { - forEach(listener -> listener.textKeyChanged(textInput, previousTextKey)); - } - - @Override - public void textBindTypeChanged(TextInput textInput, BindType previousTextBindType) { - forEach(listener -> listener.textBindTypeChanged(textInput, previousTextBindType)); - } - - @Override - public void textBindMappingChanged(TextInput textInput, - TextBindMapping previousTextBindMapping) { - forEach(listener -> listener.textBindMappingChanged(textInput, previousTextBindMapping)); - } - } - private StringBuilder characters = new StringBuilder(); private AttributedStringCharacterIterator composedText = null; @@ -248,10 +130,10 @@ public class TextInput extends Component private LinkedList<Edit> editHistory = new LinkedList<>(); - private TextInputListenerList textInputListeners = new TextInputListenerList(); - private TextInputContentListenerList textInputContentListeners = new TextInputContentListenerList(); - private TextInputSelectionListenerList textInputSelectionListeners = new TextInputSelectionListenerList(); - private TextInputBindingListenerList textInputBindingListeners = new TextInputBindingListenerList(); + private TextInputListener.List textInputListeners = new TextInputListener.List(); + private TextInputContentListener.List textInputContentListeners = new TextInputContentListener.List(); + private TextInputSelectionListener.List textInputSelectionListeners = new TextInputSelectionListener.List(); + private TextInputBindingListener.List textInputBindingListeners = new TextInputBindingListener.List(); public static final int DEFAULT_TEXT_SIZE = 16; Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputBindingListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputBindingListener.java?rev=1817255&r1=1817254&r2=1817255&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputBindingListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputBindingListener.java Wed Dec 6 01:00:53 2017 @@ -16,6 +16,9 @@ */ package org.apache.pivot.wtk; +import org.apache.pivot.util.ListenerList; + + /** * Text input binding listener interface. */ @@ -41,6 +44,28 @@ public interface TextInputBindingListene } } + /** + * Text input binding listener list. + */ + public static class List extends ListenerList<TextInputBindingListener> + implements TextInputBindingListener { + @Override + public void textKeyChanged(TextInput textInput, String previousTextKey) { + forEach(listener -> listener.textKeyChanged(textInput, previousTextKey)); + } + + @Override + public void textBindTypeChanged(TextInput textInput, BindType previousTextBindType) { + forEach(listener -> listener.textBindTypeChanged(textInput, previousTextBindType)); + } + + @Override + public void textBindMappingChanged(TextInput textInput, + TextInput.TextBindMapping previousTextBindMapping) { + forEach(listener -> listener.textBindMappingChanged(textInput, previousTextBindMapping)); + } + } + /** * Called when a text input's text key has changed. * Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java?rev=1817255&r1=1817254&r2=1817255&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java Wed Dec 6 01:00:53 2017 @@ -16,14 +16,17 @@ */ package org.apache.pivot.wtk; +import org.apache.pivot.util.ListenerList; import org.apache.pivot.util.Vote; +import org.apache.pivot.util.VoteResult; + /** * Text input text listener. */ public interface TextInputContentListener { /** - * Text input text listener adapter. + * Text input content listener adapter. */ public static class Adapter implements TextInputContentListener { @Override @@ -62,6 +65,55 @@ public interface TextInputContentListene } } + /** + * Text input content listener list. + */ + public static class List extends ListenerList<TextInputContentListener> + implements TextInputContentListener { + @Override + public Vote previewInsertText(TextInput textInput, CharSequence text, int index) { + VoteResult result = new VoteResult(); + + forEach(listener -> result.tally(listener.previewInsertText(textInput, text, index))); + + return result.get(); + } + + @Override + public void insertTextVetoed(TextInput textInput, Vote reason) { + forEach(listener -> listener.insertTextVetoed(textInput, reason)); + } + + @Override + public void textInserted(TextInput textInput, int index, int count) { + forEach(listener -> listener.textInserted(textInput, index, count)); + } + + @Override + public Vote previewRemoveText(TextInput textInput, int index, int count) { + VoteResult result = new VoteResult(); + + forEach(listener -> result.tally(listener.previewRemoveText(textInput, index, count))); + + return result.get(); + } + + @Override + public void removeTextVetoed(TextInput textInput, Vote reason) { + forEach(listener -> listener.removeTextVetoed(textInput, reason)); + } + + @Override + public void textRemoved(TextInput textInput, int index, int count) { + forEach(listener -> listener.textRemoved(textInput, index, count)); + } + + @Override + public void textChanged(TextInput textInput) { + forEach(listener -> listener.textChanged(textInput)); + } + } + /** * Called to preview a text insertion. * Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java?rev=1817255&r1=1817254&r2=1817255&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java Wed Dec 6 01:00:53 2017 @@ -16,6 +16,7 @@ */ package org.apache.pivot.wtk; +import org.apache.pivot.util.ListenerList; import org.apache.pivot.wtk.validation.Validator; /** @@ -67,6 +68,51 @@ public interface TextInputListener { } } + /** + * Text input listener list. + */ + public static class List extends ListenerList<TextInputListener> implements TextInputListener { + @Override + public void textSizeChanged(TextInput textInput, int previousTextSize) { + forEach(listener -> listener.textSizeChanged(textInput, previousTextSize)); + } + + @Override + public void maximumLengthChanged(TextInput textInput, int previousMaximumLength) { + forEach(listener -> listener.maximumLengthChanged(textInput, previousMaximumLength)); + } + + @Override + public void passwordChanged(TextInput textInput) { + forEach(listener -> listener.passwordChanged(textInput)); + } + + @Override + public void promptChanged(TextInput textInput, String previousPrompt) { + forEach(listener -> listener.promptChanged(textInput, previousPrompt)); + } + + @Override + public void textValidatorChanged(TextInput textInput, Validator previousValidator) { + forEach(listener -> listener.textValidatorChanged(textInput, previousValidator)); + } + + @Override + public void strictValidationChanged(TextInput textInput) { + forEach(listener -> listener.strictValidationChanged(textInput)); + } + + @Override + public void textValidChanged(TextInput textInput) { + forEach(listener -> listener.textValidChanged(textInput)); + } + + @Override + public void editableChanged(TextInput textInput) { + forEach(listener -> listener.editableChanged(textInput)); + } + } + /** * Called when a text input's text size has changed. * Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputSelectionListener.java URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputSelectionListener.java?rev=1817255&r1=1817254&r2=1817255&view=diff ============================================================================== --- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputSelectionListener.java (original) +++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputSelectionListener.java Wed Dec 6 01:00:53 2017 @@ -16,11 +16,27 @@ */ package org.apache.pivot.wtk; +import org.apache.pivot.util.ListenerList; + + /** * Text input selection listener interface. */ public interface TextInputSelectionListener { /** + * List class. + */ + public static class List extends ListenerList<TextInputSelectionListener> + implements TextInputSelectionListener { + @Override + public void selectionChanged(TextInput textInput, int previousSelectionStart, + int previousSelectionLength) { + forEach(listener -> listener.selectionChanged(textInput, previousSelectionStart, + previousSelectionLength)); + } + } + + /** * Called when a text input's selection state has changed. * * @param textInput The source of the event.