diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java index 576491b1d7..6b24e22f6a 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/AbstractCodeBrowserPlugin.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. @@ -337,7 +337,7 @@ public abstract class AbstractCodeBrowserPlugin

ex @Override public void setListingPanel(ListingPanel lp) { - connectedProvider.setPanel(lp); + connectedProvider.setOtherPanel(lp); viewChanged(currentView); } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java index 87c4a63e4a..d0ef7f1cd8 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/CodeViewerProvider.java @@ -727,7 +727,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter return panelProgram.getDomainFile().toString(); } - public void setPanel(ListingPanel lp) { + public void setOtherPanel(ListingPanel lp) { Program myProgram = listingPanel.getListingModel().getProgram(); Program otherProgram = lp.getListingModel().getProgram(); String myName = ""; diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/TitledPanel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/TitledPanel.java index 740e5a9db5..72f0f339cd 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/TitledPanel.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/TitledPanel.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. @@ -15,16 +15,11 @@ */ package docking.widgets; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; +import java.awt.*; import java.util.ArrayList; import java.util.List; -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JPanel; +import javax.swing.*; import docking.widgets.label.GDHtmlLabel; import docking.widgets.label.GDLabel; @@ -34,42 +29,36 @@ import docking.widgets.label.GDLabel; * components (usually icon buttons) */ public class TitledPanel extends JPanel { - private JLabel title; // GDLabel or GHtmlLabel + private JLabel titleLabel; private JPanel titlePanel; private JPanel iconPanel; private JComponent bottomComp; private List titleComps = new ArrayList<>(); - /** - * Creates a new TitlePanel - * @param name the name of the panel - * @param panel the component to wrap - * @param margin the size of the margin to use - */ - public TitledPanel(String name, JComponent panel, int margin) { - this(new GDHtmlLabel(name), panel, margin); - } - /** * Creates a new TitlePanel * - * @param titleLabel the title label for the panel; this allow clients to provide HTML-based + * @param title the title; this allow clients to provide HTML-based * title text. Note: it is up to the client to escape this text as needed for safety * @param panel the component to wrap * @param margin the size of the margin to use */ - public TitledPanel(JLabel titleLabel, JComponent panel, int margin) { + public TitledPanel(String title, JComponent panel, int margin) { super(new BorderLayout()); titlePanel = new JPanel(new BorderLayout()); iconPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 1)); iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - title = titleLabel; + titleLabel = new GDHtmlLabel(title); + + titleLabel.setMinimumSize(new Dimension(16, 20)); + titleLabel.setToolTipText(title); + JLabel filler = new GDLabel(); filler.setPreferredSize(new Dimension(margin, filler.getPreferredSize().height)); titlePanel.add(filler, BorderLayout.WEST); titlePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - titlePanel.add(title, BorderLayout.CENTER); + titlePanel.add(titleLabel, BorderLayout.CENTER); titlePanel.add(iconPanel, BorderLayout.EAST); add(titlePanel, BorderLayout.NORTH); @@ -77,8 +66,8 @@ public class TitledPanel extends JPanel { } public void setTitleName(String name) { - title.setText(name); - title.setToolTipText(name); + titleLabel.setText(name); + titleLabel.setToolTipText(name); } /** diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/model/DomainObjectDisplayUtils.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/model/DomainObjectDisplayUtils.java index 5aa1e002f4..24ab34207e 100644 --- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/model/DomainObjectDisplayUtils.java +++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/model/DomainObjectDisplayUtils.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. @@ -16,6 +16,7 @@ package ghidra.framework.model; import ghidra.framework.store.FileSystem; +import ghidra.util.StringUtilities; public class DomainObjectDisplayUtils { private static final String VERSION_SEP = "@"; @@ -24,13 +25,16 @@ public class DomainObjectDisplayUtils { private static final String PROJECT_SEP_ELLIPSES = ":" + FileSystem.SEPARATOR + "..." + FileSystem.SEPARATOR; + private static final int TOOLTIP_PATH_LENGTH_LIMIT = 100; + private static final int TAB_NAME_LENGTH_LIMIT = 40; + private DomainObjectDisplayUtils() { } public static String getShortPath(DomainFile df) { String pathString = df.toString(); int length = pathString.length(); - if (length < 100) { + if (length < TOOLTIP_PATH_LENGTH_LIMIT) { return pathString; } @@ -60,14 +64,16 @@ public class DomainObjectDisplayUtils { public static String getTabText(DomainFile df) { String tabName = df.getName(); - if (df.isReadOnly()) { - int version = df.getVersion(); - if (!df.canSave() && version != DomainFile.DEFAULT_VERSION) { - tabName += VERSION_SEP + version; - } - tabName = tabName + READ_ONLY; + String trimmedName = StringUtilities.trimMiddle(tabName, TAB_NAME_LENGTH_LIMIT); + if (!df.isReadOnly()) { + return trimmedName; } - return tabName; + + int version = df.getVersion(); + if (!df.canSave() && version != DomainFile.DEFAULT_VERSION) { + trimmedName += VERSION_SEP + version; + } + return trimmedName + READ_ONLY; } public static String getTabText(DomainObject object) {