Skip to content

Commit

Permalink
Support setExpanded for ExpandableNode to render next block of items.
Browse files Browse the repository at this point in the history
Search View result navigator is updated to use above fix. Now Next
search result should expand the ExpandableNode and try to find next
Result.
This also enables incremental display feature for SearchView.

Fixes eclipse-platform#1024
  • Loading branch information
raghucssit committed Aug 23, 2023
1 parent ffb0cdc commit e49f018
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2596,6 +2596,7 @@ public void setExpandedState(Object elementOrTreePath, boolean expanded) {
Assert.isNotNull(elementOrTreePath);
if (checkBusy())
return;

Widget item = internalExpand(elementOrTreePath, false);
if (item instanceof Item) {
if (expanded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1203,4 +1203,18 @@ Object getLastElement(Widget parent) {
}
return items[length - 1].getData();
}

@Override
public void setExpandedState(Object elementOrTreePath, boolean expanded) {
// Special behavior for ExpandableNode. Expand the it if it's widget is found
// otherwise do not expand it.
if (isExpandableNode(elementOrTreePath)) {
Widget expItem = findItem(elementOrTreePath);
if (expItem != null) {
handleExpandableNodeClicked(expItem);
}
return;
}
super.setExpandedState(elementOrTreePath, expanded);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.IOpenListener;
Expand Down Expand Up @@ -84,6 +85,7 @@
import org.eclipse.ui.part.Page;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.views.WorkbenchViewerSetup;

import org.eclipse.ui.texteditor.IUpdate;

Expand Down Expand Up @@ -731,7 +733,7 @@ private void createViewer(Composite parent, int layout) {
fCollapseAllAction.setViewer(viewer);
fExpandAllAction.setViewer(viewer);
}

WorkbenchViewerSetup.setupViewer((ColumnViewer) fViewer);
fCopyToClipboardAction.setViewer(fViewer);
fSelectAllAction.setViewer(fViewer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ private TreeItem getNextItemForward(TreeItem currentItem) {
return child;
TreeItem nextSibling= getNextSibling(currentItem, true);
if (nextSibling != null) {
// expand the node first and fetch the sibling again.
if (fViewer.isExpandableNode(nextSibling.getData())) {
fViewer.setExpandedState(nextSibling.getData(), true);
nextSibling = getNextSibling(currentItem, true);
}
if (hasMatches(nextSibling))
return nextSibling;
return getFirstChildWithMatches(nextSibling);
Expand All @@ -116,6 +121,11 @@ private TreeItem getNextItemForward(TreeItem currentItem) {
while (parent != null) {
nextSibling= getNextSibling(parent, true);
if (nextSibling != null) {
// expand the node first and fetch the sibling again.
if (fViewer.isExpandableNode(nextSibling.getData())) {
fViewer.setExpandedState(nextSibling.getData(), true);
nextSibling = getNextSibling(parent, true);
}
if (hasMatches(nextSibling))
return nextSibling;
return getFirstChildWithMatches(nextSibling);
Expand Down

0 comments on commit e49f018

Please sign in to comment.