Search in sources :

Example 1 with Descriptor

use of com.intellij.codeInspection.ex.Descriptor in project intellij-community by JetBrains.

the class ScopesChooser method fillActionGroup.

private void fillActionGroup(final DefaultActionGroup group, final List<NamedScope> scopes, final List<Descriptor> defaultDescriptors, final InspectionProfileImpl inspectionProfile, final Set<String> excludedScopeNames) {
    for (final NamedScope scope : scopes) {
        final String scopeName = scope.getName();
        if (excludedScopeNames.contains(scopeName)) {
            continue;
        }
        group.add(new DumbAwareAction(scopeName) {

            @Override
            public void actionPerformed(final AnActionEvent e) {
                for (final Descriptor defaultDescriptor : defaultDescriptors) {
                    inspectionProfile.addScope(defaultDescriptor.getToolWrapper().createCopy(), scope, defaultDescriptor.getLevel(), true, getEventProject(e));
                }
                onScopeAdded();
            }
        });
    }
}
Also used : NamedScope(com.intellij.psi.search.scope.packageSet.NamedScope) Descriptor(com.intellij.codeInspection.ex.Descriptor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction)

Example 2 with Descriptor

use of com.intellij.codeInspection.ex.Descriptor in project intellij-community by JetBrains.

the class ToolDescriptors method fromScopeToolState.

public static ToolDescriptors fromScopeToolState(final ScopeToolState state, @NotNull InspectionProfileModifiableModel profile, final Project project) {
    List<ScopeToolState> nonDefaultTools = profile.getNonDefaultTools(state.getTool().getShortName(), project);
    ArrayList<Descriptor> descriptors = new ArrayList<>(nonDefaultTools.size());
    for (final ScopeToolState nonDefaultToolState : nonDefaultTools) {
        descriptors.add(new Descriptor(nonDefaultToolState, profile, project));
    }
    return new ToolDescriptors(new Descriptor(state, profile, project), descriptors);
}
Also used : ScopeToolState(com.intellij.codeInspection.ex.ScopeToolState) ArrayList(java.util.ArrayList) Descriptor(com.intellij.codeInspection.ex.Descriptor)

Example 3 with Descriptor

use of com.intellij.codeInspection.ex.Descriptor 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

Descriptor (com.intellij.codeInspection.ex.Descriptor)3 ScopeToolState (com.intellij.codeInspection.ex.ScopeToolState)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1 ToolDescriptors (com.intellij.profile.codeInspection.ui.ToolDescriptors)1 NamedScope (com.intellij.psi.search.scope.packageSet.NamedScope)1 SimpleColoredComponent (com.intellij.ui.SimpleColoredComponent)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 ArrayList (java.util.ArrayList)1 NonNls (org.jetbrains.annotations.NonNls)1