Drop the line count from the Server Log window
The label under the log now only appears while loading, on a failure or for an empty log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -90,7 +90,8 @@ final class ServerLogDialog extends JDialog {
|
|||||||
private final Map<Level, JCheckBox> levelBoxes = new EnumMap<>(Level.class);
|
private final Map<Level, JCheckBox> levelBoxes = new EnumMap<>(Level.class);
|
||||||
private final JComboBox<String> timeZone = new JComboBox<>(new String[]{"UTC time", "Local time"});
|
private final JComboBox<String> timeZone = new JComboBox<>(new String[]{"UTC time", "Local time"});
|
||||||
private final JButton olderButton = new JButton("Show Older");
|
private final JButton olderButton = new JButton("Show Older");
|
||||||
private final JLabel status = new JLabel(" ");
|
/** Loading, failures and an empty log; hidden otherwise. */
|
||||||
|
private final JLabel status = new JLabel();
|
||||||
|
|
||||||
/** Everything read so far, oldest first. */
|
/** Everything read so far, oldest first. */
|
||||||
private final List<ServerLogEntry> entries = new ArrayList<>();
|
private final List<ServerLogEntry> entries = new ArrayList<>();
|
||||||
@@ -215,7 +216,7 @@ final class ServerLogDialog extends JDialog {
|
|||||||
bottom.setOpaque(false);
|
bottom.setOpaque(false);
|
||||||
bottom.add(status, BorderLayout.NORTH);
|
bottom.add(status, BorderLayout.NORTH);
|
||||||
bottom.add(row, BorderLayout.SOUTH);
|
bottom.add(row, BorderLayout.SOUTH);
|
||||||
status.setForeground(Theme.chatEvent());
|
status.setVisible(false);
|
||||||
return bottom;
|
return bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,8 +262,7 @@ final class ServerLogDialog extends JDialog {
|
|||||||
if (loading) return;
|
if (loading) return;
|
||||||
loading = true;
|
loading = true;
|
||||||
olderButton.setEnabled(false);
|
olderButton.setEnabled(false);
|
||||||
status.setForeground(Theme.chatEvent());
|
showStatus("Loading…", Theme.chatEvent());
|
||||||
status.setText("Loading…");
|
|
||||||
conn.requestServerLog(from, (page, error) -> SwingUtilities.invokeLater(() -> {
|
conn.requestServerLog(from, (page, error) -> SwingUtilities.invokeLater(() -> {
|
||||||
loading = false;
|
loading = false;
|
||||||
if (!isDisplayable()) return;
|
if (!isDisplayable()) return;
|
||||||
@@ -285,10 +285,10 @@ final class ServerLogDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void failed(String error) {
|
private void failed(String error) {
|
||||||
status.setForeground(Theme.isDark() ? new Color(0xFF6B6B) : new Color(0xC00000));
|
showStatus(error.toLowerCase(Locale.ROOT).contains("insufficient")
|
||||||
status.setText(error.toLowerCase(Locale.ROOT).contains("insufficient")
|
|
||||||
? "Insufficient permissions to view Server Log"
|
? "Insufficient permissions to view Server Log"
|
||||||
: "Error requesting server log: " + error);
|
: "Error requesting server log: " + error,
|
||||||
|
Theme.isDark() ? new Color(0xFF6B6B) : new Color(0xC00000));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void settingsChanged() {
|
private void settingsChanged() {
|
||||||
@@ -304,7 +304,6 @@ final class ServerLogDialog extends JDialog {
|
|||||||
for (ServerLogEntry e : entries) channelWidth = Math.max(channelWidth, e.channel().length());
|
for (ServerLogEntry e : entries) channelWidth = Math.max(channelWidth, e.channel().length());
|
||||||
|
|
||||||
int scrollY = log.getVisibleRect().y;
|
int scrollY = log.getVisibleRect().y;
|
||||||
int shown = 0;
|
|
||||||
try {
|
try {
|
||||||
doc.remove(0, doc.getLength());
|
doc.remove(0, doc.getLength());
|
||||||
for (ServerLogEntry e : entries) {
|
for (ServerLogEntry e : entries) {
|
||||||
@@ -312,16 +311,12 @@ final class ServerLogDialog extends JDialog {
|
|||||||
if (!view.shows(e.level(), line)) continue;
|
if (!view.shows(e.level(), line)) continue;
|
||||||
if (onlyMatching != null && !onlyMatching.matches(line)) continue;
|
if (onlyMatching != null && !onlyMatching.matches(line)) continue;
|
||||||
doc.insertString(doc.getLength(), line + "\n", style(view.highlightFor(line)));
|
doc.insertString(doc.getLength(), line + "\n", style(view.highlightFor(line)));
|
||||||
shown++;
|
|
||||||
}
|
}
|
||||||
} catch (BadLocationException ignored) {
|
} catch (BadLocationException ignored) {
|
||||||
// appending at the end never fails
|
// appending at the end never fails
|
||||||
}
|
}
|
||||||
|
|
||||||
status.setForeground(Theme.chatEvent());
|
showStatus(entries.isEmpty() ? "No log entries available" : null, Theme.chatEvent());
|
||||||
if (entries.isEmpty()) status.setText("No log entries available");
|
|
||||||
else if (shown == entries.size()) status.setText(lines(shown));
|
|
||||||
else status.setText(shown + " of " + lines(entries.size()));
|
|
||||||
|
|
||||||
if (toEnd) {
|
if (toEnd) {
|
||||||
log.setCaretPosition(doc.getLength());
|
log.setCaretPosition(doc.getLength());
|
||||||
@@ -331,8 +326,11 @@ final class ServerLogDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String lines(int n) {
|
/** Shows {@code text} under the log, or hides the label for {@code null}. */
|
||||||
return n == 1 ? "1 line" : n + " lines";
|
private void showStatus(String text, Color color) {
|
||||||
|
status.setText(text);
|
||||||
|
status.setForeground(color);
|
||||||
|
status.setVisible(text != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String format(ServerLogEntry e, int channelWidth) {
|
private String format(ServerLogEntry e, int channelWidth) {
|
||||||
|
|||||||
Reference in New Issue
Block a user