2021-06-26 01:13:46 +00:00
|
|
|
package the.bytecode.club.bytecodeviewer.gui.util;
|
2015-11-11 04:16:45 +00:00
|
|
|
|
2021-04-12 20:19:12 +00:00
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import java.awt.Font;
|
|
|
|
import java.awt.event.InputEvent;
|
2021-04-12 22:31:22 +00:00
|
|
|
import java.util.Objects;
|
2021-04-12 20:19:12 +00:00
|
|
|
import java.util.regex.Matcher;
|
2021-06-29 00:17:30 +00:00
|
|
|
import javax.swing.*;
|
2019-04-17 06:45:15 +00:00
|
|
|
import javax.swing.event.CaretEvent;
|
|
|
|
import javax.swing.event.CaretListener;
|
|
|
|
import javax.swing.event.ChangeEvent;
|
|
|
|
import javax.swing.event.ChangeListener;
|
2021-04-12 20:19:12 +00:00
|
|
|
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
2021-07-14 11:09:46 +00:00
|
|
|
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
2021-04-12 20:19:12 +00:00
|
|
|
import org.fife.ui.rtextarea.RTextScrollPane;
|
2021-07-14 11:33:20 +00:00
|
|
|
import org.objectweb.asm.ClassWriter;
|
2021-04-12 20:19:12 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
2021-07-14 11:09:46 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.Configuration;
|
|
|
|
import the.bytecode.club.bytecodeviewer.compilers.Compiler;
|
2021-07-04 05:59:42 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
|
2021-06-26 01:13:46 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.gui.components.MethodsRenderer;
|
|
|
|
import the.bytecode.club.bytecodeviewer.gui.components.SearchableRSyntaxTextArea;
|
2021-07-14 11:33:20 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.gui.hexviewer.JHexEditor;
|
|
|
|
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.BytecodeViewPanel;
|
2021-06-26 01:13:46 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
|
2021-04-12 20:19:12 +00:00
|
|
|
import the.bytecode.club.bytecodeviewer.util.MethodParser;
|
2019-04-17 06:45:15 +00:00
|
|
|
|
2021-06-26 01:13:46 +00:00
|
|
|
import static the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane.BLANK_COLOR;
|
2021-07-14 11:09:46 +00:00
|
|
|
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.EDITABLE;
|
2019-04-17 06:45:15 +00:00
|
|
|
|
2021-06-26 03:33:06 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* 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 <http://www.gnu.org/licenses/>. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2015-11-11 04:16:45 +00:00
|
|
|
/**
|
2021-07-14 11:33:20 +00:00
|
|
|
* Updates the Bytecode View Panel in a background thread
|
2018-01-31 15:41:24 +00:00
|
|
|
*
|
2015-11-11 04:16:45 +00:00
|
|
|
* @author Konloch
|
2021-06-29 01:25:24 +00:00
|
|
|
* @author WaterWolf
|
2019-04-17 06:45:15 +00:00
|
|
|
* @author DreamSworK
|
2021-07-04 07:04:08 +00:00
|
|
|
* @since 09/26/2011
|
2015-11-11 04:16:45 +00:00
|
|
|
*/
|
2021-07-14 11:33:20 +00:00
|
|
|
|
|
|
|
public class BytecodeViewPanelUpdater implements Runnable
|
2021-06-26 01:13:46 +00:00
|
|
|
{
|
2021-07-04 05:20:25 +00:00
|
|
|
public final ClassViewer viewer;
|
2021-07-14 11:33:20 +00:00
|
|
|
public final BytecodeViewPanel bytecodeViewPanel;
|
|
|
|
private final JButton button;
|
2021-07-14 11:58:35 +00:00
|
|
|
private final byte[] classBytes;
|
2021-07-14 11:33:20 +00:00
|
|
|
|
|
|
|
|
2021-06-26 01:13:46 +00:00
|
|
|
public SearchableRSyntaxTextArea updateUpdaterTextArea;
|
2019-04-17 06:45:15 +00:00
|
|
|
public JComboBox<Integer> methodsList;
|
2021-07-14 11:09:46 +00:00
|
|
|
public boolean isPanelEditable;
|
2021-07-14 11:33:20 +00:00
|
|
|
public boolean waitingFor;
|
2021-06-26 01:13:46 +00:00
|
|
|
private Thread thread;
|
|
|
|
|
2021-07-14 11:58:35 +00:00
|
|
|
public BytecodeViewPanelUpdater(BytecodeViewPanel bytecodeViewPanel, ClassViewer cv, byte[] classBytes, boolean isPanelEditable, JButton button)
|
2021-06-26 01:13:46 +00:00
|
|
|
{
|
2021-07-14 11:33:20 +00:00
|
|
|
this.viewer = cv;
|
|
|
|
this.bytecodeViewPanel = bytecodeViewPanel;
|
2021-07-14 11:58:35 +00:00
|
|
|
this.classBytes = classBytes;
|
2021-07-14 11:33:20 +00:00
|
|
|
this.isPanelEditable = isPanelEditable;
|
|
|
|
this.button = button;
|
|
|
|
waitingFor = true;
|
2021-06-26 01:13:46 +00:00
|
|
|
}
|
|
|
|
|
2021-07-14 11:33:20 +00:00
|
|
|
public void processDisplay()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
BytecodeViewer.updateBusyStatus(true);
|
|
|
|
|
|
|
|
if (bytecodeViewPanel.decompiler != Decompiler.NONE)
|
|
|
|
{
|
|
|
|
//hex viewer
|
|
|
|
if (bytecodeViewPanel.decompiler == Decompiler.HEXCODE_VIEWER)
|
|
|
|
{
|
|
|
|
final ClassWriter cw = new ClassWriter(0);
|
2021-07-14 11:58:35 +00:00
|
|
|
viewer.resource.getResourceClassNode().accept(cw);
|
2021-07-14 11:33:20 +00:00
|
|
|
|
|
|
|
SwingUtilities.invokeLater(() ->
|
|
|
|
{
|
|
|
|
final JHexEditor hex = new JHexEditor(cw.toByteArray());
|
|
|
|
hex.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
|
|
|
|
|
|
|
|
bytecodeViewPanel.panel.add(hex);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
final Decompiler decompiler = bytecodeViewPanel.decompiler;
|
|
|
|
|
|
|
|
//perform decompiling inside of this thread
|
2021-07-14 11:58:35 +00:00
|
|
|
final String decompiledSource = decompiler.getDecompiler().decompileClassNode(viewer.resource.getResourceClassNode(), classBytes);
|
2021-07-14 11:33:20 +00:00
|
|
|
|
|
|
|
//set the swing components on the swing thread
|
|
|
|
SwingUtilities.invokeLater(() ->
|
|
|
|
{
|
|
|
|
buildTextArea(decompiler, decompiledSource);
|
|
|
|
waitingFor = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
//hold this thread until the swing thread has finished attaching the components
|
|
|
|
while (waitingFor)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
Thread.sleep(1);
|
|
|
|
} catch (Exception e) {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (IndexOutOfBoundsException | NullPointerException e)
|
|
|
|
{
|
|
|
|
//ignore
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
BytecodeViewer.handleException(e);
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
viewer.resetDivider();
|
|
|
|
BytecodeViewer.updateBusyStatus(false);
|
|
|
|
SwingUtilities.invokeLater(() ->
|
|
|
|
{
|
|
|
|
if (button != null)
|
|
|
|
button.setEnabled(true);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2021-06-26 01:13:46 +00:00
|
|
|
|
|
|
|
public void startNewThread()
|
|
|
|
{
|
2021-07-01 09:48:10 +00:00
|
|
|
thread = new Thread(this, "Pane Update");
|
2021-06-26 01:13:46 +00:00
|
|
|
thread.start();
|
|
|
|
}
|
2018-01-31 15:03:53 +00:00
|
|
|
|
2018-01-31 15:41:24 +00:00
|
|
|
@Override
|
2021-06-26 01:13:46 +00:00
|
|
|
public void run()
|
|
|
|
{
|
2021-07-14 11:33:20 +00:00
|
|
|
if(bytecodeViewPanel.decompiler == Decompiler.NONE)
|
2021-06-26 01:13:46 +00:00
|
|
|
return;
|
|
|
|
|
2021-07-04 05:59:42 +00:00
|
|
|
processDisplay();
|
2021-07-14 11:09:46 +00:00
|
|
|
|
|
|
|
//nullcheck broken pane
|
|
|
|
if(updateUpdaterTextArea == null || updateUpdaterTextArea.getScrollPane() == null
|
|
|
|
|| updateUpdaterTextArea.getScrollPane().getViewport() == null)
|
|
|
|
{
|
|
|
|
//build an error message
|
|
|
|
SwingUtilities.invokeLater(() ->
|
2021-07-14 11:33:20 +00:00
|
|
|
buildTextArea(bytecodeViewPanel.decompiler, "Critical BCV Error"));
|
2021-07-14 11:09:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-29 00:51:25 +00:00
|
|
|
//this still freezes the swing UI
|
2019-04-17 06:45:15 +00:00
|
|
|
synchronizePane();
|
2021-06-29 00:54:39 +00:00
|
|
|
|
|
|
|
//attach CTRL + Mouse Wheel Zoom
|
|
|
|
SwingUtilities.invokeLater(()->
|
|
|
|
attachCtrlMouseWheelZoom(updateUpdaterTextArea.getScrollPane(), updateUpdaterTextArea));
|
2019-04-25 21:27:35 +00:00
|
|
|
}
|
|
|
|
|
2021-06-29 01:25:24 +00:00
|
|
|
public void attachCtrlMouseWheelZoom(RTextScrollPane scrollPane, RSyntaxTextArea panelArea)
|
|
|
|
{
|
2021-04-12 20:19:12 +00:00
|
|
|
if (scrollPane == null)
|
2019-04-25 21:27:35 +00:00
|
|
|
return;
|
2021-06-29 01:25:24 +00:00
|
|
|
|
|
|
|
scrollPane.addMouseWheelListener(e ->
|
|
|
|
{
|
2021-04-12 22:31:22 +00:00
|
|
|
if (panelArea == null || panelArea.getText().isEmpty())
|
|
|
|
return;
|
|
|
|
|
2021-06-29 01:25:24 +00:00
|
|
|
if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0)
|
|
|
|
{
|
2021-04-12 22:31:22 +00:00
|
|
|
Font font = panelArea.getFont();
|
|
|
|
int size = font.getSize();
|
2021-06-29 01:25:24 +00:00
|
|
|
|
|
|
|
if (e.getWheelRotation() > 0) //Up
|
2021-04-12 22:31:22 +00:00
|
|
|
panelArea.setFont(new Font(font.getName(), font.getStyle(), --size >= 2 ? --size : 2));
|
2021-06-29 01:25:24 +00:00
|
|
|
else //Down
|
2021-04-12 22:31:22 +00:00
|
|
|
panelArea.setFont(new Font(font.getName(), font.getStyle(), ++size));
|
2019-04-25 21:27:35 +00:00
|
|
|
}
|
2021-04-12 22:31:22 +00:00
|
|
|
e.consume();
|
2019-04-25 21:27:35 +00:00
|
|
|
});
|
2019-04-17 06:45:15 +00:00
|
|
|
}
|
|
|
|
|
2021-06-28 01:10:29 +00:00
|
|
|
public final CaretListener caretListener = new CaretListener()
|
|
|
|
{
|
2019-04-17 06:45:15 +00:00
|
|
|
@Override
|
2021-06-28 01:10:29 +00:00
|
|
|
public void caretUpdate(CaretEvent e)
|
|
|
|
{
|
2021-07-14 11:33:20 +00:00
|
|
|
MethodParser methods = viewer.methods.get(bytecodeViewPanel.panelIndex);
|
2021-06-28 01:10:29 +00:00
|
|
|
if (methods != null)
|
|
|
|
{
|
2021-06-26 01:13:46 +00:00
|
|
|
int methodLine = methods.findActiveMethod(updateUpdaterTextArea.getCaretLineNumber());
|
2021-06-28 01:10:29 +00:00
|
|
|
|
2021-04-12 20:19:12 +00:00
|
|
|
if (methodLine != -1) {
|
|
|
|
if (BytecodeViewer.viewer.showClassMethods.isSelected()) {
|
|
|
|
if (methodsList != null) {
|
2021-04-12 22:31:22 +00:00
|
|
|
if (methodLine != (int) Objects.requireNonNull(methodsList.getSelectedItem())) {
|
2019-04-17 06:45:15 +00:00
|
|
|
methodsList.setSelectedItem(methodLine);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-12 20:19:12 +00:00
|
|
|
if (BytecodeViewer.viewer.synchronizedViewing.isSelected()) {
|
2019-04-17 06:45:15 +00:00
|
|
|
int panes = 2;
|
2021-07-14 11:33:20 +00:00
|
|
|
if (viewer.bytecodeViewPanel3.panel != null)
|
2019-04-17 06:45:15 +00:00
|
|
|
panes = 3;
|
|
|
|
|
2021-04-12 20:19:12 +00:00
|
|
|
for (int i = 0; i < panes; i++) {
|
2021-07-14 11:33:20 +00:00
|
|
|
if (i != bytecodeViewPanel.panelIndex) {
|
2019-04-17 06:45:15 +00:00
|
|
|
ClassViewer.selectMethod(viewer, i, methods.getMethod(methodLine));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
public final ChangeListener viewportListener = new ChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void stateChanged(ChangeEvent e) {
|
|
|
|
int panes = 2;
|
2021-07-14 11:33:20 +00:00
|
|
|
if (viewer.bytecodeViewPanel3.panel != null)
|
2019-04-17 06:45:15 +00:00
|
|
|
panes = 3;
|
|
|
|
|
|
|
|
if (BytecodeViewer.viewer.synchronizedViewing.isSelected()) {
|
2021-06-26 01:13:46 +00:00
|
|
|
if (updateUpdaterTextArea.isShowing() && (updateUpdaterTextArea.hasFocus() || updateUpdaterTextArea.getMousePosition() != null)) {
|
|
|
|
int caretLine = updateUpdaterTextArea.getCaretLineNumber();
|
|
|
|
int maxViewLine = ClassViewer.getMaxViewLine(updateUpdaterTextArea);
|
|
|
|
int activeViewLine = ClassViewer.getViewLine(updateUpdaterTextArea);
|
2021-04-12 20:19:12 +00:00
|
|
|
int activeLine = (activeViewLine == maxViewLine && caretLine > maxViewLine) ? caretLine :
|
|
|
|
activeViewLine;
|
2019-04-17 06:45:15 +00:00
|
|
|
int activeLineDelta = -1;
|
|
|
|
MethodParser.Method activeMethod = null;
|
2021-07-14 11:33:20 +00:00
|
|
|
MethodParser activeMethods = viewer.methods.get(bytecodeViewPanel.panelIndex);
|
2019-04-17 06:45:15 +00:00
|
|
|
if (activeMethods != null) {
|
|
|
|
int activeMethodLine = activeMethods.findActiveMethod(activeLine);
|
|
|
|
if (activeMethodLine != -1) {
|
|
|
|
activeLineDelta = activeLine - activeMethodLine;
|
|
|
|
activeMethod = activeMethods.getMethod(activeMethodLine);
|
2021-06-26 01:13:46 +00:00
|
|
|
ClassViewer.selectMethod(updateUpdaterTextArea, activeMethodLine);
|
2019-04-17 06:45:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < panes; i++) {
|
2021-07-14 11:33:20 +00:00
|
|
|
if (i != bytecodeViewPanel.panelIndex) {
|
2019-04-17 06:45:15 +00:00
|
|
|
int setLine = -1;
|
|
|
|
|
|
|
|
RSyntaxTextArea area = null;
|
2021-04-12 20:19:12 +00:00
|
|
|
switch (i) {
|
|
|
|
case 0:
|
2021-07-14 11:33:20 +00:00
|
|
|
area = viewer.bytecodeViewPanel1.updateThread.updateUpdaterTextArea;
|
2021-04-12 20:19:12 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-07-14 11:33:20 +00:00
|
|
|
area = viewer.bytecodeViewPanel2.updateThread.updateUpdaterTextArea;
|
2021-04-12 20:19:12 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-07-14 11:33:20 +00:00
|
|
|
area = viewer.bytecodeViewPanel3.updateThread.updateUpdaterTextArea;
|
2021-04-12 20:19:12 +00:00
|
|
|
break;
|
2019-04-17 06:45:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (area != null) {
|
|
|
|
if (activeMethod != null && activeLineDelta >= 0) {
|
|
|
|
MethodParser methods = viewer.methods.get(i);
|
|
|
|
if (methods != null) {
|
|
|
|
int methodLine = methods.findMethod(activeMethod);
|
|
|
|
if (methodLine != -1) {
|
|
|
|
int viewLine = ClassViewer.getViewLine(area);
|
|
|
|
if (activeLineDelta != viewLine - methodLine) {
|
|
|
|
setLine = methodLine + activeLineDelta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-12 20:19:12 +00:00
|
|
|
} else if (activeLine != ClassViewer.getViewLine(area)) {
|
2019-04-17 06:45:15 +00:00
|
|
|
setLine = activeLine;
|
|
|
|
}
|
|
|
|
if (setLine >= 0) {
|
|
|
|
ClassViewer.setViewLine(area, setLine);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2021-06-26 01:13:46 +00:00
|
|
|
|
|
|
|
public void synchronizePane()
|
|
|
|
{
|
2021-07-14 11:33:20 +00:00
|
|
|
if(bytecodeViewPanel.decompiler == Decompiler.HEXCODE_VIEWER
|
|
|
|
|| bytecodeViewPanel.decompiler == Decompiler.NONE)
|
2021-06-26 01:13:46 +00:00
|
|
|
return;
|
|
|
|
|
2021-06-29 00:17:30 +00:00
|
|
|
SwingUtilities.invokeLater(()->
|
|
|
|
{
|
2021-07-01 23:08:56 +00:00
|
|
|
JViewport viewport = updateUpdaterTextArea.getScrollPane().getViewport();
|
2021-06-29 00:17:30 +00:00
|
|
|
viewport.addChangeListener(viewportListener);
|
|
|
|
updateUpdaterTextArea.addCaretListener(caretListener);
|
|
|
|
});
|
2021-06-26 01:13:46 +00:00
|
|
|
|
2021-07-14 11:33:20 +00:00
|
|
|
final MethodParser methods = viewer.methods.get(bytecodeViewPanel.panelIndex);
|
2021-06-28 01:10:29 +00:00
|
|
|
for (int i = 0; i < updateUpdaterTextArea.getLineCount(); i++)
|
|
|
|
{
|
|
|
|
String lineText = updateUpdaterTextArea.getLineText(i);
|
2019-04-17 06:45:15 +00:00
|
|
|
Matcher regexMatcher = MethodParser.regex.matcher(lineText);
|
2021-06-28 01:10:29 +00:00
|
|
|
if (regexMatcher.find())
|
|
|
|
{
|
2019-04-17 06:45:15 +00:00
|
|
|
String methodName = regexMatcher.group("name");
|
|
|
|
String methodParams = regexMatcher.group("params");
|
|
|
|
methods.addMethod(i, methodName, methodParams);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-29 00:17:30 +00:00
|
|
|
//TODO fix this
|
|
|
|
if (BytecodeViewer.viewer.showClassMethods.isSelected())
|
|
|
|
{
|
|
|
|
if (!methods.isEmpty())
|
|
|
|
{
|
2019-04-17 06:45:15 +00:00
|
|
|
methodsList = new JComboBox<>();
|
2021-06-29 00:17:30 +00:00
|
|
|
|
|
|
|
for (Integer line : methods.getMethodsLines())
|
2019-04-17 06:45:15 +00:00
|
|
|
methodsList.addItem(line);
|
2021-06-29 00:17:30 +00:00
|
|
|
|
2021-06-26 01:13:46 +00:00
|
|
|
methodsList.setRenderer(new MethodsRenderer(this));
|
|
|
|
methodsList.addActionListener(e ->
|
|
|
|
{
|
2021-04-12 22:31:22 +00:00
|
|
|
int line = (int) Objects.requireNonNull(methodsList.getSelectedItem());
|
|
|
|
|
|
|
|
RSyntaxTextArea area = null;
|
2021-07-14 11:33:20 +00:00
|
|
|
switch (bytecodeViewPanel.panelIndex)
|
2021-06-26 01:13:46 +00:00
|
|
|
{
|
|
|
|
case 0:
|
2021-07-14 11:33:20 +00:00
|
|
|
area = viewer.bytecodeViewPanel1.updateThread.updateUpdaterTextArea;
|
2021-06-26 01:13:46 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-07-14 11:33:20 +00:00
|
|
|
area = viewer.bytecodeViewPanel2.updateThread.updateUpdaterTextArea;
|
2021-06-26 01:13:46 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-07-14 11:33:20 +00:00
|
|
|
area = viewer.bytecodeViewPanel3.updateThread.updateUpdaterTextArea;
|
2021-06-26 01:13:46 +00:00
|
|
|
break;
|
2019-04-17 06:45:15 +00:00
|
|
|
}
|
2021-04-12 22:31:22 +00:00
|
|
|
|
|
|
|
if (area != null)
|
|
|
|
ClassViewer.selectMethod(area, line);
|
2019-04-17 06:45:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
JPanel panel = new JPanel(new BorderLayout());
|
2021-06-26 01:13:46 +00:00
|
|
|
panel.add(updateUpdaterTextArea.getScrollPane().getColumnHeader().getComponent(0), BorderLayout.NORTH);
|
2019-04-17 06:45:15 +00:00
|
|
|
panel.add(methodsList, BorderLayout.SOUTH);
|
2021-06-26 01:13:46 +00:00
|
|
|
methodsList.setBackground(BLANK_COLOR);
|
2021-06-29 00:54:39 +00:00
|
|
|
|
|
|
|
SwingUtilities.invokeLater(()->
|
|
|
|
{
|
|
|
|
updateUpdaterTextArea.getScrollPane().getColumnHeader().removeAll();
|
|
|
|
updateUpdaterTextArea.getScrollPane().getColumnHeader().add(panel);
|
|
|
|
});
|
2019-04-17 06:45:15 +00:00
|
|
|
}
|
|
|
|
}
|
2018-01-31 15:41:24 +00:00
|
|
|
}
|
2021-07-14 11:09:46 +00:00
|
|
|
|
|
|
|
public void buildTextArea(Decompiler decompiler, String decompiledSource)
|
|
|
|
{
|
|
|
|
updateUpdaterTextArea = new SearchableRSyntaxTextArea();
|
|
|
|
|
|
|
|
Configuration.rstaTheme.apply(updateUpdaterTextArea);
|
2021-07-14 11:33:20 +00:00
|
|
|
bytecodeViewPanel.panel.add(updateUpdaterTextArea.getScrollPane());
|
|
|
|
bytecodeViewPanel.panel.add(updateUpdaterTextArea.getTitleHeader(), BorderLayout.NORTH);
|
2021-07-14 11:09:46 +00:00
|
|
|
|
2021-07-14 11:33:20 +00:00
|
|
|
bytecodeViewPanel.textArea = updateUpdaterTextArea;
|
|
|
|
bytecodeViewPanel.textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
|
|
|
|
bytecodeViewPanel.textArea.setCodeFoldingEnabled(true);
|
|
|
|
bytecodeViewPanel.textArea.setAntiAliasingEnabled(true);
|
|
|
|
bytecodeViewPanel.textArea.setText(decompiledSource);
|
|
|
|
bytecodeViewPanel.textArea.setCaretPosition(0);
|
|
|
|
bytecodeViewPanel.textArea.setEditable(isPanelEditable);
|
2021-07-14 11:09:46 +00:00
|
|
|
|
|
|
|
if(isPanelEditable && decompiler == Decompiler.SMALI_DISASSEMBLER)
|
2021-07-14 11:33:20 +00:00
|
|
|
bytecodeViewPanel.compiler = Compiler.SMALI_ASSEMBLER;
|
2021-07-14 11:09:46 +00:00
|
|
|
else if(isPanelEditable && decompiler == Decompiler.KRAKATAU_DISASSEMBLER)
|
2021-07-14 11:33:20 +00:00
|
|
|
bytecodeViewPanel.compiler = Compiler.KRAKATAU_ASSEMBLER;
|
2021-07-14 11:09:46 +00:00
|
|
|
|
|
|
|
String editable = isPanelEditable ? " - " + EDITABLE : "";
|
2021-07-14 11:33:20 +00:00
|
|
|
bytecodeViewPanel.textArea.getTitleHeader().setText(decompiler.getDecompilerName() + editable);
|
|
|
|
bytecodeViewPanel.textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
|
2021-07-14 11:09:46 +00:00
|
|
|
}
|
2018-01-31 15:03:53 +00:00
|
|
|
}
|