Skip to content

Commit 5718d70

Browse files
authored
Merge pull request #250 from SeeSharpSoft/master
Release 2.14.3
2 parents 36e6a17 + c2c7343 commit 5718d70

File tree

13 files changed

+107
-18
lines changed

13 files changed

+107
-18
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: java
22
jdk:
3-
- openjdk9
3+
- openjdk11
44

55
env:
66
- IDEA_VERSION=PC-2019.3.3 GRAMMAR_KIT_VERSION=2019.3

CHANGELOG

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2.14.3
2+
Oct 10, 2020
3+
4+
NEW: Added default "Header row fixed" setting
5+
NEW: Support "Comment with line comment" #247
6+
FIX: "Value coloring" change not applied to open files
7+
18
2.14.2
29
Sep 17, 2020
310

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This enables default editor features like syntax validation, highlighting and in
2020
- flexible Table Editor
2121
- customizable text editor
2222
- customizable column coloring
23+
- customizable line comment
2324
- syntax validation
2425
- syntax highlighting (customizable)
2526
- content formatting (customizable)
@@ -145,11 +146,11 @@ _Default Escape Character_ defines which escape character is used as standard fo
145146

146147
Define the character(s) that should be used to mark a line as a comment within a CSV document.
147148

148-
Please note:
149+
**Please note:**
149150

150151
- If not set, comments are disabled, which also will increase lexer/parser performance on large files.
151152
- If a line starts with those characters (leading whitespaces are ignored), the whole line isn't considered data and skipped e.g. for formatting, structure view and the table editor.
152-
- Files containing comments can't be edited but still viewed via the **Table Editor** (without showing the comments).
153+
- Files containing comments **can't be edited** - but still viewed - via the **Table Editor** (without showing the comments)!
153154

154155
##### Column numbering
155156

@@ -210,6 +211,10 @@ The maximum width of a single table column in _px_, which is used when adjusting
210211

211212
If selected, the table column widths are adjusted based on the column contents automatically when the table editor is opened. This setting can be changed in the table editor itself per file.
212213

214+
##### Header row fixed (default)
215+
216+
If selected, the first record of CSV files will be considered the header per default, which affects the column names in the table editor. This setting can be changed in the table editor itself per file.
217+
213218
##### Keep/ignore linebreak at file end
214219

215220
If the file ends with a completely empty line (no spaces or tabs either), the table editor will not show this line as empty values but ignore it. When table data is serialized, an existing empty line is kept at the end of the file.

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jacocoTestReport {
2424
}
2525

2626
group 'net.seesharpsoft.intellij.plugins'
27-
version '2.14.2'
27+
version '2.14.3'
2828

2929
apply plugin: 'java'
3030
sourceCompatibility = javaVersion

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# https://www.jetbrains.com/intellij-repository/snapshots
44

55
name='CSV Plugin'
6-
javaVersion=9
7-
javaTargetVersion=9
6+
javaVersion=11
7+
javaTargetVersion=11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package net.seesharpsoft.intellij.plugins.csv;
2+
3+
import com.intellij.lang.Commenter;
4+
import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings;
5+
import org.jetbrains.annotations.Nullable;
6+
7+
public class CsvCommenter implements Commenter {
8+
9+
@Nullable
10+
@Override
11+
public String getLineCommentPrefix() {
12+
String commentIndicator = CsvEditorSettings.getInstance().getCommentIndicator();
13+
return commentIndicator == null || commentIndicator.isEmpty() ? null : commentIndicator + " ";
14+
}
15+
16+
@Nullable
17+
@Override
18+
public String getBlockCommentPrefix() {
19+
return null;
20+
}
21+
22+
@Nullable
23+
@Override
24+
public String getBlockCommentSuffix() {
25+
return null;
26+
}
27+
28+
@Nullable
29+
@Override
30+
public String getCommentedBlockCommentPrefix() {
31+
return null;
32+
}
33+
34+
@Nullable
35+
@Override
36+
public String getCommentedBlockCommentSuffix() {
37+
return null;
38+
}
39+
}

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorState.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,15 @@ public void setColumnWidths(int[] widths) {
3333
}
3434

3535
public boolean showInfoPanel() {
36-
if (showInfoPanel == null) {
37-
return CsvEditorSettings.getInstance().showTableEditorInfoPanel();
38-
}
39-
return showInfoPanel;
36+
return showInfoPanel == null ? CsvEditorSettings.getInstance().showTableEditorInfoPanel() : showInfoPanel;
4037
}
4138

4239
public void setShowInfoPanel(boolean showInfoPanelArg) {
4340
showInfoPanel = showInfoPanelArg;
4441
}
4542

4643
public boolean getFixedHeaders() {
47-
return fixedHeaders == null ? false : fixedHeaders;
44+
return fixedHeaders == null ? CsvEditorSettings.getInstance().isHeaderRowFixed() : fixedHeaders;
4845
}
4946

