You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2013/10/05 01:45:53 UTC
svn commit: r1529349 [34/44] - in /pivot/trunk:
charts/src/org/apache/pivot/charts/
charts/src/org/apache/pivot/charts/skin/ core/src/org/apache/pivot/beans/
core/src/org/apache/pivot/collections/
core/src/org/apache/pivot/collections/adapter/ core/src...
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java?rev=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea.java Fri Oct 4 23:45:40 2013
@@ -96,8 +96,7 @@ public class TextArea extends Component
int count = text.length();
- if (textArea != null
- && textArea.characterCount + count > textArea.maximumLength) {
+ if (textArea != null && textArea.characterCount + count > textArea.maximumLength) {
throw new IllegalArgumentException("Insertion of text would exceed maximum length.");
}
@@ -131,8 +130,7 @@ public class TextArea extends Component
}
public void removeText(int index, int count) {
- if (index < 0
- || index + count > characters.length()) {
+ if (index < 0 || index + count > characters.length()) {
throw new IndexOutOfBoundsException();
}
@@ -191,29 +189,19 @@ public class TextArea extends Component
/**
* Called when text has been inserted into a paragraph.
- *
- * @param paragraph
- * The source of the event.
- *
- * @param index
- * The index at which the text was inserted.
- *
- * @param count
- * The number of characters that were inserted.
+ *
+ * @param paragraph The source of the event.
+ * @param index The index at which the text was inserted.
+ * @param count The number of characters that were inserted.
*/
public void textInserted(Paragraph paragraph, int index, int count);
/**
* Called when characters have been removed from a paragraph.
- *
- * @param paragraph
- * The source of the event.
- *
- * @param index
- * The index from which the text was removed.
- *
- * @param count
- * The number of characters that were removed.
+ *
+ * @param paragraph The source of the event.
+ * @param index The index from which the text was removed.
+ * @param count The number of characters that were removed.
*/
public void textRemoved(Paragraph paragraph, int index, int count);
}
@@ -222,18 +210,16 @@ public class TextArea extends Component
* Enum representing a scroll direction.
*/
public enum ScrollDirection {
- UP,
- DOWN
+ UP, DOWN
}
/**
- * Text area skin interface. Text area skins are required to implement
- * this.
+ * Text area skin interface. Text area skins are required to implement this.
*/
public interface Skin {
/**
* Returns the insertion point for a given location.
- *
+ *
* @param x
* @param y
*/
@@ -242,7 +228,7 @@ public class TextArea extends Component
/**
* Returns the next insertion point given an x coordinate and a
* character index.
- *
+ *
* @param x
* @param from
* @param direction
@@ -251,15 +237,15 @@ public class TextArea extends Component
/**
* Returns the row index of the character at a given index.
- *
+ *
* @param index
*/
public int getRowAt(int index);
/**
- * Returns the index of the first character in the row containing
- * a given character index.
- *
+ * Returns the index of the first character in the row containing a
+ * given character index.
+ *
* @param index
*/
public int getRowOffset(int index);
@@ -267,7 +253,7 @@ public class TextArea extends Component
/**
* Returns the number of characters in the row containing a given
* character index.
- *
+ *
* @param index
*/
public int getRowLength(int index);
@@ -279,14 +265,14 @@ public class TextArea extends Component
/**
* Returns the bounds of the character at a given index.
- *
+ *
* @param index
*/
public Bounds getCharacterBounds(int index);
/**
- * Returns the current setting of the "tabWidth" style
- * (so "setText" uses the same value as Ctrl-Tab from user).
+ * Returns the current setting of the "tabWidth" style (so "setText"
+ * uses the same value as Ctrl-Tab from user).
*/
public int getTabWidth();
}
@@ -296,17 +282,17 @@ public class TextArea extends Component
*/
public interface TextBindMapping {
/**
- * Converts a value from the bind context to a text representation during a
- * {@link Component#load(Object)} operation.
- *
+ * Converts a value from the bind context to a text representation
+ * during a {@link Component#load(Object)} operation.
+ *
* @param value
*/
public String toString(Object value);
/**
- * Converts a text string to a value to be stored in the bind context during a
- * {@link Component#store(Object)} operation.
- *
+ * Converts a text string to a value to be stored in the bind context
+ * during a {@link Component#store(Object)} operation.
+ *
* @param text
*/
public Object valueOf(String text);
@@ -331,7 +317,8 @@ public class TextArea extends Component
}
if (paragraph.textArea != null) {
- throw new IllegalArgumentException("paragraph is already in use by another text area.");
+ throw new IllegalArgumentException(
+ "paragraph is already in use by another text area.");
}
// Determine insertion count, including terminator character
@@ -377,8 +364,8 @@ public class TextArea extends Component
if (selectionStart != previousSelectionStart
|| selectionLength != previousSelectionLength) {
- textAreaSelectionListeners.selectionChanged(TextArea.this,
- selectionStart, selectionLength);
+ textAreaSelectionListeners.selectionChanged(TextArea.this, selectionStart,
+ selectionLength);
}
}
@@ -388,7 +375,7 @@ public class TextArea extends Component
}
@Override
- public int remove(Paragraph paragraph){
+ public int remove(Paragraph paragraph) {
int index = indexOf(paragraph);
if (index != -1) {
remove(index, 1);
@@ -410,7 +397,8 @@ public class TextArea extends Component
characterCountLocal += paragraph.characters.length() + 1;
}
- // Don't include the implicit final terminator in the character count
+ // Don't include the implicit final terminator in the character
+ // count
if (getLength() == 0) {
characterCountLocal--;
}
@@ -422,8 +410,8 @@ public class TextArea extends Component
// Update selection state
int previousSelectionStart = selectionStart;
int previousSelectionLength = selectionLength;
- selectionStart = (index == paragraphs.getLength()) ?
- TextArea.this.characterCount : paragraphs.get(index).offset;
+ selectionStart = (index == paragraphs.getLength()) ? TextArea.this.characterCount
+ : paragraphs.get(index).offset;
selectionLength = 0;
// Fire change events
@@ -432,8 +420,8 @@ public class TextArea extends Component
if (selectionStart != previousSelectionStart
|| selectionLength != previousSelectionLength) {
- textAreaSelectionListeners.selectionChanged(TextArea.this,
- selectionStart, selectionLength);
+ textAreaSelectionListeners.selectionChanged(TextArea.this, selectionStart,
+ selectionLength);
}
}
@@ -495,8 +483,8 @@ public class TextArea extends Component
}
}
- private static class TextAreaListenerList extends WTKListenerList<TextAreaListener>
- implements TextAreaListener {
+ private static class TextAreaListenerList extends WTKListenerList<TextAreaListener> implements
+ TextAreaListener {
@Override
public void maximumLengthChanged(TextArea textArea, int previousMaximumLength) {
for (TextAreaListener listener : this) {
@@ -512,8 +500,8 @@ public class TextArea extends Component
}
}
- private static class TextAreaContentListenerList extends WTKListenerList<TextAreaContentListener>
- implements TextAreaContentListener {
+ private static class TextAreaContentListenerList extends
+ WTKListenerList<TextAreaContentListener> implements TextAreaContentListener {
@Override
public void paragraphInserted(TextArea textArea, int index) {
for (TextAreaContentListener listener : this) {
@@ -522,7 +510,8 @@ public class TextArea extends Component
}
@Override
- public void paragraphsRemoved(TextArea textArea, int index, Sequence<TextArea.Paragraph> removed) {
+ public void paragraphsRemoved(TextArea textArea, int index,
+ Sequence<TextArea.Paragraph> removed) {
for (TextAreaContentListener listener : this) {
listener.paragraphsRemoved(textArea, index, removed);
}
@@ -536,20 +525,19 @@ public class TextArea extends Component
}
}
- private static class TextAreaSelectionListenerList extends WTKListenerList<TextAreaSelectionListener>
- implements TextAreaSelectionListener {
+ private static class TextAreaSelectionListenerList extends
+ WTKListenerList<TextAreaSelectionListener> implements TextAreaSelectionListener {
@Override
public void selectionChanged(TextArea textArea, int previousSelectionStart,
int previousSelectionLength) {
for (TextAreaSelectionListener listener : this) {
- listener.selectionChanged(textArea, previousSelectionStart,
- previousSelectionLength);
+ listener.selectionChanged(textArea, previousSelectionStart, previousSelectionLength);
}
}
}
- private static class TextAreaBindingListenerList extends WTKListenerList<TextAreaBindingListener>
- implements TextAreaBindingListener {
+ private static class TextAreaBindingListenerList extends
+ WTKListenerList<TextAreaBindingListener> implements TextAreaBindingListener {
@Override
public void textKeyChanged(TextArea textArea, String previousTextKey) {
for (TextAreaBindingListener listener : this) {
@@ -565,7 +553,8 @@ public class TextArea extends Component
}
@Override
- public void textBindMappingChanged(TextArea textArea, TextBindMapping previousTextBindMapping) {
+ public void textBindMappingChanged(TextArea textArea,
+ TextBindMapping previousTextBindMapping) {
for (TextAreaBindingListener listener : this) {
listener.textBindMappingChanged(textArea, previousTextBindMapping);
}
@@ -620,9 +609,8 @@ public class TextArea extends Component
/**
* Returns the text content of the text area.
- *
- * @return
- * A string containing a copy of the text area's text content.
+ *
+ * @return A string containing a copy of the text area's text content.
*/
public String getText() {
return getText(0, getCharacterCount());
@@ -630,20 +618,17 @@ public class TextArea extends Component
/**
* Returns a portion of the text content of the text area.
- *
+ *
* @param beginIndex
* @param endIndex
- *
- * @return
- * A string containing a copy of the text area's text content.
+ * @return A string containing a copy of the text area's text content.
*/
public String getText(int beginIndex, int endIndex) {
if (beginIndex > endIndex) {
throw new IllegalArgumentException();
}
- if (beginIndex < 0
- || endIndex > characterCount) {
+ if (beginIndex < 0 || endIndex > characterCount) {
throw new IndexOutOfBoundsException();
}
@@ -663,8 +648,7 @@ public class TextArea extends Component
// and moving to next paragraph as needed
int i = 0;
while (i < count) {
- if (characterOffset == paragraph.characters.length()
- && i < characterCount) {
+ if (characterOffset == paragraph.characters.length() && i < characterCount) {
textBuilder.append('\n');
paragraph = paragraphs.get(++paragraphIndex);
characterOffset = 0;
@@ -680,7 +664,7 @@ public class TextArea extends Component
/**
* Sets the text content of the text area.
- *
+ *
* @param text
*/
public void setText(String text) {
@@ -728,7 +712,7 @@ public class TextArea extends Component
Paragraph paragraph = new Paragraph();
int tabPosition = 0;
- int tabWidth = ((TextArea.Skin)getSkin()).getTabWidth();
+ int tabWidth = ((TextArea.Skin) getSkin()).getTabWidth();
int c = textReader.read();
while (c != -1) {
@@ -744,13 +728,14 @@ public class TextArea extends Component
int spaces = tabWidth - (tabPosition % tabWidth);
for (int i = 0; i < spaces; i++) {
if (++characterCountLocal > maximumLength) {
- throw new IllegalArgumentException("Text length is greater than maximum length.");
+ throw new IllegalArgumentException(
+ "Text length is greater than maximum length.");
}
paragraph.append(' ');
}
tabPosition += spaces;
} else {
- paragraph.append((char)c);
+ paragraph.append((char) c);
tabPosition++;
}
@@ -788,7 +773,7 @@ public class TextArea extends Component
int characterOffset = index - paragraph.offset;
int tabPosition = characterOffset;
- int tabWidth = ((TextArea.Skin)getSkin()).getTabWidth();
+ int tabWidth = ((TextArea.Skin) getSkin()).getTabWidth();
StringBuilder textBuilder = new StringBuilder();
@@ -799,7 +784,8 @@ public class TextArea extends Component
// Split paragraph at current offset
int count = paragraph.characters.length();
- CharSequence trailingCharacters = paragraph.characters.subSequence(characterOffset, count);
+ CharSequence trailingCharacters = paragraph.characters.subSequence(
+ characterOffset, count);
paragraph.removeText(characterOffset, count - characterOffset);
paragraph.insertText(textBuilder, characterOffset);
@@ -837,8 +823,7 @@ public class TextArea extends Component
}
private void removeText(int index, int count, boolean addToEditHistory) {
- if (index < 0
- || index + count > characterCount) {
+ if (index < 0 || index + count > characterCount) {
throw new IndexOutOfBoundsException();
}
@@ -863,11 +848,14 @@ public class TextArea extends Component
// The removal affects only a single paragraph
beginParagraph.removeText(index - beginParagraph.offset, count);
} else {
- // The removal spans paragraphs; remove any intervening paragraphs and
+ // The removal spans paragraphs; remove any intervening
+ // paragraphs and
// merge the leading and trailing segments
- String leadingText = beginParagraph.characters.substring(0, index - beginParagraph.offset);
+ String leadingText = beginParagraph.characters.substring(0, index
+ - beginParagraph.offset);
endParagraph.removeText(0, (index + count) - endParagraph.offset);
- paragraphSequence.remove(beginParagraphIndex, endParagraphIndex - beginParagraphIndex);
+ paragraphSequence.remove(beginParagraphIndex, endParagraphIndex
+ - beginParagraphIndex);
endParagraph.insertText(leadingText, 0);
}
}
@@ -891,7 +879,7 @@ public class TextArea extends Component
/**
* Returns the index of the paragraph containing a given character index.
- *
+ *
* @param index
*/
public int getParagraphAt(int index) {
@@ -909,7 +897,7 @@ public class TextArea extends Component
/**
* Returns the character at a given index.
- *
+ *
* @param index
*/
public char getCharacterAt(int index) {
@@ -920,8 +908,8 @@ public class TextArea extends Component
int characterOffset = index - paragraph.offset;
- return (characterOffset == paragraph.characters.length()) ?
- '\n' : paragraph.characters.charAt(characterOffset);
+ return (characterOffset == paragraph.characters.length()) ? '\n'
+ : paragraph.characters.charAt(characterOffset);
}
/**
@@ -933,8 +921,8 @@ public class TextArea extends Component
}
/**
- * Places any selected text on the clipboard and deletes it from
- * the text input.
+ * Places any selected text on the clipboard and deletes it from the text
+ * input.
*/
public void cut() {
copy();
@@ -961,13 +949,12 @@ public class TextArea extends Component
public void paste() {
Manifest clipboardContent = Clipboard.getContent();
- if (clipboardContent != null
- && clipboardContent.containsText()) {
+ if (clipboardContent != null && clipboardContent.containsText()) {
// Paste the string representation of the content
String text = null;
try {
text = clipboardContent.getText();
- } catch(IOException exception) {
+ } catch (IOException exception) {
// No-op
}
@@ -1000,9 +987,8 @@ public class TextArea extends Component
/**
* Returns the starting index of the selection.
- *
- * @return
- * The starting index of the selection.
+ *
+ * @return The starting index of the selection.
*/
public int getSelectionStart() {
return selectionStart;
@@ -1010,9 +996,8 @@ public class TextArea extends Component
/**
* Returns the length of the selection.
- *
- * @return
- * The length of the selection; may be <tt>0</tt>.
+ *
+ * @return The length of the selection; may be <tt>0</tt>.
*/
public int getSelectionLength() {
return selectionLength;
@@ -1020,41 +1005,35 @@ public class TextArea extends Component
/**
* Returns a span representing the current selection.
- *
- * @return
- * A span containing the current selection. Both start and end points are
- * inclusive. Returns <tt>null</tt> if the selection is empty.
+ *
+ * @return A span containing the current selection. Both start and end
+ * points are inclusive. Returns <tt>null</tt> if the selection is empty.
*/
public Span getSelection() {
- return (selectionLength == 0) ? null : new Span(selectionStart,
- selectionStart + selectionLength - 1);
+ return (selectionLength == 0) ? null : new Span(selectionStart, selectionStart
+ + selectionLength - 1);
}
/**
* Sets the selection. The sum of the selection start and length must be
* less than the length of the text area's content.
- *
- * @param selectionStart
- * The starting index of the selection.
- *
- * @param selectionLength
- * The length of the selection.
+ *
+ * @param selectionStart The starting index of the selection.
+ * @param selectionLength The length of the selection.
*/
public void setSelection(int selectionStart, int selectionLength) {
if (selectionLength < 0) {
throw new IllegalArgumentException("selectionLength is negative.");
}
- if (selectionStart < 0
- || selectionStart + selectionLength > characterCount) {
+ if (selectionStart < 0 || selectionStart + selectionLength > characterCount) {
throw new IndexOutOfBoundsException();
}
int previousSelectionStart = this.selectionStart;
int previousSelectionLength = this.selectionLength;
- if (previousSelectionStart != selectionStart
- || previousSelectionLength != selectionLength) {
+ if (previousSelectionStart != selectionStart || previousSelectionLength != selectionLength) {
this.selectionStart = selectionStart;
this.selectionLength = selectionLength;
@@ -1065,9 +1044,8 @@ public class TextArea extends Component
/**
* Sets the selection.
- *
+ *
* @param selection
- *
* @see #setSelection(int, int)
*/
public final void setSelection(Span selection) {
@@ -1075,7 +1053,7 @@ public class TextArea extends Component
throw new IllegalArgumentException("selection is null.");
}
- setSelection(Math.min(selection.start, selection.end), (int)selection.getLength());
+ setSelection(Math.min(selection.start, selection.end), (int) selection.getLength());
}
/**
@@ -1094,9 +1072,8 @@ public class TextArea extends Component
/**
* Returns the selected text.
- *
- * @return
- * A string containing a copy of the selected text.
+ *
+ * @return A string containing a copy of the selected text.
*/
public String getSelectedText() {
return getText(selectionStart, selectionStart + selectionLength);
@@ -1104,9 +1081,8 @@ public class TextArea extends Component
/**
* Returns the maximum length of the text area's text content.
- *
- * @return
- * The maximum length of the text area's text content.
+ *
+ * @return The maximum length of the text area's text content.
*/
public int getMaximumLength() {
return maximumLength;
@@ -1114,9 +1090,8 @@ public class TextArea extends Component
/**
* Sets the maximum length of the text area's text content.
- *
- * @param maximumLength
- * The maximum length of the text area's text content.
+ *
+ * @param maximumLength The maximum length of the text area's text content.
*/
public void setMaximumLength(int maximumLength) {
if (maximumLength < 0) {
@@ -1147,7 +1122,7 @@ public class TextArea extends Component
/**
* Sets the text area's editable flag.
- *
+ *
* @param editable
*/
public void setEditable(boolean editable) {
@@ -1166,9 +1141,8 @@ public class TextArea extends Component
/**
* Returns the text area's text key.
- *
- * @return
- * The text key, or <tt>null</tt> if no text key is set.
+ *
+ * @return The text key, or <tt>null</tt> if no text key is set.
*/
public String getTextKey() {
return textKey;
@@ -1176,9 +1150,8 @@ public class TextArea extends Component
/**
* Sets the text area's text key.
- *
- * @param textKey
- * The text key, or <tt>null</tt> to clear the binding.
+ *
+ * @param textKey The text key, or <tt>null</tt> to clear the binding.
*/
public void setTextKey(String textKey) {
String previousTextKey = this.textKey;
@@ -1221,9 +1194,7 @@ public class TextArea extends Component
@Override
public void load(Object context) {
- if (textKey != null
- && JSON.containsKey(context, textKey)
- && textBindType != BindType.STORE) {
+ if (textKey != null && JSON.containsKey(context, textKey) && textBindType != BindType.STORE) {
Object value = JSON.get(context, textKey);
if (textBindMapping == null) {
@@ -1232,17 +1203,16 @@ public class TextArea extends Component
value = textBindMapping.toString(value);
}
- setText((String)value);
+ setText((String) value);
}
}
@Override
public void store(Object context) {
- if (textKey != null
- && textBindType != BindType.LOAD) {
+ if (textKey != null && textBindType != BindType.LOAD) {
String text = getText();
- JSON.put(context, textKey, (textBindMapping == null) ?
- text : textBindMapping.valueOf(text));
+ JSON.put(context, textKey,
+ (textBindMapping == null) ? text : textBindMapping.valueOf(text));
}
}
@@ -1258,57 +1228,57 @@ public class TextArea extends Component
}
/**
- * Sets whether tab characters (<code>\t</code>) are expanded to
- * an appropriate number of spaces during {@link #setText} and
+ * Sets whether tab characters (<code>\t</code>) are expanded to an
+ * appropriate number of spaces during {@link #setText} and
* {@link #insertText} operations.
- * @param expandTabs <code>true</code> to replace tab characters
- * with space characters (depending on the
- * setting of the {@link TextArea.Skin#getTabWidth}
- * value) or <code>false</code> to leave tabs alone.
- * Note: this only affects tabs encountered during
- * program operations; tabs entered via the keyboard
- * by the user are always expanded, regardless of
- * this setting.
+ *
+ * @param expandTabs <code>true</code> to replace tab characters with space
+ * characters (depending on the setting of the
+ * {@link TextArea.Skin#getTabWidth} value) or <code>false</code> to leave
+ * tabs alone. Note: this only affects tabs encountered during program
+ * operations; tabs entered via the keyboard by the user are always
+ * expanded, regardless of this setting.
*/
public void setExpandTabs(boolean expandTabs) {
this.expandTabs = expandTabs;
}
public int getInsertionPoint(int x, int y) {
- TextArea.Skin textAreaSkin = (TextArea.Skin)getSkin();
+ TextArea.Skin textAreaSkin = (TextArea.Skin) getSkin();
return textAreaSkin.getInsertionPoint(x, y);
}
public int getNextInsertionPoint(int x, int from, ScrollDirection direction) {
- TextArea.Skin textAreaSkin = (TextArea.Skin)getSkin();
+ TextArea.Skin textAreaSkin = (TextArea.Skin) getSkin();
return textAreaSkin.getNextInsertionPoint(x, from, direction);
}
public int getRowAt(int index) {
- TextArea.Skin textAreaSkin = (TextArea.Skin)getSkin();
+ TextArea.Skin textAreaSkin = (TextArea.Skin) getSkin();
return textAreaSkin.getRowAt(index);
}
public int getRowOffset(int index) {
- TextArea.Skin textAreaSkin = (TextArea.Skin)getSkin();
+ TextArea.Skin textAreaSkin = (TextArea.Skin) getSkin();
return textAreaSkin.getRowOffset(index);
}
public int getRowLength(int index) {
- TextArea.Skin textAreaSkin = (TextArea.Skin)getSkin();
+ TextArea.Skin textAreaSkin = (TextArea.Skin) getSkin();
return textAreaSkin.getRowLength(index);
}
public int getRowCount() {
- TextArea.Skin textAreaSkin = (TextArea.Skin)getSkin();
+ TextArea.Skin textAreaSkin = (TextArea.Skin) getSkin();
return textAreaSkin.getRowCount();
}
public Bounds getCharacterBounds(int index) {
// We need to validate in case we get called from user-code after
- // a user-code initiated modification, but before another layout has run.
+ // a user-code initiated modification, but before another layout has
+ // run.
validate();
- TextArea.Skin textAreaSkin = (TextArea.Skin)getSkin();
+ TextArea.Skin textAreaSkin = (TextArea.Skin) getSkin();
return textAreaSkin.getCharacterBounds(index);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaBindingListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaBindingListener.java?rev=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaBindingListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaBindingListener.java Fri Oct 4 23:45:40 2013
@@ -35,14 +35,15 @@ public interface TextAreaBindingListener
}
@Override
- public void textBindMappingChanged(TextArea textArea, TextArea.TextBindMapping previousTextBindMapping) {
+ public void textBindMappingChanged(TextArea textArea,
+ TextArea.TextBindMapping previousTextBindMapping) {
// empty block
}
}
/**
* Called when a text area's text key has changed.
- *
+ *
* @param textArea
* @param previousTextKey
*/
@@ -50,7 +51,7 @@ public interface TextAreaBindingListener
/**
* Called when a text area's text bind type has changed.
- *
+ *
* @param textArea
* @param previousTextBindType
*/
@@ -58,9 +59,10 @@ public interface TextAreaBindingListener
/**
* Called when a text area's text bind mapping has changed.
- *
+ *
* @param textArea
* @param previousTextBindMapping
*/
- public void textBindMappingChanged(TextArea textArea, TextArea.TextBindMapping previousTextBindMapping);
+ public void textBindMappingChanged(TextArea textArea,
+ TextArea.TextBindMapping previousTextBindMapping);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaContentListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaContentListener.java?rev=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaContentListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaContentListener.java Fri Oct 4 23:45:40 2013
@@ -32,7 +32,8 @@ public interface TextAreaContentListener
}
@Override
- public void paragraphsRemoved(TextArea textArea, int index, Sequence<TextArea.Paragraph> removed) {
+ public void paragraphsRemoved(TextArea textArea, int index,
+ Sequence<TextArea.Paragraph> removed) {
// empty block
}
@@ -45,35 +46,26 @@ public interface TextAreaContentListener
/**
* Called when a paragraph has been inserted into a text area's paragraph
* sequence.
- *
- * @param textArea
- * The source of the event.
- *
- * @param index
- * The index at which the paragraph was inserted.
+ *
+ * @param textArea The source of the event.
+ * @param index The index at which the paragraph was inserted.
*/
public void paragraphInserted(TextArea textArea, int index);
/**
* Called when paragraphs have been removed from a text area's paragraph
* sequence.
- *
- * @param textArea
- * The source of the event.
- *
- * @param index
- * The starting index from which the paragraphs were removed.
- *
- * @param removed
- * The paragraphs that were removed.
+ *
+ * @param textArea The source of the event.
+ * @param index The starting index from which the paragraphs were removed.
+ * @param removed The paragraphs that were removed.
*/
public void paragraphsRemoved(TextArea textArea, int index, Sequence<TextArea.Paragraph> removed);
/**
* Called when a text area's text has changed.
- *
- * @param textArea
- * The source of the event.
+ *
+ * @param textArea The source of the event.
*/
public void textChanged(TextArea textArea);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaListener.java?rev=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaListener.java Fri Oct 4 23:45:40 2013
@@ -37,7 +37,7 @@ public interface TextAreaListener {
/**
* Called when a text area's maximum length has changed.
- *
+ *
* @param textArea
* @param previousMaximumLength
*/
@@ -45,7 +45,7 @@ public interface TextAreaListener {
/**
* Called when a text area's editable state has changed.
- *
+ *
* @param textArea
*/
public void editableChanged(TextArea textArea);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaSelectionListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaSelectionListener.java?rev=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaSelectionListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextAreaSelectionListener.java Fri Oct 4 23:45:40 2013
@@ -22,7 +22,7 @@ package org.apache.pivot.wtk;
public interface TextAreaSelectionListener {
/**
* Called when a text area's selection state has changed.
- *
+ *
* @param textArea
* @param previousSelectionStart
* @param previousSelectionLength
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextDecoration.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextDecoration.java?rev=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextDecoration.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextDecoration.java Fri Oct 4 23:45:40 2013
@@ -20,6 +20,5 @@ package org.apache.pivot.wtk;
* Enumeration representing text decoration styles.
*/
public enum TextDecoration {
- UNDERLINE,
- STRIKETHROUGH
+ UNDERLINE, STRIKETHROUGH
}
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=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java Fri Oct 4 23:45:40 2013
@@ -36,14 +36,14 @@ public class TextInput extends Component
public interface Skin {
/**
* Returns the insertion point for a given location.
- *
+ *
* @param x
*/
public int getInsertionPoint(int x);
/**
* Returns the bounds of the character at a given index.
- *
+ *
* @param index
*/
public Bounds getCharacterBounds(int index);
@@ -54,17 +54,17 @@ public class TextInput extends Component
*/
public interface TextBindMapping {
/**
- * Converts a value from the bind context to a text representation during a
- * {@link Component#load(Object)} operation.
- *
+ * Converts a value from the bind context to a text representation
+ * during a {@link Component#load(Object)} operation.
+ *
* @param value
*/
public String toString(Object value);
/**
- * Converts a text string to a value to be stored in the bind context during a
- * {@link Component#store(Object)} operation.
- *
+ * Converts a text string to a value to be stored in the bind context
+ * during a {@link Component#store(Object)} operation.
+ *
* @param text
*/
public Object valueOf(String text);
@@ -104,8 +104,8 @@ public class TextInput extends Component
}
}
- private static class TextInputListenerList extends WTKListenerList<TextInputListener>
- implements TextInputListener {
+ private static class TextInputListenerList extends WTKListenerList<TextInputListener> implements
+ TextInputListener {
@Override
public void textSizeChanged(TextInput textInput, int previousTextSize) {
for (TextInputListener listener : this) {
@@ -163,8 +163,8 @@ public class TextInput extends Component
}
}
- private static class TextInputContentListenerList extends WTKListenerList<TextInputContentListener>
- implements TextInputContentListener {
+ private static class TextInputContentListenerList extends
+ WTKListenerList<TextInputContentListener> implements TextInputContentListener {
@Override
public Vote previewInsertText(TextInput textInput, CharSequence text, int index) {
Vote vote = Vote.APPROVE;
@@ -223,20 +223,20 @@ public class TextInput extends Component
}
}
- private static class TextInputSelectionListenerList extends WTKListenerList<TextInputSelectionListener>
- implements TextInputSelectionListener {
+ private static class TextInputSelectionListenerList extends
+ WTKListenerList<TextInputSelectionListener> implements TextInputSelectionListener {
@Override
public void selectionChanged(TextInput textInput, int previousSelectionStart,
int previousSelectionLength) {
for (TextInputSelectionListener listener : this) {
- listener.selectionChanged(textInput,
- previousSelectionStart, previousSelectionLength);
+ listener.selectionChanged(textInput, previousSelectionStart,
+ previousSelectionLength);
}
}
}
- private static class TextInputBindingListenerList extends WTKListenerList<TextInputBindingListener>
- implements TextInputBindingListener {
+ private static class TextInputBindingListenerList extends
+ WTKListenerList<TextInputBindingListener> implements TextInputBindingListener {
@Override
public void textKeyChanged(TextInput textInput, String previousTextKey) {
for (TextInputBindingListener listener : this) {
@@ -252,7 +252,8 @@ public class TextInput extends Component
}
@Override
- public void textBindMappingChanged(TextInput textInput, TextBindMapping previousTextBindMapping) {
+ public void textBindMappingChanged(TextInput textInput,
+ TextBindMapping previousTextBindMapping) {
for (TextInputBindingListener listener : this) {
listener.textBindMappingChanged(textInput, previousTextBindMapping);
}
@@ -305,9 +306,8 @@ public class TextInput extends Component
/**
* Returns the text content of the text input.
- *
- * @return
- * A string containing a copy of the text input's text content.
+ *
+ * @return A string containing a copy of the text input's text content.
*/
public String getText() {
return getText(0, getCharacterCount());
@@ -315,12 +315,10 @@ public class TextInput extends Component
/**
* Returns a portion of the text content of the text input.
- *
+ *
* @param beginIndex
* @param endIndex
- *
- * @return
- * A string containing a copy of the text area's text content.
+ * @return A string containing a copy of the text area's text content.
*/
public String getText(int beginIndex, int endIndex) {
return characters.substring(beginIndex, endIndex);
@@ -357,8 +355,7 @@ public class TextInput extends Component
textInputListeners.textValidChanged(this);
}
- if (selectionStart != previousSelectionStart
- || selectionLength != previousSelectionLength) {
+ if (selectionStart != previousSelectionStart || selectionLength != previousSelectionLength) {
textInputSelectionListeners.selectionChanged(this, selectionStart, selectionLength);
}
}
@@ -408,7 +405,8 @@ public class TextInput extends Component
if (selectionStart != previousSelectionStart
|| selectionLength != previousSelectionLength) {
- textInputSelectionListeners.selectionChanged(this, selectionStart, selectionLength);
+ textInputSelectionListeners.selectionChanged(this, selectionStart,
+ selectionLength);
}
} else {
textInputContentListeners.insertTextVetoed(this, vote);
@@ -453,7 +451,8 @@ public class TextInput extends Component
if (selectionStart != previousSelectionStart
|| selectionLength != previousSelectionLength) {
- textInputSelectionListeners.selectionChanged(this, selectionStart, selectionLength);
+ textInputSelectionListeners.selectionChanged(this, selectionStart,
+ selectionLength);
}
} else {
textInputContentListeners.removeTextVetoed(this, vote);
@@ -470,7 +469,7 @@ public class TextInput extends Component
/**
* Returns the character at a given index.
- *
+ *
* @param index
*/
public char getCharacterAt(int index) {
@@ -485,8 +484,8 @@ public class TextInput extends Component
}
/**
- * Places any selected text on the clipboard and deletes it from
- * the text input.
+ * Places any selected text on the clipboard and deletes it from the text
+ * input.
*/
public void cut() {
copy();
@@ -513,13 +512,12 @@ public class TextInput extends Component
public void paste() {
Manifest clipboardContent = Clipboard.getContent();
- if (clipboardContent != null
- && clipboardContent.containsText()) {
+ if (clipboardContent != null && clipboardContent.containsText()) {
// Paste the string representation of the content
String text = null;
try {
text = clipboardContent.getText();
- } catch(IOException exception) {
+ } catch (IOException exception) {
// No-op
}
@@ -552,9 +550,8 @@ public class TextInput extends Component
/**
* Returns the starting index of the selection.
- *
- * @return
- * The starting index of the selection.
+ *
+ * @return The starting index of the selection.
*/
public int getSelectionStart() {
return selectionStart;
@@ -562,9 +559,8 @@ public class TextInput extends Component
/**
* Returns the length of the selection.
- *
- * @return
- * The length of the selection; may be <tt>0</tt>.
+ *
+ * @return The length of the selection; may be <tt>0</tt>.
*/
public int getSelectionLength() {
return selectionLength;
@@ -572,41 +568,36 @@ public class TextInput extends Component
/**
* Returns a span representing the current selection.
- *
- * @return
- * A span containing the current selection. Both start and end points are
- * inclusive. Returns <tt>null</tt> if the selection length is <tt>0</tt>.
+ *
+ * @return A span containing the current selection. Both start and end
+ * points are inclusive. Returns <tt>null</tt> if the selection length is
+ * <tt>0</tt>.
*/
public Span getSelection() {
- return (selectionLength == 0) ? null : new Span(selectionStart,
- selectionStart + selectionLength - 1);
+ return (selectionLength == 0) ? null : new Span(selectionStart, selectionStart
+ + selectionLength - 1);
}
/**
* Sets the selection. The sum of the selection start and length must be
* less than the length of the text input's content.
- *
- * @param selectionStart
- * The starting index of the selection.
- *
- * @param selectionLength
- * The length of the selection.
+ *
+ * @param selectionStart The starting index of the selection.
+ * @param selectionLength The length of the selection.
*/
public void setSelection(int selectionStart, int selectionLength) {
if (selectionLength < 0) {
throw new IllegalArgumentException("selectionLength is negative.");
}
- if (selectionStart < 0
- || selectionStart + selectionLength > characters.length()) {
+ if (selectionStart < 0 || selectionStart + selectionLength > characters.length()) {
throw new IndexOutOfBoundsException();
}
int previousSelectionStart = this.selectionStart;
int previousSelectionLength = this.selectionLength;
- if (previousSelectionStart != selectionStart
- || previousSelectionLength != selectionLength) {
+ if (previousSelectionStart != selectionStart || previousSelectionLength != selectionLength) {
this.selectionStart = selectionStart;
this.selectionLength = selectionLength;
@@ -617,9 +608,8 @@ public class TextInput extends Component
/**
* Sets the selection.
- *
+ *
* @param selection
- *
* @see #setSelection(int, int)
*/
public final void setSelection(Span selection) {
@@ -627,7 +617,7 @@ public class TextInput extends Component
throw new IllegalArgumentException("selection is null.");
}
- setSelection(Math.min(selection.start, selection.end), (int)selection.getLength());
+ setSelection(Math.min(selection.start, selection.end), (int) selection.getLength());
}
/**
@@ -646,9 +636,8 @@ public class TextInput extends Component
/**
* Returns the currently selected text.
- *
- * @return
- * A new string containing a copy of the text in the selected range.
+ *
+ * @return A new string containing a copy of the text in the selected range.
*/
public String getSelectedText() {
return getText(selectionStart, selectionStart + selectionLength);
@@ -656,9 +645,8 @@ public class TextInput extends Component
/**
* Returns the text size.
- *
- * @return
- * The number of characters to display in the text input.
+ *
+ * @return The number of characters to display in the text input.
*/
public int getTextSize() {
return textSize;
@@ -666,9 +654,8 @@ public class TextInput extends Component
/**
* Sets the text size.
- *
- * @param textSize
- * The number of characters to display in the text input.
+ *
+ * @param textSize The number of characters to display in the text input.
*/
public void setTextSize(int textSize) {
if (textSize < 0) {
@@ -685,9 +672,8 @@ public class TextInput extends Component
/**
* Returns the maximum length of the text input's text content.
- *
- * @return
- * The maximum length of the text input's text content.
+ *
+ * @return The maximum length of the text input's text content.
*/
public int getMaximumLength() {
return maximumLength;
@@ -695,9 +681,8 @@ public class TextInput extends Component
/**
* Sets the maximum length of the text input's text content.
- *
- * @param maximumLength
- * The maximum length of the text input's text content.
+ *
+ * @param maximumLength The maximum length of the text input's text content.
*/
public void setMaximumLength(int maximumLength) {
if (maximumLength < 0) {
@@ -709,7 +694,8 @@ public class TextInput extends Component
if (previousMaximumLength != maximumLength) {
this.maximumLength = maximumLength;
- // Truncate the text, if necessary (do not allow listeners to vote on this change)
+ // Truncate the text, if necessary (do not allow listeners to vote
+ // on this change)
int length = characters.length();
if (length > maximumLength) {
@@ -725,9 +711,8 @@ public class TextInput extends Component
/**
* Returns the password flag.
- *
- * @return
- * <tt>true</tt> if this is a password text input; <tt>false</tt>,
+ *
+ * @return <tt>true</tt> if this is a password text input; <tt>false</tt>,
* otherwise.
*/
public boolean isPassword() {
@@ -737,10 +722,9 @@ public class TextInput extends Component
/**
* Sets or clears the password flag. If the password flag is set, the text
* input will visually mask its contents.
- *
- * @param password
- * <tt>true</tt> if this is a password text input; <tt>false</tt>,
- * otherwise.
+ *
+ * @param password <tt>true</tt> if this is a password text input;
+ * <tt>false</tt>, otherwise.
*/
public void setPassword(boolean password) {
if (this.password != password) {
@@ -753,29 +737,27 @@ public class TextInput extends Component
* Returns the text input's prompt.
*/
public String getPrompt() {
- return prompt;
+ return prompt;
}
/**
* Sets the text input's prompt.
- *
- * @param prompt
- * The prompt text, or <tt>null</tt> for no prompt.
+ *
+ * @param prompt The prompt text, or <tt>null</tt> for no prompt.
*/
public void setPrompt(String prompt) {
- String previousPrompt = this.prompt;
+ String previousPrompt = this.prompt;
- if (previousPrompt != prompt) {
- this.prompt = prompt;
- textInputListeners.promptChanged(this, previousPrompt);
- }
+ if (previousPrompt != prompt) {
+ this.prompt = prompt;
+ textInputListeners.promptChanged(this, previousPrompt);
+ }
}
/**
* Returns the text input's text key.
- *
- * @return
- * The text key, or <tt>null</tt> if no text key is set.
+ *
+ * @return The text key, or <tt>null</tt> if no text key is set.
*/
public String getTextKey() {
return textKey;
@@ -783,9 +765,8 @@ public class TextInput extends Component
/**
* Sets the text input's text key.
- *
- * @param textKey
- * The text key, or <tt>null</tt> to clear the binding.
+ *
+ * @param textKey The text key, or <tt>null</tt> to clear the binding.
*/
public void setTextKey(String textKey) {
String previousTextKey = this.textKey;
@@ -828,9 +809,7 @@ public class TextInput extends Component
@Override
public void load(Object context) {
- if (textKey != null
- && JSON.containsKey(context, textKey)
- && textBindType != BindType.STORE) {
+ if (textKey != null && JSON.containsKey(context, textKey) && textBindType != BindType.STORE) {
Object value = JSON.get(context, textKey);
if (textBindMapping == null) {
@@ -839,17 +818,16 @@ public class TextInput extends Component
value = textBindMapping.toString(value);
}
- setText((String)value);
+ setText((String) value);
}
}
@Override
public void store(Object context) {
- if (textKey != null
- && textBindType != BindType.LOAD) {
+ if (textKey != null && textBindType != BindType.LOAD) {
String text = getText();
- JSON.put(context, textKey, (textBindMapping == null) ?
- text : textBindMapping.valueOf(text));
+ JSON.put(context, textKey,
+ (textBindMapping == null) ? text : textBindMapping.valueOf(text));
}
}
@@ -861,12 +839,12 @@ public class TextInput extends Component
}
public int getInsertionPoint(int x) {
- TextInput.Skin textInputSkin = (TextInput.Skin)getSkin();
+ TextInput.Skin textInputSkin = (TextInput.Skin) getSkin();
return textInputSkin.getInsertionPoint(x);
}
public Bounds getCharacterBounds(int index) {
- TextInput.Skin textInputSkin = (TextInput.Skin)getSkin();
+ TextInput.Skin textInputSkin = (TextInput.Skin) getSkin();
return textInputSkin.getCharacterBounds(index);
}
@@ -879,9 +857,9 @@ public class TextInput extends Component
/**
* Sets the validator associated with this text input.
- *
- * @param validator
- * The validator to use, or <tt>null</tt> to use no validator.
+ *
+ * @param validator The validator to use, or <tt>null</tt> to use no
+ * validator.
*/
public void setValidator(Validator validator) {
Validator previousValidator = this.validator;
@@ -912,9 +890,9 @@ public class TextInput extends Component
}
/**
- * Sets the text input's strict validation flag. When enabled, only valid text will be
- * accepted by the text input.
- *
+ * Sets the text input's strict validation flag. When enabled, only valid
+ * text will be accepted by the text input.
+ *
* @param strictValidation
*/
public void setStrictValidation(boolean strictValidation) {
@@ -927,9 +905,8 @@ public class TextInput extends Component
/**
* Reports whether this text input's text is currently valid as defined by
* its validator.
- *
- * @return
- * <tt>true</tt> if the text is valid or no validator is installed;
+ *
+ * @return <tt>true</tt> if the text is valid or no validator is installed;
* <tt>false</tt>, otherwise.
*/
public boolean isTextValid() {
@@ -945,7 +922,7 @@ public class TextInput extends Component
/**
* Sets the text area's editable flag.
- *
+ *
* @param editable
*/
public void setEditable(boolean editable) {
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=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputBindingListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputBindingListener.java Fri Oct 4 23:45:40 2013
@@ -35,14 +35,15 @@ public interface TextInputBindingListene
}
@Override
- public void textBindMappingChanged(TextInput textInput, TextInput.TextBindMapping previousTextBindMapping) {
+ public void textBindMappingChanged(TextInput textInput,
+ TextInput.TextBindMapping previousTextBindMapping) {
// empty block
}
}
/**
* Called when a text input's text key has changed.
- *
+ *
* @param textInput
* @param previousTextKey
*/
@@ -50,7 +51,7 @@ public interface TextInputBindingListene
/**
* Called when a text input's text bind type has changed.
- *
+ *
* @param textInput
* @param previousTextBindType
*/
@@ -58,9 +59,10 @@ public interface TextInputBindingListene
/**
* Called when a text input's text bind mapping has changed.
- *
+ *
* @param textInput
* @param previousTextBindMapping
*/
- public void textBindMappingChanged(TextInput textInput, TextInput.TextBindMapping previousTextBindMapping);
+ public void textBindMappingChanged(TextInput textInput,
+ TextInput.TextBindMapping previousTextBindMapping);
}
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=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java Fri Oct 4 23:45:40 2013
@@ -64,84 +64,59 @@ public interface TextInputContentListene
/**
* Called to preview a text insertion.
- *
- * @param textInput
- * The source of the event.
- *
- * @param text
- * The text that will be inserted.
- *
- * @param index
- * The index at which the text will be inserted.
+ *
+ * @param textInput The source of the event.
+ * @param text The text that will be inserted.
+ * @param index The index at which the text will be inserted.
*/
public Vote previewInsertText(TextInput textInput, CharSequence text, int index);
/**
* Called when a text insertion has been vetoed.
- *
- * @param textInput
- * The source of the event.
- *
- * @param reason
- * The reason the event was vetoed.
+ *
+ * @param textInput The source of the event.
+ * @param reason The reason the event was vetoed.
*/
public void insertTextVetoed(TextInput textInput, Vote reason);
/**
* Called when text has been inserted into a text input.
- *
- * @param textInput
- * The source of the event.
- *
- * @param index
- * The index at which the text was inserted.
- *
- * @param count
- * The number of characters that were inserted.
+ *
+ * @param textInput The source of the event.
+ * @param index The index at which the text was inserted.
+ * @param count The number of characters that were inserted.
*/
public void textInserted(TextInput textInput, int index, int count);
/**
* Called to preview a text removal.
- *
- * @param textInput
- * The source of the event.
- *
- * @param index
- * The starting index from which the text will be removed.
+ *
+ * @param textInput The source of the event.
+ * @param index The starting index from which the text will be removed.
*/
public Vote previewRemoveText(TextInput textInput, int index, int count);
/**
* Called when a text removal has been vetoed.
- *
- * @param textInput
- * The source of the event.
- *
- * @param reason
- * The reason the event was vetoed.
+ *
+ * @param textInput The source of the event.
+ * @param reason The reason the event was vetoed.
*/
public void removeTextVetoed(TextInput textInput, Vote reason);
/**
* Called when text has been removed from a text input.
- *
- * @param textInput
- * The source of the event.
- *
- * @param index
- * The index from which the text was removed.
- *
- * @param count
- * The number of characters that were removed.
+ *
+ * @param textInput The source of the event.
+ * @param index The index from which the text was removed.
+ * @param count The number of characters that were removed.
*/
public void textRemoved(TextInput textInput, int index, int count);
/**
* Called when a text input's text has changed.
- *
- * @param textInput
- * The source of the event.
+ *
+ * @param textInput The source of the event.
*/
public void textChanged(TextInput textInput);
}
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=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputListener.java Fri Oct 4 23:45:40 2013
@@ -69,7 +69,7 @@ public interface TextInputListener {
/**
* Called when a text input's text size has changed.
- *
+ *
* @param textInput
* @param previousTextSize
*/
@@ -77,7 +77,7 @@ public interface TextInputListener {
/**
* Called when a text input's maximum length has changed.
- *
+ *
* @param textInput
* @param previousMaximumLength
*/
@@ -85,14 +85,14 @@ public interface TextInputListener {
/**
* Called when a text input's password flag has changed.
- *
+ *
* @param textInput
*/
public void passwordChanged(TextInput textInput);
/**
* Called when a text input's prompt has changed.
- *
+ *
* @param textInput
* @param previousPrompt
*/
@@ -100,7 +100,7 @@ public interface TextInputListener {
/**
* Called when the validator changes.
- *
+ *
* @param textInput
* @param previousValidator
*/
@@ -108,21 +108,21 @@ public interface TextInputListener {
/**
* Called when a text input's strict validation flag has changed.
- *
+ *
* @param textInput
*/
public void strictValidationChanged(TextInput textInput);
/**
* Called when the text changes validity.
- *
+ *
* @param textInput
*/
public void textValidChanged(TextInput textInput);
/**
* Called when the editable state has changed.
- *
+ *
* @param textInput
*/
public void editableChanged(TextInput textInput);
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=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputSelectionListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputSelectionListener.java Fri Oct 4 23:45:40 2013
@@ -22,17 +22,13 @@ package org.apache.pivot.wtk;
public interface TextInputSelectionListener {
/**
* Called when a text input's selection state has changed.
- *
- * @param textInput
- * The source of the event.
- *
- * @param previousSelectionStart
- * If the selection changed directly, the previous selection start index.
- * Otherwise, the current selection start index.
- *
- * @param previousSelectionLength
- * If the selection changed directly, the previous selection length.
- * Otherwise, the current selection length.
+ *
+ * @param textInput The source of the event.
+ * @param previousSelectionStart If the selection changed directly, the
+ * previous selection start index. Otherwise, the current selection start
+ * index.
+ * @param previousSelectionLength If the selection changed directly, the
+ * previous selection length. Otherwise, the current selection length.
*/
public void selectionChanged(TextInput textInput, int previousSelectionStart,
int previousSelectionLength);
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPane.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPane.java?rev=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPane.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPane.java Fri Oct 4 23:45:40 2013
@@ -45,64 +45,55 @@ public class TextPane extends Container
* Enum representing a scroll direction.
*/
public enum ScrollDirection {
- UP,
- DOWN
+ UP, DOWN
}
/**
- * Text pane skin interface. Text pane skins are required to implement
- * this.
+ * Text pane skin interface. Text pane skins are required to implement this.
*/
public interface Skin {
/**
* Returns the insertion point for a given location.
- *
+ *
* @param x
* @param y
- *
- * @return
- * The insertion point for the given location.
+ * @return The insertion point for the given location.
*/
public int getInsertionPoint(int x, int y);
/**
- * Returns the next insertion point given an x coordinate and a character offset.
- *
+ * Returns the next insertion point given an x coordinate and a
+ * character offset.
+ *
* @param x
* @param from
* @param direction
- *
- * @return
- * The next insertion point.
+ * @return The next insertion point.
*/
public int getNextInsertionPoint(int x, int from, ScrollDirection direction);
/**
- * Returns the row index of the character at a given offset within the document.
- *
+ * Returns the row index of the character at a given offset within the
+ * document.
+ *
* @param offset
- *
- * @return
- * The row index of the character at the given offset.
+ * @return The row index of the character at the given offset.
*/
public int getRowAt(int offset);
/**
* Returns the total number of rows in the document.
- *
- * @return
- * The number of rows in the document.
+ *
+ * @return The number of rows in the document.
*/
public int getRowCount();
/**
* Returns the bounds of the character at a given offset within the
* document.
- *
+ *
* @param offset
- *
- * @return
- * The bounds of the character at the given offset.
+ * @return The bounds of the character at the given offset.
*/
public Bounds getCharacterBounds(int offset);
}
@@ -125,7 +116,7 @@ public class TextPane extends Container
@Override
public void undo() {
Document tmp = new Document();
- for (int i=0; i<removed.getLength(); i++) {
+ for (int i = 0; i < removed.getLength(); i++) {
tmp.add(removed.get(i));
}
node.insertRange(tmp, offset);
@@ -158,8 +149,8 @@ public class TextPane extends Container
}
}
- private static class TextPaneListenerList extends WTKListenerList<TextPaneListener>
- implements TextPaneListener {
+ private static class TextPaneListenerList extends WTKListenerList<TextPaneListener> implements
+ TextPaneListener {
@Override
public void documentChanged(TextPane textPane, Document previousText) {
for (TextPaneListener listener : this) {
@@ -175,8 +166,8 @@ public class TextPane extends Container
}
}
- private static class TextPaneCharacterListenerList extends WTKListenerList<TextPaneCharacterListener>
- implements TextPaneCharacterListener {
+ private static class TextPaneCharacterListenerList extends
+ WTKListenerList<TextPaneCharacterListener> implements TextPaneCharacterListener {
@Override
public void charactersInserted(TextPane textPane, int index, int count) {
for (TextPaneCharacterListener listener : this) {
@@ -192,11 +183,11 @@ public class TextPane extends Container
}
}
- private static class TextPaneSelectionListenerList extends WTKListenerList<TextPaneSelectionListener>
- implements TextPaneSelectionListener {
+ private static class TextPaneSelectionListenerList extends
+ WTKListenerList<TextPaneSelectionListener> implements TextPaneSelectionListener {
@Override
- public void selectionChanged(TextPane textPane,
- int previousSelectionStart, int previousSelectionLength) {
+ public void selectionChanged(TextPane textPane, int previousSelectionStart,
+ int previousSelectionLength) {
for (TextPaneSelectionListener listener : this) {
listener.selectionChanged(textPane, previousSelectionStart, previousSelectionLength);
}
@@ -322,10 +313,10 @@ public class TextPane extends Container
}
/**
- * Sets the document that backs the text pane.
- * Documents are not shareable across multiple TextPanes;
- * because a Document may contain Components, and a Component may only be in one Container at a time.
- *
+ * Sets the document that backs the text pane. Documents are not shareable
+ * across multiple TextPanes; because a Document may contain Components, and
+ * a Component may only be in one Container at a time.
+ *
* @param document
*/
public void setDocument(Document document) {
@@ -381,7 +372,7 @@ public class TextPane extends Container
if (n > 0) {
Node node = element.get(n - 1);
if (node instanceof Element) {
- return getRightmostDescendant((Element)node);
+ return getRightmostDescendant((Element) node);
}
return node;
}
@@ -389,8 +380,8 @@ public class TextPane extends Container
}
/**
- * Helper function to remove a range of characters from the document
- * and notify the listeners just once (instead of once per node).
+ * Helper function to remove a range of characters from the document and
+ * notify the listeners just once (instead of once per node).
*/
private Node removeDocumentRange(int start, int count) {
bulkOperation = true;
@@ -432,21 +423,21 @@ public class TextPane extends Container
if (descendant instanceof TextNode) {
// The caret is positioned within an existing text node
- TextNode textNode = (TextNode)descendant;
+ TextNode textNode = (TextNode) descendant;
textNode.insertText(text, offset);
} else if (descendant instanceof Paragraph) {
// The caret is positioned on the paragraph terminator
// so get to the bottom rightmost descendant and add there
- Paragraph paragraph = (Paragraph)descendant;
+ Paragraph paragraph = (Paragraph) descendant;
Node node = getRightmostDescendant(paragraph);
if (node instanceof TextNode) {
// Insert the text into the existing node
- TextNode textNode = (TextNode)node;
+ TextNode textNode = (TextNode) node;
textNode.insertText(text, selectionStart - textNode.getDocumentOffset());
} else if (node instanceof Element) {
// Append a new text node
- Element element = (Element)node;
+ Element element = (Element) node;
element.add(new TextNode(text));
} else {
// The paragraph is currently empty
@@ -470,8 +461,7 @@ public class TextPane extends Container
throw new IllegalArgumentException("image is null.");
}
- if (document == null
- || document.getCharacterCount() == 0) {
+ if (document == null || document.getCharacterCount() == 0) {
throw new IllegalStateException();
}
@@ -488,8 +478,7 @@ public class TextPane extends Container
}
public void insertParagraph() {
- if (document == null
- || document.getCharacterCount() == 0) {
+ if (document == null || document.getCharacterCount() == 0) {
throw new IllegalStateException();
}
@@ -504,11 +493,11 @@ public class TextPane extends Container
}
// Split the paragraph at the insertion point
- Paragraph leadingSegment = (Paragraph)descendant;
+ Paragraph leadingSegment = (Paragraph) descendant;
int offset = selectionStart - leadingSegment.getDocumentOffset();
int characterCount = leadingSegment.getCharacterCount() - offset;
- Paragraph trailingSegment = (Paragraph)leadingSegment.removeRange(offset, characterCount);
+ Paragraph trailingSegment = (Paragraph) leadingSegment.removeRange(offset, characterCount);
Element parent = leadingSegment.getParent();
int index = parent.indexOf(leadingSegment);
@@ -520,17 +509,16 @@ public class TextPane extends Container
/**
* Returns character count of the document.
- *
- * @return
- * The document's character count, or <tt>0</tt> if the document is <tt>null</tt>.
+ *
+ * @return The document's character count, or <tt>0</tt> if the document is
+ * <tt>null</tt>.
*/
public int getCharacterCount() {
return (document == null) ? 0 : document.getCharacterCount();
}
public void delete(boolean backspace) {
- if (document == null
- || document.getCharacterCount() == 0) {
+ if (document == null || document.getCharacterCount() == 0) {
throw new IllegalStateException();
}
@@ -547,14 +535,12 @@ public class TextPane extends Container
characterCount = 1;
}
- if (offset >= 0
- && offset < document.getCharacterCount()) {
+ if (offset >= 0 && offset < document.getCharacterCount()) {
Node descendant = document.getDescendantAt(offset);
- if (selectionLength == 0
- && descendant instanceof Paragraph) {
+ if (selectionLength == 0 && descendant instanceof Paragraph) {
// We are deleting a paragraph terminator
- Paragraph paragraph = (Paragraph)descendant;
+ Paragraph paragraph = (Paragraph) descendant;
Element parent = paragraph.getParent();
int index = parent.indexOf(paragraph);
@@ -565,7 +551,7 @@ public class TextPane extends Container
// find the next paragraph by walking the tree, then
// remove any empty nodes
Sequence<Node> removed = parent.remove(index + 1, 1);
- Paragraph nextParagraph = (Paragraph)removed.get(0);
+ Paragraph nextParagraph = (Paragraph) removed.get(0);
paragraph.insertRange(nextParagraph, paragraph.getCharacterCount() - 1);
}
} else {
@@ -585,14 +571,13 @@ public class TextPane extends Container
}
public void cut() {
- if (document == null
- || document.getCharacterCount() == 0) {
+ if (document == null || document.getCharacterCount() == 0) {
throw new IllegalStateException();
}
if (selectionLength > 0) {
// Copy selection to clipboard
- Document selection = (Document)removeDocumentRange(selectionStart, selectionLength);
+ Document selection = (Document) removeDocumentRange(selectionStart, selectionLength);
String selectedText = null;
try {
@@ -600,7 +585,7 @@ public class TextPane extends Container
StringWriter writer = new StringWriter();
serializer.writeObject(selection, writer);
selectedText = writer.toString();
- } catch(IOException exception) {
+ } catch (IOException exception) {
throw new RuntimeException(exception);
}
@@ -615,8 +600,7 @@ public class TextPane extends Container
}
public void copy() {
- if (document == null
- || document.getCharacterCount() == 0) {
+ if (document == null || document.getCharacterCount() == 0) {
throw new IllegalStateException();
}
@@ -630,25 +614,22 @@ public class TextPane extends Container
}
public void paste() {
- if (document == null
- || document.getCharacterCount() == 0) {
+ if (document == null || document.getCharacterCount() == 0) {
throw new IllegalStateException();
}
Manifest clipboardContent = Clipboard.getContent();
- if (clipboardContent != null
- && clipboardContent.containsText()) {
+ if (clipboardContent != null && clipboardContent.containsText()) {
// Paste the string representation of the content
String text = null;
try {
text = clipboardContent.getText();
- } catch(IOException exception) {
+ } catch (IOException exception) {
// No-op
}
- if (text != null
- && text.length() > 0) {
+ if (text != null && text.length() > 0) {
// Remove any existing selection
if (selectionLength > 0) {
// TODO Make this part of the undoable action (for all such
@@ -671,7 +652,7 @@ public class TextPane extends Container
bulkOperation = false;
textPaneCharacterListeners.charactersInserted(this, start, n);
- } catch(IOException exception) {
+ } catch (IOException exception) {
throw new RuntimeException(exception);
}
@@ -705,10 +686,9 @@ public class TextPane extends Container
private void addToText(StringBuilder text, Element element) {
for (Node node : element) {
if (node instanceof TextNode) {
- text.append(((TextNode)node).getCharacters());
- }
- else if (node instanceof Element) {
- addToText(text, (Element)node);
+ text.append(((TextNode) node).getCharacters());
+ } else if (node instanceof Element) {
+ addToText(text, (Element) node);
}
// TODO: anything more that could/should be handled?
}
@@ -718,8 +698,9 @@ public class TextPane extends Container
}
/**
- * Convenience method to get all the text from the current document
- * into a single string.
+ * Convenience method to get all the text from the current document into a
+ * single string.
+ *
* @see #setText
*/
public String getText() {
@@ -733,8 +714,8 @@ public class TextPane extends Container
}
/**
- * Convenience method to create a text-only document consisting
- * of one paragraph per line of the given text.
+ * Convenience method to create a text-only document consisting of one
+ * paragraph per line of the given text.
*/
public void setText(String text) {
Document doc = new Document();
@@ -748,9 +729,8 @@ public class TextPane extends Container
/**
* Returns the starting index of the selection.
- *
- * @return
- * The starting index of the selection.
+ *
+ * @return The starting index of the selection.
*/
public int getSelectionStart() {
return selectionStart;
@@ -758,9 +738,8 @@ public class TextPane extends Container
/**
* Returns the length of the selection.
- *
- * @return
- * The length of the selection; may be <tt>0</tt>.
+ *
+ * @return The length of the selection; may be <tt>0</tt>.
*/
public int getSelectionLength() {
return selectionLength;
@@ -768,61 +747,56 @@ public class TextPane extends Container
/**
* Returns a span representing the current selection.
- *
- * @return
- * A span containing the current selection. Both start and end points are
- * inclusive. Returns <tt>null</tt> if the selection is empty.
+ *
+ * @return A span containing the current selection. Both start and end
+ * points are inclusive. Returns <tt>null</tt> if the selection is empty.
*/
public Span getSelection() {
- return (selectionLength == 0) ? null : new Span(selectionStart,
- selectionStart + selectionLength - 1);
+ return (selectionLength == 0) ? null : new Span(selectionStart, selectionStart
+ + selectionLength - 1);
}
/**
* Sets the selection. The sum of the selection start and length must be
* less than the length of the text input's content.
- *
- * @param selectionStart
- * The starting index of the selection.
- *
- * @param selectionLength
- * The length of the selection.
+ *
+ * @param selectionStart The starting index of the selection.
+ * @param selectionLength The length of the selection.
*/
public void setSelection(int selectionStart, int selectionLength) {
- if (document == null
- || document.getCharacterCount() == 0) {
+ if (document == null || document.getCharacterCount() == 0) {
throw new IllegalStateException();
}
if (selectionLength < 0) {
- throw new IllegalArgumentException("selectionLength is negative, selectionLength=" + selectionLength);
+ throw new IllegalArgumentException("selectionLength is negative, selectionLength="
+ + selectionLength);
}
indexBoundsCheck("selectionStart", selectionStart, 0, document.getCharacterCount() - 1);
if (selectionStart + selectionLength > document.getCharacterCount()) {
- throw new IndexOutOfBoundsException("selectionStart=" + selectionStart + ", selectionLength=" + selectionLength
- + ", document.characterCount=" + document.getCharacterCount());
+ throw new IndexOutOfBoundsException("selectionStart=" + selectionStart
+ + ", selectionLength=" + selectionLength + ", document.characterCount="
+ + document.getCharacterCount());
}
int previousSelectionStart = this.selectionStart;
int previousSelectionLength = this.selectionLength;
- if (previousSelectionStart != selectionStart
- || previousSelectionLength != selectionLength) {
+ if (previousSelectionStart != selectionStart || previousSelectionLength != selectionLength) {
this.selectionStart = selectionStart;
this.selectionLength = selectionLength;
- textPaneSelectionListeners.selectionChanged(this,
- previousSelectionStart, previousSelectionLength);
+ textPaneSelectionListeners.selectionChanged(this, previousSelectionStart,
+ previousSelectionLength);
}
}
/**
* Sets the selection.
- *
+ *
* @param selection
- *
* @see #setSelection(int, int)
*/
public final void setSelection(Span selection) {
@@ -830,7 +804,7 @@ public class TextPane extends Container
throw new IllegalArgumentException("selection is null.");
}
- setSelection(Math.min(selection.start, selection.end), (int)selection.getLength());
+ setSelection(Math.min(selection.start, selection.end), (int) selection.getLength());
}
/**
@@ -853,23 +827,22 @@ public class TextPane extends Container
/**
* Returns the currently selected text.
- *
- * @return
- * A new string containing a copy of the text in the selected range, or
- * <tt>null</tt> if nothing is selected.
+ *
+ * @return A new string containing a copy of the text in the selected range,
+ * or <tt>null</tt> if nothing is selected.
*/
public String getSelectedText() {
String selectedText = null;
if (selectionLength > 0) {
- Document selection = (Document)document.getRange(selectionStart, selectionLength);
+ Document selection = (Document) document.getRange(selectionStart, selectionLength);
try {
PlainTextSerializer serializer = new PlainTextSerializer();
StringWriter writer = new StringWriter();
serializer.writeObject(selection, writer);
selectedText = writer.toString();
- } catch(IOException exception) {
+ } catch (IOException exception) {
throw new RuntimeException(exception);
}
}
@@ -886,7 +859,7 @@ public class TextPane extends Container
/**
* Sets the text pane's editable flag.
- *
+ *
* @param editable
*/
public void setEditable(boolean editable) {
@@ -904,30 +877,31 @@ public class TextPane extends Container
}
public int getInsertionPoint(int x, int y) {
- TextPane.Skin textPaneSkin = (TextPane.Skin)getSkin();
+ TextPane.Skin textPaneSkin = (TextPane.Skin) getSkin();
return textPaneSkin.getInsertionPoint(x, y);
}
public int getNextInsertionPoint(int x, int from, ScrollDirection direction) {
- TextPane.Skin textPaneSkin = (TextPane.Skin)getSkin();
+ TextPane.Skin textPaneSkin = (TextPane.Skin) getSkin();
return textPaneSkin.getNextInsertionPoint(x, from, direction);
}
public int getRowAt(int offset) {
- TextPane.Skin textPaneSkin = (TextPane.Skin)getSkin();
+ TextPane.Skin textPaneSkin = (TextPane.Skin) getSkin();
return textPaneSkin.getRowAt(offset);
}
public int getRowCount() {
- TextPane.Skin textPaneSkin = (TextPane.Skin)getSkin();
+ TextPane.Skin textPaneSkin = (TextPane.Skin) getSkin();
return textPaneSkin.getRowCount();
}
public Bounds getCharacterBounds(int offset) {
// We need to validate in case we get called from user-code after
- // a user-code initiated modification, but before another layout has run.
+ // a user-code initiated modification, but before another layout has
+ // run.
validate();
- TextPane.Skin textPaneSkin = (TextPane.Skin)getSkin();
+ TextPane.Skin textPaneSkin = (TextPane.Skin) getSkin();
return textPaneSkin.getCharacterBounds(offset);
}
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPaneCharacterListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPaneCharacterListener.java?rev=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPaneCharacterListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPaneCharacterListener.java Fri Oct 4 23:45:40 2013
@@ -37,7 +37,7 @@ public interface TextPaneCharacterListen
/**
* Called when characters have been inserted into a text pane.
- *
+ *
* @param textPane
* @param index
* @param count
@@ -46,7 +46,7 @@ public interface TextPaneCharacterListen
/**
* Called when characters have been removed from a text pane.
- *
+ *
* @param textPane
* @param index
* @param count
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPaneListener.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPaneListener.java?rev=1529349&r1=1529348&r2=1529349&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPaneListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextPaneListener.java Fri Oct 4 23:45:40 2013
@@ -39,7 +39,7 @@ public interface TextPaneListener {
/**
* Called when a text pane's document has changed.
- *
+ *
* @param textPane
* @param previousDocument
*/
@@ -47,7 +47,7 @@ public interface TextPaneListener {
/**
* Called when a text pane's editable state has changed.
- *
+ *
* @param textPane
*/
public void editableChanged(TextPane textPane);