diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java index f4fb5afc..2a3cac77 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/FileViewer.java @@ -3,11 +3,13 @@ package the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer; import java.awt.BorderLayout; import java.awt.Font; import java.awt.image.BufferedImage; +import java.io.File; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import org.apache.commons.io.FilenameUtils; +import org.fife.ui.rsyntaxtextarea.FileTypeUtil; import org.imgscalr.Scalr; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; @@ -19,7 +21,6 @@ import the.bytecode.club.bytecodeviewer.resources.Resource; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; import the.bytecode.club.bytecodeviewer.resources.ResourceType; import the.bytecode.club.bytecodeviewer.util.MiscUtils; -import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -143,7 +144,7 @@ public class FileViewer extends ResourceViewer } textArea.setCodeFoldingEnabled(true); - textArea.setSyntaxEditingStyle(SyntaxLanguage.detectLanguage(nameLowerCase, contentsAsString).getSyntaxConstant()); + textArea.setSyntaxEditingStyle(FileTypeUtil.get().guessContentType(new File(nameLowerCase))); textArea.setText(contentsAsString); textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue())); textArea.setCaretPosition(0); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java index e4e33472..4bdfe063 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/PluginWriter.java @@ -15,6 +15,7 @@ import javax.swing.JPanel; import me.konloch.kontainer.io.DiskReader; import me.konloch.kontainer.io.DiskWriter; import org.apache.commons.compress.utils.FileNameUtils; +import org.fife.ui.rsyntaxtextarea.FileTypeUtil; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.gui.components.FileChooser; @@ -26,7 +27,6 @@ import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenu; import the.bytecode.club.bytecodeviewer.translation.components.TranslatedJMenuItem; import the.bytecode.club.bytecodeviewer.util.DialogUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils; -import the.bytecode.club.bytecodeviewer.util.SyntaxLanguage; import static the.bytecode.club.bytecodeviewer.Constants.fs; import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory; @@ -88,7 +88,7 @@ public class PluginWriter extends JFrame area.setOnCtrlS(this::save); area.setText(content); area.setCaretPosition(0); - area.setSyntaxEditingStyle(SyntaxLanguage.detectLanguage(pluginName, content).getSyntaxConstant()); + area.setSyntaxEditingStyle(FileTypeUtil.get().guessContentType(new File(pluginName))); content = null; JButton run = new JButton("Run"); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java index bb66f36c..6613bc2d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/resources/ResourceType.java @@ -29,9 +29,10 @@ import javax.swing.ImageIcon; public enum ResourceType { - //TODO tar/gzip? - //TODO add the files icons for the missing files from the.bytecode.club.bytecodeviewer.util.SyntaxLanguage - + // TODO tar/gzip? + // TODO add the files icons for the missing files from the.bytecode.club.bytecodeviewer.util.SyntaxLanguage + // or from org.fife.ui.rsyntaxtextarea.FileTypeUtil or from org.fife.ui.rsyntaxtextarea.SyntaxConstants + CLASS_FILE(IconResources.classIcon, "class"), JAVA_ARCHIVE(IconResources.jarIcon, "jar", "war", "ear"), ZIP_ARCHIVE(IconResources.zipIcon, "zip"), diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java index cab24097..60aab8dc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/SyntaxLanguage.java @@ -23,7 +23,9 @@ import org.fife.ui.rsyntaxtextarea.SyntaxConstants; /** * @author ThexXTURBOXx + * @deprecated See {@link org.fife.ui.rsyntaxtextarea.FileTypeUtil#guessContentType(java.io.File)} */ +@Deprecated public enum SyntaxLanguage { XML(SyntaxConstants.SYNTAX_STYLE_XML, @@ -92,4 +94,4 @@ public enum SyntaxLanguage } return NONE; } -} \ No newline at end of file +}