mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-04 15:14:49 +00:00
@@ -85,6 +85,8 @@ public class DebugPanel extends JPanel {
|
||||
|
||||
private boolean loading = false;
|
||||
|
||||
public ABCPanel.VariablesTableModel localsTable;
|
||||
|
||||
public static enum SelectedTab {
|
||||
|
||||
LOG, STACK, SCOPECHAIN, LOCALS, REGISTERS, CALLSTACK, CONSTANTPOOL
|
||||
@@ -346,6 +348,7 @@ public class DebugPanel extends JPanel {
|
||||
synchronized (DebugPanel.this) {
|
||||
|
||||
SelectedTab oldSel = selectedTab;
|
||||
localsTable = null;
|
||||
InFrame f = Main.getDebugHandler().getFrame();
|
||||
if (f != null) {
|
||||
|
||||
@@ -362,7 +365,8 @@ public class DebugPanel extends JPanel {
|
||||
localIds.addAll(f.argumentFrameIds);
|
||||
localIds.addAll(f.frameIds);
|
||||
|
||||
safeSetTreeModel(debugLocalsTable, new ABCPanel.VariablesTableModel(debugLocalsTable, locals, localIds));
|
||||
localsTable = new ABCPanel.VariablesTableModel(debugLocalsTable, locals, localIds);
|
||||
safeSetTreeModel(debugLocalsTable, localsTable);
|
||||
safeSetTreeModel(debugScopeTable, new ABCPanel.VariablesTableModel(debugScopeTable, f.scopeChain, f.scopeChainFrameIds));
|
||||
|
||||
/*TableModelListener refreshListener = new TableModelListener() {
|
||||
|
||||
@@ -823,7 +823,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
|
||||
return abcPanel;
|
||||
}
|
||||
|
||||
private ActionPanel getActionPanel() {
|
||||
public ActionPanel getActionPanel() {
|
||||
if (actionPanel == null) {
|
||||
actionPanel = new ActionPanel(MainPanel.this);
|
||||
displayPanel.add(actionPanel, CARDACTIONSCRIPTPANEL);
|
||||
|
||||
@@ -119,6 +119,7 @@ import javax.swing.JTable;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.ToolTipManager;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.event.EventListenerList;
|
||||
import javax.swing.event.TableModelListener;
|
||||
@@ -820,6 +821,31 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String TryGetDebugHoverToolTipText(String varName) {
|
||||
String lowerName = varName.toLowerCase();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
FindVarAndAppendDataToString(root, lowerName, builder);
|
||||
String text = builder.toString();
|
||||
|
||||
if (text == null || text.isEmpty())
|
||||
return null;
|
||||
else
|
||||
return "<html>" + text + "</html>";
|
||||
}
|
||||
|
||||
private void FindVarAndAppendDataToString(VariableNode node, String lowerVarName, StringBuilder builder) {
|
||||
if (node.var != null && node.var.name.toLowerCase().contains(lowerVarName)) {
|
||||
builder.append(node.var.name + ": " + node.var.getValueAsStr() + "<br>");
|
||||
}
|
||||
|
||||
if (node.childs != null) {
|
||||
for (int i = 0; i < node.childs.size(); i++) {
|
||||
FindVarAndAppendDataToString(node.childs.get(i), lowerVarName, builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ABCPanel(MainPanel mainPanel) {
|
||||
@@ -847,6 +873,28 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
}
|
||||
});
|
||||
|
||||
// Register the component on the tooltip manager
|
||||
// So that #getToolTipText(MouseEvent) gets invoked when the mouse
|
||||
// hovers the component, and we can show debug information
|
||||
ToolTipManager.sharedInstance().registerComponent(decompiledTextArea);
|
||||
decompiledTextArea.addMouseListener(new MouseAdapter()
|
||||
{
|
||||
final int initialTimeout = ToolTipManager.sharedInstance().getInitialDelay();
|
||||
final int dismissTimeout = ToolTipManager.sharedInstance().getDismissDelay();
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
ToolTipManager.sharedInstance().setInitialDelay(0);
|
||||
ToolTipManager.sharedInstance().setDismissDelay(1000 * 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
ToolTipManager.sharedInstance().setInitialDelay(initialTimeout);
|
||||
ToolTipManager.sharedInstance().setDismissDelay(dismissTimeout);
|
||||
}
|
||||
});
|
||||
|
||||
searchPanel = new SearchPanel<>(new FlowLayout(), this);
|
||||
|
||||
decompiledScrollPane = new JScrollPane(decompiledTextArea);
|
||||
@@ -1534,4 +1582,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
|
||||
|
||||
return detailPanel.isEditing() || isModified();
|
||||
}
|
||||
|
||||
public DebugPanel getDebugPanel() {
|
||||
return debugPanel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.helpers.CancellableWorker;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
@@ -789,4 +790,24 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL
|
||||
super.setText(t);
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTipText(MouseEvent e) {
|
||||
// not debugging: so return existing text
|
||||
if (abcPanel.getDebugPanel().localsTable == null)
|
||||
return super.getToolTipText();
|
||||
|
||||
final Point point = new Point(e.getX(), e.getY());
|
||||
final int pos = abcPanel.decompiledTextArea.viewToModel(point);
|
||||
final String identifier = abcPanel.getMainPanel().getActionPanel().getStringUnderPosition(pos, abcPanel.decompiledTextArea);
|
||||
|
||||
if (identifier != null && !identifier.isEmpty())
|
||||
{
|
||||
String tooltipText = abcPanel.getDebugPanel().localsTable.TryGetDebugHoverToolTipText(identifier);
|
||||
return (tooltipText == null ? super.getToolTipText() : tooltipText);
|
||||
}
|
||||
|
||||
// not found: so return existing text
|
||||
return super.getToolTipText();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ import javax.swing.SwingConstants;
|
||||
import javax.swing.event.CaretEvent;
|
||||
import javax.swing.event.CaretListener;
|
||||
import javax.swing.text.Highlighter;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import javax.swing.tree.TreePath;
|
||||
import jsyntaxpane.SyntaxDocument;
|
||||
import jsyntaxpane.Token;
|
||||
@@ -182,10 +183,12 @@ public class ActionPanel extends JPanel implements SearchListener<ActionSearchRe
|
||||
|
||||
public String getStringUnderCursor() {
|
||||
View.checkAccess();
|
||||
|
||||
int pos = decompiledEditor.getCaretPosition();
|
||||
|
||||
SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(decompiledEditor);
|
||||
return getStringUnderPosition(pos, decompiledEditor);
|
||||
}
|
||||
|
||||
public String getStringUnderPosition(int pos, JTextComponent component) {
|
||||
SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(component);
|
||||
if (sDoc != null) {
|
||||
Token t = sDoc.getTokenAt(pos + 1);
|
||||
String ident = null;
|
||||
|
||||
Reference in New Issue
Block a user