public static Icon type12(String type) { return type(type + "12"); }
public static Icon severity12(String severity) { return severity(severity + "12"); }
@Test public void testSeverities() { assertThat(SonarLintIcons.severity("MAJOR")).isNotNull(); assertThat(SonarLintIcons.severity("MINOR")).isNotNull(); assertThat(SonarLintIcons.severity("BLOCKER")).isNotNull(); assertThat(SonarLintIcons.severity("INFO")).isNotNull(); assertThat(SonarLintIcons.severity("CRITICAL")).isNotNull(); assertThat(SonarLintIcons.severity12("MAJOR")).isNotNull(); assertThat(SonarLintIcons.severity12("MINOR")).isNotNull(); assertThat(SonarLintIcons.severity12("BLOCKER")).isNotNull(); assertThat(SonarLintIcons.severity12("INFO")).isNotNull(); assertThat(SonarLintIcons.severity12("CRITICAL")).isNotNull(); }
@Nullable @Override public Object getValueAt(final Object node, final int column) { if (column == TREE_COLUMN) { return null; } if (column == ICONS_COLUMN) { if (node instanceof RulesTreeNode.Rule) { RulesTreeNode.Rule rule = (RulesTreeNode.Rule) node; int gap = JBUI.isHiDPI() ? 8 : 4; return new CompoundIcon(CompoundIcon.Axis.X_AXIS, gap, SonarLintIcons.type12(rule.type()), SonarLintIcons.severity12(rule.severity())); } return null; } if (column == IS_ENABLED_COLUMN) { RulesTreeNode treeNode = (RulesTreeNode) node; return treeNode.isActivated(); } throw new IllegalArgumentException(); }
@Test public void testTypes() { assertThat(SonarLintIcons.type("BUG")).isNotNull(); assertThat(SonarLintIcons.type("VULNERABILITY")).isNotNull(); assertThat(SonarLintIcons.type("CODE_SMELL")).isNotNull(); assertThat(SonarLintIcons.type12("BUG")).isNotNull(); assertThat(SonarLintIcons.type12("VULNERABILITY")).isNotNull(); assertThat(SonarLintIcons.type12("CODE_SMELL")).isNotNull(); }
private void cacheImage(@Nullable URL url) { if (url == null) { return; } String path = url.getPath(); if (path == null) { return; } Icon icon; if (path.startsWith("/severity/")) { String severity = url.getPath().substring(10); icon = SonarLintIcons.severity(severity); } else if (path.startsWith("/type/")) { String type = url.getPath().substring(6); icon = SonarLintIcons.type(type); } else { return; } // in presentation mode we don't want huge icons if (JBUI.isHiDPI()) { icon = IconUtil.scale(icon, 0.5); } Dictionary<URL, Image> cache = (Dictionary<URL, Image>) getDocument().getProperty("imageCache"); if (cache == null) { cache = new Hashtable<>(); } cache.put(url, SonarLintUtils.iconToImage(icon)); getDocument().putProperty("imageCache", cache); } }
private void load(boolean editing) { Icon sqIcon = SonarLintIcons.icon("SonarQube"); Icon clIcon = SonarLintIcons.icon("SonarCloud"); if (model.getServerType() == WizardModel.ServerType.SONARCLOUD || model.getServerType() == null) { radioSonarCloud.setSelected(true); if (editing) { sqIcon = SonarLintIcons.toDisabled(sqIcon); } } else { radioSonarQube.setSelected(true); urlText.setText(model.getServerUrl()); if (editing) { clIcon = SonarLintIcons.toDisabled(clIcon); } } nameField.setText(model.getName()); if (editing) { nameField.setEnabled(false); radioSonarQube.setEnabled(false); radioSonarCloud.setEnabled(false); } sonarqubeIcon.setIcon(sqIcon); sonarcloudIcon.setIcon(clIcon); }
private void setIcon(TreeCellRenderer renderer, Icon icon) { if (issue.isValid()) { renderer.setIcon(icon); } else { renderer.setIcon(SonarLintIcons.toDisabled(icon)); } }
private void createUIComponents() { sonarcloudIcon = new JLabel(SonarLintIcons.icon("SonarCloud")); sonarqubeIcon = new JLabel(SonarLintIcons.icon("SonarQube")); sonarcloudText = SwingHelper.createHtmlViewer(false, null, null, null); sonarqubeText = SwingHelper.createHtmlViewer(false, null, null, null); JBTextField text = new JBTextField(); text.getEmptyText().setText("Example: http://localhost:9000"); urlText = text; nameField = new JBTextField(); nameField.setDocument(new LengthRestrictedDocument(NAME_MAX_LENGTH)); } }
renderer.setIconToolTip(severity + " " + typeStr); int gap = JBUI.isHiDPI() ? 8 : 4; setIcon(renderer, new CompoundIcon(CompoundIcon.Axis.X_AXIS, gap, SonarLintIcons.type12(type), SonarLintIcons.severity12(severity))); } else { renderer.setIconToolTip(severity); setIcon(renderer, SonarLintIcons.severity12(severity));
@Test public void testDisabled() { assertThat(SonarLintIcons.toDisabled(SonarLintIcons.WARN)).isNotNull(); } }