5047
public void setFixedHeaders(boolean fixedHeadersArg) {

src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvFile.java

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public void propertyChange(PropertyChangeEvent evt) {
2828
case "defaultEscapeCharacter":
2929
case "defaultValueSeparator":
3030
case "commentIndicator":
31+
case "valueColoring":
3132
FileContentUtilCore.reparseFiles(CsvFile.this.getVirtualFile());
3233
break;
3334
default:

src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettings.java

+13
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public static final class OptionSet {
7272
public int TABLE_DEFAULT_COLUMN_WIDTH = TABLE_DEFAULT_COLUMN_WIDTH_DEFAULT;
7373
public boolean TABLE_AUTO_COLUMN_WIDTH_ON_OPEN = false;
7474
public boolean ZERO_BASED_COLUMN_NUMBERING = false;
75+
public boolean TABLE_HEADER_ROW_FIXED = false;
7576

7677
public boolean SHOW_TABLE_EDITOR_INFO_PANEL = true;
7778
public boolean QUOTING_ENFORCED = false;
@@ -296,7 +297,19 @@ public ValueColoring getValueColoring() {
296297
}
297298

298299
public void setValueColoring(ValueColoring valueColoring) {
300+
ValueColoring oldValue = getValueColoring();
299301
getState().VALUE_COLORING = valueColoring;
302+
if (valueColoring != oldValue) {
303+
myPropertyChangeSupport.firePropertyChange("valueColoring", oldValue, getValueColoring());
304+
}
305+
}
306+
307+
public boolean isHeaderRowFixed() {
308+
return getState().TABLE_HEADER_ROW_FIXED;
309+
}
310+
311+
public void setHeaderRowFixed(boolean headerRowFixed) {
312+
getState().TABLE_HEADER_ROW_FIXED = headerRowFixed;
300313
}
301314

302315
public boolean checkCurrentPluginVersion(String actualVersion) {

src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettingsProvider.form

+12-4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
</grid>
8787
</children>
8888
</grid>
89-
<grid id="3e325" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
89+
<grid id="3e325" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
9090
<margin top="10" left="10" bottom="10" right="10"/>
9191
<constraints>
9292
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -96,23 +96,23 @@
9696
<children>
9797
<component id="97488" class="javax.swing.JCheckBox" binding="cbShowInfoPanel">
9898
<constraints>
99-
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
99+
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
100100
</constraints>
101101
<properties>
102102
<text value="Show info panel"/>
103103
</properties>
104104
</component>
105105
<component id="d6a8e" class="javax.swing.JCheckBox" binding="cbQuotingEnforced">
106106
<constraints>
107-
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
107+
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
108108
</constraints>
109109
<properties>
110110
<text value="Enforce value quoting"/>
111111
</properties>
112112
</component>
113113
<component id="e470c" class="javax.swing.JCheckBox" binding="cbFileEndLineBreak">
114114
<constraints>
115-
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
115+
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
116116
</constraints>
117117
<properties>
118118
<text value="Keep/ignore linebreak at file end"/>
@@ -231,6 +231,14 @@
231231
</hspacer>
232232
</children>
233233
</grid>
234+
<component id="8e063" class="javax.swing.JCheckBox" binding="cbHeaderRowFixed">
235+
<constraints>
236+
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
237+
</constraints>
238+
<properties>
239+
<text value="Header row fixed (default)"/>
240+
</properties>
241+
</component>
234242
</children>
235243
</grid>
236244
<vspacer id="ff292">

src/main/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettingsProvider.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class CsvEditorSettingsProvider implements EditorOptionsProvider {
4242
private JCheckBox cbKeepTrailingWhitespaces;
4343
private JTextField tfCommentIndicator;
4444
private JComboBox comboValueColoring;
45+
private JCheckBox cbHeaderRowFixed;
4546

4647
@NotNull
4748
@Override
@@ -92,7 +93,8 @@ public boolean isModified() {
9293
!Objects.equals(comboValueSeparator.getSelectedItem(), csvEditorSettings.getDefaultValueSeparator()) ||
9394
isModified(cbKeepTrailingWhitespaces, csvEditorSettings.getKeepTrailingSpaces()) ||
9495
isModified(tfCommentIndicator, csvEditorSettings.getCommentIndicator()) ||
95-
!Objects.equals(comboValueColoring.getSelectedItem(), csvEditorSettings.getValueColoring());
96+
!Objects.equals(comboValueColoring.getSelectedItem(), csvEditorSettings.getValueColoring()) ||
97+
isModified(cbHeaderRowFixed, csvEditorSettings.isHeaderRowFixed());
9698
}
9799

98100
@Override
@@ -117,6 +119,7 @@ public void reset() {
117119
cbKeepTrailingWhitespaces.setSelected(csvEditorSettings.getKeepTrailingSpaces());
118120
tfCommentIndicator.setText(csvEditorSettings.getCommentIndicator());
119121
comboValueColoring.setSelectedItem(csvEditorSettings.getValueColoring());
122+
cbHeaderRowFixed.setSelected(csvEditorSettings.isHeaderRowFixed());
120123
}
121124

122125
@Override
@@ -141,6 +144,7 @@ public void apply() throws ConfigurationException {
141144
csvEditorSettings.setKeepTrailingSpaces(cbKeepTrailingWhitespaces.isSelected());
142145
csvEditorSettings.setCommentIndicator(tfCommentIndicator.getText());
143146
csvEditorSettings.setValueColoring((CsvEditorSettings.ValueColoring) comboValueColoring.getSelectedItem());
147+
csvEditorSettings.setHeaderRowFixed(cbHeaderRowFixed.isSelected());
144148
}
145149

146150
protected void createUIComponents() {

src/main/resources/META-INF/plugin.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<li>customizable Table Editor</li>
1616
<li>customizable text editor</li>
1717
<li>customizable column coloring</li>
18+
<li>customizable line comment</li>
1819
<li>syntax validation</li>
1920
<li>syntax highlighting</li>
2021
<li>content formatting</li>
@@ -49,8 +50,9 @@
4950

5051
<change-notes><![CDATA[
5152
<pre style="font-family: sans-serif">
52-
FIX: Settings reset every update #245
53-
FIX: Removing comment indicator causes parsing errors
53+
NEW: Added default "Header row fixed" setting
54+
NEW: Support "Comment with line comment" #247
55+
FIX: "Value coloring" change not applied to open files
5456
</pre>
5557
]]>
5658
</change-notes>
@@ -168,6 +170,8 @@ FIX: Removing comment indicator causes parsing errors
168170
<todoIndexer implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvTodoIndexer" filetype="PSV" />
169171

170172
<postStartupActivity implementation="net.seesharpsoft.intellij.plugins.csv.CsvPlugin" />
173+
174+
<lang.commenter implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvCommenter" language="csv" />
171175
</extensions>
172176

173177
<actions>

src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvEditorSettingsProviderTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public void testResetAndModified() throws ConfigurationException {
7979
csvEditorSettings.setKeepTrailingSpaces(true);
8080
csvEditorSettings.setCommentIndicator("//");
8181
csvEditorSettings.setValueColoring(CsvEditorSettings.ValueColoring.SIMPLE);
82+
csvEditorSettings.setHeaderRowFixed(true);
8283

8384
assertEquals(true, editorSettingsPanel.isModified());
8485

@@ -102,6 +103,7 @@ public void testResetAndModified() throws ConfigurationException {
102103
assertEquals(true, csvEditorSettings.getKeepTrailingSpaces());
103104
assertEquals("//", csvEditorSettings.getCommentIndicator());
104105
assertEquals( CsvEditorSettings.ValueColoring.SIMPLE, csvEditorSettings.getValueColoring());
106+
assertEquals(true, csvEditorSettings.isHeaderRowFixed());
105107

106108
editorSettingsPanel.disposeUIResources();
107109
}
@@ -112,6 +114,7 @@ public void testApply() throws ConfigurationException {
112114
CsvEditorSettings csvEditorSettings = CsvEditorSettings.getInstance();
113115
csvEditorSettings.loadState(new CsvEditorSettings.OptionSet());
114116
editorSettingsPanel.reset();
117+
115118
csvEditorSettings.setCaretRowShown(false);
116119
csvEditorSettings.setUseSoftWraps(true);
117120
csvEditorSettings.setHighlightTabSeparator(false);
@@ -125,6 +128,10 @@ public void testApply() throws ConfigurationException {
125128
csvEditorSettings.setTableAutoColumnWidthOnOpen(false);
126129
csvEditorSettings.setDefaultEscapeCharacter(CsvEscapeCharacter.BACKSLASH);
127130
csvEditorSettings.setDefaultValueSeparator(CsvValueSeparator.PIPE);
131+
csvEditorSettings.setKeepTrailingSpaces(true);
132+
csvEditorSettings.setCommentIndicator("//");
133+
csvEditorSettings.setValueColoring(CsvEditorSettings.ValueColoring.SIMPLE);
134+
csvEditorSettings.setHeaderRowFixed(true);
128135

129136
editorSettingsPanel.apply();
130137

@@ -147,6 +154,10 @@ public void testApply() throws ConfigurationException {
147154
assertEquals(freshOptionSet.KEEP_TRAILING_SPACES, csvEditorSettings.getKeepTrailingSpaces());
148155
assertEquals(freshOptionSet.COMMENT_INDICATOR, csvEditorSettings.getCommentIndicator());
149156
assertEquals(freshOptionSet.VALUE_COLORING, csvEditorSettings.getValueColoring());
157+
assertEquals(freshOptionSet.KEEP_TRAILING_SPACES, csvEditorSettings.getKeepTrailingSpaces());
158+
assertEquals(freshOptionSet.COMMENT_INDICATOR, csvEditorSettings.getCommentIndicator());
159+
assertEquals(freshOptionSet.VALUE_COLORING, csvEditorSettings.getValueColoring());
160+
assertEquals(freshOptionSet.TABLE_HEADER_ROW_FIXED, csvEditorSettings.isHeaderRowFixed());
150161

151162
editorSettingsPanel.disposeUIResources();
152163
}

0 commit comments

Comments
 (0)