GP-626 - Fixed bad title text appending

Closes #2506
This commit is contained in:
dragonmacher 2021-01-25 15:18:33 -05:00
parent b5c7e7104c
commit 6e77720f7f
4 changed files with 26 additions and 4 deletions

View file

@ -48,8 +48,10 @@ public abstract class AbstractErrDialog extends DialogComponentProvider {
abstract int getExceptionCount(); abstract int getExceptionCount();
abstract String getBaseTitle();
void updateTitle() { void updateTitle() {
setTitle(getTitle() + ERRORS_PREFIX + getExceptionCount() + ERRORS_SUFFIX); setTitle(getBaseTitle() + ERRORS_PREFIX + getExceptionCount() + ERRORS_SUFFIX);
} }
void setClosedCallback(Callback callback) { void setClosedCallback(Callback callback) {

View file

@ -71,6 +71,7 @@ public class ErrLogDialog extends AbstractErrDialog {
private static ErrorReporter errorReporter; private static ErrorReporter errorReporter;
private List<ErrorEntry> errors = new ArrayList<>(); private List<ErrorEntry> errors = new ArrayList<>();
private String baseTitle;
public static ErrLogDialog createExceptionDialog(String title, String message, Throwable t) { public static ErrLogDialog createExceptionDialog(String title, String message, Throwable t) {
return new ErrLogDialog(title, message, t); return new ErrLogDialog(title, message, t);
@ -79,6 +80,8 @@ public class ErrLogDialog extends AbstractErrDialog {
private ErrLogDialog(String title, String message, Throwable throwable) { private ErrLogDialog(String title, String message, Throwable throwable) {
super(title != null ? title : "Error"); super(title != null ? title : "Error");
baseTitle = getTitle();
ErrorEntry error = new ErrorEntry(message, throwable); ErrorEntry error = new ErrorEntry(message, throwable);
errors.add(error); errors.add(error);
@ -246,6 +249,11 @@ public class ErrLogDialog extends AbstractErrDialog {
return errors.size(); return errors.size();
} }
@Override
String getBaseTitle() {
return baseTitle;
}
private class ErrorDetailsSplitPane extends JSplitPane { private class ErrorDetailsSplitPane extends JSplitPane {
private final double TOP_PREFERRED_RESIZE_WEIGHT = .80; private final double TOP_PREFERRED_RESIZE_WEIGHT = .80;
@ -323,7 +331,7 @@ public class ErrLogDialog extends AbstractErrDialog {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
model = new ErrEntryTableModel(); model = new ErrEntryTableModel();
errorsTable = new GTable(model); errorsTable = new GTable(model);
tableFilterPanel = new GTableFilterPanel<ErrorEntry>(errorsTable, model); tableFilterPanel = new GTableFilterPanel<>(errorsTable, model);
errorsTable.getSelectionManager().addListSelectionListener(e -> { errorsTable.getSelectionManager().addListSelectionListener(e -> {
if (e.getValueIsAdjusting()) { if (e.getValueIsAdjusting()) {
@ -458,7 +466,7 @@ public class ErrLogDialog extends AbstractErrDialog {
@Override @Override
protected TableColumnDescriptor<ErrorEntry> createTableColumnDescriptor() { protected TableColumnDescriptor<ErrorEntry> createTableColumnDescriptor() {
TableColumnDescriptor<ErrorEntry> descriptor = new TableColumnDescriptor<ErrorEntry>(); TableColumnDescriptor<ErrorEntry> descriptor = new TableColumnDescriptor<>();
descriptor.addVisibleColumn(new IdColumn(), 1, true); descriptor.addVisibleColumn(new IdColumn(), 1, true);
descriptor.addVisibleColumn(new MessageColumn()); descriptor.addVisibleColumn(new MessageColumn());
descriptor.addHiddenColumn(new DetailsColumn()); descriptor.addHiddenColumn(new DetailsColumn());

View file

@ -55,6 +55,7 @@ public class ErrLogExpandableDialog extends AbstractErrDialog {
protected ReportRootNode root; protected ReportRootNode root;
protected GTree tree; protected GTree tree;
private List<Throwable> errors = new ArrayList<>(); private List<Throwable> errors = new ArrayList<>();
private String baseTitle;
/** This spacer addresses the optical impression that the message panel changes size when showing details */ /** This spacer addresses the optical impression that the message panel changes size when showing details */
protected Component horizontalSpacer; protected Component horizontalSpacer;
@ -66,6 +67,7 @@ public class ErrLogExpandableDialog extends AbstractErrDialog {
protected ErrLogExpandableDialog(String title, String msg, Throwable throwable) { protected ErrLogExpandableDialog(String title, String msg, Throwable throwable) {
super(title); super(title);
baseTitle = title;
errors.add(throwable); errors.add(throwable);
popup = new JPopupMenu(); popup = new JPopupMenu();
@ -272,6 +274,11 @@ public class ErrLogExpandableDialog extends AbstractErrDialog {
return root.getChildCount(); return root.getChildCount();
} }
@Override
String getBaseTitle() {
return baseTitle;
}
@Override @Override
public String getMessage() { public String getMessage() {
return root.getReportText(); return root.getReportText();
@ -389,7 +396,7 @@ public class ErrLogExpandableDialog extends AbstractErrDialog {
@Override @Override
protected List<GTreeNode> generateChildren() { protected List<GTreeNode> generateChildren() {
List<GTreeNode> list = new ArrayList<GTreeNode>(); List<GTreeNode> list = new ArrayList<>();
list.add(new ReportStackTraceNode(exc)); list.add(new ReportStackTraceNode(exc));
Throwable c = exc.getCause(); Throwable c = exc.getCause();
if (c != null) { if (c != null) {

View file

@ -66,6 +66,11 @@ public class DockingErrorDisplayTest extends AbstractDockingTest {
reportException(display, logger, new NullPointerException("It is null!")); reportException(display, logger, new NullPointerException("It is null!"));
assertExceptionCount(dialog, 2); assertExceptionCount(dialog, 2);
reportException(display, logger, new NullPointerException("It is null!"));
assertExceptionCount(dialog, 3);
assertEquals("Test Title (3 Errors)", dialog.getTitle());
close(dialog); close(dialog);
} }