mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
select the same tab when switching back (PY-22411)
This commit is contained in:
@@ -42,6 +42,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PyDataView implements DumbAware {
|
||||
@@ -52,6 +54,7 @@ public class PyDataView implements DumbAware {
|
||||
|
||||
@NotNull private final Project myProject;
|
||||
private JBEditorTabs myTabs;
|
||||
private final Map<ProcessHandler, TabInfo> mySelectedInfos = new ConcurrentHashMap<>();
|
||||
|
||||
public PyDataView(@NotNull Project project) {
|
||||
myProject = project;
|
||||
@@ -89,6 +92,7 @@ public class PyDataView implements DumbAware {
|
||||
}
|
||||
|
||||
public void updateTabs(@NotNull ProcessHandler handler) {
|
||||
saveSelectedInfo();
|
||||
for (TabInfo info : myTabs.getTabs()) {
|
||||
PyDataViewerPanel panel = getPanel(info);
|
||||
PyFrameAccessor accessor = panel.getFrameAccessor();
|
||||
@@ -98,6 +102,7 @@ public class PyDataView implements DumbAware {
|
||||
boolean shouldBeShown = Comparing.equal(handler, ((PyDebugProcess)accessor).getProcessHandler());
|
||||
info.setHidden(!shouldBeShown);
|
||||
}
|
||||
restoreSelectedInfo(handler);
|
||||
if (myTabs.getSelectedInfo() == null) {
|
||||
PyFrameAccessor accessor = getFrameAccessor(handler);
|
||||
if (accessor != null) {
|
||||
@@ -106,6 +111,24 @@ public class PyDataView implements DumbAware {
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreSelectedInfo(@NotNull ProcessHandler handler) {
|
||||
TabInfo savedSelection = mySelectedInfos.get(handler);
|
||||
if (savedSelection != null) {
|
||||
myTabs.select(savedSelection, true);
|
||||
mySelectedInfos.remove(handler);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveSelectedInfo() {
|
||||
TabInfo selectedInfo = myTabs.getSelectedInfo();
|
||||
if (!hasOnlyEmptyTab() && selectedInfo != null) {
|
||||
PyFrameAccessor accessor = getPanel(selectedInfo).getFrameAccessor();
|
||||
if (accessor instanceof PyDebugProcess) {
|
||||
mySelectedInfos.put(((PyDebugProcess)accessor).getProcessHandler(), selectedInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PyFrameAccessor getFrameAccessor(@NotNull ProcessHandler handler) {
|
||||
for (PyDebugProcess process : XDebuggerManager.getInstance(myProject).getDebugProcesses(PyDebugProcess.class)) {
|
||||
|
||||
Reference in New Issue
Block a user