summaryrefslogtreecommitdiff
path: root/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree
diff options
context:
space:
mode:
Diffstat (limited to 'platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree')
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionConfigTreeNode.java97
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeComparator.java74
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeRenderer.java95
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java257
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/MultiScopeSeverityIcon.java74
-rw-r--r--platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/ScopesAndSeveritiesHintTable.java106
6 files changed, 703 insertions, 0 deletions
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionConfigTreeNode.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionConfigTreeNode.java
new file mode 100644
index 000000000000..1f26308c61b1
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionConfigTreeNode.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.profile.codeInspection.ui.inspectionsTree;
+
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInspection.ex.Descriptor;
+import com.intellij.openapi.util.ClearableLazyValue;
+import com.intellij.profile.codeInspection.ui.ToolDescriptors;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+/**
+ * @author anna
+ * @since 14-May-2009
+ */
+public class InspectionConfigTreeNode extends DefaultMutableTreeNode {
+ private final ClearableLazyValue<Boolean> myProperSetting = new ClearableLazyValue<Boolean>() {
+ @NotNull
+ @Override
+ protected Boolean compute() {
+ ToolDescriptors descriptors = getDescriptors();
+ if (descriptors != null) {
+ final Descriptor defaultDescriptor = descriptors.getDefaultDescriptor();
+ return defaultDescriptor.getInspectionProfile().isProperSetting(defaultDescriptor.getToolWrapper().getShortName());
+ }
+ for (int i = 0; i < getChildCount(); i++) {
+ InspectionConfigTreeNode node = (InspectionConfigTreeNode)getChildAt(i);
+ if (node.isProperSetting()) {
+ return true;
+ }
+ }
+ return false;
+ }
+ };
+
+ public InspectionConfigTreeNode(@NotNull Object userObject) {
+ super(userObject);
+ }
+
+ public HighlightDisplayKey getKey() {
+ return getDefaultDescriptor().getKey();
+ }
+
+ @Nullable
+ public Descriptor getDefaultDescriptor() {
+ final ToolDescriptors descriptors = getDescriptors();
+ return descriptors == null ? null : descriptors.getDefaultDescriptor();
+ }
+
+ @Nullable
+ public ToolDescriptors getDescriptors() {
+ if (userObject instanceof String) return null;
+ return (ToolDescriptors)userObject;
+ }
+
+ @Nullable
+ public String getGroupName() {
+ return userObject instanceof String ? (String)userObject : null;
+ }
+
+ @Nullable
+ public String getScopeName() {
+ final ToolDescriptors descriptors = getDescriptors();
+ return descriptors != null ? descriptors.getDefaultScopeToolState().getScopeName() : null;
+ }
+
+ public boolean isProperSetting() {
+ return myProperSetting.getValue();
+ }
+
+ public void dropCache() {
+ myProperSetting.drop();
+ }
+
+ @Override
+ public String toString() {
+ if (userObject instanceof Descriptor) {
+ return ((Descriptor)userObject).getText();
+ }
+ return super.toString();
+ }
+} \ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeComparator.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeComparator.java
new file mode 100644
index 000000000000..b920b0b741ab
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeComparator.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * User: anna
+ * Date: 14-May-2009
+ */
+package com.intellij.profile.codeInspection.ui.inspectionsTree;
+
+import com.intellij.profile.codeInspection.ui.ToolDescriptors;
+
+import java.util.Comparator;
+
+public class InspectionsConfigTreeComparator implements Comparator<InspectionConfigTreeNode> {
+ @Override
+ public int compare(InspectionConfigTreeNode o1, InspectionConfigTreeNode o2) {
+ String s1 = null;
+ String s2 = null;
+ Object userObject1 = o1.getUserObject();
+ Object userObject2 = o2.getUserObject();
+
+ if (userObject1 instanceof String && userObject2 instanceof String) {
+ s1 = (String)userObject1;
+ s2 = (String)userObject2;
+ } else {
+ if (userObject1 instanceof String) return -1;
+ if (userObject2 instanceof String) return 1;
+ }
+
+ if (s1 != null) {
+ return getDisplayTextToSort(s1).compareToIgnoreCase(getDisplayTextToSort(s2));
+ }
+
+ final ToolDescriptors descriptors1 = o1.getDescriptors();
+ final ToolDescriptors descriptors2 = o2.getDescriptors();
+ if (descriptors1 != null && descriptors2 != null) {
+ s1 = descriptors1.getDefaultDescriptor().getText();
+ s2 = descriptors2.getDefaultDescriptor().getText();
+ }
+
+ if (s1 != null && s2 != null) {
+ return getDisplayTextToSort(s1).compareToIgnoreCase(getDisplayTextToSort(s2));
+ }
+
+ //can't be
+ return -1;
+ }
+
+ public static String getDisplayTextToSort(String s) {
+ if (s.length() == 0) {
+ return s;
+ }
+ while (!Character.isLetterOrDigit(s.charAt(0))) {
+ s = s.substring(1);
+ if (s.length() == 0) {
+ return s;
+ }
+ }
+ return s;
+ }
+} \ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeRenderer.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeRenderer.java
new file mode 100644
index 000000000000..43b791cbe6a2
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeRenderer.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2000-2012 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * User: anna
+ * Date: 14-May-2009
+ */
+package com.intellij.profile.codeInspection.ui.inspectionsTree;
+
+import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.codeInspection.ex.Descriptor;
+import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
+import com.intellij.codeInspection.ex.InspectionToolWrapper;
+import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
+import com.intellij.ide.ui.search.SearchUtil;
+import com.intellij.profile.codeInspection.ui.ToolDescriptors;
+import com.intellij.ui.ColoredTreeCellRenderer;
+import com.intellij.ui.SimpleTextAttributes;
+import com.intellij.util.ui.PlatformColors;
+import com.intellij.util.ui.UIUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+
+public abstract class InspectionsConfigTreeRenderer extends ColoredTreeCellRenderer {
+ protected abstract String getFilter();
+
+ @Override
+ public void customizeCellRenderer(@NotNull final JTree tree,
+ final Object value,
+ final boolean selected,
+ final boolean expanded,
+ final boolean leaf,
+ final int row,
+ final boolean hasFocus) {
+ if (!(value instanceof InspectionConfigTreeNode)) return;
+ InspectionConfigTreeNode node = (InspectionConfigTreeNode)value;
+
+ Object object = node.getUserObject();
+
+ final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
+ UIUtil.changeBackGround(this, background);
+ Color foreground =
+ selected ? UIUtil.getTreeSelectionForeground() : node.isProperSetting() ? PlatformColors.BLUE : UIUtil.getTreeTextForeground();
+
+ @NonNls String text;
+ int style = SimpleTextAttributes.STYLE_PLAIN;
+ String hint = null;
+ if (object instanceof String) {
+ text = (String)object;
+ style = SimpleTextAttributes.STYLE_BOLD;
+ }
+ else {
+ final ToolDescriptors descriptors = node.getDescriptors();
+ assert descriptors != null;
+ final Descriptor defaultDescriptor = descriptors.getDefaultDescriptor();
+ text = defaultDescriptor.getText();
+ hint = getHint(defaultDescriptor);
+ }
+
+ if (text != null) {
+ SearchUtil.appendFragments(getFilter(), text, style, foreground, background, this);
+ }
+ if (hint != null) {
+ append(" " + hint, selected ? new SimpleTextAttributes(Font.PLAIN, foreground) : SimpleTextAttributes.GRAYED_ATTRIBUTES);
+ }
+ setForeground(foreground);
+ }
+
+ @Nullable
+ private static String getHint(final Descriptor descriptor) {
+ final InspectionToolWrapper toolWrapper = descriptor.getToolWrapper();
+ if (toolWrapper instanceof LocalInspectionToolWrapper ||
+ toolWrapper instanceof GlobalInspectionToolWrapper && !((GlobalInspectionToolWrapper)toolWrapper).worksInBatchModeOnly()) {
+ return null;
+ }
+ return InspectionsBundle.message("inspection.tool.availability.in.tree.node1");
+ }
+} \ No newline at end of file
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java
new file mode 100644
index 000000000000..966a456e1d38
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/InspectionsConfigTreeTable.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.profile.codeInspection.ui.inspectionsTree;
+
+import com.intellij.codeHighlighting.HighlightDisplayLevel;
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInspection.ex.InspectionProfileImpl;
+import com.intellij.codeInspection.ex.ScopeToolState;
+import com.intellij.ide.IdeTooltip;
+import com.intellij.ide.IdeTooltipManager;
+import com.intellij.lang.annotation.HighlightSeverity;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Comparing;
+import com.intellij.profile.codeInspection.ui.InspectionsAggregationUtil;
+import com.intellij.profile.codeInspection.ui.table.ScopesAndSeveritiesTable;
+import com.intellij.profile.codeInspection.ui.table.ThreeStateCheckBoxRenderer;
+import com.intellij.ui.treeStructure.treetable.TreeTable;
+import com.intellij.ui.treeStructure.treetable.TreeTableModel;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import javax.swing.table.TableColumn;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+import java.awt.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.*;
+import java.util.List;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public class InspectionsConfigTreeTable extends TreeTable {
+ private final static Logger LOG = Logger.getInstance(InspectionsConfigTreeTable.class);
+
+ private final static int TREE_COLUMN = 0;
+ private final static int SEVERITIES_COLUMN = 1;
+ private final static int IS_ENABLED_COLUMN = 2;
+
+ public InspectionsConfigTreeTable(final InspectionsConfigTreeTableSettings settings) {
+ super(new InspectionsConfigTreeTableModel(settings));
+
+ final TableColumn severitiesColumn = getColumnModel().getColumn(SEVERITIES_COLUMN);
+ severitiesColumn.setMaxWidth(20);
+
+ final TableColumn isEnabledColumn = getColumnModel().getColumn(IS_ENABLED_COLUMN);
+ isEnabledColumn.setMaxWidth(20);
+ isEnabledColumn.setCellRenderer(new ThreeStateCheckBoxRenderer());
+ isEnabledColumn.setCellEditor(new ThreeStateCheckBoxRenderer());
+
+ addMouseMotionListener(new MouseAdapter() {
+ @Override
+ public void mouseMoved(final MouseEvent e) {
+ final Point point = e.getPoint();
+ final int column = columnAtPoint(point);
+ if (column != SEVERITIES_COLUMN) {
+ return;
+ }
+ final int row = rowAtPoint(point);
+ final Object maybeIcon = getModel().getValueAt(row, column);
+ if (maybeIcon instanceof MultiScopeSeverityIcon) {
+ final LinkedHashMap<String, HighlightSeverity> scopeToAverageSeverityMap =
+ ((MultiScopeSeverityIcon)maybeIcon).getScopeToAverageSeverityMap();
+ IdeTooltipManager.getInstance().show(new IdeTooltip(InspectionsConfigTreeTable.this, point, new ScopesAndSeveritiesHintTable(scopeToAverageSeverityMap)), false);
+ }
+ }
+ });
+ }
+
+ public abstract static class InspectionsConfigTreeTableSettings {
+ private final TreeNode myRoot;
+ private final Project myProject;
+
+ public InspectionsConfigTreeTableSettings(final TreeNode root, final Project project) {
+ myRoot = root;
+ myProject = project;
+ }
+
+ public TreeNode getRoot() {
+ return myRoot;
+ }
+
+ public Project getProject() {
+ return myProject;
+ }
+
+ protected abstract InspectionProfileImpl getInspectionProfile();
+
+ protected abstract void onChanged(InspectionConfigTreeNode node);
+ }
+
+ private static class InspectionsConfigTreeTableModel extends DefaultTreeModel implements TreeTableModel {
+
+ private final InspectionsConfigTreeTableSettings mySettings;
+
+ public InspectionsConfigTreeTableModel(final InspectionsConfigTreeTableSettings settings) {
+ super(settings.getRoot());
+ mySettings = settings;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 3;
+ }
+
+ @Nullable
+ @Override
+ public String getColumnName(final int column) {
+ return null;
+ }
+
+ @Override
+ public Class getColumnClass(final int column) {
+ switch (column) {
+ case TREE_COLUMN:
+ return TreeTableModel.class;
+ case SEVERITIES_COLUMN:
+ return Icon.class;
+ case IS_ENABLED_COLUMN:
+ return Boolean.class;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ @Nullable
+ @Override
+ public Object getValueAt(final Object node, final int column) {
+ if (column == TREE_COLUMN) {
+ return null;
+ }
+ final InspectionConfigTreeNode treeNode = (InspectionConfigTreeNode)node;
+ final List<HighlightDisplayKey> inspectionsKeys = InspectionsAggregationUtil.getInspectionsKeys(treeNode);
+ if (column == SEVERITIES_COLUMN) {
+ final MultiColoredHighlightSeverityIconSink sink = new MultiColoredHighlightSeverityIconSink();
+ for (final HighlightDisplayKey selectedInspectionsNode : inspectionsKeys) {
+ final String toolId = selectedInspectionsNode.toString();
+ if (mySettings.getInspectionProfile().getTools(toolId, mySettings.getProject()).isEnabled()) {
+ sink.put(mySettings.getInspectionProfile().getToolDefaultState(toolId, mySettings.getProject()),
+ mySettings.getInspectionProfile().getNonDefaultTools(toolId, mySettings.getProject()));
+ }
+ }
+ return sink.constructIcon();
+ } else if (column == IS_ENABLED_COLUMN) {
+ return isEnabled(inspectionsKeys);
+ }
+ throw new IllegalArgumentException();
+ }
+
+ @Nullable
+ private Boolean isEnabled(final List<HighlightDisplayKey> selectedInspectionsNodes) {
+ Boolean isPreviousEnabled = null;
+ for (final HighlightDisplayKey key : selectedInspectionsNodes) {
+ final boolean enabled = mySettings.getInspectionProfile().getTools(key.toString(), mySettings.getProject()).isEnabled();
+ if (isPreviousEnabled == null) {
+ isPreviousEnabled = enabled;
+ } else if (!isPreviousEnabled.equals(enabled)) {
+ return null;
+ }
+ }
+ return isPreviousEnabled;
+ }
+
+ @Override
+ public boolean isCellEditable(final Object node, final int column) {
+ return column == IS_ENABLED_COLUMN;
+ }
+
+ @Override
+ public void setValueAt(final Object aValue, final Object node, final int column) {
+ LOG.assertTrue(column == IS_ENABLED_COLUMN);
+ LOG.assertTrue(aValue != null);
+ final boolean doEnable = (Boolean) aValue;
+ for (final InspectionConfigTreeNode aNode : InspectionsAggregationUtil.getInspectionsNodes((InspectionConfigTreeNode) node)) {
+ final String toolId = aNode.getKey().toString();
+ if (doEnable) {
+ mySettings.getInspectionProfile().enableTool(toolId, mySettings.getProject());
+ } else {
+ mySettings.getInspectionProfile().disableTool(toolId, mySettings.getProject());
+ }
+ aNode.dropCache();
+ mySettings.onChanged(aNode);
+ }
+ }
+
+ @Override
+ public void setTree(final JTree tree) {
+ }
+ }
+
+ private static class MultiColoredHighlightSeverityIconSink {
+
+ private final LinkedHashMap<String, HighlightSeverity> myScopeToAverageSeverityMap = new LinkedHashMap<String, HighlightSeverity>();
+
+ private boolean myIsFirst = true;
+
+ public Icon constructIcon() {
+ if (myScopeToAverageSeverityMap.isEmpty()) {
+ return null;
+ }
+ //TODO order scopes
+ return !allScopesHasMixedSeverity()
+ ? new MultiScopeSeverityIcon(myScopeToAverageSeverityMap)
+ : ScopesAndSeveritiesTable.MIXED_FAKE_LEVEL.getIcon();
+ }
+
+ private boolean allScopesHasMixedSeverity() {
+ for (final Map.Entry<String, HighlightSeverity> e : myScopeToAverageSeverityMap.entrySet()) {
+ if (!ScopesAndSeveritiesTable.MIXED_FAKE_SEVERITY.equals(e.getValue())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void put(final ScopeToolState defaultState, final Collection<ScopeToolState> nonDefault) {
+ putOne(defaultState);
+ for (final ScopeToolState scopeToolState : nonDefault) {
+ putOne(scopeToolState);
+ }
+ if (myIsFirst) {
+ myIsFirst = false;
+ }
+ }
+
+ public void putOne(final ScopeToolState state) {
+ final Icon icon = state.getLevel().getIcon();
+ final String scopeName = state.getScopeName();
+ if (icon instanceof HighlightDisplayLevel.SingleColorIconWithMask) {
+ if (myIsFirst) {
+ myScopeToAverageSeverityMap.put(scopeName, state.getLevel().getSeverity());
+ } else {
+ final HighlightSeverity severity = myScopeToAverageSeverityMap.get(scopeName);
+ if (!ScopesAndSeveritiesTable.MIXED_FAKE_SEVERITY.equals(severity) && !Comparing.equal(severity, state.getLevel().getSeverity())) {
+ myScopeToAverageSeverityMap.put(scopeName, ScopesAndSeveritiesTable.MIXED_FAKE_SEVERITY);
+ }
+ }
+ } else if (!ScopesAndSeveritiesTable.MIXED_FAKE_SEVERITY.equals(myScopeToAverageSeverityMap.get(scopeName))) {
+ myScopeToAverageSeverityMap.put(scopeName, ScopesAndSeveritiesTable.MIXED_FAKE_SEVERITY);
+ }
+ }
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/MultiScopeSeverityIcon.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/MultiScopeSeverityIcon.java
new file mode 100644
index 000000000000..6f093ca66349
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/MultiScopeSeverityIcon.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.profile.codeInspection.ui.inspectionsTree;
+
+
+import com.intellij.codeHighlighting.HighlightDisplayLevel;
+import com.intellij.lang.annotation.HighlightSeverity;
+import com.intellij.ui.JBColor;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public class MultiScopeSeverityIcon implements Icon {
+ private final static JBColor MIXED_SEVERITY_COLOR = JBColor.DARK_GRAY;
+
+ private final static int SIZE = 12;
+
+ private final LinkedHashMap<String, HighlightSeverity> myScopeToAverageSeverityMap;
+
+ public MultiScopeSeverityIcon(final LinkedHashMap<String, HighlightSeverity> scopeToAverageSeverityMap) {
+ myScopeToAverageSeverityMap = scopeToAverageSeverityMap;
+ }
+
+ public LinkedHashMap<String, HighlightSeverity> getScopeToAverageSeverityMap() {
+ return myScopeToAverageSeverityMap;
+ }
+
+ @Override
+ public void paintIcon(final Component c, final Graphics g, final int i, final int j) {
+ final int iconWidth = getIconWidth();
+
+ final int partWidth = iconWidth / myScopeToAverageSeverityMap.size();
+
+ final Collection<HighlightSeverity> values = myScopeToAverageSeverityMap.values();
+ int idx = 0;
+ for (final HighlightSeverity severity : values) {
+ final Icon icon = HighlightDisplayLevel.find(severity).getIcon();
+ g.setColor(icon instanceof HighlightDisplayLevel.SingleColorIconWithMask ?
+ ((HighlightDisplayLevel.SingleColorIconWithMask)icon).getColor() : MIXED_SEVERITY_COLOR);
+ final int x = i + partWidth * idx;
+ g.fillRect(x, j, partWidth, getIconHeight());
+ idx++;
+ }
+ g.drawImage(HighlightDisplayLevel.ImageHolder.ourErrorMaskImage, i, j, null);
+ }
+
+ @Override
+ public int getIconWidth() {
+ return SIZE;
+ }
+
+ @Override
+ public int getIconHeight() {
+ return SIZE;
+ }
+}
diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/ScopesAndSeveritiesHintTable.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/ScopesAndSeveritiesHintTable.java
new file mode 100644
index 000000000000..05cb7ab193f5
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/inspectionsTree/ScopesAndSeveritiesHintTable.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.profile.codeInspection.ui.inspectionsTree;
+
+import com.intellij.codeHighlighting.HighlightDisplayLevel;
+import com.intellij.lang.annotation.HighlightSeverity;
+import com.intellij.profile.codeInspection.ui.SingleInspectionProfilePanel;
+import com.intellij.ui.table.JBTable;
+
+import javax.swing.*;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+/**
+ * @author Dmitry Batkovich
+ */
+public class ScopesAndSeveritiesHintTable extends JBTable {
+ private final static int SCOPE_COLUMN = 0;
+ private final static int SEVERITY_COLUMN = 1;
+
+ public ScopesAndSeveritiesHintTable(final LinkedHashMap<String, HighlightSeverity> scopeToAverageSeverityMap) {
+ super(new MyModel(scopeToAverageSeverityMap));
+
+ final DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
+ cellRenderer.setOpaque(false);
+ getColumnModel().getColumn(SCOPE_COLUMN).setCellRenderer(cellRenderer);
+
+ getColumnModel().getColumn(SEVERITY_COLUMN).setCellRenderer(new DefaultTableCellRenderer() {
+ @Override
+ public Component getTableCellRendererComponent(final JTable table,
+ final Object value,
+ final boolean isSelected,
+ final boolean hasFocus,
+ final int row,
+ final int column) {
+ super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ final HighlightSeverity severity = (HighlightSeverity)value;
+ setIcon(HighlightDisplayLevel.find(severity).getIcon());
+ setText(SingleInspectionProfilePanel.renderSeverity(severity));
+ setOpaque(false);
+ return this;
+ }
+ });
+ setShowGrid(false);
+ setRowSelectionAllowed(false);
+ setColumnSelectionAllowed(false);
+ setOpaque(false);
+ }
+
+ private final static class MyModel extends AbstractTableModel {
+
+ private final LinkedHashMap<String, HighlightSeverity> myScopeToAverageSeverityMap;
+ private final List<String> myScopes;
+
+ public MyModel(final LinkedHashMap<String, HighlightSeverity> scopeToAverageSeverityMap) {
+ myScopeToAverageSeverityMap = scopeToAverageSeverityMap;
+ myScopes = new ArrayList<String>(myScopeToAverageSeverityMap.keySet());
+ }
+
+ @Override
+ public Class<?> getColumnClass(final int columnIndex) {
+ switch (columnIndex) {
+ case SCOPE_COLUMN: return String.class;
+ case SEVERITY_COLUMN: return HighlightSeverity.class;
+ default: throw new IllegalArgumentException();
+ }
+ }
+
+ @Override
+ public int getRowCount() {
+ return myScopes.size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ @Override
+ public Object getValueAt(final int rowIndex, final int columnIndex) {
+ switch (columnIndex) {
+ case SCOPE_COLUMN: return myScopes.get(rowIndex);
+ case SEVERITY_COLUMN: return myScopeToAverageSeverityMap.get(myScopes.get(rowIndex));
+ default: throw new IllegalArgumentException();
+ }
+
+ }
+ }
+}