Skip to content

Commit

Permalink
Project Explorer: auto-expand long paths of single elements #1063
Browse files Browse the repository at this point in the history
This commit enables auto-expansion of paths of elements with single
children in the project explorer.
In order not to accidentally lazy-load a big amount of files,
the auto-expansion is limited to a depth of 10 elements.

Implements #1063
  • Loading branch information
Wittmaxi authored and HeikoKlare committed Mar 28, 2024
1 parent c40b7a1 commit 3f00c8b
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
Expand Down Expand Up @@ -84,6 +85,14 @@
@SuppressWarnings("restriction")
public final class ProjectExplorer extends CommonNavigator implements ISecondarySaveableSource {

/**
* Number of levels to automatically expand when an element only has a single
* child.
*
* @see AbstractTreeViewer#setAutoExpandOnSingleChildLevels(int)
*/
private static final int AUTO_EXPAND_ON_SINGLE_CHILD_LEVEL_COUNT = 10;

/**
* Provides a constant for the standard instance of the Common Navigator.
*
Expand Down Expand Up @@ -164,6 +173,7 @@ public void createPartControl(Composite aParent) {
if (this.userFilters.stream().anyMatch(UserFilter::isEnabled)) {
getCommonViewer().refresh();
}
getCommonViewer().setAutoExpandOnSingleChildLevels(AUTO_EXPAND_ON_SINGLE_CHILD_LEVEL_COUNT);
}

@Override
Expand Down

0 comments on commit 3f00c8b

Please sign in to comment.