diff --git a/changes.txt b/changes.txt index 06c91ae9..2662f104 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,6 @@ 0.2.4 -- Added String field in values panel -- Fixed Can't close any tabs once a binary file is opened (issue #35) +- Added String field in values panel (issue #8) +- Fixed 2021.1: Can't close any tabs once a binary file is opened (issue #35) 0.2.3 (2020-07-30) - Fixed debugger array support for PHP diff --git a/lib/bined-core-0.2.0-SNAPSHOT.jar b/lib/bined-core-0.2.0-SNAPSHOT.jar index 3ead4dc5..5c13b922 100644 Binary files a/lib/bined-core-0.2.0-SNAPSHOT.jar and b/lib/bined-core-0.2.0-SNAPSHOT.jar differ diff --git a/lib/bined-extended-0.2.0-SNAPSHOT.jar b/lib/bined-extended-0.2.0-SNAPSHOT.jar index 9de8a3a1..455f3562 100644 Binary files a/lib/bined-extended-0.2.0-SNAPSHOT.jar and b/lib/bined-extended-0.2.0-SNAPSHOT.jar differ diff --git a/lib/bined-highlight-swing-0.2.0-SNAPSHOT.jar b/lib/bined-highlight-swing-0.2.0-SNAPSHOT.jar index ff3e3603..b8bc267e 100644 Binary files a/lib/bined-highlight-swing-0.2.0-SNAPSHOT.jar and b/lib/bined-highlight-swing-0.2.0-SNAPSHOT.jar differ diff --git a/lib/bined-operation-0.2.0-SNAPSHOT.jar b/lib/bined-operation-0.2.0-SNAPSHOT.jar index b9dfa2f4..ca0091e9 100644 Binary files a/lib/bined-operation-0.2.0-SNAPSHOT.jar and b/lib/bined-operation-0.2.0-SNAPSHOT.jar differ diff --git a/lib/bined-operation-swing-0.2.0-SNAPSHOT.jar b/lib/bined-operation-swing-0.2.0-SNAPSHOT.jar index 6f37df3d..89f6795b 100644 Binary files a/lib/bined-operation-swing-0.2.0-SNAPSHOT.jar and b/lib/bined-operation-swing-0.2.0-SNAPSHOT.jar differ diff --git a/lib/bined-swing-0.2.0-SNAPSHOT.jar b/lib/bined-swing-0.2.0-SNAPSHOT.jar index 3256b782..eea497a4 100644 Binary files a/lib/bined-swing-0.2.0-SNAPSHOT.jar and b/lib/bined-swing-0.2.0-SNAPSHOT.jar differ diff --git a/lib/bined-swing-extended-0.2.0-SNAPSHOT.jar b/lib/bined-swing-extended-0.2.0-SNAPSHOT.jar index 9a9765ef..43aceab9 100644 Binary files a/lib/bined-swing-extended-0.2.0-SNAPSHOT.jar and b/lib/bined-swing-extended-0.2.0-SNAPSHOT.jar differ diff --git a/src/org/exbin/bined/intellij/BinEdFileEditor.java b/src/org/exbin/bined/intellij/BinEdFileEditor.java index fff79562..8d9a2047 100644 --- a/src/org/exbin/bined/intellij/BinEdFileEditor.java +++ b/src/org/exbin/bined/intellij/BinEdFileEditor.java @@ -32,13 +32,12 @@ import javax.swing.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; -import java.util.List; /** * File editor using BinEd editor component. * * @author ExBin Project (http://exbin.org) - * @version 0.2.2 2020/01/17 + * @version 0.2.4 2021/04/10 */ @ParametersAreNonnullByDefault public class BinEdFileEditor implements FileEditor, DumbAware { @@ -205,6 +204,7 @@ public void setDisplayName(String displayName) { this.displayName = displayName; } + @Nonnull public BinEdVirtualFile getVirtualFile() { return virtualFile; } diff --git a/src/org/exbin/bined/intellij/BinEdNativeFileEditor.java b/src/org/exbin/bined/intellij/BinEdNativeFileEditor.java index fcb513c1..6f2b7dda 100644 --- a/src/org/exbin/bined/intellij/BinEdNativeFileEditor.java +++ b/src/org/exbin/bined/intellij/BinEdNativeFileEditor.java @@ -148,6 +148,9 @@ public BinEdNativeFile getNativeFile() { return nativeFile; } + @Override + public VirtualFile getFile() { return nativeFile.getVirtualFile(); } + public Project getProject() { return project; } diff --git a/src/org/exbin/bined/intellij/BinEdVirtualFile.java b/src/org/exbin/bined/intellij/BinEdVirtualFile.java index da5f9bf5..a6073e93 100644 --- a/src/org/exbin/bined/intellij/BinEdVirtualFile.java +++ b/src/org/exbin/bined/intellij/BinEdVirtualFile.java @@ -19,6 +19,7 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileSystem; +import com.intellij.openapi.vfs.VirtualFileWithId; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -32,9 +33,9 @@ * Virtual file for binary editor. * * @author ExBin Project (http://exbin.org) - * @version 0.2.1 2019/08/23 + * @version 0.2.4 2021/04/11 */ -public class BinEdVirtualFile extends VirtualFile { +public class BinEdVirtualFile extends VirtualFile implements VirtualFileWithId { public static final String PATH_PREFIX = "bined://"; @@ -191,4 +192,14 @@ public void setClosed(boolean closed) { public JComponent getPreferredFocusedComponent() { return editorFile.getPreferredFocusedComponent(); } + + /** + * Seems like some versions of IDE taps into this for some reason. + * + * @return invalid ID + */ + @Override + public int getId() { + return 0; + } } \ No newline at end of file diff --git a/src/org/exbin/bined/intellij/OpenAsBinaryAction.java b/src/org/exbin/bined/intellij/OpenAsBinaryAction.java index 09556905..0ef15173 100644 --- a/src/org/exbin/bined/intellij/OpenAsBinaryAction.java +++ b/src/org/exbin/bined/intellij/OpenAsBinaryAction.java @@ -15,15 +15,19 @@ */ package org.exbin.bined.intellij; +import com.intellij.ide.highlighter.ArchiveFileType; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; +import com.intellij.openapi.fileTypes.DirectoryFileType; +import com.intellij.openapi.fileTypes.UnknownFileType; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; +import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; @@ -33,7 +37,7 @@ * Open file in binary editor action. * * @author ExBin Project (http://exbin.org) - * @version 0.2.1 2019/08/22 + * @version 0.2.4 2021/04/10 */ public class OpenAsBinaryAction extends AnAction implements DumbAware { @@ -44,7 +48,8 @@ public OpenAsBinaryAction() { @Override public void update(@NotNull AnActionEvent event) { super.update(event); - event.getPresentation().setEnabledAndVisible(true); + VirtualFile virtualFile = event.getData(PlatformDataKeys.VIRTUAL_FILE); + event.getPresentation().setEnabledAndVisible(virtualFile != null && virtualFile.isValid() && !(virtualFile.getFileType() instanceof DirectoryFileType || virtualFile.getFileType() instanceof UnknownFileType)); } @Override @@ -55,7 +60,17 @@ public void actionPerformed(@NotNull AnActionEvent event) { } VirtualFile virtualFile = event.getData(PlatformDataKeys.VIRTUAL_FILE); - if (virtualFile != null && virtualFile.isValid() && !virtualFile.isDirectory()) { + boolean isValid = virtualFile != null && virtualFile.isValid(); + if (isValid && virtualFile.isDirectory()) { + isValid = false; + if (virtualFile.getFileType() instanceof ArchiveFileType) { + if (virtualFile.getFileSystem() instanceof JarFileSystem) { + virtualFile = ((JarFileSystem) virtualFile.getFileSystem()).getVirtualFileForJar(virtualFile); + isValid = virtualFile != null; + } + } + } + if (isValid) { BinEdVirtualFile binEdVirtualFile = new BinEdVirtualFile(virtualFile); OpenFileDescriptor descriptor = new OpenFileDescriptor(project, binEdVirtualFile, 0); FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);