Merge remote-tracking branch 'origin/GP-5152-dragonmacher-diff-resize-bug'

This commit is contained in:
Ryan Kurtz 2024-11-25 11:09:22 -05:00
commit 46ceac4f5c
4 changed files with 35 additions and 40 deletions

View file

@ -337,7 +337,7 @@ public abstract class AbstractCodeBrowserPlugin<P extends CodeViewerProvider> ex
@Override @Override
public void setListingPanel(ListingPanel lp) { public void setListingPanel(ListingPanel lp) {
connectedProvider.setPanel(lp); connectedProvider.setOtherPanel(lp);
viewChanged(currentView); viewChanged(currentView);
} }

View file

@ -727,7 +727,7 @@ public class CodeViewerProvider extends NavigatableComponentProviderAdapter
return panelProgram.getDomainFile().toString(); return panelProgram.getDomainFile().toString();
} }
public void setPanel(ListingPanel lp) { public void setOtherPanel(ListingPanel lp) {
Program myProgram = listingPanel.getListingModel().getProgram(); Program myProgram = listingPanel.getListingModel().getProgram();
Program otherProgram = lp.getListingModel().getProgram(); Program otherProgram = lp.getListingModel().getProgram();
String myName = "<EMPTY>"; String myName = "<EMPTY>";

View file

@ -15,16 +15,11 @@
*/ */
package docking.widgets; package docking.widgets;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import docking.widgets.label.GDHtmlLabel; import docking.widgets.label.GDHtmlLabel;
import docking.widgets.label.GDLabel; import docking.widgets.label.GDLabel;
@ -34,42 +29,36 @@ import docking.widgets.label.GDLabel;
* components (usually icon buttons) * components (usually icon buttons)
*/ */
public class TitledPanel extends JPanel { public class TitledPanel extends JPanel {
private JLabel title; // GDLabel or GHtmlLabel private JLabel titleLabel;
private JPanel titlePanel; private JPanel titlePanel;
private JPanel iconPanel; private JPanel iconPanel;
private JComponent bottomComp; private JComponent bottomComp;
private List<JComponent> titleComps = new ArrayList<>(); private List<JComponent> 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 * 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 * title text. Note: it is up to the client to escape this text as needed for safety
* @param panel the component to wrap * @param panel the component to wrap
* @param margin the size of the margin to use * @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()); super(new BorderLayout());
titlePanel = new JPanel(new BorderLayout()); titlePanel = new JPanel(new BorderLayout());
iconPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 1)); iconPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 4, 1));
iconPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); 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(); JLabel filler = new GDLabel();
filler.setPreferredSize(new Dimension(margin, filler.getPreferredSize().height)); filler.setPreferredSize(new Dimension(margin, filler.getPreferredSize().height));
titlePanel.add(filler, BorderLayout.WEST); titlePanel.add(filler, BorderLayout.WEST);
titlePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); titlePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
titlePanel.add(title, BorderLayout.CENTER); titlePanel.add(titleLabel, BorderLayout.CENTER);
titlePanel.add(iconPanel, BorderLayout.EAST); titlePanel.add(iconPanel, BorderLayout.EAST);
add(titlePanel, BorderLayout.NORTH); add(titlePanel, BorderLayout.NORTH);
@ -77,8 +66,8 @@ public class TitledPanel extends JPanel {
} }
public void setTitleName(String name) { public void setTitleName(String name) {
title.setText(name); titleLabel.setText(name);
title.setToolTipText(name); titleLabel.setToolTipText(name);
} }
/** /**

View file

@ -16,6 +16,7 @@
package ghidra.framework.model; package ghidra.framework.model;
import ghidra.framework.store.FileSystem; import ghidra.framework.store.FileSystem;
import ghidra.util.StringUtilities;
public class DomainObjectDisplayUtils { public class DomainObjectDisplayUtils {
private static final String VERSION_SEP = "@"; private static final String VERSION_SEP = "@";
@ -24,13 +25,16 @@ public class DomainObjectDisplayUtils {
private static final String PROJECT_SEP_ELLIPSES = private static final String PROJECT_SEP_ELLIPSES =
":" + FileSystem.SEPARATOR + "..." + FileSystem.SEPARATOR; ":" + FileSystem.SEPARATOR + "..." + FileSystem.SEPARATOR;
private static final int TOOLTIP_PATH_LENGTH_LIMIT = 100;
private static final int TAB_NAME_LENGTH_LIMIT = 40;
private DomainObjectDisplayUtils() { private DomainObjectDisplayUtils() {
} }
public static String getShortPath(DomainFile df) { public static String getShortPath(DomainFile df) {
String pathString = df.toString(); String pathString = df.toString();
int length = pathString.length(); int length = pathString.length();
if (length < 100) { if (length < TOOLTIP_PATH_LENGTH_LIMIT) {
return pathString; return pathString;
} }
@ -60,14 +64,16 @@ public class DomainObjectDisplayUtils {
public static String getTabText(DomainFile df) { public static String getTabText(DomainFile df) {
String tabName = df.getName(); String tabName = df.getName();
if (df.isReadOnly()) { String trimmedName = StringUtilities.trimMiddle(tabName, TAB_NAME_LENGTH_LIMIT);
if (!df.isReadOnly()) {
return trimmedName;
}
int version = df.getVersion(); int version = df.getVersion();
if (!df.canSave() && version != DomainFile.DEFAULT_VERSION) { if (!df.canSave() && version != DomainFile.DEFAULT_VERSION) {
tabName += VERSION_SEP + version; trimmedName += VERSION_SEP + version;
} }
tabName = tabName + READ_ONLY; return trimmedName + READ_ONLY;
}
return tabName;
} }
public static String getTabText(DomainObject object) { public static String getTabText(DomainObject object) {