Skip to content

Commit 2ed5b28

Browse files
authored
Merge pull request #68 from SeeSharpSoft/master
Release 1.9.1
2 parents 5ec9d13 + 53e4701 commit 2ed5b28

File tree

8 files changed

+49
-23
lines changed

8 files changed

+49
-23
lines changed

CHANGELOG

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.9.1
2+
Oct 12, 2018
3+
4+
FIX: reading/writing CSV editor states
5+
16
1.9.0
27
Oct 01, 2018
38

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
}
1111

1212
plugins {
13-
id 'org.jetbrains.intellij' version '0.3.1'
13+
id 'org.jetbrains.intellij' version '0.3.12'
1414
id 'jacoco'
1515
id 'com.github.kt3k.coveralls' version '2.8.2'
1616
}
@@ -68,7 +68,7 @@ idea {
6868
apply plugin: 'org.jetbrains.intellij'
6969
intellij {
7070
// IDE version - https://www.jetbrains.com/intellij-repository/releases
71-
version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-2018.1')
71+
version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-2018.2.4')
7272
pluginName = 'CSV Plugin'
7373
instrumentCode = true
7474
updateSinceUntilBuild = false

gradle.properties

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

55
name='CSV Plugin'
6-
pluginVersion=1.9.0
6+
pluginVersion=1.9.1
77
javaVersion=1.8
88
javaTargetVersion=1.8
99
downloadIntellijSources=false

intellij-csv-validator.iml

+1-1
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.2" 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.9.1" 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/editor/CsvAnnotator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected boolean handleSeparatorElement(@NotNull PsiElement element, @NotNull A
108108
}
109109
}
110110
if (textAttributes != null) {
111-
Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, element.getTextRange(), "<TAB>");
111+
Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, element.getTextRange(), showInfoBalloon(holder.getCurrentAnnotationSession()) ? "↹" : null);
112112
annotation.setEnforcedTextAttributes(textAttributes);
113113
annotation.setNeedsUpdateOnTyping(false);
114114
}

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorProvider.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package net.seesharpsoft.intellij.plugins.csv.editor;
22

33
import com.intellij.openapi.editor.EditorSettings;
4-
import com.intellij.openapi.fileEditor.FileEditor;
5-
import com.intellij.openapi.fileEditor.FileEditorPolicy;
6-
import com.intellij.openapi.fileEditor.FileEditorProvider;
7-
import com.intellij.openapi.fileEditor.TextEditor;
4+
import com.intellij.openapi.fileEditor.*;
85
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
96
import com.intellij.openapi.fileTypes.LanguageFileType;
107
import com.intellij.openapi.project.Project;
8+
import com.intellij.openapi.util.Disposer;
119
import com.intellij.openapi.vfs.VirtualFile;
1210
import com.intellij.psi.SingleRootFileViewProvider;
1311
import net.seesharpsoft.intellij.plugins.csv.CsvLanguage;
12+
import org.jdom.Element;
1413
import org.jetbrains.annotations.NotNull;
1514

1615
public class CsvFileEditorProvider implements FileEditorProvider {
@@ -50,4 +49,19 @@ public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile vi
5049
return textEditor;
5150
}
5251

52+
@Override
53+
public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
54+
return TextEditorProvider.getInstance().readState(sourceElement, project, file);
55+
}
56+
57+
@Override
58+
public void writeState(@NotNull FileEditorState state, @NotNull Project project, @NotNull Element targetElement) {
59+
TextEditorProvider.getInstance().writeState(state, project, targetElement);
60+
}
61+
62+
@Override
63+
public void disposeEditor(@NotNull FileEditor editor) {
64+
TextEditorProvider.getInstance().disposeEditor(editor);
65+
}
66+
5367
}

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@
4141

4242
<change-notes><![CDATA[
4343
<pre style="font-family: sans-serif">
44-
NEW: CSV/TSV editor settings (File > Settings > General > CSV/TSV Editor)
45-
NEW: TAB (separator) highlighting
46-
NEW: Enable/disable balloon info
47-
NEW: Soft wrap settings specific for CSV/TSV
44+
FIX: reading/writing CSV editor states
4845
</pre>
4946
]]>
5047
</change-notes>

