You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/09/04 14:41:36 UTC

svn commit: r992592 - in /pivot/trunk: wtk-terra/src/org/apache/pivot/wtk/skin/terra/ wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/text/

Author: gbrown
Date: Sat Sep  4 12:41:35 2010
New Revision: 992592

URL: http://svn.apache.org/viewvc?rev=992592&view=rev
Log:
Minor updates to new text area; make all insertText() methods take a CharSequence rather than String for increased flexibility.

Modified:
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=992592&r1=992591&r2=992592&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Sat Sep  4 12:41:35 2010
@@ -1301,7 +1301,7 @@ public class TerraTextInputSkin extends 
 
     // Text input character events
     @Override
-    public Vote previewInsertText(TextInput textInput, String text, int index) {
+    public Vote previewInsertText(TextInput textInput, CharSequence text, int index) {
         Vote vote = Vote.APPROVE;
 
         if (textInput.isStrictValidation()) {

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java?rev=992592&r1=992591&r2=992592&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextArea2.java Sat Sep  4 12:41:35 2010
@@ -39,20 +39,24 @@ public class TextArea2 extends Component
     /**
      * Class representing a paragraph of text.
      */
-    public final class Paragraph {
-        private StringBuilder characters;
-
-        private Paragraph() {
-            characters = new StringBuilder(INITIAL_PARAGRAPH_CAPACITY);
-        }
+    public static final class Paragraph {
+        private StringBuilder characters = new StringBuilder(INITIAL_PARAGRAPH_CAPACITY);
+        private TextArea2 textArea = null;
+        private int offset = -1;
 
         public CharSequence getCharacters() {
             return characters;
         }
 
-        public void insertText(String text, int index) {
+        public TextArea2 getTextArea() {
+            return textArea;
+        }
+
+        public void insertText(CharSequence text, int index) {
             characters.insert(index, text);
 
+            // TODO Perform offset bookkeeping
+
             // TODO Fire event
             // TODO Update selection state
         }
@@ -60,13 +64,14 @@ public class TextArea2 extends Component
         public void removeText(int index, int count) {
             characters.delete(index, index + count);
 
+            // TODO Perform offset bookkeeping
+
             // TODO Fire event
             // TODO Update selection state
         }
 
         public int getOffset() {
-            // TODO
-            return -1;
+            return offset;
         }
 
         // TODO Add listener list accessor
@@ -197,12 +202,14 @@ public class TextArea2 extends Component
         }
 
         public void insert(Paragraph paragraph, int index) {
-            // TODO
+            // TODO Ensure that paragraph.textArea is null
+
+            // TODO Set paragraph.textArea to TextArea2.this
+            // TODO Perform offset bookkeeping
         }
 
         public Paragraph update(int index, Paragraph paragraph) {
-            // TODO
-            return null;
+            throw new UnsupportedOperationException();
         }
 
         public int remove(Paragraph paragraph){
@@ -211,7 +218,8 @@ public class TextArea2 extends Component
         }
 
         public Sequence<Paragraph> remove(int index, int count) {
-            // TODO
+            // TODO For each removed paragraph, set paragraph.textArea to null
+            // TODO Perform offset bookkeeping
             return null;
         }
 
@@ -517,8 +525,11 @@ public class TextArea2 extends Component
      * @param index
      */
     public int getParagraphAt(int index) {
+        // TODO Search backwards from end to simplify logic
+
         // TODO Be sure to return paragraph corresponding to terminator character,
         // including implicit final terminator
+
         return -1;
     }
 
@@ -528,7 +539,10 @@ public class TextArea2 extends Component
      * @param index
      */
     public char getCharacterAt(int index) {
-        // TODO
+        // TODO Call getParagraphAt(), then get character offset from
+        // index - <paragraph offset>; be sure to return appropriate terminator
+        // character, either for paragraph or implicit final terminator
+
         return 0x00;
     }
 

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=992592&r1=992591&r2=992592&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInput.java Sat Sep  4 12:41:35 2010
@@ -125,7 +125,7 @@ public class TextInput extends Component
     private static class TextInputContentListenerList extends ListenerList<TextInputContentListener>
         implements TextInputContentListener {
         @Override
-        public Vote previewInsertText(TextInput textInput, String text, int index) {
+        public Vote previewInsertText(TextInput textInput, CharSequence text, int index) {
             Vote vote = Vote.APPROVE;
 
             for (TextInputContentListener listener : this) {
@@ -314,7 +314,7 @@ public class TextInput extends Component
         }
     }
 
-    public void insertText(String text, int index) {
+    public void insertText(CharSequence text, int index) {
         if (text == null) {
             throw new IllegalArgumentException();
         }

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=992592&r1=992591&r2=992592&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/TextInputContentListener.java Sat Sep  4 12:41:35 2010
@@ -27,7 +27,7 @@ public interface TextInputContentListene
      */
     public static class Adapter implements TextInputContentListener {
         @Override
-        public Vote previewInsertText(TextInput textInput, String text, int index) {
+        public Vote previewInsertText(TextInput textInput, CharSequence text, int index) {
             return Vote.APPROVE;
         }
 
@@ -69,7 +69,7 @@ public interface TextInputContentListene
      * @param index
      * The index at which the text will be inserted.
      */
-    public Vote previewInsertText(TextInput textInput, String text, int index);
+    public Vote previewInsertText(TextInput textInput, CharSequence text, int index);
 
     /**
      * Called when a text insertion has been vetoed.

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java?rev=992592&r1=992591&r2=992592&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/TextNode.java Sat Sep  4 12:41:35 2010
@@ -75,11 +75,7 @@ public final class TextNode extends Node
         insertText(text, 0);
     }
 
-    public void insertText(char text, int index) {
-        insertText(Character.toString(text), index);
-    }
-
-    public void insertText(String text, int index) {
+    public void insertText(CharSequence text, int index) {
         if (text == null) {
             throw new IllegalArgumentException("text is null.");
         }