Skip to content

Commit 6021213

Browse files
committed
[INTERNAL] column coloring
Fixes #49
1 parent d0a8b7f commit 6021213

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

intellij-csv-validator.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module external.linked.project.id="intellij-csv-validator" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="net.seesharpsoft.intellij.plugins" external.system.module.version="1.8.1" relativePaths="true" type="JAVA_MODULE" version="4">
2+
<module external.linked.project.id="intellij-csv-validator" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="net.seesharpsoft.intellij.plugins" external.system.module.version="1.8.0" relativePaths="true" type="JAVA_MODULE" version="4">
33
<component name="NewModuleRootManager" inherit-compiler-output="true">
44
<exclude-output />
55
<content url="file://$MODULE_DIR$">

src/main/java/net/seesharpsoft/intellij/plugins/csv/annotation/CsvAnnotator.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@
1515
import net.seesharpsoft.intellij.plugins.csv.psi.CsvTypes;
1616
import org.jetbrains.annotations.NotNull;
1717

18+
import java.awt.*;
19+
1820
import static com.intellij.spellchecker.SpellCheckerSeveritiesProvider.TYPO;
1921

2022
public class CsvAnnotator implements Annotator {
2123

22-
private static final TextAttributes EMPTY_TEXT_ATTRIBUTES =
23-
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, null, 0, null, null, null));
24+
public static final TextAttributes[] COLUMNS = new TextAttributes[] {
25+
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, null, 0, null, null, null)),
26+
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, new Color(240, 240, 240), 0, null, null, null)),
27+
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, new Color(255, 240, 240), 0, null, null, null)),
28+
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, new Color(240, 255, 240), 0, null, null, null)),
29+
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, new Color(240, 240, 255), 0, null, null, null)),
30+
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, new Color(255, 255, 240), 0, null, null, null)),
31+
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, new Color(255, 240, 255), 0, null, null, null)),
32+
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, new Color(240, 255, 255), 0, null, null, null)),
33+
TextAttributes.fromFlyweight(AttributesFlyweight.create(null, new Color(255, 255, 255), 0, null, null, null)),
34+
};
2435

2536
public static final HighlightSeverity CSV_COLUMN_INFO_SEVERITY =
2637
new HighlightSeverity("CSV_COLUMN_INFO_SEVERITY", TYPO.myVal + 5);
@@ -50,8 +61,12 @@ public void annotate(@NotNull final PsiElement element, @NotNull final Annotatio
5061
}
5162

5263
Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, textRange, message, tooltip);
53-
annotation.setEnforcedTextAttributes(EMPTY_TEXT_ATTRIBUTES);
64+
annotation.setEnforcedTextAttributes(getTextAttributes(columnInfo));
5465
annotation.setNeedsUpdateOnTyping(false);
5566
}
5667
}
68+
69+
protected TextAttributes getTextAttributes(CsvColumnInfo<PsiElement> columnInfo) {
70+
return COLUMNS[columnInfo.getColumnIndex() % COLUMNS.length];
71+
}
5772
}

0 commit comments

Comments
 (0)