Skip to content

Commit 2650bcb

Browse files
committed
#4141 Show selected item after expand all
1 parent c1cccea commit 2650bcb

File tree

3 files changed

+47
-10
lines changed

3 files changed

+47
-10
lines changed

stroom-core-client/src/main/java/stroom/explorer/client/presenter/ExplorerTreeModel.java

+15-8
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class ExplorerTreeModel {
6060

6161
private Integer minDepth = 1;
6262
private Set<ExplorerNodeKey> ensureVisible;
63+
private ExplorerNode forceSelection;
6364
private boolean showAlerts = false;
6465

6566
private FetchExplorerNodesRequest currentCriteria;
@@ -117,9 +118,13 @@ public void setRequiredPermissions(final String... requiredPermissions) {
117118
explorerTreeFilterBuilder.setRequiredPermissions(requiredPermissions);
118119
}
119120

121+
public void setForceSelection(final ExplorerNode forceSelection) {
122+
this.forceSelection = forceSelection;
123+
}
124+
120125
public void setEnsureVisible(final Set<ExplorerNode> ensureVisible) {
121126
this.ensureVisible = null;
122-
if (ensureVisible != null) {
127+
if (ensureVisible != null && ensureVisible.size() > 0) {
123128
this.ensureVisible = new HashSet<>();
124129
for (ExplorerNode node : ensureVisible) {
125130
if (node != null && node.getUniqueKey() != null) {
@@ -131,7 +136,7 @@ public void setEnsureVisible(final Set<ExplorerNode> ensureVisible) {
131136

132137
public void setEnsureVisible(final ExplorerNode... ensureVisible) {
133138
this.ensureVisible = null;
134-
if (ensureVisible != null) {
139+
if (ensureVisible != null && ensureVisible.length > 0) {
135140
this.ensureVisible = new HashSet<>();
136141
for (ExplorerNode node : ensureVisible) {
137142
if (node != null && node.getUniqueKey() != null) {
@@ -230,9 +235,11 @@ private void handleFetchResult(final FetchExplorerNodesRequest criteria,
230235
// Try and find the item we have asked to make visible first and if we can't find
231236
// that try and select one of the folders that has been forced open in an attempt to
232237
// 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) {
234242
final ExplorerNodeKey uniqueKey = criteria.getEnsureVisible().iterator().next();
235-
ExplorerNode nextSelection = null;
236243
if (uniqueKey != null) {
237244
nextSelection = ExplorerNode.builder()
238245
.type(uniqueKey.getType())
@@ -269,10 +276,9 @@ private void handleFetchResult(final FetchExplorerNodesRequest criteria,
269276
// that we get the latest version with any new name it might have.
270277
nextSelection = rows.get(index);
271278
}
272-
273-
if (nextSelection != null) {
274-
explorerTree.setInitialSelectedItem(nextSelection);
275-
}
279+
}
280+
if (nextSelection != null) {
281+
explorerTree.setInitialSelectedItem(nextSelection);
276282
}
277283

278284
// We do not want the root to always be forced open.
@@ -283,6 +289,7 @@ private void handleFetchResult(final FetchExplorerNodesRequest criteria,
283289
// ensure visibility of. We can forget them now as we have a result that should have
284290
// opened required folders to make them visible.
285291
ensureVisible = null;
292+
forceSelection = null;
286293

287294
// We aren't loading any more.
288295
loading.setVisible(false);

stroom-core-client/src/main/java/stroom/explorer/client/presenter/NavigationPresenter.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,14 @@ protected void onBind() {
207207
}
208208
locate.setEnabled(selectedDoc != null);
209209
}));
210-
registerHandler(collapseAll.addClickHandler((e) -> explorerTree.getTreeModel().collapseAll()));
211-
registerHandler(expandAll.addClickHandler((e) -> explorerTree.getTreeModel().expandAll()));
210+
registerHandler(collapseAll.addClickHandler((e) -> {
211+
explorerTree.getTreeModel().setForceSelection(explorerTree.getSelectionModel().getSelected());
212+
explorerTree.getTreeModel().collapseAll();
213+
}));
214+
registerHandler(expandAll.addClickHandler((e) -> {
215+
explorerTree.getTreeModel().setForceSelection(explorerTree.getSelectionModel().getSelected());
216+
explorerTree.getTreeModel().expandAll();
217+
}));
212218
registerHandler(locate.addClickHandler((e) -> LocateDocEvent.fire(this, selectedDoc)));
213219
registerHandler(find.addClickHandler((e) -> ShowFindInContentEvent.fire(this)));
214220
registerHandler(add.addClickHandler((e) -> newItem(add.getElement())));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
* Issue **#4141** : Show selected item after expand all.
2+
3+
4+
```sh
5+
# ********************************************************************************
6+
# Issue title: Expand /Collapse All can't see currently highlighted Item
7+
# Issue link: https://github.com/gchq/stroom/issues/4141
8+
# ********************************************************************************
9+
10+
# ONLY the top line will be included as a change entry in the CHANGELOG.
11+
# The entry should be in GitHub flavour markdown and should be written on a SINGLE
12+
# line with no hard breaks. You can have multiple change files for a single GitHub issue.
13+
# The entry should be written in the imperative mood, i.e. 'Fix nasty bug' rather than
14+
# 'Fixed nasty bug'.
15+
#
16+
# Examples of acceptable entries are:
17+
#
18+
#
19+
# * Issue **123** : Fix bug with an associated GitHub issue in this repository
20+
#
21+
# * Issue **namespace/other-repo#456** : Fix bug with an associated GitHub issue in another repository
22+
#
23+
# * Fix bug with no associated GitHub issue.
24+
```

0 commit comments

Comments
 (0)