use of com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode in project intellij-community by JetBrains.
the class InspectionsAggregationUtil method getInspectionsNodes.
private static List<InspectionConfigTreeNode> getInspectionsNodes(final Queue<InspectionConfigTreeNode> queue) {
final Set<InspectionConfigTreeNode> nodes = new THashSet<>();
while (!queue.isEmpty()) {
final InspectionConfigTreeNode node = queue.pullFirst();
if (node.getDescriptors() == null) {
for (int i = 0; i < node.getChildCount(); i++) {
final InspectionConfigTreeNode childNode = (InspectionConfigTreeNode) node.getChildAt(i);
queue.addLast(childNode);
}
} else {
nodes.add(node);
}
}
return new ArrayList<>(nodes);
}
use of com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode in project intellij-community by JetBrains.
the class SingleInspectionProfilePanel method selectInspectionGroup.
public void selectInspectionGroup(String[] path) {
final InspectionConfigTreeNode node = findGroupNodeByPath(path, 0, myRoot);
selectNode(node);
if (node != null) {
myTreeTable.getTree().expandPath(new TreePath(node.getPath()));
}
}
use of com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode in project intellij-community by JetBrains.
the class SingleInspectionProfilePanel method updateErrorLevelUpInHierarchy.
private void updateErrorLevelUpInHierarchy(@NotNull HighlightDisplayLevel level, boolean showOptionsAndDescriptorPanels, InspectionConfigTreeNode node) {
node.dropCache();
for (int j = 0; j < node.getChildCount(); j++) {
final InspectionConfigTreeNode child = (InspectionConfigTreeNode) node.getChildAt(j);
final Object userObject = child.getUserObject();
if (userObject instanceof ToolDescriptors && (child.getScopeName() != null || child.isLeaf())) {
updateErrorLevel(child, showOptionsAndDescriptorPanels, level);
} else {
updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, child);
}
}
}
use of com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode in project intellij-community by JetBrains.
the class SingleInspectionProfilePanel method fillTreeData.
private void fillTreeData(@Nullable String filter, boolean forceInclude) {
if (myProfile == null)
return;
myRoot.removeAllChildren();
myRoot.dropCache();
List<Set<String>> keySetList = new ArrayList<>();
final Set<String> quoted = new HashSet<>();
if (filter != null && !filter.isEmpty()) {
keySetList.addAll(SearchUtil.findKeys(filter, quoted));
}
Project project = myProjectProfileManager.getProject();
final boolean emptyFilter = myInspectionsFilter.isEmptyFilter();
for (ToolDescriptors toolDescriptors : myInitialToolDescriptors.values()) {
final Descriptor descriptor = toolDescriptors.getDefaultDescriptor();
if (filter != null && !filter.isEmpty() && !isDescriptorAccepted(descriptor, filter, forceInclude, keySetList, quoted)) {
continue;
}
final InspectionConfigTreeNode node = new InspectionConfigTreeNode.Tool(toolDescriptors.getDefaultDescriptor().getKey(), this);
if (!emptyFilter && !myInspectionsFilter.matches(myProfile.getTools(toolDescriptors.getDefaultDescriptor().getKey().toString(), project), node)) {
continue;
}
getGroupNode(myRoot, toolDescriptors.getDefaultDescriptor().getGroup()).add(node);
myRoot.dropCache();
}
if (filter != null && forceInclude && myRoot.getChildCount() == 0) {
final Set<String> filters = SearchableOptionsRegistrar.getInstance().getProcessedWords(filter);
if (filters.size() > 1 || !quoted.isEmpty()) {
fillTreeData(filter, false);
}
}
TreeUtil.sortRecursively(myRoot, new InspectionsConfigTreeComparator());
}
use of com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode 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