diff --git a/api.visual/apichanges.xml b/api.visual/apichanges.xml --- a/api.visual/apichanges.xml +++ b/api.visual/apichanges.xml @@ -573,6 +573,20 @@ made subject to such option by the copyr + + + + Support of Widget children ordering + + + + + + New methods of Widget children ordering introduced: Widget.orderChildren, WidgetSupport.bringBackward and WidgetSupport.bringForward. + + + + diff --git a/api.visual/manifest.mf b/api.visual/manifest.mf --- a/api.visual/manifest.mf +++ b/api.visual/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.api.visual OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/visual/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 2.10 +OpenIDE-Module-Specification-Version: 2.11 AutoUpdate-Essential-Module: true diff --git a/api.visual/src/org/netbeans/api/visual/widget/Widget.java b/api.visual/src/org/netbeans/api/visual/widget/Widget.java --- a/api.visual/src/org/netbeans/api/visual/widget/Widget.java +++ b/api.visual/src/org/netbeans/api/visual/widget/Widget.java @@ -50,8 +50,8 @@ import org.netbeans.modules.visual.widge import org.netbeans.modules.visual.widget.WidgetAccessibleContext; import org.openide.util.Lookup; +import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; -import javax.accessibility.Accessible; import java.awt.*; import java.awt.geom.AffineTransform; import java.util.*; @@ -334,6 +334,29 @@ public class Widget implements Accessibl protected void notifyRemoved () { } + /** + * Reorders children with specified permutation. + * @param permutation List consisting of new order. Each array slot contains Integer value pointing to a Widget at particular index in previous order. + * @since 2.11 + */ + public final void orderChildren(List permutation) { + if (permutation == null || permutation.size() != children.size ()) + throw new IllegalArgumentException("Invalid permutation: " + permutation); + for (Widget widget : permutation) + if (! children.contains (widget)) + throw new IllegalArgumentException("Invalid permutation: " + permutation); + for (Widget widget : children) + if (! permutation.contains (widget)) + throw new IllegalArgumentException("Invalid permutation: " + permutation); + + children.clear (); + children.addAll (permutation); + + revalidate (); + for (Widget child : children) + child.revalidate (); + } + /** * Brings the widget to the front. Means: the widget becomes the last child in the list of children of the parent widget. */ diff --git a/api.visual/src/org/netbeans/api/visual/widget/doc-files/documentation.html b/api.visual/src/org/netbeans/api/visual/widget/doc-files/documentation.html --- a/api.visual/src/org/netbeans/api/visual/widget/doc-files/documentation.html +++ b/api.visual/src/org/netbeans/api/visual/widget/doc-files/documentation.html @@ -309,8 +309,8 @@ A widget placement is resolved by a layo getScene Returns a scene where the widget belongs. The scene instance is assigned in the constructor and could not be changed anymore. -getParentWidget
getChildren
addChild
removeChild
removeFromParent
addChildren
removeChildren
bringToFront
bringToBack -Methods for manipulation with the tree hierarchy of widgets. +getParentWidget
getChildren
addChild
removeChild
removeFromParent
addChildren
removeChildren
bringToFront
bringToBack
orderChildren +Methods for manipulation with the tree hierarchy of widgets. The Widget.orderChildren allows to change order of children. Additional tree-manipulation methods getChildConstraint
setChildConstraint Controls constraints assigned to child widgets. Used by Layouts similarly to Swing. See Layout section.