mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-5821 - Fixed bug that caused incorrect tab to be selected when closing docked component provider tabs via the 'x' button
This commit is contained in:
parent
8c56fc8e04
commit
5a631afc45
1 changed files with 25 additions and 13 deletions
|
@ -39,6 +39,7 @@ import utilities.util.reflection.ReflectionUtilities;
|
||||||
class ComponentNode extends Node {
|
class ComponentNode extends Node {
|
||||||
|
|
||||||
private ComponentPlaceholder top;
|
private ComponentPlaceholder top;
|
||||||
|
private int lastActiveTabIndex;
|
||||||
private List<ComponentPlaceholder> windowPlaceholders;
|
private List<ComponentPlaceholder> windowPlaceholders;
|
||||||
private JComponent comp;
|
private JComponent comp;
|
||||||
private boolean isDisposed;
|
private boolean isDisposed;
|
||||||
|
@ -167,6 +168,7 @@ class ComponentNode extends Node {
|
||||||
void add(ComponentPlaceholder placeholder) {
|
void add(ComponentPlaceholder placeholder) {
|
||||||
windowPlaceholders.add(placeholder);
|
windowPlaceholders.add(placeholder);
|
||||||
placeholder.setNode(this);
|
placeholder.setNode(this);
|
||||||
|
|
||||||
if (placeholder.isActive()) {
|
if (placeholder.isActive()) {
|
||||||
top = placeholder;
|
top = placeholder;
|
||||||
invalidate();
|
invalidate();
|
||||||
|
@ -238,9 +240,7 @@ class ComponentNode extends Node {
|
||||||
@Override
|
@Override
|
||||||
void close() {
|
void close() {
|
||||||
List<ComponentPlaceholder> list = new ArrayList<>(windowPlaceholders);
|
List<ComponentPlaceholder> list = new ArrayList<>(windowPlaceholders);
|
||||||
Iterator<ComponentPlaceholder> it = list.iterator();
|
for (ComponentPlaceholder placeholder : list) {
|
||||||
while (it.hasNext()) {
|
|
||||||
ComponentPlaceholder placeholder = it.next();
|
|
||||||
placeholder.close();
|
placeholder.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,6 +293,7 @@ class ComponentNode extends Node {
|
||||||
|
|
||||||
DockableComponent activeComp =
|
DockableComponent activeComp =
|
||||||
(DockableComponent) tabbedPane.getComponentAt(activeIndex);
|
(DockableComponent) tabbedPane.getComponentAt(activeIndex);
|
||||||
|
|
||||||
top = activeComp.getComponentWindowingPlaceholder();
|
top = activeComp.getComponentWindowingPlaceholder();
|
||||||
tabbedPane.setSelectedComponent(activeComp);
|
tabbedPane.setSelectedComponent(activeComp);
|
||||||
}
|
}
|
||||||
|
@ -302,8 +303,17 @@ class ComponentNode extends Node {
|
||||||
|
|
||||||
private int addComponentsToTabbedPane(List<ComponentPlaceholder> activeComponents,
|
private int addComponentsToTabbedPane(List<ComponentPlaceholder> activeComponents,
|
||||||
JTabbedPane tabbedPane) {
|
JTabbedPane tabbedPane) {
|
||||||
|
|
||||||
|
// When rebuilding tabs, we wish to restore the tab location for users so the UI doesn't
|
||||||
|
// jump around. How we do this depends on if the user has closed or opened a new view.
|
||||||
|
// We will use the last active tab index to restore the active tab after the user has closed
|
||||||
|
// a tab. We use the 'top' variable to find the active tab when the user opens a new tab.
|
||||||
int count = activeComponents.size();
|
int count = activeComponents.size();
|
||||||
int activeIndex = 0;
|
int activeIndex = lastActiveTabIndex;
|
||||||
|
if (activeIndex >= count) {
|
||||||
|
activeIndex = count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
ComponentPlaceholder placeholder = activeComponents.get(i);
|
ComponentPlaceholder placeholder = activeComponents.get(i);
|
||||||
DockableComponent c = placeholder.getComponent();
|
DockableComponent c = placeholder.getComponent();
|
||||||
|
@ -329,6 +339,7 @@ class ComponentNode extends Node {
|
||||||
activeIndex = i;
|
activeIndex = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return activeIndex;
|
return activeIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,11 +486,15 @@ class ComponentNode extends Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
DockableComponent dc = placeholder.getComponent();
|
DockableComponent dc = placeholder.getComponent();
|
||||||
if (dc != null) {
|
if (dc == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
top = placeholder;
|
||||||
JTabbedPane tab = (JTabbedPane) comp;
|
JTabbedPane tab = (JTabbedPane) comp;
|
||||||
if (tab.getSelectedComponent() != dc) {
|
if (tab.getSelectedComponent() != dc) {
|
||||||
tab.setSelectedComponent(dc);
|
tab.setSelectedComponent(dc);
|
||||||
}
|
lastActiveTabIndex = tab.getSelectedIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,10 +512,7 @@ class ComponentNode extends Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
root.setAttribute("TOP_INFO", "" + topIndex);
|
root.setAttribute("TOP_INFO", "" + topIndex);
|
||||||
Iterator<ComponentPlaceholder> it = windowPlaceholders.iterator();
|
for (ComponentPlaceholder placeholder : windowPlaceholders) {
|
||||||
while (it.hasNext()) {
|
|
||||||
|
|
||||||
ComponentPlaceholder placeholder = it.next();
|
|
||||||
|
|
||||||
Element elem = new Element("COMPONENT_INFO");
|
Element elem = new Element("COMPONENT_INFO");
|
||||||
elem.setAttribute("NAME", placeholder.getName());
|
elem.setAttribute("NAME", placeholder.getName());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue