diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java index 4cb46c73..7ebf4a3e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java @@ -270,20 +270,34 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File } public void quickDecompile(Decompiler decompiler, TreePath selPath) + { + quickDecompile(decompiler, selPath, false); + } + + public void quickDecompile(Decompiler decompiler, TreePath selPath, boolean quickEdit) { Decompiler tempDecompiler1 = BytecodeViewer.viewer.viewPane1.getSelectedDecompiler(); + boolean editable1 = BytecodeViewer.viewer.viewPane1.isPaneEditable(); Decompiler tempDecompiler2 = BytecodeViewer.viewer.viewPane2.getSelectedDecompiler(); + boolean editable2 = BytecodeViewer.viewer.viewPane2.isPaneEditable(); Decompiler tempDecompiler3 = BytecodeViewer.viewer.viewPane3.getSelectedDecompiler(); + boolean editable3 = BytecodeViewer.viewer.viewPane3.isPaneEditable(); BytecodeViewer.viewer.viewPane1.setSelectedDecompiler(decompiler); + BytecodeViewer.viewer.viewPane1.setPaneEditable(quickEdit); BytecodeViewer.viewer.viewPane2.setSelectedDecompiler(Decompiler.NONE); + BytecodeViewer.viewer.viewPane2.setPaneEditable(false); BytecodeViewer.viewer.viewPane3.setSelectedDecompiler(Decompiler.NONE); + BytecodeViewer.viewer.viewPane3.setPaneEditable(false); openPath(selPath); BytecodeViewer.viewer.viewPane1.setSelectedDecompiler(tempDecompiler1); + BytecodeViewer.viewer.viewPane1.setPaneEditable(editable1); BytecodeViewer.viewer.viewPane2.setSelectedDecompiler(tempDecompiler2); + BytecodeViewer.viewer.viewPane2.setPaneEditable(editable2); BytecodeViewer.viewer.viewPane3.setSelectedDecompiler(tempDecompiler3); + BytecodeViewer.viewer.viewPane3.setPaneEditable(editable3); } public void openPath(TreePath path) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/contextmenu/ContextMenu.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/contextmenu/ContextMenu.java index 5a8d7fd1..47940e26 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/contextmenu/ContextMenu.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/contextmenu/ContextMenu.java @@ -40,9 +40,10 @@ public class ContextMenu static { addContext(new New()); - addContext(new Remove()); + addContext(new Remove()); //TODO rename to delete and add support for resources & whole parent nodes (directories) addContext(new Open()); addContext(new QuickOpen()); + addContext(new QuickEdit()); addContext(new Expand()); addContext(new Collapse()); } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/contextmenu/impl/QuickEdit.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/contextmenu/impl/QuickEdit.java new file mode 100644 index 00000000..030cea8a --- /dev/null +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/contextmenu/impl/QuickEdit.java @@ -0,0 +1,52 @@ +package the.bytecode.club.bytecodeviewer.gui.resourcelist.contextmenu.impl; + +import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.decompilers.Decompiler; +import the.bytecode.club.bytecodeviewer.gui.resourcelist.contextmenu.ContextMenuItem; +import the.bytecode.club.bytecodeviewer.gui.resourcelist.contextmenu.ContextMenuType; +import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; + +import javax.swing.*; + +/*************************************************************************** + * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * + * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + ***************************************************************************/ + +/** + * @author Konloch + * @since 7/27/2021 + */ +public class QuickEdit extends ContextMenuItem +{ + public QuickEdit() + { + super(ContextMenuType.RESOURCE, ((tree, selPath, menu) -> + { + JMenu quickOpen = new JMenu("Quick Edit"); + quickOpen.add(createMenu(TranslatedStrings.KRAKATAU.toString(), ()-> + BytecodeViewer.viewer.resourcePane.quickDecompile(Decompiler.KRAKATAU_DISASSEMBLER, selPath, true))); + menu.add(quickOpen); + })); + } + + private static JMenuItem createMenu(String name, Runnable onClick) + { + JMenuItem menu = new JMenuItem(name); + menu.addActionListener((e)->onClick.run()); + return menu; + } +}