src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package net.seesharpsoft.intellij.plugins.csv.editor;
22

33
import com.intellij.openapi.editor.EditorSettings;
4-
import com.intellij.openapi.fileEditor.FileEditor;
5-
import com.intellij.openapi.fileEditor.FileEditorPolicy;
6-
import com.intellij.openapi.fileEditor.FileEditorProvider;
7-
import com.intellij.openapi.fileEditor.TextEditor;
4+
import com.intellij.openapi.fileEditor.*;
85
import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager;
6+
import com.intellij.openapi.fileEditor.impl.text.TextEditorState;
97
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
8+
import org.jdom.Element;
109

1110
public class CsvFileEditorTest extends LightCodeInsightFixtureTestCase {
1211

@@ -18,11 +17,11 @@ protected String getTestDataPath() {
1817
@Override
1918
protected void setUp() throws Exception {
2019
super.setUp();
21-
}
2220

23-
public void testCsvFileEditorProviderIsAvailableAndHasCorrectNameAndPolicy() {
2421
myFixture.configureByFiles("AnyFile.csv");
22+
}
2523

24+
public void testCsvFileEditorProviderIsAvailableAndHasCorrectNameAndPolicy() {
2625
FileEditorProvider[] fileEditorProviders = FileEditorProviderManager.getInstance().getProviders(myFixture.getProject(), myFixture.getFile().getVirtualFile());
2726
assertEquals(1, fileEditorProviders.length);
2827
assertInstanceOf(fileEditorProviders[0], CsvFileEditorProvider.class);
@@ -38,8 +37,6 @@ private void disposeTextEditor(FileEditor fileEditor) {
3837
}
3938

4039
public void testCsvEditorIsTextEditorWithInitialCsvEditorSettings() {
41-
myFixture.configureByFiles("AnyFile.csv");
42-
4340
FileEditorProvider[] fileEditorProviders = FileEditorProviderManager.getInstance().getProviders(myFixture.getProject(), myFixture.getFile().getVirtualFile());
4441
FileEditor fileEditor = fileEditorProviders[0].createEditor(myFixture.getProject(), myFixture.getFile().getVirtualFile());
4542
assertInstanceOf(fileEditor, TextEditor.class);
@@ -60,8 +57,6 @@ private TextEditor getCurrentTextEditor() {
6057
}
6158

6259
public void testCsvEditorSettingsAreApplied() {
63-
myFixture.configureByFiles("AnyFile.csv");
64-
6560
CsvEditorSettingsExternalizable csvEditorSettingsExternalizable = CsvEditorSettingsExternalizable.getInstance();
6661
csvEditorSettingsExternalizable.setCaretRowShown(false);
6762
csvEditorSettingsExternalizable.setUseSoftWraps(true);
@@ -74,5 +69,20 @@ public void testCsvEditorSettingsAreApplied() {
7469

7570
disposeTextEditor(textEditor);
7671
}
72+
73+
public void testCsvEditorStateReadsAndWritesStates() {
74+
TextEditor textEditor = getCurrentTextEditor();
7775

76+
FileEditorProvider[] fileEditorProviders = FileEditorProviderManager.getInstance().getProviders(myFixture.getProject(), myFixture.getFile().getVirtualFile());
77+
CsvFileEditorProvider fileEditorProvider = (CsvFileEditorProvider)fileEditorProviders[0];
78+
Element dummy = new Element("dummy");
79+
80+
FileEditorState state = fileEditorProvider.readState(dummy, this.getProject(), this.getFile().getVirtualFile());
81+
assertInstanceOf(state, TextEditorState.class);
82+
textEditor.setState(state);
83+
fileEditorProvider.writeState(state, this.getProject(), dummy);
84+
85+
disposeTextEditor(textEditor);
86+
}
87+
7888
}

0 commit comments

Comments
 (0)