Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.18.1
Nov 04, 2021

FIX: set require-restart attribute
NEW: Ability to open urls from IntelliJ CSV view #312

2.18.0
Oct 21, 2021

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jacocoTestReport {
}

group 'net.seesharpsoft.intellij.plugins'
version '2.18.0'
version '2.18.1'

apply plugin: 'java'
project.sourceCompatibility = JavaVersion.VERSION_11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ public static String getRelativeFilePath(Project project, VirtualFile virtualFil
if (project == null || virtualFile == null) {
return null;
}
if (virtualFile instanceof VirtualFileWindow) {
virtualFile = ((VirtualFileWindow) virtualFile).getDelegate();
}
String filePath = virtualFile.getUserData(RELATIVE_FILE_URL);
VirtualFile targetFile = virtualFile instanceof VirtualFileWindow ?
((VirtualFileWindow) virtualFile).getDelegate() :
virtualFile;
String filePath = targetFile.getUserData(RELATIVE_FILE_URL);
if (filePath == null && project.getBasePath() != null) {
String localFilePath = PathUtil.getLocalPath(virtualFile);
String localFilePath = PathUtil.getLocalPath(targetFile);
if (localFilePath == null) {
return null;
}
String projectDir = PathUtil.getLocalPath(project.getBasePath());
filePath = localFilePath.replaceFirst("^" + Pattern.quote(projectDir), "");
virtualFile.putUserData(RELATIVE_FILE_URL, filePath);
targetFile.putUserData(RELATIVE_FILE_URL, filePath);
}
return filePath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.ArrayList;
import java.util.Objects;


/**
Expand Down Expand Up @@ -154,7 +155,7 @@ public static JTable addNumberColumn(final JTable userTable, int startingNumber)
// 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.
JViewport viewport = scrollPane.getViewport();

if (viewport == null || viewport.getView() != userTable) {
if (viewport == null || !Objects.equals(viewport.getView(), userTable)) {
return null;
}

Expand Down Expand Up @@ -318,7 +319,7 @@ private TableSynchronizer(JTable rowHeadersTableArg, JTable userTableArg) {
}

public void valueChanged(ListSelectionEvent e) {
if (e.getSource() == userTable.getSelectionModel()) {
if (Objects.equals(e.getSource(), userTable.getSelectionModel())) {
rowHeadersTable.getSelectionModel().removeListSelectionListener(this);
rowHeadersTable.getSelectionModel().clearSelection();

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

rowHeadersTable.getSelectionModel().addListSelectionListener(this);
} else if (e.getSource() == rowHeadersTable.getSelectionModel()) {
} else if (Objects.equals(e.getSource(), rowHeadersTable.getSelectionModel())) {
boolean isColumnSelectionAllowed = userTable.getColumnSelectionAllowed();
boolean isRowSelectionAllowed = userTable.getRowSelectionAllowed();
boolean isCellSelectionAllowed = userTable.getCellSelectionEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.intellij.openapi.fileTypes.LanguageFileType;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
import net.seesharpsoft.intellij.plugins.csv.CsvColumnInfoMap;
import net.seesharpsoft.intellij.plugins.csv.CsvHelper;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -45,4 +47,9 @@ public String toString() {
public Icon getIcon(int flags) {
return super.getIcon(flags);
}

@Override
public PsiReference @NotNull [] getReferences() {
return ReferenceProvidersRegistry.getReferencesFromProviders(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.seesharpsoft.intellij.plugins.csv.psi;

import com.intellij.patterns.PlatformPatterns;
import com.intellij.psi.PsiReferenceContributor;
import com.intellij.psi.PsiReferenceRegistrar;
import com.intellij.psi.impl.source.resolve.reference.ArbitraryPlaceUrlReferenceProvider;
import org.jetbrains.annotations.NotNull;

public class CsvPsiReferenceContributor extends PsiReferenceContributor {
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(PlatformPatterns.psiFile(CsvFile.class), new ArbitraryPlaceUrlReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY);
}
}
8 changes: 5 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<idea-plugin>
<idea-plugin require-restart="true">
<id>net.seesharpsoft.intellij.plugins.csv</id>
<name>CSV</name>
<vendor url="https://github.com/SeeSharpSoft/intellij-csv-validator">
Expand Down Expand Up @@ -50,8 +50,8 @@

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

<lang.commenter implementationClass="net.seesharpsoft.intellij.plugins.csv.CsvCommenter" language="csv" />

<psi.referenceContributor language="csv" implementation="net.seesharpsoft.intellij.plugins.csv.psi.CsvPsiReferenceContributor" />
</extensions>

<actions>
Expand Down