From a4fd06fba51082ef2300287bd9325b5810d04e45 Mon Sep 17 00:00:00 2001 From: GeeK Date: Tue, 27 Aug 2019 11:01:50 +0200 Subject: [PATCH 1/8] [FIX] Some characters not represented properly in table editor ATTENTION: change increases minimum IDE version Targets #122 --- .travis.yml | 8 +- build.gradle | 2 +- .../CsvEditorSettingsExternalizable.java | 9 + .../csv/editor/CsvEditorSettingsProvider.form | 277 +++++++++++------- .../csv/editor/CsvEditorSettingsProvider.java | 6 +- .../csv/editor/table/CsvTableEditor.java | 14 +- .../table/swing/MultiLineCellRenderer.java | 31 ++ src/main/resources/META-INF/plugin.xml | 13 +- 8 files changed, 225 insertions(+), 135 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09eb017b..4f4fbabb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,7 @@ jdk: - openjdk8 env: - - IDEA_VERSION=IC-2016.3.2 GRAMMAR_KIT_VERSION=1.4.3 - - IDEA_VERSION=IC-2017.3.2 GRAMMAR_KIT_VERSION=2017.1.2 - - IDEA_VERSION=IC-2018.3.2 GRAMMAR_KIT_VERSION=2017.1.6 + - IDEA_VERSION=IC-192.5728.98 GRAMMAR_KIT_VERSION=2017.1.6 - IDEA_VERSION=PC-LATEST-EAP-SNAPSHOT GRAMMAR_KIT_VERSION=2017.1.6 script: xvfb-run gradle check @@ -16,9 +14,9 @@ after_success: jobs: include: - if: (branch = master AND type = push) OR (type = pull_request) - env: IDEA_VERSION=IC-191.5701.16 GRAMMAR_KIT_VERSION=2017.1.6 + env: IDEA_VERSION=IC-192.5728.98 GRAMMAR_KIT_VERSION=2017.1.6 script: xvfb-run gradle check verifyPlugin - stage: deploy if: branch IN (Testing, Staging, Stable) AND type = push - env: IDEA_VERSION=IC-191.5701.16 GRAMMAR_KIT_VERSION=2017.1.6 JI_CHANNELS=$TRAVIS_BRANCH + env: IDEA_VERSION=IC-192.5728.98 GRAMMAR_KIT_VERSION=2017.1.6 JI_CHANNELS=$TRAVIS_BRANCH script: xvfb-run gradle publishPlugin diff --git a/build.gradle b/build.gradle index 549c0523..241b5415 100644 --- a/build.gradle +++ b/build.gradle @@ -71,7 +71,7 @@ idea { apply plugin: 'org.jetbrains.intellij' intellij { // IDE version - https://www.jetbrains.com/intellij-repository/releases - version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-191.5701.16') + version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-192.5728.98') pluginName = 'CSV Plugin' instrumentCode = true updateSinceUntilBuild = false diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java index ddec5f48..8b194f80 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java @@ -50,6 +50,7 @@ public static final class OptionSet { public boolean SHOW_TABLE_EDITOR_INFO_PANEL; public boolean QUOTING_ENFORCED; public boolean FILE_END_LINE_BREAK; + public boolean ADVANCED_FONT_HANDLING; public OptionSet() { EditorSettingsExternalizable editorSettingsExternalizable = EditorSettingsExternalizable.getInstance(); @@ -69,6 +70,7 @@ public OptionSet() { TABLE_COLUMN_HIGHTLIGHTING = true; ZERO_BASED_COLUMN_NUMBERING = false; FILE_END_LINE_BREAK = true; + ADVANCED_FONT_HANDLING = true; } } @@ -221,4 +223,11 @@ public boolean isTableAutoColumnWidthOnOpen() { public void setTableAutoColumnWidthOnOpen(boolean tableAutoColumnWidthOnOpen) { getState().TABLE_AUTO_COLUMN_WIDTH_ON_OPEN = tableAutoColumnWidthOnOpen; } + + public boolean isAdvancedFontHandling() { + return getState().ADVANCED_FONT_HANDLING; + } + public void setAdvancedFontHandling(boolean advancedFontHandling) { + getState().ADVANCED_FONT_HANDLING = advancedFontHandling; + } } \ No newline at end of file diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.form b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.form index e6fdf66b..c4e47b22 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.form +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.form @@ -1,9 +1,9 @@
- + - + @@ -16,12 +16,12 @@ - + - + @@ -31,7 +31,7 @@ - + @@ -39,7 +39,7 @@ - + @@ -51,11 +51,6 @@ - - - - - @@ -91,17 +86,17 @@ - + - + - + @@ -109,7 +104,7 @@ - + @@ -117,146 +112,214 @@ - + - - - - - - + - + - + - + - + - + - - + + + + + + - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + + + + + - + + + + + + + + + + + - + - + - + - + + + + + + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.java index d109b25d..d43e6971 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.java @@ -35,6 +35,7 @@ public class CsvEditorSettingsProvider implements SearchableConfigurable { private JFormattedTextField tfMaxColumnWidth; private JFormattedTextField tfDefaultColumnWidth; private JCheckBox cbAdjustColumnWidthOnOpen; + private JCheckBox cbAdvancedFontHandling; @NotNull @Override @@ -82,7 +83,8 @@ public boolean isModified() { isModified(cbFileEndLineBreak, csvEditorSettingsExternalizable.isFileEndLineBreak()) || !tfMaxColumnWidth.getValue().equals(csvEditorSettingsExternalizable.getTableAutoMaxColumnWidth()) || !tfDefaultColumnWidth.getValue().equals(csvEditorSettingsExternalizable.getTableDefaultColumnWidth()) || - isModified(cbAdjustColumnWidthOnOpen, csvEditorSettingsExternalizable.isTableAutoColumnWidthOnOpen()); + isModified(cbAdjustColumnWidthOnOpen, csvEditorSettingsExternalizable.isTableAutoColumnWidthOnOpen()) || + isModified(cbAdvancedFontHandling, csvEditorSettingsExternalizable.isAdvancedFontHandling()); } @Override @@ -104,6 +106,7 @@ public void reset() { tfMaxColumnWidth.setValue(csvEditorSettingsExternalizable.getTableAutoMaxColumnWidth()); tfDefaultColumnWidth.setValue(csvEditorSettingsExternalizable.getTableDefaultColumnWidth()); cbAdjustColumnWidthOnOpen.setSelected(csvEditorSettingsExternalizable.isTableAutoColumnWidthOnOpen()); + cbAdvancedFontHandling.setSelected(csvEditorSettingsExternalizable.isAdvancedFontHandling()); } @Override @@ -125,6 +128,7 @@ public void apply() throws ConfigurationException { csvEditorSettingsExternalizable.setTableAutoMaxColumnWidth((int)tfMaxColumnWidth.getValue()); csvEditorSettingsExternalizable.setTableDefaultColumnWidth((int)tfDefaultColumnWidth.getValue()); csvEditorSettingsExternalizable.setTableAutoColumnWidthOnOpen(cbAdjustColumnWidthOnOpen.isSelected()); + csvEditorSettingsExternalizable.setAdvancedFontHandling(cbAdvancedFontHandling.isSelected()); } protected void createUIComponents() { diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java index 61b9965c..bfd7f2ad 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditor.java @@ -11,7 +11,6 @@ import com.intellij.openapi.fileEditor.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.UserDataHolder; import com.intellij.openapi.util.UserDataHolderBase; import com.intellij.openapi.vfs.ReadonlyStatusHandler; @@ -20,6 +19,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.util.ArrayUtil; +import com.intellij.util.ui.UIUtil; import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfo; import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfoMap; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; @@ -31,8 +31,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; -import javax.swing.plaf.FontUIResource; -import javax.swing.text.StyleContext; import java.awt.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; @@ -323,15 +321,7 @@ public final int getRowCount() { } public Font getFont() { - // the one-liner to be used requires 172.2465.6 - compatibility - // return UIUtil.getFontWithFallback(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)); - - Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN); - String familyName = font.getFamily(); - int style = font.getStyle(); - int size = font.getSize(); - Font fontWithFallback = SystemInfo.isMac ? new Font(familyName, style, size) : (new StyleContext()).getFont(familyName, style, size); - return fontWithFallback instanceof FontUIResource ? (FontUIResource)fontWithFallback : new FontUIResource(fontWithFallback); + return UIUtil.getFontWithFallback(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)); } protected int getStringWidth(String text) { diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java index d6d1e345..e3a7566b 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java @@ -1,7 +1,11 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table.swing; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.EditorFontType; +import com.intellij.openapi.editor.impl.FontFallbackIterator; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.UserDataHolder; +import com.intellij.util.ui.UIUtil; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; import net.seesharpsoft.intellij.plugins.csv.settings.CsvColorSettings; @@ -102,6 +106,33 @@ public Object getCellEditorValue() { return this.getText(); } + @Override + public void setText(String text) { + if (CsvEditorSettingsExternalizable.getInstance().isAdvancedFontHandling()) { + setFont(determineFont(text)); + } + super.setText(text); + } + + public Font determineFont(String text) { + Font baseFont = UIUtil.getFontWithFallback(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)); + + FontFallbackIterator it = new FontFallbackIterator(); + it.setPreferredFont(baseFont.getFamily(), baseFont.getSize()); + it.setFontStyle(baseFont.getStyle()); + it.start(text, 0, text.length()); + + Font finalFont = baseFont; + for(; !it.atEnd(); it.advance()) { + Font font = it.getFont(); + if(!font.getFamily().equals(baseFont.getFamily())) { + finalFont = font; + break; + } + } + return finalFont; + } + @Override public boolean isCellEditable(EventObject anEvent) { return true; diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 0b9ff4ab..11c57eaf 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -52,21 +52,16 @@ FIX: Index out of bound error on multi line clear cells #151 - + com.intellij.modules.lang - - - - - - - - + + + From a7ad42b297637cd44e39395a7172fb28ccf9099d Mon Sep 17 00:00:00 2001 From: GeeK Date: Wed, 28 Aug 2019 07:03:19 +0200 Subject: [PATCH 2/8] [INTERNAL] Update test setup --- build.gradle | 2 +- .../plugins/csv/CsvFileTypeFactory.java | 12 ---------- .../plugins/psv/PsvFileTypeFactory.java | 12 ---------- .../plugins/tsv/TsvFileTypeFactory.java | 12 ---------- src/main/resources/META-INF/plugin.xml | 24 ++++++++++++++++--- .../actions/CsvChangeSeparatorActionTest.java | 4 ++-- .../plugins/csv/editor/CsvAnnotatorTest.java | 4 ++-- .../editor/CsvEditorSettingsProviderTest.java | 4 ++-- .../plugins/csv/editor/CsvFileEditorTest.java | 4 ++-- .../table/CsvTableEditorProviderTest.java | 4 ++-- .../editor/table/CsvTableEditorStateTest.java | 4 ++-- .../table/api/TableDataChangeEventTest.java | 4 ++-- .../table/api/TableDataHandlerTest.java | 4 ++-- .../swing/CsvTableEditorSwingTestBase.java | 4 ++-- .../csv/formatter/CsvFormatterTest.java | 4 ++-- .../CsvHighlightUsagesHandlerTest.java | 4 ++-- .../csv/inspection/CsvInspectionTest.java | 4 ++-- .../csv/intention/CsvIntentionTest.java | 4 ++-- .../settings/CsvCodeStyleSettingsTest.java | 4 ++-- .../structureview/CsvStructureViewTest.java | 4 ++-- .../tsv/inspection/TsvInspectionTest.java | 4 ++-- 21 files changed, 54 insertions(+), 72 deletions(-) delete mode 100644 src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvFileTypeFactory.java delete mode 100644 src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileTypeFactory.java delete mode 100644 src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileTypeFactory.java diff --git a/build.gradle b/build.gradle index 241b5415..6f9fe99a 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { plugins { // https://github.com/JetBrains/gradle-intellij-plugin - id 'org.jetbrains.intellij' version '0.4.9' + id 'org.jetbrains.intellij' version '0.4.10' id 'jacoco' id 'com.github.kt3k.coveralls' version '2.8.2' id "com.github.ManifestClasspath" version "0.1.0-RELEASE" diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvFileTypeFactory.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvFileTypeFactory.java deleted file mode 100644 index 14237f96..00000000 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvFileTypeFactory.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.seesharpsoft.intellij.plugins.csv; - -import com.intellij.openapi.fileTypes.FileTypeConsumer; -import com.intellij.openapi.fileTypes.FileTypeFactory; -import org.jetbrains.annotations.NotNull; - -public class CsvFileTypeFactory extends FileTypeFactory { - @Override - public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { - fileTypeConsumer.consume(CsvFileType.INSTANCE, String.join(FileTypeConsumer.EXTENSION_DELIMITER, new String[]{"csv"})); - } -} \ No newline at end of file diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileTypeFactory.java b/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileTypeFactory.java deleted file mode 100644 index 0f851596..00000000 --- a/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileTypeFactory.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.seesharpsoft.intellij.plugins.psv; - -import com.intellij.openapi.fileTypes.FileTypeConsumer; -import com.intellij.openapi.fileTypes.FileTypeFactory; -import org.jetbrains.annotations.NotNull; - -public class PsvFileTypeFactory extends FileTypeFactory { - @Override - public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { - fileTypeConsumer.consume(PsvFileType.INSTANCE, String.join(FileTypeConsumer.EXTENSION_DELIMITER, new String[]{"psv"})); - } -} \ No newline at end of file diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileTypeFactory.java b/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileTypeFactory.java deleted file mode 100644 index 5e794476..00000000 --- a/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileTypeFactory.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.seesharpsoft.intellij.plugins.tsv; - -import com.intellij.openapi.fileTypes.FileTypeConsumer; -import com.intellij.openapi.fileTypes.FileTypeFactory; -import org.jetbrains.annotations.NotNull; - -public class TsvFileTypeFactory extends FileTypeFactory { - @Override - public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { - fileTypeConsumer.consume(TsvFileType.INSTANCE, String.join(FileTypeConsumer.EXTENSION_DELIMITER, new String[]{"tsv", "tab"})); - } -} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 11c57eaf..fea8b782 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -59,9 +59,27 @@ FIX: Index out of bound error on multi line clear cells #151 com.intellij.modules.lang - - - + + + diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java index e3ca18ab..29daaac1 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java @@ -1,10 +1,10 @@ package net.seesharpsoft.intellij.plugins.csv.actions; import com.intellij.openapi.actionSystem.Presentation; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import net.seesharpsoft.intellij.plugins.csv.settings.CsvCodeStyleSettings; -public class CsvChangeSeparatorActionTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvChangeSeparatorActionTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotatorTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotatorTest.java index c08ed0e9..7894e252 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotatorTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotatorTest.java @@ -14,7 +14,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.testFramework.EdtTestUtil; import com.intellij.testFramework.ExpectedHighlightingData; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import org.jetbrains.annotations.NotNull; import java.util.Collections; @@ -23,7 +23,7 @@ import static net.seesharpsoft.intellij.plugins.csv.editor.CsvAnnotator.CSV_COLUMN_INFO_SEVERITY; -public class CsvAnnotatorTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvAnnotatorTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProviderTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProviderTest.java index dd9ec41b..5296ce29 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProviderTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProviderTest.java @@ -1,11 +1,11 @@ package net.seesharpsoft.intellij.plugins.csv.editor; import com.intellij.openapi.options.ConfigurationException; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import java.awt.*; -public class CsvEditorSettingsProviderTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvEditorSettingsProviderTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java index 39e18d13..61ce6be3 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java @@ -4,10 +4,10 @@ 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.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import org.jdom.Element; -public class CsvFileEditorTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvFileEditorTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorProviderTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorProviderTest.java index 8e5a538d..ef14562f 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorProviderTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorProviderTest.java @@ -5,13 +5,13 @@ import com.intellij.openapi.fileEditor.FileEditorProvider; import com.intellij.openapi.fileEditor.FileEditorState; import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; import org.jdom.Element; import java.util.Objects; -public class CsvTableEditorProviderTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvTableEditorProviderTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorStateTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorStateTest.java index 62db1f80..687e2d76 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorStateTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorStateTest.java @@ -1,10 +1,10 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; import org.jdom.Element; -public class CsvTableEditorStateTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvTableEditorStateTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataChangeEventTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataChangeEventTest.java index e8660002..a4f4e812 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataChangeEventTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataChangeEventTest.java @@ -1,12 +1,12 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table.api; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import org.junit.Test; import java.util.Arrays; -public class TableDataChangeEventTest extends LightPlatformCodeInsightFixtureTestCase { +public class TableDataChangeEventTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataHandlerTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataHandlerTest.java index d2e18d29..c9a73a9b 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataHandlerTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataHandlerTest.java @@ -1,13 +1,13 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table.api; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import net.seesharpsoft.intellij.plugins.csv.editor.table.CsvTableEditor; import net.seesharpsoft.intellij.plugins.csv.editor.table.swing.CsvTableEditorSwing; import java.util.Arrays; -public class TableDataHandlerTest extends LightPlatformCodeInsightFixtureTestCase { +public class TableDataHandlerTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwingTestBase.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwingTestBase.java index b2b5b6d1..d9148248 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwingTestBase.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwingTestBase.java @@ -1,14 +1,14 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table.swing; import com.intellij.testFramework.exceptionCases.AbstractExceptionCase; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import com.intellij.util.ThrowableRunnable; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public abstract class CsvTableEditorSwingTestBase extends LightPlatformCodeInsightFixtureTestCase { +public abstract class CsvTableEditorSwingTestBase extends BasePlatformTestCase { protected CsvTableEditorSwing fileEditor; diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatterTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatterTest.java index b09effc7..ee36305f 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatterTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatterTest.java @@ -3,7 +3,7 @@ import com.intellij.openapi.command.WriteCommandAction; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import com.intellij.util.containers.ContainerUtil; import net.seesharpsoft.intellij.plugins.csv.settings.CsvCodeStyleSettings; import org.junit.Assert; @@ -12,7 +12,7 @@ import java.time.Instant; import java.util.Properties; -public class CsvFormatterTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvFormatterTest extends BasePlatformTestCase { @Override protected void setUp() throws Exception { super.setUp(); diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightUsagesHandlerTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightUsagesHandlerTest.java index def94c36..80afd912 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightUsagesHandlerTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightUsagesHandlerTest.java @@ -6,9 +6,9 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.openapi.util.TextRange; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; -public class CsvHighlightUsagesHandlerTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvHighlightUsagesHandlerTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvInspectionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvInspectionTest.java index a3d24e9e..8cd09c11 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvInspectionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvInspectionTest.java @@ -1,9 +1,9 @@ package net.seesharpsoft.intellij.plugins.csv.inspection; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; -public class CsvInspectionTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvInspectionTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java index 0d22d0b0..ec59194b 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java @@ -1,9 +1,9 @@ package net.seesharpsoft.intellij.plugins.csv.intention; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; -public class CsvIntentionTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvIntentionTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsTest.java index 05ce9f4a..e9c8ba91 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsTest.java @@ -1,8 +1,8 @@ package net.seesharpsoft.intellij.plugins.csv.settings; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; -public class CsvCodeStyleSettingsTest extends LightPlatformCodeInsightFixtureTestCase { +public class CsvCodeStyleSettingsTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/structureview/CsvStructureViewTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/structureview/CsvStructureViewTest.java index b8c7fcd0..e0be33eb 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/structureview/CsvStructureViewTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/structureview/CsvStructureViewTest.java @@ -3,10 +3,10 @@ import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.ide.util.treeView.smartTree.TreeElement; import com.intellij.navigation.ItemPresentation; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; -public class CsvStructureViewTest extends LightPlatformCodeInsightFixtureTestCase{ +public class CsvStructureViewTest extends BasePlatformTestCase{ @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/tsv/inspection/TsvInspectionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/tsv/inspection/TsvInspectionTest.java index 9240b305..ba0d2d83 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/tsv/inspection/TsvInspectionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/tsv/inspection/TsvInspectionTest.java @@ -1,10 +1,10 @@ package net.seesharpsoft.intellij.plugins.tsv.inspection; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.testFramework.fixtures.BasePlatformTestCase; import net.seesharpsoft.intellij.plugins.csv.inspection.CsvValidationInspection; -public class TsvInspectionTest extends LightPlatformCodeInsightFixtureTestCase { +public class TsvInspectionTest extends BasePlatformTestCase { @Override protected String getTestDataPath() { From 8c50b9494bdf8f7dacbbbc0bd08620ff3f681ff0 Mon Sep 17 00:00:00 2001 From: GeeK Date: Thu, 29 Aug 2019 07:04:50 +0200 Subject: [PATCH 3/8] [INTERNAL] remove fileNamesCaseInsensitive https://intellij-support.jetbrains.com/hc/en-us/community/posts/360004946759-fileType-extension-point-not-considered-in-tests- --- src/main/resources/META-INF/plugin.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index fea8b782..6b4aadaa 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -63,21 +63,18 @@ FIX: Index out of bound error on multi line clear cells #151 implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvFileType" extensions="csv" language="csv" - fileNamesCaseInsensitive="true" fieldName="INSTANCE" /> From 6212a9b00d2a3fa311dd849592c4e4ce8d3ca18a Mon Sep 17 00:00:00 2001 From: GeeK Date: Tue, 17 Sep 2019 08:13:14 +0200 Subject: [PATCH 4/8] [INTERNAL] Resolve merge conflicts and revert changes towards v2019.2 --- .travis.yml | 10 +- README.md | 2 +- build.gradle | 4 +- .../plugins/csv/CsvFileTypeFactory.java | 12 ++ .../CsvEditorSettingsExternalizable.java | 1 + .../table/swing/MultiLineCellRenderer.java | 45 +++---- .../plugins/psv/PsvFileTypeFactory.java | 12 ++ .../plugins/tsv/TsvFileTypeFactory.java | 12 ++ src/main/resources/META-INF/plugin.xml | 118 +++++++++++++----- .../actions/CsvChangeSeparatorActionTest.java | 4 +- .../plugins/csv/editor/CsvAnnotatorTest.java | 4 +- .../editor/CsvEditorSettingsProviderTest.java | 4 +- .../plugins/csv/editor/CsvFileEditorTest.java | 4 +- .../table/CsvTableEditorProviderTest.java | 4 +- .../editor/table/CsvTableEditorStateTest.java | 4 +- .../table/api/TableDataChangeEventTest.java | 4 +- .../table/api/TableDataHandlerTest.java | 4 +- .../swing/CsvTableEditorSwingTestBase.java | 4 +- .../csv/formatter/CsvFormatterTest.java | 4 +- .../CsvHighlightUsagesHandlerTest.java | 4 +- .../csv/inspection/CsvInspectionTest.java | 4 +- .../csv/intention/CsvIntentionTest.java | 4 +- .../settings/CsvCodeStyleSettingsTest.java | 4 +- .../structureview/CsvStructureViewTest.java | 4 +- .../tsv/inspection/TsvInspectionTest.java | 4 +- 25 files changed, 190 insertions(+), 90 deletions(-) create mode 100644 src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvFileTypeFactory.java create mode 100644 src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileTypeFactory.java create mode 100644 src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileTypeFactory.java diff --git a/.travis.yml b/.travis.yml index 4f4fbabb..62998912 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,10 @@ jdk: - openjdk8 env: - - IDEA_VERSION=IC-192.5728.98 GRAMMAR_KIT_VERSION=2017.1.6 - - IDEA_VERSION=PC-LATEST-EAP-SNAPSHOT GRAMMAR_KIT_VERSION=2017.1.6 + - IDEA_VERSION=IC-2017.3.1 GRAMMAR_KIT_VERSION=2017.1.2 + - IDEA_VERSION=IC-2018.3.2 GRAMMAR_KIT_VERSION=2017.1.7 + - IDEA_VERSION=IC-2019.1.3 GRAMMAR_KIT_VERSION=2017.1.7 + - IDEA_VERSION=PC-LATEST-EAP-SNAPSHOT GRAMMAR_KIT_VERSION=07f30a1e7666f36ae780f614b6bbc89690ba36c3 script: xvfb-run gradle check @@ -14,9 +16,9 @@ after_success: jobs: include: - if: (branch = master AND type = push) OR (type = pull_request) - env: IDEA_VERSION=IC-192.5728.98 GRAMMAR_KIT_VERSION=2017.1.6 + env: IDEA_VERSION=IC-191.5701.16 GRAMMAR_KIT_VERSION=2017.1.7 script: xvfb-run gradle check verifyPlugin - stage: deploy if: branch IN (Testing, Staging, Stable) AND type = push - env: IDEA_VERSION=IC-192.5728.98 GRAMMAR_KIT_VERSION=2017.1.6 JI_CHANNELS=$TRAVIS_BRANCH + env: IDEA_VERSION=IC-191.5701.16 GRAMMAR_KIT_VERSION=2017.1.7 JI_CHANNELS=$TRAVIS_BRANCH script: xvfb-run gradle publishPlugin diff --git a/README.md b/README.md index e6a4533a..68549166 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ # Lightweight CSV Plugin for JetBrains IDE family -Compatible with _IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode CLion Gogland DataGrip Rider MPS Android Studio_ - __2016.3.2 and newer__ +Compatible with _IntelliJ IDEA PhpStorm WebStorm PyCharm RubyMine AppCode CLion Gogland DataGrip Rider MPS Android Studio_ - __2017.3.1 and newer__ This plugin introduces CSV (_Comma-Separated Values_) as a language to Jetbrains IDE with a syntax definition, structured language elements and associated file types (.csv/.tsv/.psv). This enables default editor features like syntax validation, highlighting and inspections for CSV-alike files. diff --git a/build.gradle b/build.gradle index 939809a6..502fc864 100644 --- a/build.gradle +++ b/build.gradle @@ -71,11 +71,11 @@ idea { apply plugin: 'org.jetbrains.intellij' intellij { // IDE version - https://www.jetbrains.com/intellij-repository/releases - version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-192.5728.98') + version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-191.5701.16') pluginName = 'CSV Plugin' instrumentCode = true updateSinceUntilBuild = false - downloadSources = false + downloadSources = true } publishPlugin { token = System.getenv().getOrDefault('JI_TOKEN', '') diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvFileTypeFactory.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvFileTypeFactory.java new file mode 100644 index 00000000..53f851f6 --- /dev/null +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvFileTypeFactory.java @@ -0,0 +1,12 @@ +package net.seesharpsoft.intellij.plugins.csv; + +import com.intellij.openapi.fileTypes.FileTypeConsumer; +import com.intellij.openapi.fileTypes.FileTypeFactory; +import org.jetbrains.annotations.NotNull; + +public class CsvFileTypeFactory extends FileTypeFactory { + @Override + public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { + fileTypeConsumer.consume(CsvFileType.INSTANCE, String.join(FileTypeConsumer.EXTENSION_DELIMITER, new String[] {"csv"})); + } +} \ No newline at end of file diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java index 6fd205e9..b029937b 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java @@ -243,6 +243,7 @@ public void setTableAutoColumnWidthOnOpen(boolean tableAutoColumnWidthOnOpen) { public boolean isAdvancedFontHandling() { return getState().ADVANCED_FONT_HANDLING; } + public void setAdvancedFontHandling(boolean advancedFontHandling) { getState().ADVANCED_FONT_HANDLING = advancedFontHandling; } diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java index 39f15561..81adf36c 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java @@ -9,6 +9,7 @@ import com.intellij.util.ui.UIUtil; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; import net.seesharpsoft.intellij.plugins.csv.settings.CsvColorSettings; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.border.EmptyBorder; @@ -80,13 +81,13 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole myTextArea.setBorder(new EmptyBorder(1, 2, 1, 2)); } + this.setText(value == null ? "" : value.toString()); + final int columnWidth = table.getColumnModel().getColumn(column).getWidth(); final int rowHeight = table.getRowHeight(row); - this.setFont(table.getFont()); + this.setSize(columnWidth, rowHeight); this.validate(); - myTextArea.setText((value == null) ? "" : value.toString()); - myTextArea.setFont(table.getFont()); myTextArea.setSize(columnWidth, rowHeight); myTextArea.validate(); @@ -118,30 +119,30 @@ public Object getCellEditorValue() { return myTextArea.getText(); } - @Override - public void setText(String text) { - if (CsvEditorSettingsExternalizable.getInstance().isAdvancedFontHandling()) { - setFont(determineFont(text)); - } - super.setText(text); + protected void setText(@NotNull String text) { + Font font = determineFont(text); + this.setFont(font); + myTextArea.setFont(font); + myTextArea.setText(text); } - public Font determineFont(String text) { - Font baseFont = UIUtil.getFontWithFallback(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)); - - FontFallbackIterator it = new FontFallbackIterator(); - it.setPreferredFont(baseFont.getFamily(), baseFont.getSize()); - it.setFontStyle(baseFont.getStyle()); - it.start(text, 0, text.length()); + protected Font determineFont(@NotNull String text) { + Font finalFont = UIUtil.getFontWithFallback(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)); - Font finalFont = baseFont; - for(; !it.atEnd(); it.advance()) { - Font font = it.getFont(); - if(!font.getFamily().equals(baseFont.getFamily())) { - finalFont = font; - break; + if (CsvEditorSettingsExternalizable.getInstance().isAdvancedFontHandling()) { + FontFallbackIterator it = new FontFallbackIterator(); + it.setPreferredFont(finalFont.getFamily(), finalFont.getSize()); + it.setFontStyle(finalFont.getStyle()); + it.start(text, 0, text.length()); + for (; !it.atEnd(); it.advance()) { + Font font = it.getFont(); + if (!font.getFamily().equals(finalFont.getFamily())) { + finalFont = font; + break; + } } } + return finalFont; } diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileTypeFactory.java b/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileTypeFactory.java new file mode 100644 index 00000000..f2f973a8 --- /dev/null +++ b/src/main/java/net/seesharpsoft/intellij/plugins/psv/PsvFileTypeFactory.java @@ -0,0 +1,12 @@ +package net.seesharpsoft.intellij.plugins.psv; + +import com.intellij.openapi.fileTypes.FileTypeConsumer; +import com.intellij.openapi.fileTypes.FileTypeFactory; +import org.jetbrains.annotations.NotNull; + +public class PsvFileTypeFactory extends FileTypeFactory { + @Override + public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { + fileTypeConsumer.consume(PsvFileType.INSTANCE, String.join(FileTypeConsumer.EXTENSION_DELIMITER, new String[] {"psv"})); + } +} \ No newline at end of file diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileTypeFactory.java b/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileTypeFactory.java new file mode 100644 index 00000000..1cf16007 --- /dev/null +++ b/src/main/java/net/seesharpsoft/intellij/plugins/tsv/TsvFileTypeFactory.java @@ -0,0 +1,12 @@ +package net.seesharpsoft.intellij.plugins.tsv; + +import com.intellij.openapi.fileTypes.FileTypeConsumer; +import com.intellij.openapi.fileTypes.FileTypeFactory; +import org.jetbrains.annotations.NotNull; + +public class TsvFileTypeFactory extends FileTypeFactory { + @Override + public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { + fileTypeConsumer.consume(TsvFileType.INSTANCE, String.join(FileTypeConsumer.EXTENSION_DELIMITER, new String[] {"tsv", "tab"})); + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 6b4aadaa..7acb27f7 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -7,28 +7,27 @@ The Table Editor is a newly introduced feature of CSV Plugin v2.*. Support its ongoing development by reporting issues, providing suggestions, contributing ideas/features or by just giving it a thumbs up.

+

Lightweight plugin for editing CSV/TSV/PSV files with a flexible table editor, syntax validation, structure highlighting, customizable coloring, new intentions and helpful inspections.




- - Lightweight CSV plugin that supports editing files in CSV/TSV format.

Features:
    -
  • CSV/TSV/PSV file detection
  • -
  • table editor
  • +
  • support for CSV/TSV/PSV file extensions
  • +
  • customizable table editor
  • customizable text editor
  • +
  • customizable column coloring
  • syntax validation
  • -
  • syntax highlighting (configurable)
  • -
  • content formatting (configurable)
  • +
  • syntax highlighting
  • +
  • content formatting
  • quick fix inspections
  • intentions (Alt+Enter), e.g. Quote/Unquote (all), Shift Column Left/Right
  • +
  • balloon help & spell checker
  • structure view (header-entry layout)
  • support for ',', ';', '|' or '↹' as value separator
  • highlight of active column values
  • -
  • customizable column coloring
  • tab (↹) separator highlighting
- TSV file support: TSV files are recognized as such but treated as a variant of CSV files, the same syntax highlighting and code style settings are applied. + TSV/PSV file support: TSV/PSV files are recognized as such but treated as a variant of CSV files, the same syntax highlighting and code style settings are applied.

Code formatting: Default code formatting is 'Tabularize'. Can be changed in Settings -> Editor -> Code Style -> CSV

@@ -46,37 +45,24 @@ -FIX: Index out of bound error on multi line clear cells #151 +NEW: add separator selection to table editor #140 +FIX: coloring of table cells (e.g. selection mode) +FIX: enter edit mode via keyboard (e.g. ENTER key in cell) ]]> - + com.intellij.modules.lang - - - + + + @@ -160,6 +146,77 @@ FIX: Index out of bound error on multi line clear cells #151 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java index 29daaac1..e3ca18ab 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/actions/CsvChangeSeparatorActionTest.java @@ -1,10 +1,10 @@ package net.seesharpsoft.intellij.plugins.csv.actions; import com.intellij.openapi.actionSystem.Presentation; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import net.seesharpsoft.intellij.plugins.csv.settings.CsvCodeStyleSettings; -public class CsvChangeSeparatorActionTest extends BasePlatformTestCase { +public class CsvChangeSeparatorActionTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotatorTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotatorTest.java index 7894e252..c08ed0e9 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotatorTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotatorTest.java @@ -14,7 +14,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.testFramework.EdtTestUtil; import com.intellij.testFramework.ExpectedHighlightingData; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import org.jetbrains.annotations.NotNull; import java.util.Collections; @@ -23,7 +23,7 @@ import static net.seesharpsoft.intellij.plugins.csv.editor.CsvAnnotator.CSV_COLUMN_INFO_SEVERITY; -public class CsvAnnotatorTest extends BasePlatformTestCase { +public class CsvAnnotatorTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProviderTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProviderTest.java index 5296ce29..dd9ec41b 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProviderTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProviderTest.java @@ -1,11 +1,11 @@ package net.seesharpsoft.intellij.plugins.csv.editor; import com.intellij.openapi.options.ConfigurationException; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import java.awt.*; -public class CsvEditorSettingsProviderTest extends BasePlatformTestCase { +public class CsvEditorSettingsProviderTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java index 61ce6be3..39e18d13 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvFileEditorTest.java @@ -4,10 +4,10 @@ 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.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import org.jdom.Element; -public class CsvFileEditorTest extends BasePlatformTestCase { +public class CsvFileEditorTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorProviderTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorProviderTest.java index ef14562f..8e5a538d 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorProviderTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorProviderTest.java @@ -5,13 +5,13 @@ import com.intellij.openapi.fileEditor.FileEditorProvider; import com.intellij.openapi.fileEditor.FileEditorState; import com.intellij.openapi.fileEditor.ex.FileEditorProviderManager; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; import org.jdom.Element; import java.util.Objects; -public class CsvTableEditorProviderTest extends BasePlatformTestCase { +public class CsvTableEditorProviderTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorStateTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorStateTest.java index 687e2d76..62db1f80 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorStateTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/CsvTableEditorStateTest.java @@ -1,10 +1,10 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; import org.jdom.Element; -public class CsvTableEditorStateTest extends BasePlatformTestCase { +public class CsvTableEditorStateTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataChangeEventTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataChangeEventTest.java index a4f4e812..e8660002 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataChangeEventTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataChangeEventTest.java @@ -1,12 +1,12 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table.api; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import org.junit.Test; import java.util.Arrays; -public class TableDataChangeEventTest extends BasePlatformTestCase { +public class TableDataChangeEventTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataHandlerTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataHandlerTest.java index c9a73a9b..d2e18d29 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataHandlerTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/api/TableDataHandlerTest.java @@ -1,13 +1,13 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table.api; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import net.seesharpsoft.intellij.plugins.csv.editor.table.CsvTableEditor; import net.seesharpsoft.intellij.plugins.csv.editor.table.swing.CsvTableEditorSwing; import java.util.Arrays; -public class TableDataHandlerTest extends BasePlatformTestCase { +public class TableDataHandlerTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwingTestBase.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwingTestBase.java index d9148248..b2b5b6d1 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwingTestBase.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/CsvTableEditorSwingTestBase.java @@ -1,14 +1,14 @@ package net.seesharpsoft.intellij.plugins.csv.editor.table.swing; import com.intellij.testFramework.exceptionCases.AbstractExceptionCase; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import com.intellij.util.ThrowableRunnable; import net.seesharpsoft.intellij.plugins.csv.CsvHelper; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public abstract class CsvTableEditorSwingTestBase extends BasePlatformTestCase { +public abstract class CsvTableEditorSwingTestBase extends LightPlatformCodeInsightFixtureTestCase { protected CsvTableEditorSwing fileEditor; diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatterTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatterTest.java index ee36305f..b09effc7 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatterTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/formatter/CsvFormatterTest.java @@ -3,7 +3,7 @@ import com.intellij.openapi.command.WriteCommandAction; import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import com.intellij.util.containers.ContainerUtil; import net.seesharpsoft.intellij.plugins.csv.settings.CsvCodeStyleSettings; import org.junit.Assert; @@ -12,7 +12,7 @@ import java.time.Instant; import java.util.Properties; -public class CsvFormatterTest extends BasePlatformTestCase { +public class CsvFormatterTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected void setUp() throws Exception { super.setUp(); diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightUsagesHandlerTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightUsagesHandlerTest.java index 80afd912..def94c36 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightUsagesHandlerTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/highlighter/CsvHighlightUsagesHandlerTest.java @@ -6,9 +6,9 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.markup.RangeHighlighter; import com.intellij.openapi.util.TextRange; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; -public class CsvHighlightUsagesHandlerTest extends BasePlatformTestCase { +public class CsvHighlightUsagesHandlerTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvInspectionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvInspectionTest.java index 8cd09c11..a3d24e9e 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvInspectionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/inspection/CsvInspectionTest.java @@ -1,9 +1,9 @@ package net.seesharpsoft.intellij.plugins.csv.inspection; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; -public class CsvInspectionTest extends BasePlatformTestCase { +public class CsvInspectionTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java index ec59194b..0d22d0b0 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/intention/CsvIntentionTest.java @@ -1,9 +1,9 @@ package net.seesharpsoft.intellij.plugins.csv.intention; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; -public class CsvIntentionTest extends BasePlatformTestCase { +public class CsvIntentionTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsTest.java index e9c8ba91..05ce9f4a 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/settings/CsvCodeStyleSettingsTest.java @@ -1,8 +1,8 @@ package net.seesharpsoft.intellij.plugins.csv.settings; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; -public class CsvCodeStyleSettingsTest extends BasePlatformTestCase { +public class CsvCodeStyleSettingsTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/csv/structureview/CsvStructureViewTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/csv/structureview/CsvStructureViewTest.java index e0be33eb..b8c7fcd0 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/csv/structureview/CsvStructureViewTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/csv/structureview/CsvStructureViewTest.java @@ -3,10 +3,10 @@ import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.ide.util.treeView.smartTree.TreeElement; import com.intellij.navigation.ItemPresentation; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import net.seesharpsoft.intellij.plugins.csv.editor.CsvEditorSettingsExternalizable; -public class CsvStructureViewTest extends BasePlatformTestCase{ +public class CsvStructureViewTest extends LightPlatformCodeInsightFixtureTestCase{ @Override protected String getTestDataPath() { diff --git a/src/test/java/net/seesharpsoft/intellij/plugins/tsv/inspection/TsvInspectionTest.java b/src/test/java/net/seesharpsoft/intellij/plugins/tsv/inspection/TsvInspectionTest.java index ba0d2d83..9240b305 100644 --- a/src/test/java/net/seesharpsoft/intellij/plugins/tsv/inspection/TsvInspectionTest.java +++ b/src/test/java/net/seesharpsoft/intellij/plugins/tsv/inspection/TsvInspectionTest.java @@ -1,10 +1,10 @@ package net.seesharpsoft.intellij.plugins.tsv.inspection; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; +import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; import net.seesharpsoft.intellij.plugins.csv.inspection.CsvValidationInspection; -public class TsvInspectionTest extends BasePlatformTestCase { +public class TsvInspectionTest extends LightPlatformCodeInsightFixtureTestCase { @Override protected String getTestDataPath() { From cace4617447fda58bed3a8725c9daf27a919a935 Mon Sep 17 00:00:00 2001 From: GeeK Date: Tue, 17 Sep 2019 08:37:05 +0200 Subject: [PATCH 5/8] [FIX] advanced font handling for balloon help in text editor --- .../intellij/plugins/csv/editor/CsvAnnotator.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java index 99804ca1..21f097bc 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java @@ -4,6 +4,7 @@ import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.vcs.ui.FontUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.tree.IElementType; import com.intellij.xml.util.XmlStringUtil; @@ -43,12 +44,16 @@ public void annotate(@NotNull final PsiElement element, @NotNull final Annotatio if (columnInfo != null) { PsiElement headerElement = columnInfo.getHeaderElement(); - String message = XmlStringUtil.escapeString(headerElement == null ? "" : headerElement.getText(), true); + String message = FontUtil.getHtmlWithFonts( + XmlStringUtil.escapeString(headerElement == null ? "" : headerElement.getText(), true) + ); String tooltip = null; if (showInfoBalloon(holder.getCurrentAnnotationSession())) { tooltip = XmlStringUtil.wrapInHtml( String.format("%s

Header: %s
Index: %d", - XmlStringUtil.escapeString(element.getText(), true), + FontUtil.getHtmlWithFonts( + XmlStringUtil.escapeString(element.getText(), true) + ), message, columnInfo.getColumnIndex() + (CsvEditorSettingsExternalizable.getInstance().isZeroBasedColumnNumbering() ? 0 : 1) ) From c144467aa7a5b5b2f9158d2bf2bf3fd3c50df22d Mon Sep 17 00:00:00 2001 From: GeeK Date: Tue, 17 Sep 2019 08:42:34 +0200 Subject: [PATCH 6/8] [INTERNAL] remove introduced advanced font setting (always apply) --- .../CsvEditorSettingsExternalizable.java | 10 ---------- .../csv/editor/CsvEditorSettingsProvider.form | 12 ++--------- .../csv/editor/CsvEditorSettingsProvider.java | 6 +----- .../table/swing/MultiLineCellRenderer.java | 20 +++++++++---------- 4 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java index b029937b..0bf16dac 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsExternalizable.java @@ -50,7 +50,6 @@ public static final class OptionSet { public boolean SHOW_TABLE_EDITOR_INFO_PANEL; public boolean QUOTING_ENFORCED; public boolean FILE_END_LINE_BREAK; - public boolean ADVANCED_FONT_HANDLING; public OptionSet() { EditorSettingsExternalizable editorSettingsExternalizable = EditorSettingsExternalizable.getInstance(); @@ -70,7 +69,6 @@ public OptionSet() { TABLE_COLUMN_HIGHTLIGHTING = true; ZERO_BASED_COLUMN_NUMBERING = false; FILE_END_LINE_BREAK = true; - ADVANCED_FONT_HANDLING = true; } } @@ -239,12 +237,4 @@ public boolean isTableAutoColumnWidthOnOpen() { public void setTableAutoColumnWidthOnOpen(boolean tableAutoColumnWidthOnOpen) { getState().TABLE_AUTO_COLUMN_WIDTH_ON_OPEN = tableAutoColumnWidthOnOpen; } - - public boolean isAdvancedFontHandling() { - return getState().ADVANCED_FONT_HANDLING; - } - - public void setAdvancedFontHandling(boolean advancedFontHandling) { - getState().ADVANCED_FONT_HANDLING = advancedFontHandling; - } } \ No newline at end of file diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.form b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.form index c4e47b22..ef9d7f3b 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.form +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.form @@ -86,7 +86,7 @@ - + @@ -112,7 +112,7 @@ - + @@ -134,14 +134,6 @@ - - - - - - - - diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.java index 9519f763..8d7f7701 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvEditorSettingsProvider.java @@ -35,7 +35,6 @@ public class CsvEditorSettingsProvider implements SearchableConfigurable { private JFormattedTextField tfMaxColumnWidth; private JFormattedTextField tfDefaultColumnWidth; private JCheckBox cbAdjustColumnWidthOnOpen; - private JCheckBox cbAdvancedFontHandling; @NotNull @Override @@ -83,8 +82,7 @@ public boolean isModified() { isModified(cbFileEndLineBreak, csvEditorSettingsExternalizable.isFileEndLineBreak()) || !tfMaxColumnWidth.getValue().equals(csvEditorSettingsExternalizable.getTableAutoMaxColumnWidth()) || !tfDefaultColumnWidth.getValue().equals(csvEditorSettingsExternalizable.getTableDefaultColumnWidth()) || - isModified(cbAdjustColumnWidthOnOpen, csvEditorSettingsExternalizable.isTableAutoColumnWidthOnOpen()) || - isModified(cbAdvancedFontHandling, csvEditorSettingsExternalizable.isAdvancedFontHandling()); + isModified(cbAdjustColumnWidthOnOpen, csvEditorSettingsExternalizable.isTableAutoColumnWidthOnOpen()); } @Override @@ -106,7 +104,6 @@ public void reset() { tfMaxColumnWidth.setValue(csvEditorSettingsExternalizable.getTableAutoMaxColumnWidth()); tfDefaultColumnWidth.setValue(csvEditorSettingsExternalizable.getTableDefaultColumnWidth()); cbAdjustColumnWidthOnOpen.setSelected(csvEditorSettingsExternalizable.isTableAutoColumnWidthOnOpen()); - cbAdvancedFontHandling.setSelected(csvEditorSettingsExternalizable.isAdvancedFontHandling()); } @Override @@ -128,7 +125,6 @@ public void apply() throws ConfigurationException { csvEditorSettingsExternalizable.setTableAutoMaxColumnWidth((int) tfMaxColumnWidth.getValue()); csvEditorSettingsExternalizable.setTableDefaultColumnWidth((int) tfDefaultColumnWidth.getValue()); csvEditorSettingsExternalizable.setTableAutoColumnWidthOnOpen(cbAdjustColumnWidthOnOpen.isSelected()); - csvEditorSettingsExternalizable.setAdvancedFontHandling(cbAdvancedFontHandling.isSelected()); } protected void createUIComponents() { diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java index 81adf36c..025bf736 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/MultiLineCellRenderer.java @@ -129,17 +129,15 @@ protected void setText(@NotNull String text) { protected Font determineFont(@NotNull String text) { Font finalFont = UIUtil.getFontWithFallback(EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN)); - if (CsvEditorSettingsExternalizable.getInstance().isAdvancedFontHandling()) { - FontFallbackIterator it = new FontFallbackIterator(); - it.setPreferredFont(finalFont.getFamily(), finalFont.getSize()); - it.setFontStyle(finalFont.getStyle()); - it.start(text, 0, text.length()); - for (; !it.atEnd(); it.advance()) { - Font font = it.getFont(); - if (!font.getFamily().equals(finalFont.getFamily())) { - finalFont = font; - break; - } + FontFallbackIterator it = new FontFallbackIterator(); + it.setPreferredFont(finalFont.getFamily(), finalFont.getSize()); + it.setFontStyle(finalFont.getStyle()); + it.start(text, 0, text.length()); + for (; !it.atEnd(); it.advance()) { + Font font = it.getFont(); + if (!font.getFamily().equals(finalFont.getFamily())) { + finalFont = font; + break; } } From 4556d92b1f90346e1a2b052cce1bfc59decf25dc Mon Sep 17 00:00:00 2001 From: GeeK Date: Tue, 17 Sep 2019 09:15:54 +0200 Subject: [PATCH 7/8] [INTERNAL] general cleanup --- CHANGELOG | 6 ++++++ README.md | 3 +-- .../intellij/plugins/csv/editor/CsvAnnotator.java | 4 +--- src/main/resources/META-INF/plugin.xml | 5 ++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 09111f54..ddaa552b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +2.8.0 +??? + +NEW: improved font handling in table editor #122 +FIX: proper font handling in balloon tooltips + 2.7.0 Sep 16, 2019 diff --git a/README.md b/README.md index 68549166..e687bbc7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ [![Known Vulnerabilities](https://snyk.io/test/github/SeeSharpSoft/intellij-csv-validator/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/SeeSharpSoft/intellij-csv-validator?targetFile=build.gradle) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/97769359388e44bfb7101346d510fccf)](https://www.codacy.com/app/github_124/intellij-csv-validator?utm_source=github.com&utm_medium=referral&utm_content=SeeSharpSoft/intellij-csv-validator&utm_campaign=Badge_Grade) [![BCH compliance](https://bettercodehub.com/edge/badge/SeeSharpSoft/intellij-csv-validator?branch=master)](https://bettercodehub.com/results/SeeSharpSoft/intellij-csv-validator/) -[![Donate](https://img.shields.io/badge/Paypal-Donate-yellow)](https://paypal.me/knerzbert) # Lightweight CSV Plugin for JetBrains IDE family @@ -18,6 +17,7 @@ This enables default editor features like syntax validation, highlighting and in - CSV/TSV/PSV file detection - table editor - customizable text editor +- customizable column coloring - syntax validation - syntax highlighting (customizable) - content formatting (customizable) @@ -26,7 +26,6 @@ This enables default editor features like syntax validation, highlighting and in - structure view (header-entry layout) - support for ',', ';', '|' and '↹' as value separator - highlight of active column values -- customizable column coloring - tab (↹) separator highlighting (see [full changelog](./CHANGELOG)) diff --git a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java index 21f097bc..e70c42ba 100644 --- a/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java +++ b/src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/CsvAnnotator.java @@ -109,6 +109,4 @@ protected boolean handleSeparatorElement(@NotNull PsiElement element, @NotNull A } return false; } - - -} \ No newline at end of file +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 7acb27f7..f326d81e 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -45,9 +45,8 @@ -NEW: add separator selection to table editor #140 -FIX: coloring of table cells (e.g. selection mode) -FIX: enter edit mode via keyboard (e.g. ENTER key in cell) +NEW: improved font handling in table editor #122 +FIX: proper font handling in balloon tooltips ]]> From 6447db99af670cf73eb29f1a0ad4484f1a9339ad Mon Sep 17 00:00:00 2001 From: GeeK Date: Fri, 27 Sep 2019 08:14:03 +0200 Subject: [PATCH 8/8] [INTERNAL] rebase --- CHANGELOG | 2 ++ build.gradle | 4 ++-- src/main/resources/META-INF/plugin.xml | 9 ++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index dbd62849..a8ba06da 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,8 @@ NEW: improved font handling in table editor #122 FIX: proper font handling in balloon tooltips +NOTE: IDE versions older than 2017.3.* are no longer supported! + 2.7.1 Sep 26, 2019 diff --git a/build.gradle b/build.gradle index 6d61d0a8..2e319d8a 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ jacocoTestReport { } group 'net.seesharpsoft.intellij.plugins' -version '2.7.1' +version '2.8.0' apply plugin: 'java' sourceCompatibility = javaVersion @@ -71,7 +71,7 @@ idea { apply plugin: 'org.jetbrains.intellij' intellij { // IDE version - https://www.jetbrains.com/intellij-repository/releases - version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-192.6817.14') + version = System.getenv().getOrDefault('IDEA_VERSION', 'IC-191.5701.16') pluginName = 'CSV Plugin' instrumentCode = true updateSinceUntilBuild = false diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index f326d81e..e3dab70d 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -39,7 +39,6 @@

IntelliJ IDEA Ultimate/PhpStorm/DataGrip/etc.: The plugin is fully compatible with the 'Edit as Table...' functionality.

- In IDE releases prior v2017.3, the shortcut in the editor context menu becomes invisible when using this plugin. However, the option can still be accessed via Toolbar -> Edit -> 'Edit as Table...'.
]]>
@@ -47,18 +46,26 @@
 NEW: improved font handling in table editor #122
 FIX: proper font handling in balloon tooltips
+
+NOTE: IDE versions prior to 2017.3.* are no longer supported!
       
]]> + com.intellij.modules.lang + + + + +