Skip to content

Commit

Permalink
Merge e83f0de into 6ca5bb2
Browse files Browse the repository at this point in the history
  • Loading branch information
SeeSharpSoft committed Oct 12, 2018
2 parents 6ca5bb2 + e83f0de commit 25f1302
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
@@ -1,3 +1,8 @@
1.9.1
Oct 12, 2018

FIX: reading/writing CSV editor states

1.9.0
Oct 01, 2018

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -10,7 +10,7 @@ buildscript {
}

plugins {
id 'org.jetbrains.intellij' version '0.3.1'
id 'org.jetbrains.intellij' version '0.3.12'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.8.2'
}
Expand Down Expand Up @@ -68,7 +68,7 @@ idea {
apply plugin: 'org.jetbrains.intellij'
intellij {
// IDE version - https://www.jetbrains.com/intellij-repository/releases
version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-2018.1')
version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-2018.2.4')
pluginName = 'CSV Plugin'
instrumentCode = true
updateSinceUntilBuild = false
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -3,7 +3,7 @@
# https://www.jetbrains.com/intellij-repository/snapshots

name='CSV Plugin'
pluginVersion=1.9.0
pluginVersion=1.9.1
javaVersion=1.8
javaTargetVersion=1.8
downloadIntellijSources=false
2 changes: 1 addition & 1 deletion intellij-csv-validator.iml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
Expand Down
Expand Up @@ -108,7 +108,7 @@ protected boolean handleSeparatorElement(@NotNull PsiElement element, @NotNull A
}
}
if (textAttributes != null) {
Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, element.getTextRange(), "<TAB>");
Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, element.getTextRange(), showInfoBalloon(holder.getCurrentAnnotationSession()) ? "↹" : null);
annotation.setEnforcedTextAttributes(textAttributes);
annotation.setNeedsUpdateOnTyping(false);
}
Expand Down
@@ -1,16 +1,15 @@
package net.seesharpsoft.intellij.plugins.csv.editor;

import com.intellij.openapi.editor.EditorSettings;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorPolicy;
import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.SingleRootFileViewProvider;
import net.seesharpsoft.intellij.plugins.csv.CsvLanguage;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;

public class CsvFileEditorProvider implements FileEditorProvider {
Expand Down Expand Up @@ -50,4 +49,19 @@ public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile vi
return textEditor;
}

@Override
public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
return TextEditorProvider.getInstance().readState(sourceElement, project, file);
}

@Override
public void writeState(@NotNull FileEditorState state, @NotNull Project project, @NotNull Element targetElement) {
TextEditorProvider.getInstance().writeState(state, project, targetElement);
}

@Override
public void disposeEditor(@NotNull FileEditor editor) {
TextEditorProvider.getInstance().disposeEditor(editor);
}

}
5 changes: 1 addition & 4 deletions src/main/resources/META-INF/plugin.xml
Expand Up @@ -41,10 +41,7 @@

<change-notes><![CDATA[
<pre style="font-family: sans-serif">
NEW: CSV/TSV editor settings (File > Settings > General > CSV/TSV Editor)
NEW: TAB (separator) highlighting
NEW: Enable/disable balloon info
NEW: Soft wrap settings specific for CSV/TSV
FIX: reading/writing CSV editor states
</pre>
]]>
</change-notes>
Expand Down
@@ -1,12 +1,11 @@
package net.seesharpsoft.intellij.plugins.csv.editor;

import com.intellij.openapi.editor.EditorSettings;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorPolicy;
import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager;
import com.intellij.openapi.fileEditor.impl.text.TextEditorState;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.jdom.Element;

public class CsvFileEditorTest extends LightCodeInsightFixtureTestCase {

Expand All @@ -18,11 +17,11 @@ protected String getTestDataPath() {
@Override
protected void setUp() throws Exception {
super.setUp();
}

public void testCsvFileEditorProviderIsAvailableAndHasCorrectNameAndPolicy() {
myFixture.configureByFiles("AnyFile.csv");
}

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

public void testCsvEditorIsTextEditorWithInitialCsvEditorSettings() {
myFixture.configureByFiles("AnyFile.csv");

FileEditorProvider[] fileEditorProviders = FileEditorProviderManager.getInstance().getProviders(myFixture.getProject(), myFixture.getFile().getVirtualFile());
FileEditor fileEditor = fileEditorProviders[0].createEditor(myFixture.getProject(), myFixture.getFile().getVirtualFile());
assertInstanceOf(fileEditor, TextEditor.class);
Expand All @@ -60,8 +57,6 @@ private TextEditor getCurrentTextEditor() {
}

public void testCsvEditorSettingsAreApplied() {
myFixture.configureByFiles("AnyFile.csv");

CsvEditorSettingsExternalizable csvEditorSettingsExternalizable = CsvEditorSettingsExternalizable.getInstance();
csvEditorSettingsExternalizable.setCaretRowShown(false);
csvEditorSettingsExternalizable.setUseSoftWraps(true);
Expand All @@ -74,5 +69,20 @@ public void testCsvEditorSettingsAreApplied() {

disposeTextEditor(textEditor);
}

public void testCsvEditorStateReadsAndWritesStates() {
TextEditor textEditor = getCurrentTextEditor();

FileEditorProvider[] fileEditorProviders = FileEditorProviderManager.getInstance().getProviders(myFixture.getProject(), myFixture.getFile().getVirtualFile());
CsvFileEditorProvider fileEditorProvider = (CsvFileEditorProvider)fileEditorProviders[0];
Element dummy = new Element("dummy");

FileEditorState state = fileEditorProvider.readState(dummy, this.getProject(), this.getFile().getVirtualFile());
assertInstanceOf(state, TextEditorState.class);
textEditor.setState(state);
fileEditorProvider.writeState(state, this.getProject(), dummy);

disposeTextEditor(textEditor);
}

}

0 comments on commit 25f1302

Please sign in to comment.