Skip to content

Commit

Permalink
Adding functionality to change the delay time to expand the tree whil…
Browse files Browse the repository at this point in the history
…e searching.

The api consumer can pass the delay time to expand the tree while searching, the change was made for the issue #1337 as this will be its first consumer

eclipse-jdt/eclipse.jdt.ui#1337
  • Loading branch information
ShahzaibIbrahim committed Apr 23, 2024
1 parent 66847ac commit 67617b6
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bundles/org.eclipse.e4.ui.dialogs/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.e4.ui.dialogs
Bundle-Version: 1.4.300.qualifier
Bundle-Version: 1.5.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,41 @@ public class FilteredTree extends Composite {
*/
private static final long SOFT_MAX_EXPAND_TIME = 200;

/**
* Time delay after which the search is triggered, acting as a debounce
* mechanism.
*/
private final long refreshJobDelayInMillis;

/**
* Default time for refresh job delay in ms
*/
private static final long DEFAULT_REFRESH_TIME = 200;

/**
* Create a new instance of the receiver.
*
* @param parent
* the parent <code>Composite</code>
* @param treeStyle
* the style bits for the <code>Tree</code>
* @param filter
* the filter to be used
*/
public FilteredTree(Composite parent, int treeStyle, PatternFilter filter) {
* @param parent the parent <code>Composite</code>
* @param treeStyle the style bits for the <code>Tree</code>
* @param filter the filter to be used
* @param refreshDelayTime refresh delay in ms, the time to expand the tree
* after debounce
* @since 1.5
*/
public FilteredTree(Composite parent, int treeStyle, PatternFilter filter, long refreshDelayTime) {
super(parent, SWT.NONE);
this.refreshJobDelayInMillis = refreshDelayTime;
init(treeStyle, filter);
}

/**
* Calls {@link #FilteredTree(Composite, int, PatternFilter, long)} with a
* default refresh time
*/
public FilteredTree(Composite parent, int treeStyle, PatternFilter filter) {
this(parent, treeStyle, filter, DEFAULT_REFRESH_TIME);
}

/**
* Create a new instance of the receiver. Subclasses that wish to override
* the default creation behavior may use this constructor, but must ensure
Expand All @@ -129,6 +149,7 @@ public FilteredTree(Composite parent, int treeStyle, PatternFilter filter) {
*/
protected FilteredTree(Composite parent) {
super(parent, SWT.NONE);
this.refreshJobDelayInMillis = DEFAULT_REFRESH_TIME;
}

/**
Expand Down Expand Up @@ -540,7 +561,7 @@ protected void textChanged() {
* @since 3.5
*/
protected long getRefreshJobDelay() {
return 200;
return refreshJobDelayInMillis;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ public class FilteredTree extends Composite {
*/
private static final long SOFT_MAX_EXPAND_TIME = 200;

/**
* Time for refresh job delay in terms of expansion in long value
*/
private final long refreshJobDelayInMillis;

/**
* Default time for refresh job delay in ms
*/
private static final long DEFAULT_REFRESH_TIME = 200;

/**
* Create a new instance of the receiver. Subclasses that wish to override the
* default creation behavior may use this constructor, but must ensure that the
Expand All @@ -171,11 +181,24 @@ public class FilteredTree extends Composite {
public FilteredTree(Composite parent, boolean useNewLook, boolean useFastHashLookup) {
super(parent, SWT.NONE);
this.parent = parent;
this.refreshJobDelayInMillis = DEFAULT_REFRESH_TIME;
if (treeViewer != null) {
treeViewer.setUseHashlookup(useFastHashLookup);
}
}

/**
* Calls
* {@link #FilteredTree(Composite, int, PatternFilter, boolean, boolean, long)}
* with a default refresh time
*
* @since 3.116
*/
public FilteredTree(Composite parent, int treeStyle, PatternFilter filter, boolean useNewLook,
boolean useFastHashLookup) {
this(parent, treeStyle, filter, useNewLook, useFastHashLookup, DEFAULT_REFRESH_TIME);
}

/**
* Create a new instance of the receiver.
*
Expand All @@ -187,20 +210,24 @@ public FilteredTree(Composite parent, boolean useNewLook, boolean useFastHashLoo
*
* </p>
*
* @param parent the parent <code>Composite</code>
* @param treeStyle the style bits for the <code>Tree</code>
* @param filter the filter to be used
* @param useNewLook ignored, keep for API compliance
* @param useFastHashLookup true, if tree should use fast hash lookup, false, if
* the tree should be slow but working for data with
* mutable or broken hashcode implementation. Only used
* if treeViewer is already initialized
* @since 3.116
* @param parent the parent <code>Composite</code>
* @param treeStyle the style bits for the <code>Tree</code>
* @param filter the filter to be used
* @param useNewLook ignored, keep for API compliance
* @param useFastHashLookup true, if tree should use fast hash lookup,
* false, if the tree should be slow but working
* for data with mutable or broken hashcode
* implementation. Only used if treeViewer is
* already initialized
* @param refreshJobDelayInMillis refresh delay in ms, the time to expand the
* tree after debounce
* @since 3.132
*/
public FilteredTree(Composite parent, int treeStyle, PatternFilter filter, boolean useNewLook,
boolean useFastHashLookup) {
boolean useFastHashLookup, long refreshJobDelayInMillis) {
super(parent, SWT.NONE);
this.parent = parent;
this.refreshJobDelayInMillis = refreshJobDelayInMillis;
init(treeStyle, filter);
if (treeViewer != null) {
treeViewer.setUseHashlookup(useFastHashLookup);
Expand Down Expand Up @@ -231,6 +258,7 @@ public FilteredTree(Composite parent, int treeStyle, PatternFilter filter, boole
@Deprecated
protected FilteredTree(Composite parent) {
super(parent, SWT.NONE);
this.refreshJobDelayInMillis = DEFAULT_REFRESH_TIME;
this.parent = parent;
}

Expand Down Expand Up @@ -259,8 +287,7 @@ protected FilteredTree(Composite parent) {
*/
@Deprecated
protected FilteredTree(Composite parent, boolean useNewLook) {
super(parent, SWT.NONE);
this.parent = parent;
this(parent);
}

/**
Expand All @@ -282,8 +309,7 @@ protected FilteredTree(Composite parent, boolean useNewLook) {
*/
@Deprecated
public FilteredTree(Composite parent, int treeStyle, PatternFilter filter) {
super(parent, SWT.NONE);
this.parent = parent;
this(parent);
init(treeStyle, filter);
}

Expand All @@ -308,9 +334,7 @@ public FilteredTree(Composite parent, int treeStyle, PatternFilter filter) {
*/
@Deprecated
public FilteredTree(Composite parent, int treeStyle, PatternFilter filter, boolean useNewLook) {
super(parent, SWT.NONE);
this.parent = parent;
init(treeStyle, filter);
this(parent, treeStyle, filter);
}

/**
Expand Down Expand Up @@ -755,7 +779,7 @@ protected void textChanged() {
* @since 3.5
*/
protected long getRefreshJobDelay() {
return 200;
return refreshJobDelayInMillis;
}

/**
Expand Down

0 comments on commit 67617b6

Please sign in to comment.