Fixed the sometimes incorrect use of ComponentPlaceholder.isShowing()

This commit is contained in:
dragonmacher 2024-11-26 17:26:33 -05:00
parent 6e9340b4b8
commit 0ad14b25c8
4 changed files with 24 additions and 18 deletions

View File

@ -167,7 +167,7 @@ class ComponentNode extends Node {
void add(ComponentPlaceholder placeholder) {
windowPlaceholders.add(placeholder);
placeholder.setNode(this);
if (placeholder.isShowing()) {
if (placeholder.isActive()) {
top = placeholder;
invalidate();
}
@ -185,7 +185,7 @@ class ComponentNode extends Node {
return; // this node has been disconnected.
}
if (placeholder.isShowing()) {
if (placeholder.isActive()) {
if (top == placeholder) {
top = null;
}
@ -212,7 +212,7 @@ class ComponentNode extends Node {
* @param keepEmptyPlaceholder flag indicating to keep a placeholder placeholder object.
*/
void remove(ComponentPlaceholder placeholder, boolean keepEmptyPlaceholder) {
if (placeholder.isShowing()) {
if (placeholder.isActive()) {
placeholder.show(false);
if (top == placeholder) {
top = null;
@ -241,9 +241,7 @@ class ComponentNode extends Node {
Iterator<ComponentPlaceholder> it = list.iterator();
while (it.hasNext()) {
ComponentPlaceholder placeholder = it.next();
if (placeholder.isShowing()) {
placeholder.close();
}
placeholder.close();
}
}
@ -404,7 +402,7 @@ class ComponentNode extends Node {
@Override
void populateActiveComponents(List<ComponentPlaceholder> list) {
for (ComponentPlaceholder placeholder : windowPlaceholders) {
if (placeholder.isShowing()) {
if (placeholder.isActive()) {
list.add(placeholder);
}
}
@ -508,7 +506,7 @@ class ComponentNode extends Node {
elem.setAttribute("NAME", placeholder.getName());
elem.setAttribute("OWNER", placeholder.getOwner());
elem.setAttribute("TITLE", placeholder.getTitle());
elem.setAttribute("ACTIVE", "" + placeholder.isShowing());
elem.setAttribute("ACTIVE", "" + placeholder.isActive());
elem.setAttribute("GROUP", placeholder.getGroup());
elem.setAttribute("INSTANCE_ID", Long.toString(placeholder.getInstanceID()));
root.addContent(elem);
@ -516,13 +514,10 @@ class ComponentNode extends Node {
return root;
}
//
// Tabbed pane listener methods
//
@Override
boolean contains(ComponentPlaceholder placeholder) {
for (ComponentPlaceholder ph : windowPlaceholders) {
if (ph.isShowing() && ph.equals(placeholder)) {
if (ph.isActive() && ph.equals(placeholder)) {
return true;
}
}

View File

@ -136,10 +136,21 @@ public class ComponentPlaceholder {
}
/**
* Returns true if the component is not hidden
* Returns true if the component is showing and visible to the user.
* @return true if showing
* @see #isActive()
*/
boolean isShowing() {
return isShowing && comp != null && comp.isShowing();
}
/**
* Returns true if this provider wants to be showing and has a component provider, regardless
* of whether the provider is showing to the user.
* @return true if active
* @see #isShowing()
*/
boolean isActive() {
return isShowing && componentProvider != null;
}

View File

@ -830,7 +830,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
return;
}
if (!placeholder.isShowing()) {
if (!placeholder.isActive()) {
showComponent(placeholder, true, false);
}
@ -947,7 +947,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
return;
}
if (visibleState == placeholder.isShowing()) {
if (visibleState == placeholder.isActive()) {
if (visibleState) {
movePlaceholderToFront(placeholder, shouldEmphasize);
setNextFocusPlaceholder(placeholder);

View File

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -63,7 +63,7 @@ class PlaceholderManager {
restoredPlaceholder.showHeader(false);
}
if (defaultPlaceholder.isShowing() != restoredPlaceholder.isShowing()) {
if (defaultPlaceholder.isActive() != restoredPlaceholder.isActive()) {
if (restoredPlaceholder.isShowing()) {
provider.componentShown();
}