Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandr Miloslavskiy2019-07-11 08:15:31 -0400
committerAlexandr Miloslavskiy2019-08-12 09:29:02 -0400
commitc989fbf5032fec9b056dbea3d1977e0d24da2574 (patch)
tree5df1ffa19248663fa7f8a68ebe3c558abfad5d5a
parent883617bbac79f2080ae98da651e65406acd7435b (diff)
downloadeclipse.platform.swt-c989fbf5032fec9b056dbea3d1977e0d24da2574.tar.gz
eclipse.platform.swt-c989fbf5032fec9b056dbea3d1977e0d24da2574.tar.xz
eclipse.platform.swt-c989fbf5032fec9b056dbea3d1977e0d24da2574.zip
Bug 549171 - Document the fastest way of bulk inserting/deleting
Change-Id: Icaeb86dee722efa5f249ffc516b128904a12bf21 Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java79
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java79
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java79
6 files changed, 84 insertions, 160 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
index b5d5988b80..e3ea3a9532 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java
@@ -698,6 +698,7 @@ void createItem (TreeColumn column, int index) {
}
}
+// For fast bulk insert, see comments for TreeItem#TreeItem(TreeItem,int,int)
void createItem (TreeItem item, TreeItem parentItem, int index) {
int count;
TreeItem [] items;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java
index 107e610b11..1a331c0ecc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/TreeItem.java
@@ -64,22 +64,13 @@ public class TreeItem extends Item {
public SWTTreeItem handle;
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as last direct child of the tree.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * For bulk insert scenarios, see TreeItem#TreeItem(Tree,int,int)
*
* @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
@@ -98,22 +89,17 @@ public TreeItem (Tree parent, int style) {
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as <code>index</code> direct child of the tree.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is:
+ * <ol>
+ * <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
+ * <li>Insert every item at index 0 (insert them in reverse to get the same result)</li>
+ * </ol>
*
* @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
* @param index the zero-relative index to store the receiver in its parent
*
* @exception IllegalArgumentException <ul>
@@ -128,28 +114,20 @@ public TreeItem (Tree parent, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
+ * @see Tree#setRedraw
*/
public TreeItem (Tree parent, int style, int index) {
this (checkNull (parent), null, style, checkIndex (index), true);
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as last direct child of the specified <code>TreeItem</code>.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * For bulk insert scenarios, see TreeItem#TreeItem(TreeItem,int,int)
*
* @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
@@ -168,22 +146,18 @@ public TreeItem (TreeItem parentItem, int style) {
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as <code>index</code> direct child of the specified <code>TreeItem</code>.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is:
+ * <ol>
+ * <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
+ * <li>Insert child items while parent item is collapsed</li>
+ * <li>Insert every item at index 0 (insert them in reverse to get the same result)</li>
+ * </ol>
*
* @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
* @param index the zero-relative index to store the receiver in its parent
*
* @exception IllegalArgumentException <ul>
@@ -198,6 +172,7 @@ public TreeItem (TreeItem parentItem, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
+ * @see Tree#setRedraw
*/
public TreeItem (TreeItem parentItem, int style, int index) {
this (checkNull (parentItem).parent, parentItem, style, checkIndex (index), true);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index 7145a599e8..29c3cb6d88 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -910,10 +910,7 @@ void createItem (TreeColumn column, int index) {
}
}
-/*
- * NOTE: the fastest way to bulk-insert items is to insert every item
- * at index 0 (insert in reverse to preserve order).
- */
+// For fast bulk insert, see comments for TreeItem#TreeItem(TreeItem,int,int)
void createItem (TreeItem item, long parentIter, int index) {
/*
* Try to achieve maximum possible performance in bulk insert scenarios.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index a9fc6fc845..9170f1a469 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
@@ -46,22 +46,13 @@ public class TreeItem extends Item {
static final int EXPANDER_EXTRA_PADDING = 4;
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as last direct child of the tree.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * For bulk insert scenarios, see TreeItem#TreeItem(Tree,int,int)
*
* @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
@@ -80,22 +71,17 @@ public TreeItem (Tree parent, int style) {
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as <code>index</code> direct child of the tree.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is:
+ * <ol>
+ * <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
+ * <li>Insert every item at index 0 (insert them in reverse to get the same result)</li>
+ * </ol>
*
* @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
* @param index the zero-relative index to store the receiver in its parent
*
* @exception IllegalArgumentException <ul>
@@ -110,28 +96,20 @@ public TreeItem (Tree parent, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
+ * @see Tree#setRedraw
*/
public TreeItem (Tree parent, int style, int index) {
this (checkNull (parent), 0, style, checkIndex (index), true);
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as last direct child of the specified <code>TreeItem</code>.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * For bulk insert scenarios, see TreeItem#TreeItem(TreeItem,int,int)
*
* @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
@@ -150,22 +128,18 @@ public TreeItem (TreeItem parentItem, int style) {
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as <code>index</code> direct child of the specified <code>TreeItem</code>.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is:
+ * <ol>
+ * <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
+ * <li>Insert child items while parent item is collapsed</li>
+ * <li>Insert every item at index 0 (insert them in reverse to get the same result)</li>
+ * </ol>
*
* @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
* @param index the zero-relative index to store the receiver in its parent
*
* @exception IllegalArgumentException <ul>
@@ -180,6 +154,7 @@ public TreeItem (TreeItem parentItem, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
+ * @see Tree#setRedraw
*/
public TreeItem (TreeItem parentItem, int style, int index) {
this (checkNull (parentItem).parent, parentItem.handle, style, checkIndex (index), true);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
index 9f5e8f3295..843d68c363 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -2068,6 +2068,7 @@ void createItem (TreeColumn column, int index) {
}
}
+// For fast bulk insert, see comments for TreeItem#TreeItem(TreeItem,int,int)
void createItem (TreeItem item, long hParent, long hInsertAfter, long hItem) {
int id = -1;
if (item != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
index 172cfda00f..35e7f5ee77 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
@@ -61,22 +61,13 @@ public class TreeItem extends Item {
int [] cellBackground, cellForeground;
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as last direct child of the tree.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * For bulk insert scenarios, see TreeItem#TreeItem(Tree,int,int)
*
* @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
@@ -95,22 +86,17 @@ public TreeItem (Tree parent, int style) {
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as <code>index</code> direct child of the tree.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is:
+ * <ol>
+ * <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
+ * <li>Insert every item at index 0 (insert them in reverse to get the same result)</li>
+ * </ol>
*
* @param parent a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
* @param index the zero-relative index to store the receiver in its parent
*
* @exception IllegalArgumentException <ul>
@@ -125,28 +111,20 @@ public TreeItem (Tree parent, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
+ * @see Tree#setRedraw
*/
public TreeItem (Tree parent, int style, int index) {
this (parent, style, OS.TVGN_ROOT, findPrevious (parent, index), 0);
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>)
- * and a style value describing its behavior and appearance.
- * The item is added to the end of the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as last direct child of the specified <code>TreeItem</code>.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * For bulk insert scenarios, see TreeItem#TreeItem(TreeItem,int,int)
*
* @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
*
* @exception IllegalArgumentException <ul>
* <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
@@ -165,22 +143,18 @@ public TreeItem (TreeItem parentItem, int style) {
}
/**
- * Constructs a new instance of this class given its parent
- * (which must be a <code>Tree</code> or a <code>TreeItem</code>),
- * a style value describing its behavior and appearance, and the index
- * at which to place it in the items maintained by its parent.
+ * Constructs <code>TreeItem</code> and <em>inserts</em> it into <code>Tree</code>.
+ * Item is inserted as <code>index</code> direct child of the specified <code>TreeItem</code>.
* <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
+ * The fastest way to insert many items is:
+ * <ol>
+ * <li>Use {@link Tree#setRedraw} to disable drawing during bulk insert</li>
+ * <li>Insert child items while parent item is collapsed</li>
+ * <li>Insert every item at index 0 (insert them in reverse to get the same result)</li>
+ * </ol>
*
* @param parentItem a tree control which will be the parent of the new instance (cannot be null)
- * @param style the style of control to construct
+ * @param style no styles are currently supported, pass SWT.NONE
* @param index the zero-relative index to store the receiver in its parent
*
* @exception IllegalArgumentException <ul>
@@ -195,6 +169,7 @@ public TreeItem (TreeItem parentItem, int style) {
* @see SWT
* @see Widget#checkSubclass
* @see Widget#getStyle
+ * @see Tree#setRedraw
*/
public TreeItem (TreeItem parentItem, int style, int index) {
this (checkNull (parentItem).parent, style, parentItem.handle, findPrevious (parentItem, index), 0);

Back to the top