Search in sources :

Example 6 with InspectionConfigTreeNode

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);
}
Also used : ArrayList(java.util.ArrayList) THashSet(gnu.trove.THashSet) InspectionConfigTreeNode(com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode)

Example 7 with InspectionConfigTreeNode

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()));
    }
}
Also used : TreePath(javax.swing.tree.TreePath) InspectionConfigTreeNode(com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode)

Example 8 with InspectionConfigTreeNode

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);
        }
    }
}
Also used : InspectionConfigTreeNode(com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode)

Example 9 with InspectionConfigTreeNode

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());
}
Also used : THashSet(gnu.trove.THashSet) InspectionConfigTreeNode(com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode) Project(com.intellij.openapi.project.Project) InspectionsConfigTreeComparator(com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigTreeComparator) THashSet(gnu.trove.THashSet)

Example 10 with InspectionConfigTreeNode

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;
}
Also used : InspectionsConfigTreeRenderer(com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigTreeRenderer) InspectionConfigTreeNode(com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode) TreePath(javax.swing.tree.TreePath)

Aggregations

InspectionConfigTreeNode (com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionConfigTreeNode)13 TreePath (javax.swing.tree.TreePath)7 THashSet (gnu.trove.THashSet)3 Project (com.intellij.openapi.project.Project)2 InspectionsConfigTreeComparator (com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigTreeComparator)2 InspectionsConfigTreeRenderer (com.intellij.profile.codeInspection.ui.inspectionsTree.InspectionsConfigTreeRenderer)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 Nullable (org.jetbrains.annotations.Nullable)2 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)1 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1 HighlightInfoType (com.intellij.codeInsight.daemon.impl.HighlightInfoType)1 SeverityRegistrar (com.intellij.codeInsight.daemon.impl.SeverityRegistrar)1 HintUtil (com.intellij.codeInsight.hint.HintUtil)1 InspectionsBundle (com.intellij.codeInspection.InspectionsBundle)1 com.intellij.codeInspection.ex (com.intellij.codeInspection.ex)1 AllIcons (com.intellij.icons.AllIcons)1 com.intellij.ide (com.intellij.ide)1 SearchUtil (com.intellij.ide.ui.search.SearchUtil)1 SearchableOptionsRegistrar (com.intellij.ide.ui.search.SearchableOptionsRegistrar)1 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)1