Merge remote-tracking branch 'origin/GP-5344-dragonmacher-front-end-tool-closing-fix'

This commit is contained in:
Ryan Kurtz 2025-02-07 14:24:32 -05:00
commit 69439da80a
2 changed files with 22 additions and 4 deletions

View file

@ -1104,17 +1104,21 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
@Override @Override
public void actionPerformed(ActionContext context) { public void actionPerformed(ActionContext context) {
Tool tool = getTool();
DockingWindowManager myDwm = tool.getWindowManager();
boolean isFrustrated = isFrustrated(); boolean isFrustrated = isFrustrated();
boolean isFocused = isFocused(); boolean isFocused = isFocused();
if (isFocused && !isFrustrated) { if (isFocused && !isFrustrated) {
// the user has decided to hide this component and is not madly clicking // the user has decided to hide this component and is not madly clicking; also, we
setVisible(false); // don't allow the last component in a window to be closed in order to prevent an
// empty window.
if (!myDwm.isLastComponentInWindow(ComponentProvider.this)) {
setVisible(false);
}
return; return;
} }
boolean emphasize = getComponent().isShowing() && isFrustrated; boolean emphasize = getComponent().isShowing() && isFrustrated;
Tool tool = getTool();
DockingWindowManager myDwm = tool.getWindowManager();
myDwm.showComponent(ComponentProvider.this, true, emphasize); myDwm.showComponent(ComponentProvider.this, true, emphasize);
} }

View file

@ -478,6 +478,20 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
return windowNode.getComponentCount() == 1; return windowNode.getComponentCount() == 1;
} }
/**
* Returns true if the given provider is the last provider in its window.
* @param provider the provider
* @return true if the given provider is the last provider in its window.
*/
public boolean isLastComponentInWindow(ComponentProvider provider) {
Window providerWindow = getProviderWindow(provider);
WindowNode providerNode = root.getNodeForWindow(providerWindow);
if (providerNode != null) {
return providerNode.getComponentCount() == 1;
}
return false;
}
/** /**
* Sets the visible state of the set of docking windows. * Sets the visible state of the set of docking windows.
* *