You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2015/08/08 03:22:49 UTC

svn commit: r1694754 - in /pivot/trunk: tests/src/org/apache/pivot/tests/HyperlinkButtonTest.java wtk/src/org/apache/pivot/wtk/text/ComponentNode.java wtk/src/org/apache/pivot/wtk/text/ImageNode.java

Author: rwhitcomb
Date: Sat Aug  8 01:22:49 2015
New Revision: 1694754

URL: http://svn.apache.org/r1694754
Log:
Code cleanup:  this should eventually go into a JIRA issue...

Small changes to allow ComponentNode and ImageNode to actually work inside
a TextPane.  Not sure of the reasons, but it was very difficult to get this
to work without turning both into subclasses of Block instead of Node.

Now, at least, one can insert either straight into a Document and then into
a TextPane and they will work.  Update the HyperlinkButtonTest program to
illustrate this.

Modified:
    pivot/trunk/tests/src/org/apache/pivot/tests/HyperlinkButtonTest.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java

Modified: pivot/trunk/tests/src/org/apache/pivot/tests/HyperlinkButtonTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/tests/src/org/apache/pivot/tests/HyperlinkButtonTest.java?rev=1694754&r1=1694753&r2=1694754&view=diff
==============================================================================
--- pivot/trunk/tests/src/org/apache/pivot/tests/HyperlinkButtonTest.java (original)
+++ pivot/trunk/tests/src/org/apache/pivot/tests/HyperlinkButtonTest.java Sat Aug  8 01:22:49 2015
@@ -24,6 +24,12 @@ import org.apache.pivot.wtk.Display;
 import org.apache.pivot.wtk.Frame;
 import org.apache.pivot.wtk.Orientation;
 import org.apache.pivot.wtk.HyperlinkButton;
+import org.apache.pivot.wtk.TextPane;
+import org.apache.pivot.wtk.text.ComponentNode;
+import org.apache.pivot.wtk.text.Document;
+import org.apache.pivot.wtk.text.ImageNode;
+import org.apache.pivot.wtk.text.Paragraph;
+import org.apache.pivot.wtk.text.TextNode;
 
 
 public class HyperlinkButtonTest extends Application.Adapter {
@@ -37,11 +43,25 @@ public class HyperlinkButtonTest extends
 
         HyperlinkButton button1 = new HyperlinkButton("http://pivot.apache.org");
         HyperlinkButton button2 = new HyperlinkButton("Apache website", "http://apache.org");
-        BoxPane bp = new BoxPane(Orientation.VERTICAL);
-        bp.add(button1);
-        bp.add(button2);
+        TextPane textPane = new TextPane();
+        Document document = new Document();
+        TextNode text1 = new TextNode("Link to the Apache Pivot site: ");
+        TextNode text2 = new TextNode("Main Apache Software Foundation website: ");
+        ComponentNode compNode1 = new ComponentNode(button1);
+        ComponentNode compNode2 = new ComponentNode(button2);
+        Paragraph para1 = new Paragraph();
+        para1.add(text1);
+        document.add(para1);
+        document.add(compNode1);
+        Paragraph para2 = new Paragraph();
+        para2.add(text2);
+        document.add(para2);
+        document.add(compNode2);
+        ImageNode image1 = new ImageNode("/org/apache/pivot/tests/house.png");
+        document.add(image1);
+        textPane.setDocument(document);
 
-        frame.setContent(bp);
+        frame.setContent(textPane);
 
         frame.open(display);
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java?rev=1694754&r1=1694753&r2=1694754&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java Sat Aug  8 01:22:49 2015
@@ -22,7 +22,7 @@ import org.apache.pivot.wtk.Component;
 /**
  * Node representing a live pivot component.
  */
-public class ComponentNode extends Node {
+public class ComponentNode extends Block {
 
     private static class ComponentNodeListenerList extends ListenerList<ComponentNodeListener>
         implements ComponentNodeListener {
@@ -83,7 +83,7 @@ public class ComponentNode extends Node
     }
 
     @Override
-    public Node getRange(int offset, int characterCount) {
+    public Element getRange(int offset, int characterCount) {
         if (offset < 0 || offset > 1) {
             throw new IndexOutOfBoundsException();
         }
@@ -96,7 +96,7 @@ public class ComponentNode extends Node
     }
 
     @Override
-    public Node duplicate(boolean recursive) {
+    public Element duplicate(boolean recursive) {
         return new ComponentNode(this);
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java?rev=1694754&r1=1694753&r2=1694754&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ImageNode.java Sat Aug  8 01:22:49 2015
@@ -24,7 +24,7 @@ import org.apache.pivot.wtk.media.Image;
 /**
  * Node representing an image.
  */
-public class ImageNode extends Node {
+public class ImageNode extends Block {
     private static class ImageNodeListenerList extends ListenerList<ImageNodeListener> implements
         ImageNodeListener {
         @Override
@@ -128,7 +128,7 @@ public class ImageNode extends Node {
     }
 
     @Override
-    public Node getRange(int offset, int characterCount) {
+    public Element getRange(int offset, int characterCount) {
         if (offset < 0 || offset > 1) {
             throw new IndexOutOfBoundsException();
         }
@@ -141,7 +141,7 @@ public class ImageNode extends Node {
     }
 
     @Override
-    public Node duplicate(boolean recursive) {
+    public Element duplicate(boolean recursive) {
         return new ImageNode(this);
     }