Skip to content

Commit

Permalink
Merge pull request #149 from SeeSharpSoft/master
Browse files Browse the repository at this point in the history
Release 2.6.2
  • Loading branch information
SeeSharpSoft committed Aug 9, 2019
2 parents 39f422c + 8fb68c9 commit 7306e99
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
@@ -1,3 +1,9 @@
2.6.2
Aug 09, 2019

FIX: AssertionError: Already disposed: Project (Disposed) #147
FIX: No fallback font used in table editor #145

2.6.1
Aug 01, 2019

Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -4,6 +4,7 @@
[![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

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Expand Up @@ -14,6 +14,7 @@ plugins {
id 'org.jetbrains.intellij' version '0.4.9'
id 'jacoco'
id 'com.github.kt3k.coveralls' version '2.8.2'
id "com.github.ManifestClasspath" version "0.1.0-RELEASE"
}

jacocoTestReport {
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=2.6.1
pluginVersion=2.6.2
javaVersion=1.8
javaTargetVersion=1.8
downloadIntellijSources=false
Expand Up @@ -11,6 +11,7 @@
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;
Expand All @@ -30,6 +31,8 @@
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;
Expand Down Expand Up @@ -108,8 +111,11 @@ public CsvColumnInfoMap<PsiElement> getColumnInfoMap() {
}

public boolean hasErrors() {
if (!isValid()) {
return true;
}
CsvColumnInfoMap columnInfoMap = getColumnInfoMap();
return !isValid() || (columnInfoMap != null && columnInfoMap.hasErrors());
return (columnInfoMap != null && columnInfoMap.hasErrors());
}

protected Object[][] storeStateChange(Object[][] data) {
Expand All @@ -129,7 +135,8 @@ public void saveChanges(final String content) {
return;
}
ApplicationManager.getApplication().invokeLater(() -> {
if (!this.document.isWritable() && ReadonlyStatusHandler.getInstance(this.project).ensureFilesWritable(this.file).hasReadonlyFiles()) {
if (project == null || project.isDisposed() ||
(!this.document.isWritable() && ReadonlyStatusHandler.getInstance(this.project).ensureFilesWritable(this.file).hasReadonlyFiles())) {
return;
}
ApplicationManager.getApplication().runWriteAction(() ->
Expand Down Expand Up @@ -206,6 +213,9 @@ public boolean isModified() {

@Override
public boolean isValid() {
if (file == null || !file.isValid()) {
return false;
}
CsvFile csvFile = this.getCsvFile();
return csvFile != null && csvFile.isValid();
}
Expand Down Expand Up @@ -277,7 +287,7 @@ public int compareTo(@NotNull FileEditorLocation o) {

@Nullable
public StructureViewBuilder getStructureViewBuilder() {
return file != null && file.isValid() ? StructureViewBuilder.PROVIDER.getStructureViewBuilder(file.getFileType(), file, this.project) : null;
return isValid() ? StructureViewBuilder.PROVIDER.getStructureViewBuilder(file.getFileType(), file, this.project) : null;
}

@Nullable
Expand All @@ -292,6 +302,9 @@ public Project getProject() {

@Nullable
public final CsvFile getCsvFile() {
if (project == null || project.isDisposed()) {
return null;
}
if (this.psiFile == null || !this.psiFile.isValid()) {
this.document = FileDocumentManager.getInstance().getDocument(this.file);
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
Expand All @@ -310,7 +323,15 @@ public final int getRowCount() {
}

public Font getFont() {
return EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN);
// 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);
}

protected int getStringWidth(String text) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Expand Up @@ -46,7 +46,8 @@

<change-notes><![CDATA[
<pre style="font-family: sans-serif">
NEW: plugin logo icons added (Thx to FineVisuals for support)
FIX: AssertionError: Already disposed Project #147
FIX: No fallback font used in table editor #145
</pre>
]]>
</change-notes>
Expand Down

0 comments on commit 7306e99

Please sign in to comment.