Skip to content

Commit 5f72bc4

Browse files
committed
Quick Edit
This adds quick edit and fixes a bug with the quick decompile displaying as editable
1 parent 2c57424 commit 5f72bc4

3 files changed

Lines changed: 68 additions & 1 deletion

File tree

src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/ResourceListPane.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,20 +270,34 @@ public void resetWorkspace()
270270
}
271271

272272
public void quickDecompile(Decompiler decompiler, TreePath selPath)
273+
{
274+
quickDecompile(decompiler, selPath, false);
275+
}
276+
277+
public void quickDecompile(Decompiler decompiler, TreePath selPath, boolean quickEdit)
273278
{
274279
Decompiler tempDecompiler1 = BytecodeViewer.viewer.viewPane1.getSelectedDecompiler();
280+
boolean editable1 = BytecodeViewer.viewer.viewPane1.isPaneEditable();
275281
Decompiler tempDecompiler2 = BytecodeViewer.viewer.viewPane2.getSelectedDecompiler();
282+
boolean editable2 = BytecodeViewer.viewer.viewPane2.isPaneEditable();
276283
Decompiler tempDecompiler3 = BytecodeViewer.viewer.viewPane3.getSelectedDecompiler();
284+
boolean editable3 = BytecodeViewer.viewer.viewPane3.isPaneEditable();
277285

278286
BytecodeViewer.viewer.viewPane1.setSelectedDecompiler(decompiler);
287+
BytecodeViewer.viewer.viewPane1.setPaneEditable(quickEdit);
279288
BytecodeViewer.viewer.viewPane2.setSelectedDecompiler(Decompiler.NONE);
289+
BytecodeViewer.viewer.viewPane2.setPaneEditable(false);
280290
BytecodeViewer.viewer.viewPane3.setSelectedDecompiler(Decompiler.NONE);
291+
BytecodeViewer.viewer.viewPane3.setPaneEditable(false);
281292

282293
openPath(selPath);
283294

284295
BytecodeViewer.viewer.viewPane1.setSelectedDecompiler(tempDecompiler1);
296+
BytecodeViewer.viewer.viewPane1.setPaneEditable(editable1);
285297
BytecodeViewer.viewer.viewPane2.setSelectedDecompiler(tempDecompiler2);
298+
BytecodeViewer.viewer.viewPane2.setPaneEditable(editable2);
286299
BytecodeViewer.viewer.viewPane3.setSelectedDecompiler(tempDecompiler3);
300+
BytecodeViewer.viewer.viewPane3.setPaneEditable(editable3);
287301
}
288302

289303
public void openPath(TreePath path)

src/main/java/the/bytecode/club/bytecodeviewer/gui/resourcelist/contextmenu/ContextMenu.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ public class ContextMenu
4040
static
4141
{
4242
addContext(new New());
43-
addContext(new Remove());
43+
addContext(new Remove()); //TODO rename to delete and add support for resources & whole parent nodes (directories)
4444
addContext(new Open());
4545
addContext(new QuickOpen());
46+
addContext(new QuickEdit());
4647
addContext(new Expand());
4748
addContext(new Collapse());
4849
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package the.bytecode.club.bytecodeviewer.gui.resourcelist.contextmenu.impl;
2+
3+
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
4+
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
5+
import the.bytecode.club.bytecodeviewer.gui.resourcelist.contextmenu.ContextMenuItem;
6+
import the.bytecode.club.bytecodeviewer.gui.resourcelist.contextmenu.ContextMenuType;
7+
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
8+
9+
import javax.swing.*;
10+
11+
/***************************************************************************
12+
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
13+
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
14+
* *
15+
* This program is free software: you can redistribute it and/or modify *
16+
* it under the terms of the GNU General Public License as published by *
17+
* the Free Software Foundation, either version 3 of the License, or *
18+
* (at your option) any later version. *
19+
* *
20+
* This program is distributed in the hope that it will be useful, *
21+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
22+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
23+
* GNU General Public License for more details. *
24+
* *
25+
* You should have received a copy of the GNU General Public License *
26+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
27+
***************************************************************************/
28+
29+
/**
30+
* @author Konloch
31+
* @since 7/27/2021
32+
*/
33+
public class QuickEdit extends ContextMenuItem
34+
{
35+
public QuickEdit()
36+
{
37+
super(ContextMenuType.RESOURCE, ((tree, selPath, menu) ->
38+
{
39+
JMenu quickOpen = new JMenu("Quick Edit");
40+
quickOpen.add(createMenu(TranslatedStrings.KRAKATAU.toString(), ()->
41+
BytecodeViewer.viewer.resourcePane.quickDecompile(Decompiler.KRAKATAU_DISASSEMBLER, selPath, true)));
42+
menu.add(quickOpen);
43+
}));
44+
}
45+
46+
private static JMenuItem createMenu(String name, Runnable onClick)
47+
{
48+
JMenuItem menu = new JMenuItem(name);
49+
menu.addActionListener((e)->onClick.run());
50+
return menu;
51+
}
52+
}

0 commit comments

Comments
 (0)