pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1766087 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationWidget.java
Date Fri, 21 Oct 2016 17:48:10 GMT
Author: tilman
Date: Fri Oct 21 17:48:10 2016
New Revision: 1766087

URL: http://svn.apache.org/viewvc?rev=1766087&view=rev
Log:
PDFBOX-3537: add setParent() method

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationWidget.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationWidget.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationWidget.java?rev=1766087&r1=1766086&r2=1766087&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationWidget.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationWidget.java
Fri Oct 21 17:48:10 2016
@@ -22,6 +22,7 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.pdmodel.interactive.action.PDActionFactory;
 import org.apache.pdfbox.pdmodel.interactive.action.PDAnnotationAdditionalActions;
 import org.apache.pdfbox.pdmodel.interactive.action.PDAction;
+import org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField;
 
 /**
  * This is the class that represents a widget.
@@ -224,4 +225,23 @@ public class PDAnnotationWidget extends
     // }
     // return null;
     // }
+
+    /**
+     * Set the parent field of a widget annotation. This is only required if this widget
annotation
+     * is one of multiple children in a field, and not to be set otherwise. You will usually
not
+     * need this, because in most cases, fields have only one widget and share a common dictionary.
+     * A usage can be found in the CreateMultiWidgetsForm example.
+     *
+     * @param field the parent field.
+     * @throws IllegalArgumentException if setParent() was called for a field that shares
a
+     * dictionary with its only widget.
+     */
+    public void setParent(PDTerminalField field)
+    {
+        if (this.getCOSObject().equals(field.getCOSObject()))
+        {
+            throw new IllegalArgumentException("setParent() is not to be called for a field
that shares a dictionary with its only widget");
+        }
+        this.getCOSObject().setItem(COSName.PARENT, field);
+    }
 }



Mime
View raw message