diff --git a/README.md b/README.md index 6255306e..0f04fa88 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ JD-GUI, a standalone graphical utility that displays Java sources from CLASS files. -![](http://java-decompiler.github.io/img/screenshot17.png) +![](https://raw.githubusercontent.com/java-decompiler/jd-gui/master/src/website/img/jd-gui.png) - Java Decompiler projects home page: [http://java-decompiler.github.io](http://java-decompiler.github.io) - JD-GUI source code: [https://github.com/java-decompiler/jd-gui](https://github.com/java-decompiler/jd-gui) diff --git a/app/src/main/java/org/jd/gui/controller/SearchInConstantPoolsController.java b/app/src/main/java/org/jd/gui/controller/SearchInConstantPoolsController.java index d0f9701c..d87182ba 100644 --- a/app/src/main/java/org/jd/gui/controller/SearchInConstantPoolsController.java +++ b/app/src/main/java/org/jd/gui/controller/SearchInConstantPoolsController.java @@ -291,15 +291,17 @@ protected void match(Indexes indexes, String indexName, String pattern, if (matchedEntries == null) { Map index = indexes.getIndex(indexName); - if (patternLength == 1) { - matchedEntries = matchWithCharFunction.apply(pattern.charAt(0), index); - } else { - String lastKey = key.substring(0, key.length() - 1); - Map lastMatchedTypes = cache.get(lastKey); - if (lastMatchedTypes != null) { - matchedEntries = matchWithStringFunction.apply(pattern, lastMatchedTypes); + if (index != null) { + if (patternLength == 1) { + matchedEntries = matchWithCharFunction.apply(pattern.charAt(0), index); } else { - matchedEntries = matchWithStringFunction.apply(pattern, index); + String lastKey = key.substring(0, key.length() - 1); + Map lastMatchedTypes = cache.get(lastKey); + if (lastMatchedTypes != null) { + matchedEntries = matchWithStringFunction.apply(pattern, lastMatchedTypes); + } else { + matchedEntries = matchWithStringFunction.apply(pattern, index); + } } } diff --git a/app/src/main/java/org/jd/gui/service/configuration/ConfigurationXmlPersisterProvider.java b/app/src/main/java/org/jd/gui/service/configuration/ConfigurationXmlPersisterProvider.java index c9b52b1c..83d93d3c 100644 --- a/app/src/main/java/org/jd/gui/service/configuration/ConfigurationXmlPersisterProvider.java +++ b/app/src/main/java/org/jd/gui/service/configuration/ConfigurationXmlPersisterProvider.java @@ -15,16 +15,15 @@ import javax.swing.*; import javax.xml.stream.*; import java.awt.*; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.util.ArrayList; +import java.io.*; +import java.net.URL; +import java.util.*; import java.util.List; -import java.util.Map; -import java.util.Stack; +import java.util.jar.Manifest; public class ConfigurationXmlPersisterProvider implements ConfigurationPersister { protected static final String ERROR_BACKGROUND_COLOR = "JdGuiPreferences.errorBackgroundColor"; + protected static final String JD_CORE_VERSION = "JdGuiPreferences.jdCoreVersion"; protected static final File FILE = getConfigFile(); @@ -57,6 +56,7 @@ protected static File getConfigFile() { return new File(Constants.CONFIG_FILENAME); } + @Override public Configuration load() { // Default values Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); @@ -170,9 +170,31 @@ public Configuration load() { config.getPreferences().put(ERROR_BACKGROUND_COLOR, "0xFF6666"); } + config.getPreferences().put(JD_CORE_VERSION, getJdCoreVersion()); + return config; } + protected String getJdCoreVersion() { + try { + Enumeration enumeration = ConfigurationXmlPersisterProvider.class.getClassLoader().getResources("META-INF/MANIFEST.MF"); + + while (enumeration.hasMoreElements()) { + try (InputStream is = enumeration.nextElement().openStream()) { + String attribute = new Manifest(is).getMainAttributes().getValue("JD-Core-Version"); + if (attribute != null) { + return attribute; + } + } + } + } catch (IOException e) { + assert ExceptionUtil.printStackTrace(e); + } + + return "SNAPSHOT"; + } + + @Override public void save(Configuration configuration) { Point l = configuration.getMainWindowLocation(); Dimension s = configuration.getMainWindowSize(); diff --git a/app/src/main/java/org/jd/gui/view/AboutView.java b/app/src/main/java/org/jd/gui/view/AboutView.java index 9c5c70dd..f7cfa84a 100644 --- a/app/src/main/java/org/jd/gui/view/AboutView.java +++ b/app/src/main/java/org/jd/gui/view/AboutView.java @@ -97,7 +97,7 @@ public AboutView(JFrame mainFrame) { hbox.add(Box.createHorizontalGlue()); hbox = Box.createHorizontalBox(); - hbox.add(new JLabel("Copyright © 2008-2019 Emmanuel Dupuy")); + hbox.add(new JLabel("Copyright © 2008, 2019 Emmanuel Dupuy")); hbox.add(Box.createHorizontalGlue()); subvbox.add(hbox); diff --git a/app/src/main/java/org/jd/gui/view/SearchInConstantPoolsView.java b/app/src/main/java/org/jd/gui/view/SearchInConstantPoolsView.java index d6f4de82..ab9258a2 100644 --- a/app/src/main/java/org/jd/gui/view/SearchInConstantPoolsView.java +++ b/app/src/main/java/org/jd/gui/view/SearchInConstantPoolsView.java @@ -250,7 +250,6 @@ public SearchInConstantPoolsView( if (selectedTreeNode != null) { selectedTypeCallback.accept(selectedTreeNode.getUri(), searchInConstantPoolsEnterTextField.getText(), getFlags()); } - searchInConstantPoolsDialog.setVisible(false); } }; searchInConstantPoolsOpenButton.addActionListener(searchInConstantPoolsOpenActionListener); diff --git a/build.gradle b/build.gradle index f3aed2bb..d046b8ce 100644 --- a/build.gradle +++ b/build.gradle @@ -15,8 +15,8 @@ apply plugin: 'edu.sc.seis.launch4j' apply plugin: 'nebula.ospackage' // Common configuration // -rootProject.version='1.5.2' -rootProject.ext.set('jdCoreVersion', '1.0.3') +rootProject.version='1.6.3' +rootProject.ext.set('jdCoreVersion', '1.0.7') targetCompatibility = '1.8' allprojects { @@ -31,10 +31,7 @@ allprojects { } repositories { - mavenCentral() - maven { - url 'https://raw.github.com/java-decompiler/mvn-repo/master' - } + jcenter() } configurations { diff --git a/services/src/main/java/org/jd/gui/service/indexer/JavaModuleFileIndexerProvider.java b/services/src/main/java/org/jd/gui/service/indexer/JavaModuleFileIndexerProvider.java index 41084238..e419b34b 100644 --- a/services/src/main/java/org/jd/gui/service/indexer/JavaModuleFileIndexerProvider.java +++ b/services/src/main/java/org/jd/gui/service/indexer/JavaModuleFileIndexerProvider.java @@ -32,6 +32,7 @@ public void index(API api, Container.Entry entry, Indexes indexes) { } } + @SuppressWarnings("unchecked") protected static void index(API api, Container.Entry entry, Indexes indexes, Map packageDeclarationIndex) { for (Container.Entry e : entry.getChildren()) { if (e.isDirectory()) { diff --git a/services/src/main/java/org/jd/gui/service/sourcesaver/ClassFileSourceSaverProvider.java b/services/src/main/java/org/jd/gui/service/sourcesaver/ClassFileSourceSaverProvider.java index 0f681e46..bd39cd73 100644 --- a/services/src/main/java/org/jd/gui/service/sourcesaver/ClassFileSourceSaverProvider.java +++ b/services/src/main/java/org/jd/gui/service/sourcesaver/ClassFileSourceSaverProvider.java @@ -16,43 +16,23 @@ import org.jd.gui.util.io.NewlineOutputStream; import java.io.*; -import java.net.URL; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Enumeration; import java.util.HashMap; import java.util.Map; -import java.util.jar.Manifest; public class ClassFileSourceSaverProvider extends AbstractSourceSaverProvider { protected static final String ESCAPE_UNICODE_CHARACTERS = "ClassFileDecompilerPreferences.escapeUnicodeCharacters"; - protected static final String REALIGN_LINE_NUMBERS = "ClassFileDecompilerPreferences.realignLineNumbers"; - protected static final String WRITE_LINE_NUMBERS = "ClassFileSaverPreferences.writeLineNumbers"; - protected static final String WRITE_METADATA = "ClassFileSaverPreferences.writeMetadata"; + protected static final String REALIGN_LINE_NUMBERS = "ClassFileDecompilerPreferences.realignLineNumbers"; + protected static final String WRITE_LINE_NUMBERS = "ClassFileSaverPreferences.writeLineNumbers"; + protected static final String WRITE_METADATA = "ClassFileSaverPreferences.writeMetadata"; + protected static final String JD_CORE_VERSION = "JdGuiPreferences.jdCoreVersion"; protected static final ClassFileToJavaSourceDecompiler DECOMPILER = new ClassFileToJavaSourceDecompiler(); protected ContainerLoader loader = new ContainerLoader(); protected LineNumberStringBuilderPrinter printer = new LineNumberStringBuilderPrinter(); - protected String jdCoreVersion = "SNAPSHOT"; - - public ClassFileSourceSaverProvider() { - try { - Enumeration enumeration = ClassFileSourceSaverProvider.class.getClassLoader().getResources("META-INF/MANIFEST.MF"); - - while (enumeration.hasMoreElements()) { - try (InputStream is = enumeration.nextElement().openStream()) { - String attribute = new Manifest(is).getMainAttributes().getValue("JD-Core-Version"); - if (attribute != null) { - jdCoreVersion = attribute; - } - } - } - } catch (IOException e) { - assert ExceptionUtil.printStackTrace(e); - } - } @Override public String[] getSelectors() { return appendSelectors("*:file:*.class"); } @@ -144,7 +124,7 @@ public void saveContent(API api, Controller controller, Listener listener, Path } // Add JD-Core version stringBuffer.append("\n * JD-Core Version: "); - stringBuffer.append(jdCoreVersion); + stringBuffer.append(preferences.get(JD_CORE_VERSION)); stringBuffer.append("\n */"); } diff --git a/services/src/main/java/org/jd/gui/util/decompiler/LineNumberStringBuilderPrinter.java b/services/src/main/java/org/jd/gui/util/decompiler/LineNumberStringBuilderPrinter.java index 0b195e12..018384ae 100644 --- a/services/src/main/java/org/jd/gui/util/decompiler/LineNumberStringBuilderPrinter.java +++ b/services/src/main/java/org/jd/gui/util/decompiler/LineNumberStringBuilderPrinter.java @@ -8,99 +8,99 @@ package org.jd.gui.util.decompiler; public class LineNumberStringBuilderPrinter extends StringBuilderPrinter { - protected boolean showLineNumbers = false; - - protected int maxLineNumber = 0; - protected int digitCount = 0; - - protected String lineNumberBeginPrefix; - protected String lineNumberEndPrefix; - protected String unknownLineNumberPrefix; - - public void setShowLineNumbers(boolean showLineNumbers) { this.showLineNumbers = showLineNumbers; } - - protected int printDigit(int dcv, int lineNumber, int divisor, int left) { - if (digitCount >= dcv) { - if (lineNumber < divisor) { - append(' '); - } else { - int e = (lineNumber-left) / divisor; - append((char)('0' + e)); - left += e*divisor; - } - } - - return left; - } - - // --- Printer --- // - @Override - public void start(int maxLineNumber, int majorVersion, int minorVersion) { - super.start(maxLineNumber, majorVersion, minorVersion); - - if (showLineNumbers) { - this.maxLineNumber = maxLineNumber; - - if (maxLineNumber > 0) { - digitCount = 1; - unknownLineNumberPrefix = " "; - int maximum = 9; - - while (maximum < maxLineNumber) { - digitCount++; - unknownLineNumberPrefix += ' '; - maximum = maximum*10 + 9; - } - - lineNumberBeginPrefix = "/* "; - lineNumberEndPrefix = " */ "; - } else { - unknownLineNumberPrefix = ""; - lineNumberBeginPrefix = ""; - lineNumberEndPrefix = ""; - } - } else { - this.maxLineNumber = 0; - unknownLineNumberPrefix = ""; - lineNumberBeginPrefix = ""; - lineNumberEndPrefix = ""; - } - } - - @Override public void startLine(int lineNumber) { - if (maxLineNumber > 0) { - append(lineNumberBeginPrefix); - - if (lineNumber == UNKNOWN_LINE_NUMBER) { - append(unknownLineNumberPrefix); - } else { - int left = 0; - - left = printDigit(5, lineNumber, 10000, left); - left = printDigit(4, lineNumber, 1000, left); - left = printDigit(3, lineNumber, 100, left); - left = printDigit(2, lineNumber, 10, left); - append((char)('0' + (lineNumber-left))); - } - - append(lineNumberEndPrefix); - } - - for (int i=0; i 0) { - if (maxLineNumber > 0) { - append(lineNumberBeginPrefix); - append(unknownLineNumberPrefix); - append(lineNumberEndPrefix); - } - - append(NEWLINE); - } - } - } + protected boolean showLineNumbers = false; + + protected int maxLineNumber = 0; + protected int digitCount = 0; + + protected String lineNumberBeginPrefix; + protected String lineNumberEndPrefix; + protected String unknownLineNumberPrefix; + + public void setShowLineNumbers(boolean showLineNumbers) { this.showLineNumbers = showLineNumbers; } + + protected int printDigit(int dcv, int lineNumber, int divisor, int left) { + if (digitCount >= dcv) { + if (lineNumber < divisor) { + stringBuffer.append(' '); + } else { + int e = (lineNumber-left) / divisor; + stringBuffer.append((char)('0' + e)); + left += e*divisor; + } + } + + return left; + } + + // --- Printer --- // + @Override + public void start(int maxLineNumber, int majorVersion, int minorVersion) { + super.start(maxLineNumber, majorVersion, minorVersion); + + if (showLineNumbers) { + this.maxLineNumber = maxLineNumber; + + if (maxLineNumber > 0) { + digitCount = 1; + unknownLineNumberPrefix = " "; + int maximum = 9; + + while (maximum < maxLineNumber) { + digitCount++; + unknownLineNumberPrefix += ' '; + maximum = maximum*10 + 9; + } + + lineNumberBeginPrefix = "/* "; + lineNumberEndPrefix = " */ "; + } else { + unknownLineNumberPrefix = ""; + lineNumberBeginPrefix = ""; + lineNumberEndPrefix = ""; + } + } else { + this.maxLineNumber = 0; + unknownLineNumberPrefix = ""; + lineNumberBeginPrefix = ""; + lineNumberEndPrefix = ""; + } + } + + @Override public void startLine(int lineNumber) { + if (maxLineNumber > 0) { + stringBuffer.append(lineNumberBeginPrefix); + + if (lineNumber == UNKNOWN_LINE_NUMBER) { + stringBuffer.append(unknownLineNumberPrefix); + } else { + int left = 0; + + left = printDigit(5, lineNumber, 10000, left); + left = printDigit(4, lineNumber, 1000, left); + left = printDigit(3, lineNumber, 100, left); + left = printDigit(2, lineNumber, 10, left); + stringBuffer.append((char)('0' + (lineNumber-left))); + } + + stringBuffer.append(lineNumberEndPrefix); + } + + for (int i=0; i 0) { + if (maxLineNumber > 0) { + stringBuffer.append(lineNumberBeginPrefix); + stringBuffer.append(unknownLineNumberPrefix); + stringBuffer.append(lineNumberEndPrefix); + } + + stringBuffer.append(NEWLINE); + } + } + } } diff --git a/services/src/main/java/org/jd/gui/util/decompiler/StringBuilderPrinter.java b/services/src/main/java/org/jd/gui/util/decompiler/StringBuilderPrinter.java index 4d98095e..345a615f 100644 --- a/services/src/main/java/org/jd/gui/util/decompiler/StringBuilderPrinter.java +++ b/services/src/main/java/org/jd/gui/util/decompiler/StringBuilderPrinter.java @@ -29,10 +29,7 @@ public class StringBuilderPrinter implements Printer { public int getMinorVersion() { return minorVersion; } public StringBuilder getStringBuffer() { return stringBuffer; } - public void append(char c) { stringBuffer.append(c); } - public void append(String s) { stringBuffer.append(s); } - - protected void printEscape(String s) { + protected void escape(String s) { if (unicodeEscape && (s != null)) { int length = s.length(); @@ -40,30 +37,30 @@ protected void printEscape(String s) { char c = s.charAt(i); if (c == '\t') { - append(c); + stringBuffer.append(c); } else if (c < 32) { // Write octal format - append("\\0"); - append((char) ('0' + (c >> 3))); - append((char) ('0' + (c & 0x7))); + stringBuffer.append("\\0"); + stringBuffer.append((char) ('0' + (c >> 3))); + stringBuffer.append((char) ('0' + (c & 0x7))); } else if (c > 127) { // Write octal format - append("\\u"); + stringBuffer.append("\\u"); int z = (c >> 12); - append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); + stringBuffer.append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); z = ((c >> 8) & 0xF); - append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); + stringBuffer.append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); z = ((c >> 4) & 0xF); - append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); + stringBuffer.append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); z = (c & 0xF); - append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); + stringBuffer.append((char) ((z <= 9) ? ('0' + z) : (('A' - 10) + z))); } else { - append(c); + stringBuffer.append(c); } } } else { - append(s); + stringBuffer.append(s); } } @@ -78,20 +75,20 @@ public void start(int maxLineNumber, int majorVersion, int minorVersion) { @Override public void end() {} - @Override public void printText(String text) { printEscape(text); } - @Override public void printNumericConstant(String constant) { append(constant); } - @Override public void printStringConstant(String constant, String ownerInternalName) { append(constant); } - @Override public void printKeyword(String keyword) { append(keyword); } + @Override public void printText(String text) { escape(text); } + @Override public void printNumericConstant(String constant) { escape(constant); } + @Override public void printStringConstant(String constant, String ownerInternalName) { escape(constant); } + @Override public void printKeyword(String keyword) { stringBuffer.append(keyword); } - @Override public void printDeclaration(int type, String internalTypeName, String name, String descriptor) { append(name); } - @Override public void printReference(int type, String internalTypeName, String name, String descriptor, String ownerInternalName) { append(name); } + @Override public void printDeclaration(int type, String internalTypeName, String name, String descriptor) { escape(name); } + @Override public void printReference(int type, String internalTypeName, String name, String descriptor, String ownerInternalName) { escape(name); } @Override public void indent() { indentationCount++; } @Override public void unindent() { if (indentationCount > 0) indentationCount--; } - @Override public void startLine(int lineNumber) { for (int i=0; i 0) append(NEWLINE); } + @Override public void startLine(int lineNumber) { for (int i=0; i 0) stringBuffer.append(NEWLINE); } @Override public void startMarker(int type) {} @Override public void endMarker(int type) {} diff --git a/services/src/main/java/org/jd/gui/view/component/ClassFilePage.java b/services/src/main/java/org/jd/gui/view/component/ClassFilePage.java index a3a5a0a0..bdd93be1 100644 --- a/services/src/main/java/org/jd/gui/view/component/ClassFilePage.java +++ b/services/src/main/java/org/jd/gui/view/component/ClassFilePage.java @@ -12,21 +12,24 @@ import org.jd.core.v1.ClassFileToJavaSourceDecompiler; import org.jd.gui.api.API; import org.jd.gui.api.model.Container; -import org.jd.gui.util.decompiler.ClassPathLoader; -import org.jd.gui.util.decompiler.ContainerLoader; -import org.jd.gui.util.decompiler.NopPrinter; -import org.jd.gui.util.decompiler.StringBuilderPrinter; +import org.jd.gui.util.decompiler.*; import org.jd.gui.util.exception.ExceptionUtil; +import org.jd.gui.util.io.NewlineOutputStream; import javax.swing.text.BadLocationException; import javax.swing.text.DefaultCaret; import java.awt.*; +import java.io.*; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.Map; public class ClassFilePage extends TypePage { protected static final String ESCAPE_UNICODE_CHARACTERS = "ClassFileDecompilerPreferences.escapeUnicodeCharacters"; protected static final String REALIGN_LINE_NUMBERS = "ClassFileDecompilerPreferences.realignLineNumbers"; + protected static final String WRITE_LINE_NUMBERS = "ClassFileSaverPreferences.writeLineNumbers"; + protected static final String WRITE_METADATA = "ClassFileSaverPreferences.writeMetadata"; + protected static final String JD_CORE_VERSION = "JdGuiPreferences.jdCoreVersion"; protected static final ClassFileToJavaSourceDecompiler DECOMPILER = new ClassFileToJavaSourceDecompiler(); @@ -97,18 +100,102 @@ protected static boolean getPreferenceValue(Map preferences, Str return (v == null) ? defaultValue : Boolean.valueOf(v); } + @Override public String getSyntaxStyle() { return SyntaxConstants.SYNTAX_STYLE_JAVA; } // --- ContentSavable --- // + @Override public String getFileName() { String path = entry.getPath(); int index = path.lastIndexOf('.'); return path.substring(0, index) + ".java"; } + @Override + public void save(API api, OutputStream os) { + try { + // Init preferences + Map preferences = api.getPreferences(); + boolean realignmentLineNumbers = getPreferenceValue(preferences, REALIGN_LINE_NUMBERS, true); + boolean unicodeEscape = getPreferenceValue(preferences, ESCAPE_UNICODE_CHARACTERS, false); + boolean showLineNumbers = getPreferenceValue(preferences, WRITE_LINE_NUMBERS, true); + + Map configuration = new HashMap<>(); + configuration.put("realignLineNumbers", realignmentLineNumbers); + + // Init loader + ContainerLoader loader = new ContainerLoader(entry); + + // Init printer + LineNumberStringBuilderPrinter printer = new LineNumberStringBuilderPrinter(); + printer.setRealignmentLineNumber(realignmentLineNumbers); + printer.setUnicodeEscape(unicodeEscape); + printer.setShowLineNumbers(showLineNumbers); + + // Format internal name + String entryPath = entry.getPath(); + assert entryPath.endsWith(".class"); + String entryInternalName = entryPath.substring(0, entryPath.length() - 6); // 6 = ".class".length() + + // Decompile class file + DECOMPILER.decompile(loader, printer, entryInternalName, configuration); + + StringBuilder stringBuffer = printer.getStringBuffer(); + + // Metadata + if (getPreferenceValue(preferences, WRITE_METADATA, true)) { + // Add location + String location = + new File(entry.getUri()).getPath() + // Escape "\ u" sequence to prevent "Invalid unicode" errors + .replaceAll("(^|[^\\\\])\\\\u", "\\\\\\\\u"); + stringBuffer.append("\n\n/* Location: "); + stringBuffer.append(location); + // Add Java compiler version + int majorVersion = printer.getMajorVersion(); + + if (majorVersion >= 45) { + stringBuffer.append("\n * Java compiler version: "); + + if (majorVersion >= 49) { + stringBuffer.append(majorVersion - (49 - 5)); + } else { + stringBuffer.append(majorVersion - (45 - 1)); + } + + stringBuffer.append(" ("); + stringBuffer.append(majorVersion); + stringBuffer.append('.'); + stringBuffer.append(printer.getMinorVersion()); + stringBuffer.append(')'); + } + // Add JD-Core version + stringBuffer.append("\n * JD-Core Version: "); + stringBuffer.append(preferences.get(JD_CORE_VERSION)); + stringBuffer.append("\n */"); + } + + try (PrintStream ps = new PrintStream(new NewlineOutputStream(os), true, "UTF-8")) { + ps.print(stringBuffer.toString()); + } catch (IOException e) { + assert ExceptionUtil.printStackTrace(e); + } + } catch (Throwable t) { + assert ExceptionUtil.printStackTrace(t); + + try (OutputStreamWriter writer = new OutputStreamWriter(os, Charset.defaultCharset())) { + writer.write("// INTERNAL ERROR //"); + } catch (IOException ee) { + assert ExceptionUtil.printStackTrace(ee); + } + } + } + // --- LineNumberNavigable --- // + @Override public int getMaximumLineNumber() { return maximumLineNumber; } + @Override public void goToLineNumber(int lineNumber) { int textAreaLineNumber = getTextAreaLineNumber(lineNumber); if (textAreaLineNumber > 0) { @@ -122,9 +209,11 @@ public void goToLineNumber(int lineNumber) { } } + @Override public boolean checkLineNumber(int lineNumber) { return lineNumber <= maximumLineNumber; } // --- PreferencesChangeListener --- // + @Override public void preferencesChanged(Map preferences) { DefaultCaret caret = (DefaultCaret)textArea.getCaret(); int updatePolicy = caret.getUpdatePolicy(); @@ -220,6 +309,7 @@ public void endLine() { super.endLine(); textAreaLineNumber++; } + @Override public void extraLine(int count) { super.extraLine(count); if (realignmentLineNumber) { diff --git a/services/src/main/java/org/jd/gui/view/component/TextPage.java b/services/src/main/java/org/jd/gui/view/component/TextPage.java index 87a8aff6..09e0ac74 100644 --- a/services/src/main/java/org/jd/gui/view/component/TextPage.java +++ b/services/src/main/java/org/jd/gui/view/component/TextPage.java @@ -22,6 +22,7 @@ public class TextPage extends AbstractTextPage implements ContentCopyable, ContentSelectable, ContentSavable { // --- ContentCopyable --- // + @Override public void copy() { if (textArea.getSelectionStart() == textArea.getSelectionEnd()) { getToolkit().getSystemClipboard().setContents(new StringSelection(""), null); @@ -31,13 +32,16 @@ public void copy() { } // --- ContentSelectable --- // + @Override public void selectAll() { textArea.selectAll(); } // --- ContentSavable --- // + @Override public String getFileName() { return "file.txt"; } + @Override public void save(API api, OutputStream os) { try (OutputStreamWriter writer = new OutputStreamWriter(new NewlineOutputStream(os), "UTF-8")) { writer.write(textArea.getText()); diff --git a/src/osx/resources/Info.plist b/src/osx/resources/Info.plist index 1f419f91..264b3fd3 100644 --- a/src/osx/resources/Info.plist +++ b/src/osx/resources/Info.plist @@ -5,16 +5,16 @@ CFBundleDevelopmentRegion English CFBundleExecutable universalJavaApplicationStub.sh CFBundleName JD-GUI - CFBundleGetInfoString JD-GUI version ${VERSION}, Copyright 2008-2019 Emmanuel Dupuy + CFBundleGetInfoString JD-GUI version ${VERSION}, Copyright 2008, 2019 Emmanuel Dupuy CFBundleIconFile jd-gui.icns CFBundleIdentifier jd.jd-gui CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType APPL - CFBundleLongVersionString ${VERSION}, Copyright 2008-2019 Emmanuel Dupuy + CFBundleLongVersionString ${VERSION}, Copyright 2008, 2019 Emmanuel Dupuy CFBundleShortVersionString ${VERSION} CSResourcesFileMapped LSRequiresCarbon - NSHumanReadableCopyright Copyright 2008-2019 Emmanuel Dupuy + NSHumanReadableCopyright Copyright 2008, 2019 Emmanuel Dupuy NSPrincipalClass NSApplication NSHighResolutionCapable CFBundleDocumentTypes @@ -24,6 +24,10 @@ class + CFBundleTypeMIMETypes + + application/java + CFBundleTypeRole Viewer CFBundleTypeName Class File LSIsAppleDefaultForType @@ -34,6 +38,10 @@ java + CFBundleTypeMIMETypes + + text/plain + CFBundleTypeRole Viewer CFBundleTypeName Java File LSIsAppleDefaultForType @@ -44,6 +52,10 @@ jar + CFBundleTypeMIMETypes + + application/java-archive + CFBundleTypeName Jar File CFBundleTypeRole Viewer LSIsAppleDefaultForType @@ -54,6 +66,10 @@ war + CFBundleTypeMIMETypes + + application/java-archive + CFBundleTypeName War File CFBundleTypeRole Viewer LSIsAppleDefaultForType @@ -64,16 +80,48 @@ ear + CFBundleTypeMIMETypes + + application/java-archive + CFBundleTypeName Ear File CFBundleTypeRole Viewer LSIsAppleDefaultForType LSTypeIsPackage + + CFBundleTypeExtensions + + aar + + CFBundleTypeName Android archive File + CFBundleTypeRole Viewer + LSIsAppleDefaultForType + LSTypeIsPackage + + + CFBundleTypeExtensions + + jmod + + CFBundleTypeMIMETypes + + application/java-archive + + CFBundleTypeName Java module File + CFBundleTypeRole Viewer + LSIsAppleDefaultForType + LSTypeIsPackage + CFBundleTypeExtensions zip + CFBundleTypeMIMETypes + + application/zip + CFBundleTypeName Zip File CFBundleTypeRole Viewer LSIsAppleDefaultForType @@ -85,6 +133,10 @@ log txt + CFBundleTypeMIMETypes + + text/plain + CFBundleTypeName Log File CFBundleTypeRole Viewer LSIsAppleDefaultForType diff --git a/src/website/img/jd-gui.png b/src/website/img/jd-gui.png new file mode 100644 index 00000000..2bc068ce Binary files /dev/null and b/src/website/img/jd-gui.png differ