Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.14.0 #240

Merged
merged 8 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.14.0
Aug 04, 2020

NEW: Predefined column colors (Rainbow-style)
NEW: Enhanced color scheme switch
NEW: Table Editor coloring

2.13.0
Jul 20, 2020

Expand Down
46 changes: 33 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ Please note:

Enable zero-based column numbering. This affects the tooltip info of the text editor as well as column numbering of the table editor.

##### Value coloring

Choose the coloring method of values. Possible options are:

- _Rainbow (Column Color)_ - values are colored based on their column.
- _Simple (Text Color)_ - values are colored based on the defined text color.

All colors can be adjusted via [CSV Color Scheme](#color-scheme) settings.

#### Text Editor

##### Highlighting
Expand All @@ -163,10 +172,6 @@ Enable zero-based column numbering. This affects the tooltip info of the text ed

The highlighting of the current caret row might interfere with custom background color settings and can be enabled/disabled for CSV/TSV/PSV files here.

###### Enable column highlighting

An easy way to switch *Column Highlighting* on or off (in text editor).

###### Highlight tab separator

Enable/disable highlighting (and choose the highlight color) of tab characters (↹) in their role as value separator (TSV). Tabs as part of a value are therefore not highlighted on purpose.
Expand Down Expand Up @@ -205,7 +210,7 @@ The maximum width of a single table column in _px_, which is used when adjusting

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

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

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

Expand All @@ -217,23 +222,22 @@ Enables/disables the info panel at the bottom of the table editor.

Always quotes a single value on save - even if not required.

##### Enable column highlighting

An easy way to switch *Column Highlighting* on or off (in table editor).

### Color Scheme

The different symbols of a CSV document, namely the separator (comma), the quotes, the escaped literals and the text elements itself, are highlighted by a coloring scheme that can be customized:
The different symbols of a CSV document, namely the *separator* (e.g. comma, pipe, semicolon), the *quote* character, the *escaped literals* and the *text* elements itself, are colored based on the CSV color scheme settings:

- _File > Settings > Editor > Color Scheme > CSV_
- _File > Settings > Editor > Color Scheme > CSV/TSV/PSV_

Preset colors are based on Jetbrains IDE defaults and support the different UI themes.

![Color scheme settings](./docs/colorsettings.png)

#### Column Highlighting Colors
#### Column Colors

Besides the colors and font-style variants for the different CSV symbols, additionally up to 10 different column colors can be defined.
Those colors are applied to the columns round robin.
Column colors are taken into account when **Rainbow** is selected as [**Value Coloring**](#value-coloring) option in the [Editor Settings](#editor-settings).

Besides defining colors and font-style variants for the different CSV symbols, additionally up to 10 different column highlight colors can be defined. Those colors are applied to the columns round robin. Undefined column highlight colors will be skipped if they are not followed by any other color definition.

### Formatting

Expand Down Expand Up @@ -401,6 +405,22 @@ You can also download the JAR package from the [Jetbrains plugin repository](htt

- _File > Settings > Plugins > Install plugin from disk..._

## Troubleshooting

#### CSV Plugin causes the IDE to stop working properly

Since version 2.11.0, the plugins requires the IntelliJ platform to be executed on JRE9 or higher. If this is not the case, the following error log can be noticed:

`com.intellij.diagnostic.PluginException: While loading class net.seesharpsoft.intellij.plugins.csv.CsvFileTypeOverrider: net/seesharpsoft/intellij/plugins/csv/CsvFileTypeOverrider has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 [Plugin: net.seesharpsoft.intellij.plugins.csv]`

In some cases the error log doesn't seem to point this out in a noticable manner, but the IDE doesn't work correctly after enabling the plugin. Always disable the plugin first before continuing with the following steps.

Please read the [official instructions](https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under) on how to switch to a newer JRE, or [manually install](https://github.com/SeeSharpSoft/intellij-csv-validator#installation) a [prior CSV plugin version](https://github.com/SeeSharpSoft/intellij-csv-validator/releases/tag/2.10.0).

#### Features of the CSV Plugin are not available

If another plugin for CSV files like [Rainbow CSV](https://plugins.jetbrains.com/plugin/12896-rainbow-csv) is enabled, this plugin might not be taken into account for parsing and presenting CSV file content.

## Contribution

Contributions are welcome. Please check [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jacocoTestReport {
}

group 'net.seesharpsoft.intellij.plugins'
version '2.13.0'
version '2.14.0'

apply plugin: 'java'
sourceCompatibility = javaVersion
Expand Down
Binary file modified docs/colorsettings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.seesharpsoft.intellij.plugins.csv;

import com.intellij.ide.scratch.ScratchFileType;
import com.intellij.ide.scratch.ScratchUtil;
import com.intellij.lang.*;
import com.intellij.lexer.Lexer;
Expand Down
85 changes: 85 additions & 0 deletions src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package net.seesharpsoft.intellij.plugins.csv;

import com.intellij.ide.actions.ShowSettingsUtilImpl;
import com.intellij.ide.plugins.IdeaPluginDescriptorImpl;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.notification.*;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings;
import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettingsProvider;
import org.jetbrains.annotations.NotNull;

import javax.swing.event.HyperlinkEvent;
import java.awt.*;
import java.io.IOException;
import java.net.URI;

public class CsvPlugin implements StartupActivity {

protected static IdeaPluginDescriptorImpl getPluginDescriptor() {
return (IdeaPluginDescriptorImpl)PluginManager.getPlugin(PluginId.getId("net.seesharpsoft.intellij.plugins.csv"));
}

protected static String getVersion() {
return getPluginDescriptor().getVersion();
}

protected static String getChangeNotes() {
return getPluginDescriptor().getChangeNotes();
}

private static void openLink(Project project, String link) {
if (!project.isDisposed() && link.startsWith("#")) {
((ShowSettingsUtilImpl)ShowSettingsUtil.getInstance()).showSettingsDialog(project, link.substring(1), null);
}
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(URI.create(link));
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

@Override
public void runActivity(@NotNull Project project) {
if (CsvEditorSettings.getInstance().checkCurrentPluginVersion(getVersion())) {
return;
}

NotificationGroup notificationGroup = new NotificationGroup(
"CsvPlugin", NotificationDisplayType.STICKY_BALLOON, true
);

NotificationListener.Adapter notificationListener = new NotificationListener.Adapter() {
@Override
protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
openLink(project, e.getDescription());
}
};

Notification notification = notificationGroup.createNotification(
"CSV Plugin " + getVersion() + " - Change Notes",
getChangeNotes() +
"<p><b>Customize plugin settings:</b> " +
"<a href=\"#" + CsvEditorSettingsProvider.CSV_EDITOR_SETTINGS_ID + "\">Editor/General</a>, " +
"<a href=\"#reference.settingsdialog.IDE.editor.colors.CSV/TSV/PSV\">Color Scheme</a>, " +
"<a href=\"#preferences.sourceCode.CSV/TSV/PSV\">Formatting</a></p>" +
"<br>" +
"<p>Visit the <a href=\"https://github.com/SeeSharpSoft/intellij-csv-validator\">CSV Plugin GitHub</a> to read more about the available features & settings, " +
"submit <a href=\"https://github.com/SeeSharpSoft/intellij-csv-validator/issues\">issues & feature request</a>, " +
"or show your support by <a href=\"https://plugins.jetbrains.com/plugin/10037-csv-plugin\">rating this plugin</a>. <b>Thanks!</b></p>"
,
NotificationType.INFORMATION,
notificationListener
);

Notifications.Bus.notify(notification);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void annotate(@NotNull final PsiElement element, @NotNull final Annotatio

Annotation annotation = holder.createAnnotation(CSV_COLUMN_INFO_SEVERITY, textRange, message, tooltip);
annotation.setEnforcedTextAttributes(
CsvEditorSettings.getInstance().isColumnHighlightingEnabled() ?
CsvEditorSettings.getInstance().getValueColoring() == CsvEditorSettings.ValueColoring.RAINBOW ?
CsvColorSettings.getTextAttributesOfColumn(columnInfo.getColumnIndex(), holder.getCurrentAnnotationSession()) :
null
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.seesharpsoft.intellij.plugins.csv.editor.table.swing;

import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
Expand Down Expand Up @@ -94,6 +95,8 @@ protected void createUIComponents() {
}

private void initializedUIComponents() {
EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();

btnRedo.addActionListener(tableEditorActions.redo);
btnUndo.addActionListener(tableEditorActions.undo);
btnAddRow.addActionListener(tableEditorActions.addRow);
Expand Down Expand Up @@ -129,6 +132,8 @@ private void initializedUIComponents() {
tblEditor.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
tblEditor.setShowColumns(true);
tblEditor.setFont(getFont());
tblEditor.setBackground(editorColorsScheme.getDefaultBackground());
tblEditor.setForeground(editorColorsScheme.getDefaultForeground());
setTableRowHeight(0);

tblEditor.getColumnModel().addColumnModelListener(tableEditorListener);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package net.seesharpsoft.intellij.plugins.csv.editor.table.swing;

import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
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.ui.components.JBScrollPane;
import com.intellij.util.ui.UIUtil;
import net.seesharpsoft.intellij.plugins.csv.settings.CsvEditorSettings;
import net.seesharpsoft.intellij.plugins.csv.settings.CsvColorSettings;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -46,10 +46,7 @@ public MultiLineCellRenderer(CsvTableEditorKeyListener keyListener, UserDataHold
}

private TextAttributes getColumnTextAttributes(int column) {
if (CsvEditorSettings.getInstance().isTableColumnHighlightingEnabled()) {
return CsvColorSettings.getTextAttributesOfColumn(column, myUserDataHolder);
}
return null;
return CsvColorSettings.getTextAttributesOfColumn(column, myUserDataHolder);
}

private Color getColumnForegroundColor(int column, Color fallback) {
Expand All @@ -64,6 +61,8 @@ private Color getColumnBackgroundColor(int column, Color fallback) {

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();

if (isSelected) {
myTextArea.setForeground(table.getSelectionForeground());
myTextArea.setBackground(table.getSelectionBackground());
Expand All @@ -74,8 +73,8 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
if (hasFocus) {
myTextArea.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
if (table.isCellEditable(row, column)) {
myTextArea.setForeground(UIManager.getColor("Table.focusCellForeground"));
myTextArea.setBackground(UIManager.getColor("Table.focusCellBackground"));
myTextArea.setForeground(UIManager.getColor(editorColorsScheme.getDefaultForeground()));
myTextArea.setBackground(UIManager.getColor(editorColorsScheme.getDefaultBackground()));
}
} else {
myTextArea.setBorder(new EmptyBorder(1, 2, 1, 2));
Expand Down
Loading