From 1cb3796bc28efcb0a6842084fbc2ac125ca3d6c6 Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:31:27 -0400 Subject: [PATCH] GP-4875 - Updated how providers track user changes to the title --- .../src/main/java/docking/ComponentNode.java | 14 ++-- .../main/java/docking/ComponentProvider.java | 65 ++++++++++++++++++- 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/Ghidra/Framework/Docking/src/main/java/docking/ComponentNode.java b/Ghidra/Framework/Docking/src/main/java/docking/ComponentNode.java index 6f54bc3046..89b415fb3c 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/ComponentNode.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/ComponentNode.java @@ -640,13 +640,13 @@ class ComponentNode extends Node { return; // cancelled } - // If the user changes the name, then we want to replace all of the - // parts of the title with that name. We skip the subtitle, as that - // doesn't make sense in that case. - provider.setTitle(newName); // title on window - provider.setSubTitle(""); // part after the title - provider.setTabText(newName); // text on the tab - placeholder.update(); + // If the user changes the name, then we want to replace all of the parts of the + // title with that name. We do not supply a custom subtitle, as that doesn't make + // sense in this case, but we clear it so the user's title is the only thing + // visible. This means that providers can still update the subtitle later. + provider.setCustomTitle(newName); // title on window + provider.setSubTitle(""); // part after the title + provider.setCustomTabText(newName); // text on the tab } } } diff --git a/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java b/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java index 90d12575d6..2fe3ef2d13 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java @@ -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. @@ -88,9 +88,13 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext protected Tool dockingTool; private String name; private final String owner; + private String title; private String subTitle; private String tabText; + private String customTitle; + private String customTabText; + private String customSubTitle; private Set actionSet = new LinkedHashSet<>(); @@ -549,6 +553,10 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext * @param title the title string to use. */ public void setTitle(String title) { + if (customTitle != null) { + return; + } + this.title = title; if (isInTool()) { dockingTool.updateTitle(this); @@ -561,6 +569,10 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext * @param subTitle the sub-title string to use. */ public void setSubTitle(String subTitle) { + if (customSubTitle != null) { + return; + } + this.subTitle = subTitle; if (isInTool()) { dockingTool.updateTitle(this); @@ -572,7 +584,56 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext * @param tabText the tab text. */ public void setTabText(String tabText) { + if (customTabText != null) { + return; + } + this.tabText = tabText; + if (isInTool()) { + dockingTool.updateTitle(this); + } + } + + /** + * The new custom title. Setting the title here prevents future calls to + * {@link #setTitle(String)} from having any effect. This is done to preserve the custom + * title. + * @param title the title + */ + public void setCustomTitle(String title) { + this.customTitle = title; + this.title = title; + if (isInTool()) { + dockingTool.updateTitle(this); + } + } + + /** + * The new custom tab text. Setting the text here prevents future calls to + * {@link #setTabText(String)} from having any effect. This is done to preserve the custom + * tab text. + * @param tabText the text + */ + public void setCustomTabText(String tabText) { + this.customTabText = tabText; + this.tabText = tabText; + if (isInTool()) { + dockingTool.updateTitle(this); + } + } + + /** + * The new custom sub-title. Setting the sub-title here prevents future calls to + * {@link #setSubTitle(String)} from having any effect. This is done to preserve the custom + * sub-title. + * @param subTitle the sub-title + */ + public void setCustomSubTitle(String subTitle) { + this.customSubTitle = subTitle; + this.subTitle = subTitle; + if (isInTool()) { + dockingTool.updateTitle(this); + } } /**