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 2018/08/25 00:26:02 UTC

svn commit: r1838997 - in /pivot/trunk/wtk/src/org/apache/pivot/wtk/text: ComponentNode.java Document.java

Author: rwhitcomb
Date: Sat Aug 25 00:26:02 2018
New Revision: 1838997

URL: http://svn.apache.org/viewvc?rev=1838997&view=rev
Log:
Change ComponentNode back to a subclass of Node (instead of Block), but
then allow Document to accept ComponentNode as a child, in addition to
a Block.  The reason for making it a Block was to allow direct insertion
into a document, but clicking on one of them that way resulted in an
exception trying to find children of that node.  So, rather than figure
that out, just make the special case exception inside a Document. This
appears to work everywhere without problems.

Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/text/ComponentNode.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Document.java

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=1838997&r1=1838996&r2=1838997&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 25 00:26:02 2018
@@ -32,7 +32,7 @@ import org.apache.pivot.wtk.content.Base
 /**
  * Node representing a live Pivot component to be inserted into a {@link TextPane}.
  */
-public class ComponentNode extends Block {
+public class ComponentNode extends Node {
     private Component component = null;
 
     private ComponentNodeListener.Listeners componentNodeListeners = new ComponentNodeListener.Listeners();
@@ -149,7 +149,7 @@ public class ComponentNode extends Block
     }
 
     @Override
-    public Element getRange(int offset, int characterCount) {
+    public Node getRange(int offset, int characterCount) {
         // Note: only supports getting the complete range of text
         String componentText = getText();
         if (offset < 0 || offset >= componentText.length()) {
@@ -164,7 +164,7 @@ public class ComponentNode extends Block
     }
 
     @Override
-    public Element duplicate(boolean recursive) {
+    public Node duplicate(boolean recursive) {
         return new ComponentNode(this);
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Document.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Document.java?rev=1838997&r1=1838996&r2=1838997&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Document.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/text/Document.java Sat Aug 25 00:26:02 2018
@@ -40,10 +40,10 @@ public class Document extends Block {
 
     @Override
     public void insert(final Node node, final int index) {
-        if (!(node instanceof Block)) {
+        if (!(node instanceof Block) && !(node instanceof ComponentNode)) {
             throw new IllegalArgumentException("Child node ("
                 + node.getClass().getSimpleName() + ") must be an instance of "
-                + Block.class.getName());
+                + Block.class.getName() + " or " + ComponentNode.class.getName());
         }
 
         super.insert(node, index);