Skip to content

Commit 2b4347f

Browse files
authored
Merge pull request #317 from SeeSharpSoft/master
Release 2.18.1
2 parents 8fc19da + 9b38099 commit 2b4347f

File tree

7 files changed

+43
-13
lines changed

7 files changed

+43
-13
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2.18.1
2+
Nov 04, 2021
3+
4+
FIX: set require-restart attribute
5+
NEW: Ability to open urls from IntelliJ CSV view #312
6+
17
2.18.0
28
Oct 21, 2021
39

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jacocoTestReport {
2727
}
2828

2929
group 'net.seesharpsoft.intellij.plugins'
30-
version '2.18.0'
30+
version '2.18.1'
3131

3232
apply plugin: 'java'
3333
project.sourceCompatibility = JavaVersion.VERSION_11

src/main/java/net/seesharpsoft/intellij/plugins/csv/CsvStorageHelper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ public static String getRelativeFilePath(Project project, VirtualFile virtualFil
1818
if (project == null || virtualFile == null) {
1919
return null;
2020
}
21-
if (virtualFile instanceof VirtualFileWindow) {
22-
virtualFile = ((VirtualFileWindow) virtualFile).getDelegate();
23-
}
24-
String filePath = virtualFile.getUserData(RELATIVE_FILE_URL);
21+
VirtualFile targetFile = virtualFile instanceof VirtualFileWindow ?
22+
((VirtualFileWindow) virtualFile).getDelegate() :
23+
virtualFile;
24+
String filePath = targetFile.getUserData(RELATIVE_FILE_URL);
2525
if (filePath == null && project.getBasePath() != null) {
26-
String localFilePath = PathUtil.getLocalPath(virtualFile);
26+
String localFilePath = PathUtil.getLocalPath(targetFile);
2727
if (localFilePath == null) {
2828
return null;
2929
}
3030
String projectDir = PathUtil.getLocalPath(project.getBasePath());
3131
filePath = localFilePath.replaceFirst("^" + Pattern.quote(projectDir), "");
32-
virtualFile.putUserData(RELATIVE_FILE_URL, filePath);
32+
targetFile.putUserData(RELATIVE_FILE_URL, filePath);
3333
}
3434
return filePath;
3535
}

src/main/java/net/seesharpsoft/intellij/plugins/csv/editor/table/swing/TableRowUtilities.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.awt.event.ComponentAdapter;
4040
import java.awt.event.ComponentEvent;
4141
import java.util.ArrayList;
42+
import java.util.Objects;
4243

4344

4445
/**
@@ -154,7 +155,7 @@ public static JTable addNumberColumn(final JTable userTable, int startingNumber)
154155
// Make certain we are the viewPort's view and not, for example, the rowHeaderView of the scrollPane - an implementor of fixed columns might do this.
155156
JViewport viewport = scrollPane.getViewport();
156157

157-
if (viewport == null || viewport.getView() != userTable) {
158+
if (viewport == null || !Objects.equals(viewport.getView(), userTable)) {
158159
return null;
159160
}
160161

@@ -318,7 +319,7 @@ private TableSynchronizer(JTable rowHeadersTableArg, JTable userTableArg) {
318319
}
319320

320321
public void valueChanged(ListSelectionEvent e) {
321-
if (e.getSource() == userTable.getSelectionModel()) {
322+
if (Objects.equals(e.getSource(), userTable.getSelectionModel())) {
322323
rowHeadersTable.getSelectionModel().removeListSelectionListener(this);
323324
rowHeadersTable.getSelectionModel().clearSelection();
324325

@@ -330,7 +331,7 @@ public void valueChanged(ListSelectionEvent e) {
330331
}
331332

332333
rowHeadersTable.getSelectionModel().addListSelectionListener(this);
333-
} else if (e.getSource() == rowHeadersTable.getSelectionModel()) {
334+
} else if (Objects.equals(e.getSource(), rowHeadersTable.getSelectionModel())) {
334335
boolean isColumnSelectionAllowed = userTable.getColumnSelectionAllowed();
335336
boolean isRowSelectionAllowed = userTable.getRowSelectionAllowed();
336337
boolean isCellSelectionAllowed = userTable.getCellSelectionEnabled();

src/main/java/net/seesharpsoft/intellij/plugins/csv/psi/CsvFile.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.intellij.openapi.fileTypes.LanguageFileType;
66
import com.intellij.psi.FileViewProvider;
77
import com.intellij.psi.PsiElement;
8+
import com.intellij.psi.PsiReference;
9+
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
810
import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfoMap;
911
import net.seesharpsoft.intellij.plugins.csv.CsvHelper;
1012
import org.jetbrains.annotations.NotNull;
@@ -45,4 +47,9 @@ public String toString() {
4547
public Icon getIcon(int flags) {
4648
return super.getIcon(flags);
4749
}
50+
51+
@Override
52+
public PsiReference @NotNull [] getReferences() {
53+
return ReferenceProvidersRegistry.getReferencesFromProviders(this);
54+
}
4855
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package net.seesharpsoft.intellij.plugins.csv.psi;
2+
3+
import com.intellij.patterns.PlatformPatterns;
4+
import com.intellij.psi.PsiReferenceContributor;
5+
import com.intellij.psi.PsiReferenceRegistrar;
6+
import com.intellij.psi.impl.source.resolve.reference.ArbitraryPlaceUrlReferenceProvider;
7+
import org.jetbrains.annotations.NotNull;
8+
9+
public class CsvPsiReferenceContributor extends PsiReferenceContributor {
10+
@Override
11+
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
12+
registrar.registerReferenceProvider(PlatformPatterns.psiFile(CsvFile.class), new ArbitraryPlaceUrlReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY);
13+
}
14+
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<idea-plugin>
1+
<idea-plugin require-restart="true">
22
<id>net.seesharpsoft.intellij.plugins.csv</id>
33
<name>CSV</name>
44
<vendor url="https://github.com/SeeSharpSoft/intellij-csv-validator">
@@ -50,8 +50,8 @@
5050

5151
<change-notes><![CDATA[
5252
<pre style="font-family: sans-serif">
53-
NOTE: Minimum version requirement changed to v2020.1 and newer
54-
FIX: Show diff opens an empty window #306
53+
FIX: set require-restart attribute
54+
NEW: Ability to open urls from IntelliJ CSV view #312
5555
</pre>
5656
]]>
5757
</change-notes>
@@ -161,6 +161,8 @@ FIX: Show diff opens an empty window #306
161161
<postStartupActivity implementation="net.seesharpsoft.intellij.plugins.csv.CsvPlugin" />
162162

163163
<lang.commenter implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvCommenter" language="csv" />
164+
165+
<psi.referenceContributor language="csv" implementation="net.seesharpsoft.intellij.plugins.csv.psi.CsvPsiReferenceContributor" />
164166
</extensions>
165167

166168
<actions>

0 commit comments

Comments
 (0)