Test fixes

This commit is contained in:
dragonmacher 2025-05-09 13:40:52 -04:00
parent c58647b7d2
commit dad56dfcbe
2 changed files with 25 additions and 9 deletions

View file

@ -48,8 +48,10 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
public void setUp() throws Exception {
tool = new DummyTool();
runSwing(() -> {
winMgr = new DockingWindowManager(tool, null);
winMgr.setVisible(true);
});
buildTable();
}
@ -63,9 +65,10 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
filteredModel = filterPanel.getTableFilterModel();
table.setAutoLookupColumn(4);
provider = new TestTableComponentProvider(tool);
});
winMgr.addComponent(provider);
});
waitForSwing();
}

View file

@ -22,8 +22,7 @@ import java.awt.event.*;
import javax.swing.*;
import docking.action.DockingActionIf;
import ghidra.util.CascadedDropTarget;
import ghidra.util.HelpLocation;
import ghidra.util.*;
import help.HelpService;
/**
@ -150,6 +149,10 @@ public class DockableComponent extends JPanel implements ContainerListener {
return;
}
if (!e.isPopupTrigger()) {
return;
}
Component component = e.getComponent();
if (component == null) {
return; // not sure this can happen
@ -162,12 +165,22 @@ public class DockableComponent extends JPanel implements ContainerListener {
}
Point point = e.getPoint();
boolean withinBounds = bounds.contains(point);
if (e.isPopupTrigger() && withinBounds) {
if (!bounds.contains(point)) {
return;
}
//
// Consume the event so that Java UI listeners do not process it. This fixes issues with
// UI classes (e.g., listeners change table selection). We want to run this code later to
// allow trailing application mouse listeners to have a chance to update the context. If
// the delayed nature causes any timing issues, then we will need a more robust way of
// registering mouse listeners to work around this issue.
//
e.consume();
Swing.runLater(() -> {
PopupMenuContext popupContext = new PopupMenuContext(e);
actionMgr.showPopupMenu(placeholder, popupContext);
e.consume();
}
});
}
@Override