Search in sources :

Example 1 with ToolDescriptors

use of com.intellij.profile.codeInspection.ui.ToolDescriptors in project intellij-community by JetBrains.

the class InspectionsConfigTreeComparator method compare.

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

Example 2 with ToolDescriptors

use of com.intellij.profile.codeInspection.ui.ToolDescriptors in project intellij-community by JetBrains.

the class InspectionsConfigTreeRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    final SimpleColoredComponent component = new SimpleColoredComponent();
    if (!(value instanceof InspectionConfigTreeNode))
        return component;
    InspectionConfigTreeNode node = (InspectionConfigTreeNode) value;
    Object object = node.getUserObject();
    boolean reallyHasFocus = ((TreeTableTree) tree).getTreeTable().hasFocus();
    final Color background = selected ? (reallyHasFocus ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground()) : UIUtil.getTreeTextBackground();
    UIUtil.changeBackGround(component, 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, component);
    }
    if (hint != null) {
        component.append(" " + hint, selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, foreground) : SimpleTextAttributes.GRAYED_ATTRIBUTES);
    }
    component.setForeground(foreground);
    return component;
}
Also used : NonNls(org.jetbrains.annotations.NonNls) ToolDescriptors(com.intellij.profile.codeInspection.ui.ToolDescriptors) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) Descriptor(com.intellij.codeInspection.ex.Descriptor) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Aggregations

ToolDescriptors (com.intellij.profile.codeInspection.ui.ToolDescriptors)2 Descriptor (com.intellij.codeInspection.ex.Descriptor)1 SimpleColoredComponent (com.intellij.ui.SimpleColoredComponent)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 NonNls (org.jetbrains.annotations.NonNls)1