use of com.intellij.ide.util.treeView.AbstractTreeStructure in project android by JetBrains.
the class TreeGrid method setModel.
private void setModel(@NotNull AbstractTreeStructure model, boolean showSectionHeaders) {
// using the AbstractTreeStructure instead of the model as the actual TreeModel when used with IJ components
// works in a very strange way, each time you expand or contract a node it will add or remove all its children.
Object root = model.getRootElement();
Object[] sections = model.getChildElements(root);
mySectionToComponent.clear();
myLists.clear();
myHideables.clear();
removeAll();
setAutoscrolls(false);
ListSelectionListener listSelectionListener = e -> {
if (e.getValueIsAdjusting()) {
return;
}
ListSelectionModel sourceSelectionModel = (ListSelectionModel) e.getSource();
if (!sourceSelectionModel.isSelectionEmpty()) {
for (JList<T> aList : myLists) {
if (sourceSelectionModel != aList.getSelectionModel()) {
aList.clearSelection();
}
}
}
};
for (Object section : sections) {
String name = section.toString();
FilteringListModel<T> listModel = new FilteringListModel<>(new AbstractListModel() {
@Override
public int getSize() {
return model.getChildElements(section).length;
}
@Override
public Object getElementAt(int index) {
return model.getChildElements(section)[index];
}
});
// Needed as otherwise the filtered list does not show any content.
listModel.refilter();
// JBList does not work with HORIZONTAL_WRAP
//noinspection UndesirableClassUsage,unchecked
JList<T> list = new JList<>(listModel);
list.setAutoscrolls(false);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setVisibleRowCount(-1);
list.getSelectionModel().addListSelectionListener(listSelectionListener);
// for tests to find the right list
list.setName(name);
list.addKeyListener(myKeyListener);
new ListSpeedSearch(list);
myLists.add(list);
if (showSectionHeaders) {
JPanel panel = new // must be BorderLayout for HideableDecorator to work
JPanel(// must be BorderLayout for HideableDecorator to work
new BorderLayout()) {
@Override
public Dimension getMaximumSize() {
return new Dimension(super.getMaximumSize().width, super.getPreferredSize().height);
}
};
HideableDecorator hidyPanel = new HideableDecorator(panel, name, false);
myHideables.add(hidyPanel);
hidyPanel.setContentComponent(list);
add(panel);
mySectionToComponent.put(section, panel);
} else {
if (getComponentCount() > 0) {
add(new JSeparator());
}
list.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
add(list);
mySectionToComponent.put(section, list);
}
}
}
use of com.intellij.ide.util.treeView.AbstractTreeStructure in project android by JetBrains.
the class TargetModulesTreeBuilder method displayTargetModules.
public void displayTargetModules(@NotNull List<AbstractDependencyNode<? extends PsAndroidDependency>> dependencyNodes) {
AbstractTreeStructure treeStructure = getTreeStructure();
if (treeStructure instanceof TargetModulesTreeStructure) {
((TargetModulesTreeStructure) treeStructure).displayTargetModules(dependencyNodes);
queueUpdate();
}
}
use of com.intellij.ide.util.treeView.AbstractTreeStructure in project android by JetBrains.
the class ResolvedDependenciesTreeBuilder method reset.
public void reset() {
AbstractTreeStructure treeStructure = getTreeStructure();
if (treeStructure instanceof ResolvedDependenciesTreeStructure) {
((ResolvedDependenciesTreeStructure) treeStructure).reset();
queueUpdateAndRestoreSelection();
}
}
use of com.intellij.ide.util.treeView.AbstractTreeStructure in project android by JetBrains.
the class TargetArtifactsTreeBuilder method displayTargetArtifacts.
public void displayTargetArtifacts(@Nullable PsAndroidDependency dependency) {
AbstractTreeStructure treeStructure = getTreeStructure();
if (treeStructure instanceof TargetArtifactsTreeStructure) {
((TargetArtifactsTreeStructure) treeStructure).displayTargetArtifacts(dependency);
queueUpdate().doWhenDone(this::expandAllNodes);
}
}
use of com.intellij.ide.util.treeView.AbstractTreeStructure in project android by JetBrains.
the class DependenciesTreeBuilder method reset.
public void reset(@Nullable Runnable onDone) {
AbstractTreeStructure treeStructure = getTreeStructure();
if (treeStructure instanceof DependenciesTreeStructure) {
((DependenciesTreeStructure) treeStructure).reset();
ActionCallback callback = queueUpdate();
if (onDone != null) {
callback.doWhenDone(onDone);
}
}
}
Aggregations