use of com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigTreeRenderer in project intellij-community by JetBrains.
the class SingleInspectionProfilePanel method initTreeScrollPane.
private JScrollPane initTreeScrollPane() {
fillTreeData(null, true);
final InspectionsConfigTreeRenderer renderer = new InspectionsConfigTreeRenderer() {
@Override
protected String getFilter() {
return myProfileFilter != null ? myProfileFilter.getFilter() : null;
}
};
myTreeTable = InspectionsConfigTreeTable.create(new InspectionsConfigTreeTable.InspectionsConfigTreeTableSettings(myRoot, myProjectProfileManager.getProject()) {
@Override
protected void onChanged(final InspectionConfigTreeNode node) {
updateUpHierarchy((InspectionConfigTreeNode) node.getParent());
}
@Override
public void updateRightPanel() {
updateOptionsAndDescriptionPanel();
}
@Override
public InspectionProfileImpl getInspectionProfile() {
return myProfile;
}
}, myDisposable);
myTreeTable.setTreeCellRenderer(renderer);
myTreeTable.setRootVisible(false);
UIUtil.setLineStyleAngled(myTreeTable.getTree());
TreeUtil.installActions(myTreeTable.getTree());
myTreeTable.getTree().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
if (myTreeTable.getTree().getSelectionPaths() != null) {
updateOptionsAndDescriptionPanel(myTreeTable.getTree().getSelectionPaths());
} else {
initOptionsAndDescriptionPanel();
}
if (!myIsInRestore) {
InspectionProfileModifiableModel selected = myProfile;
if (selected != null) {
InspectionProfileImpl baseProfile = selected.getSource();
getExpandedNodes(baseProfile).setSelectionPaths(myTreeTable.getTree().getSelectionPaths());
getExpandedNodes(selected).setSelectionPaths(myTreeTable.getTree().getSelectionPaths());
}
}
}
});
myTreeTable.addMouseListener(new PopupHandler() {
@Override
public void invokePopup(Component comp, int x, int y) {
final int[] selectionRows = myTreeTable.getTree().getSelectionRows();
if (selectionRows != null && myTreeTable.getTree().getPathForLocation(x, y) != null && Arrays.binarySearch(selectionRows, myTreeTable.getTree().getRowForLocation(x, y)) > -1) {
compoundPopup().show(comp, x, y);
}
}
});
new TreeSpeedSearch(myTreeTable.getTree(), new Convertor<TreePath, String>() {
@Override
public String convert(TreePath o) {
final InspectionConfigTreeNode node = (InspectionConfigTreeNode) o.getLastPathComponent();
final Descriptor descriptor = node.getDefaultDescriptor();
return InspectionsConfigTreeComparator.getDisplayTextToSort(descriptor != null ? descriptor.getText() : node.getGroupName());
}
});
final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTreeTable);
myTreeTable.getTree().setShowsRootHandles(true);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM + SideBorder.LEFT + SideBorder.TOP));
TreeUtil.collapseAll(myTreeTable.getTree(), 1);
myTreeTable.getTree().addTreeExpansionListener(new TreeExpansionListener() {
@Override
public void treeCollapsed(TreeExpansionEvent event) {
InspectionProfileModifiableModel selected = myProfile;
getExpandedNodes(selected.getSource()).saveVisibleState(myTreeTable.getTree());
getExpandedNodes(selected).saveVisibleState(myTreeTable.getTree());
}
@Override
public void treeExpanded(TreeExpansionEvent event) {
InspectionProfileModifiableModel selected = myProfile;
if (selected != null) {
final InspectionConfigTreeNode node = (InspectionConfigTreeNode) event.getPath().getLastPathComponent();
getExpandedNodes(selected.getSource()).expandNode(node);
getExpandedNodes(selected).expandNode(node);
}
}
});
myTreeExpander = new DefaultTreeExpander(myTreeTable.getTree()) {
@Override
public boolean canExpand() {
return myTreeTable.isShowing();
}
@Override
public boolean canCollapse() {
return myTreeTable.isShowing();
}
};
myProfileFilter = new MyFilterComponent();
return scrollPane;
}
Aggregations