fix(gui): remember selected device in debugger (PR #2153)
* ADBDialog->launchApp() if multiple devices presented should let user select the one they desire. * compare objects directly instead parsing --------- Co-authored-by: Ömer Faruk KAYIKCI <omer.kayikci@tubitak.gov.tr> Co-authored-by: Skylot <118523+skylot@users.noreply.github.com>
This commit is contained in:
@@ -69,6 +69,7 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
|
||||
private transient JTree procTree;
|
||||
private Socket deviceSocket;
|
||||
private transient List<DeviceNode> deviceNodes = new ArrayList<>();
|
||||
private transient DeviceNode lastSelectedDeviceNode;
|
||||
|
||||
public ADBDialog(MainWindow mainWindow) {
|
||||
super(mainWindow);
|
||||
@@ -147,6 +148,15 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
|
||||
}
|
||||
});
|
||||
|
||||
procTree.addTreeSelectionListener(event -> {
|
||||
Object selectedNode = procTree.getLastSelectedPathComponent();
|
||||
if (selectedNode instanceof DeviceTreeNode) {
|
||||
lastSelectedDeviceNode = deviceNodes.stream()
|
||||
.filter(item -> item.tNode == selectedNode)
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
});
|
||||
|
||||
JPanel btnPane = new JPanel();
|
||||
BoxLayout boxLayout = new BoxLayout(btnPane, BoxLayout.LINE_AXIS);
|
||||
btnPane.setLayout(boxLayout);
|
||||
@@ -511,7 +521,8 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
|
||||
return;
|
||||
}
|
||||
String fullName = pkg + "/" + cls.getCls().getClassNode().getClassInfo().getFullName();
|
||||
ADBDevice device = deviceNodes.get(0).device; // TODO: if multiple devices presented should let user select the one they desire.
|
||||
|
||||
ADBDevice device = (lastSelectedDeviceNode == null) ? deviceNodes.get(0).device : lastSelectedDeviceNode.device;
|
||||
if (device != null) {
|
||||
try {
|
||||
device.launchApp(fullName);
|
||||
|
||||
Reference in New Issue
Block a user