Skip to content

Commit

Permalink
Merge pull request #250 from SeeSharpSoft/master
Browse files Browse the repository at this point in the history
Release 2.14.3
  • Loading branch information
SeeSharpSoft authored Oct 10, 2020
2 parents 36e6a17 + c2c7343 commit 5718d70
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: java
jdk:
- openjdk9
- openjdk11

env:
- IDEA_VERSION=PC-2019.3.3 GRAMMAR_KIT_VERSION=2019.3
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.14.3
Oct 10, 2020

NEW: Added default "Header row fixed" setting
NEW: Support "Comment with line comment" #247
FIX: "Value coloring" change not applied to open files

2.14.2
Sep 17, 2020

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This enables default editor features like syntax validation, highlighting and in
- flexible Table Editor
- customizable text editor
- customizable column coloring
- customizable line comment
- syntax validation
- syntax highlighting (customizable)
- content formatting (customizable)
Expand Down Expand Up @@ -145,11 +146,11 @@ _Default Escape Character_ defines which escape character is used as standard fo

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

Please note:
**Please note:**

- If not set, comments are disabled, which also will increase lexer/parser performance on large files.
- 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.
- Files containing comments can't be edited but still viewed via the **Table Editor** (without showing the comments).
- Files containing comments **can't be edited** - but still viewed - via the **Table Editor** (without showing the comments)!

##### Column numbering

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

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.

##### Header row fixed (default)

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.

##### Keep/ignore linebreak at file end

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.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jacocoTestReport {
}

group 'net.seesharpsoft.intellij.plugins'
version '2.14.2'
version '2.14.3'

apply plugin: 'java'
sourceCompatibility = javaVersion
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# https://www.jetbrains.com/intellij-repository/snapshots

name='CSV Plugin'
javaVersion=9
javaTargetVersion=9
javaVersion=11
javaTargetVersion=11
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package net.seesharpsoft.intellij.plugins.csv;

import com.intellij.lang.Commenter;
import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings;
import org.jetbrains.annotations.Nullable;

