@@ -60,6 +60,7 @@ public class ExplorerTreeModel {
60
60
61
61
private Integer minDepth = 1 ;
62
62
private Set <ExplorerNodeKey > ensureVisible ;
63
+ private ExplorerNode forceSelection ;
63
64
private boolean showAlerts = false ;
64
65
65
66
private FetchExplorerNodesRequest currentCriteria ;
@@ -117,9 +118,13 @@ public void setRequiredPermissions(final String... requiredPermissions) {
117
118
explorerTreeFilterBuilder .setRequiredPermissions (requiredPermissions );
118
119
}
119
120
121
+ public void setForceSelection (final ExplorerNode forceSelection ) {
122
+ this .forceSelection = forceSelection ;
123
+ }
124
+
120
125
public void setEnsureVisible (final Set <ExplorerNode > ensureVisible ) {
121
126
this .ensureVisible = null ;
122
- if (ensureVisible != null ) {
127
+ if (ensureVisible != null && ensureVisible . size () > 0 ) {
123
128
this .ensureVisible = new HashSet <>();
124
129
for (ExplorerNode node : ensureVisible ) {
125
130
if (node != null && node .getUniqueKey () != null ) {
@@ -131,7 +136,7 @@ public void setEnsureVisible(final Set<ExplorerNode> ensureVisible) {
131
136
132
137
public void setEnsureVisible (final ExplorerNode ... ensureVisible ) {
133
138
this .ensureVisible = null ;
134
- if (ensureVisible != null ) {
139
+ if (ensureVisible != null && ensureVisible . length > 0 ) {
135
140
this .ensureVisible = new HashSet <>();
136
141
for (ExplorerNode node : ensureVisible ) {
137
142
if (node != null && node .getUniqueKey () != null ) {
@@ -230,9 +235,11 @@ private void handleFetchResult(final FetchExplorerNodesRequest criteria,
230
235
// Try and find the item we have asked to make visible first and if we can't find
231
236
// that try and select one of the folders that has been forced open in an attempt to
232
237
// make the requested item visible.
233
- if (criteria .getEnsureVisible () != null && criteria .getEnsureVisible ().size () > 0 ) {
238
+ ExplorerNode nextSelection = forceSelection ;
239
+ if (nextSelection == null &&
240
+ criteria .getEnsureVisible () != null &&
241
+ criteria .getEnsureVisible ().size () > 0 ) {
234
242
final ExplorerNodeKey uniqueKey = criteria .getEnsureVisible ().iterator ().next ();
235
- ExplorerNode nextSelection = null ;
236
243
if (uniqueKey != null ) {
237
244
nextSelection = ExplorerNode .builder ()
238
245
.type (uniqueKey .getType ())
@@ -269,10 +276,9 @@ private void handleFetchResult(final FetchExplorerNodesRequest criteria,
269
276
// that we get the latest version with any new name it might have.
270
277
nextSelection = rows .get (index );
271
278
}
272
-
273
- if (nextSelection != null ) {
274
- explorerTree .setInitialSelectedItem (nextSelection );
275
- }
279
+ }
280
+ if (nextSelection != null ) {
281
+ explorerTree .setInitialSelectedItem (nextSelection );
276
282
}
277
283
278
284
// We do not want the root to always be forced open.
@@ -283,6 +289,7 @@ private void handleFetchResult(final FetchExplorerNodesRequest criteria,
283
289
// ensure visibility of. We can forget them now as we have a result that should have
284
290
// opened required folders to make them visible.
285
291
ensureVisible = null ;
292
+ forceSelection = null ;
286
293
287
294
// We aren't loading any more.
288
295
loading .setVisible (false );
0 commit comments