public class CsvCommenter implements Commenter {

@Nullable
@Override
public String getLineCommentPrefix() {
String commentIndicator = CsvEditorSettings.getInstance().getCommentIndicator();
return commentIndicator == null || commentIndicator.isEmpty() ? null : commentIndicator + " ";
}

@Nullable
@Override
public String getBlockCommentPrefix() {
return null;
}

@Nullable
@Override
public String getBlockCommentSuffix() {
return null;
}

@Nullable
@Override
public String getCommentedBlockCommentPrefix() {
return null;
}

@Nullable
@Override
public String getCommentedBlockCommentSuffix() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,15 @@ public void setColumnWidths(int[] widths) {
}

public boolean showInfoPanel() {
if (showInfoPanel == null) {
return CsvEditorSettings.getInstance().showTableEditorInfoPanel();
}
return showInfoPanel;
return showInfoPanel == null ? CsvEditorSettings.getInstance().showTableEditorInfoPanel() : showInfoPanel;
}

public void setShowInfoPanel(boolean showInfoPanelArg) {
showInfoPanel = showInfoPanelArg;
}

public boolean getFixedHeaders() {
return fixedHeaders == null ? false : fixedHeaders;
return fixedHeaders == null ? CsvEditorSettings.getInstance().isHeaderRowFixed() : fixedHeaders;
}

public void setFixedHeaders(boolean fixedHeadersArg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void propertyChange(PropertyChangeEvent evt) {
case "defaultEscapeCharacter":
case "defaultValueSeparator":
case "commentIndicator":
case "valueColoring":
FileContentUtilCore.reparseFiles(CsvFile.this.getVirtualFile());
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public static final class OptionSet {
public int TABLE_DEFAULT_COLUMN_WIDTH = TABLE_DEFAULT_COLUMN_WIDTH_DEFAULT;
public boolean TABLE_AUTO_COLUMN_WIDTH_ON_OPEN = false;
public boolean ZERO_BASED_COLUMN_NUMBERING = false;
public boolean TABLE_HEADER_ROW_FIXED = false;

public boolean SHOW_TABLE_EDITOR_INFO_PANEL = true;
public boolean QUOTING_ENFORCED = false;
Expand Down Expand Up @@ -296,7 +297,19 @@ public ValueColoring getValueColoring() {
}

public void setValueColoring(ValueColoring valueColoring) {
ValueColoring oldValue = getValueColoring();
getState().VALUE_COLORING = valueColoring;
if (valueColoring != oldValue) {
myPropertyChangeSupport.firePropertyChange("valueColoring", oldValue, getValueColoring());
}
}

public boolean isHeaderRowFixed() {
return getState().TABLE_HEADER_ROW_FIXED;
}

public void setHeaderRowFixed(boolean headerRowFixed) {
getState().TABLE_HEADER_ROW_FIXED = headerRowFixed;
}

public boolean checkCurrentPluginVersion(String actualVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</grid>
</children>
</grid>
<grid id="3e325" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="3e325" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<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"/>
Expand All @@ -96,23 +96,23 @@
<children>
<component id="97488" class="javax.swing.JCheckBox" binding="cbShowInfoPanel">
<constraints>
<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"/>
<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"/>
</constraints>
<properties>
<text value="Show info panel"/>
</properties>
</component>
<component id="d6a8e" class="javax.swing.JCheckBox" binding="cbQuotingEnforced">
<constraints>
<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"/>
<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"/>
</constraints>
<properties>
<text value="Enforce value quoting"/>
</properties>
</component>
<component id="e470c" class="javax.swing.JCheckBox" binding="cbFileEndLineBreak">
<constraints>
<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"/>
<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"/>
</constraints>
<properties>
<text value="Keep/ignore linebreak at file end"/>
Expand Down Expand Up @@ -231,6 +231,14 @@
</hspacer>
</children>
</grid>
<component id="8e063" class="javax.swing.JCheckBox" binding="cbHeaderRowFixed">
<constraints>
<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"/>
</constraints>
<properties>
<text value="Header row fixed (default)"/>
</properties>
</component>
</children>
</grid>
<vspacer id="ff292">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class CsvEditorSettingsProvider implements EditorOptionsProvider {
private JCheckBox cbKeepTrailingWhitespaces;
private JTextField tfCommentIndicator;
private JComboBox comboValueColoring;
private JCheckBox cbHeaderRowFixed;

@NotNull
@Override
Expand Down Expand Up @@ -92,7 +93,8 @@ public boolean isModified() {
!Objects.equals(comboValueSeparator.getSelectedItem(), csvEditorSettings.getDefaultValueSeparator()) ||
isModified(cbKeepTrailingWhitespaces, csvEditorSettings.getKeepTrailingSpaces()) ||
isModified(tfCommentIndicator, csvEditorSettings.getCommentIndicator()) ||
!Objects.equals(comboValueColoring.getSelectedItem(), csvEditorSettings.getValueColoring());
!Objects.equals(comboValueColoring.getSelectedItem(), csvEditorSettings.getValueColoring()) ||
isModified(cbHeaderRowFixed, csvEditorSettings.isHeaderRowFixed());
}

@Override
Expand All @@ -117,6 +119,7 @@ public void reset() {
cbKeepTrailingWhitespaces.setSelected(csvEditorSettings.getKeepTrailingSpaces());
tfCommentIndicator.setText(csvEditorSettings.getCommentIndicator());
comboValueColoring.setSelectedItem(csvEditorSettings.getValueColoring());
cbHeaderRowFixed.setSelected(csvEditorSettings.isHeaderRowFixed());
}

@Override
Expand All @@ -141,6 +144,7 @@ public void apply() throws ConfigurationException {
csvEditorSettings.setKeepTrailingSpaces(cbKeepTrailingWhitespaces.isSelected());
csvEditorSettings.setCommentIndicator(tfCommentIndicator.getText());
csvEditorSettings.setValueColoring((CsvEditorSettings.ValueColoring) comboValueColoring.getSelectedItem());
csvEditorSettings.setHeaderRowFixed(cbHeaderRowFixed.isSelected());
}

protected void createUIComponents() {
Expand Down
8 changes: 6 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<li>customizable Table Editor</li>
<li>customizable text editor</li>
<li>customizable column coloring</li>
<li>customizable line comment</li>
<li>syntax validation</li>
<li>syntax highlighting</li>
<li>content formatting</li>
Expand Down Expand Up @@ -49,8 +50,9 @@

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

<postStartupActivity implementation="net.seesharpsoft.intellij.plugins.csv.CsvPlugin" />

<lang.commenter implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvCommenter" language="csv" />
</extensions>

<actions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public void testResetAndModified() throws ConfigurationException {
csvEditorSettings.setKeepTrailingSpaces(true);
csvEditorSettings.setCommentIndicator("//");
csvEditorSettings.setValueColoring(CsvEditorSettings.ValueColoring.SIMPLE);
csvEditorSettings.setHeaderRowFixed(true);

assertEquals(true, editorSettingsPanel.isModified());

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

editorSettingsPanel.disposeUIResources();
}
Expand All @@ -112,6 +114,7 @@ public void testApply() throws ConfigurationException {
CsvEditorSettings csvEditorSettings = CsvEditorSettings.getInstance();
csvEditorSettings.loadState(new CsvEditorSettings.OptionSet());
editorSettingsPanel.reset();

csvEditorSettings.setCaretRowShown(false);
csvEditorSettings.setUseSoftWraps(true);
csvEditorSettings.setHighlightTabSeparator(false);
Expand All @@ -125,6 +128,10 @@ public void testApply() throws ConfigurationException {
csvEditorSettings.setTableAutoColumnWidthOnOpen(false);
csvEditorSettings.setDefaultEscapeCharacter(CsvEscapeCharacter.BACKSLASH);
csvEditorSettings.setDefaultValueSeparator(CsvValueSeparator.PIPE);
csvEditorSettings.setKeepTrailingSpaces(true);
csvEditorSettings.setCommentIndicator("//");
csvEditorSettings.setValueColoring(CsvEditorSettings.ValueColoring.SIMPLE);
csvEditorSettings.setHeaderRowFixed(true);

editorSettingsPanel.apply();

Expand All @@ -147,6 +154,10 @@ public void testApply() throws ConfigurationException {
assertEquals(freshOptionSet.KEEP_TRAILING_SPACES, csvEditorSettings.getKeepTrailingSpaces());
assertEquals(freshOptionSet.COMMENT_INDICATOR, csvEditorSettings.getCommentIndicator());
assertEquals(freshOptionSet.VALUE_COLORING, csvEditorSettings.getValueColoring());
assertEquals(freshOptionSet.KEEP_TRAILING_SPACES, csvEditorSettings.getKeepTrailingSpaces());
assertEquals(freshOptionSet.COMMENT_INDICATOR, csvEditorSettings.getCommentIndicator());
assertEquals(freshOptionSet.VALUE_COLORING, csvEditorSettings.getValueColoring());
assertEquals(freshOptionSet.TABLE_HEADER_ROW_FIXED, csvEditorSettings.isHeaderRowFixed());

editorSettingsPanel.disposeUIResources();
}
Expand Down

0 comments on commit 5718d70

Please sign in to comment.