You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/12/04 15:42:28 UTC

[isis] branch master updated (df17929 -> 5efa8d5)

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.


 discard df17929  ISIS-2903: Xray: adds timestamps to log-entires
     new 5efa8d5  ISIS-2903: Xray: adds timestamps to log-entires

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (df17929)
            \
             N -- N -- N   refs/heads/master (5efa8d5)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:

[isis] 01/01: ISIS-2903: Xray: adds timestamps to log-entires

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 5efa8d5e81b72d7ad2a70f3b1b9846c30991b14a
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat Dec 4 16:40:43 2021 +0100

    ISIS-2903: Xray: adds timestamps to log-entires
    
    - in a multi-threaded history we need a way to tell which call-stack
    happened first
---
 .../apache/isis/commons/internal/debug/_Xray.java  |  5 +-
 .../internal/debug/xray/JavaApplication78.java     | 76 ++++++++++++++++++++++
 .../commons/internal/debug/xray/XrayDataModel.java | 21 ++++--
 .../commons/internal/debug/xray/_SwingUtil.java    | 19 ++++++
 4 files changed, 116 insertions(+), 5 deletions(-)

diff --git a/commons/src/main/java/org/apache/isis/commons/internal/debug/_Xray.java b/commons/src/main/java/org/apache/isis/commons/internal/debug/_Xray.java
index 8712766..a64688d 100644
--- a/commons/src/main/java/org/apache/isis/commons/internal/debug/_Xray.java
+++ b/commons/src/main/java/org/apache/isis/commons/internal/debug/_Xray.java
@@ -18,6 +18,8 @@
  */
 package org.apache.isis.commons.internal.debug;
 
+import java.time.LocalDateTime;
+
 import org.apache.isis.commons.collections.Can;
 import org.apache.isis.commons.internal.base._Strings;
 import org.apache.isis.commons.internal.debug.xray.XrayDataModel;
@@ -40,13 +42,14 @@ final class _Xray {
         }
 
         val threadId = ThreadMemento.fromCurrentThread();
+        val timeStamp = LocalDateTime.now();
 
         XrayUi.updateModel(model->{
             val parentNode = model.getThreadNode(threadId);
 
             val logModel = model.addDataNode(parentNode,
                     new XrayDataModel.LogEntry(
-                            "debug-log",
+                            "debug-log", timeStamp,
                             _Strings.ellipsifyAtEnd(logMessage, 80, "..."),
                             logMessage,
                             Stickiness.CAN_DELETE_NODE));
diff --git a/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/JavaApplication78.java b/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/JavaApplication78.java
new file mode 100644
index 0000000..8c45336
--- /dev/null
+++ b/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/JavaApplication78.java
@@ -0,0 +1,76 @@
+package org.apache.isis.commons.internal.debug.xray;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.EventQueue;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.util.ArrayList;
+
+import javax.swing.BorderFactory;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.border.Border;
+
+public class JavaApplication78 {
+    JFrame frame;
+    JPanel panel, labelsPanel;
+    JLabel label;
+    ArrayList<String> names = new ArrayList<String>();
+    ArrayList<JLabel> labelsArray = new ArrayList<JLabel>();
+    Border paddingBorder = BorderFactory.createEmptyBorder(10, 10, 10, 10);
+    Border border = BorderFactory.createLineBorder(Color.BLUE);
+    JScrollPane labelsScroll;
+
+    public JavaApplication78() {
+        frame = new JFrame();
+        panel = new JPanel(new BorderLayout());
+        names.add(".mp3");
+        names.add(".html");
+        names.add(".jpeg");
+        names.add(".mp4");
+        names.add(".pdf");
+
+        labelsPanel = new JPanel(new GridBagLayout());
+        GridBagConstraints gbc = new GridBagConstraints();
+        gbc.weightx = 1;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        gbc.gridwidth = GridBagConstraints.REMAINDER;
+
+        labelsScroll = new JScrollPane(labelsPanel);
+        for (String format : names) {
+            label = new JLabel(format);
+            //icon
+            labelsArray.add(label);
+            labelsPanel.add(label, gbc);
+            label.setBorder(BorderFactory.createCompoundBorder(border, paddingBorder));
+        }
+
+        panel.add(labelsScroll, BorderLayout.CENTER);
+        frame.add(panel);
+        frame.setSize(200, 400);
+        frame.setLocationRelativeTo(null);
+        frame.setVisible(true);
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    }
+
+    public static void main(final String[] args) {
+        EventQueue.invokeLater(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+                } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
+                    ex.printStackTrace();
+                }
+
+                new JavaApplication78();
+            }
+        });
+    }
+
+}
diff --git a/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/XrayDataModel.java b/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/XrayDataModel.java
index 833456e..c5677cd 100644
--- a/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/XrayDataModel.java
+++ b/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/XrayDataModel.java
@@ -21,6 +21,8 @@ package org.apache.isis.commons.internal.debug.xray;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Graphics2D;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -29,6 +31,7 @@ import java.util.UUID;
 
 import javax.swing.BorderFactory;
 import javax.swing.JEditorPane;
+import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 
@@ -100,6 +103,7 @@ public abstract class XrayDataModel extends HasIdAndLabel {
         private final List<StackTraceElement> data = new ArrayList<>();
 
         private final String id;
+        private final LocalDateTime timestamp;
         private final String label;
         private final String logMessage;
         private final @NonNull Stickiness stickiness;
@@ -117,10 +121,19 @@ public abstract class XrayDataModel extends HasIdAndLabel {
 
             // log message label
 
-            val editorPane = new JEditorPane();
-            editorPane.setEditable(false);
-            editorPane.setText(logMessage);
-            panel2.add(editorPane, BorderLayout.NORTH);
+            val logMessagePane = new JEditorPane();
+            logMessagePane.setEditable(false);
+            logMessagePane.setText(logMessage);
+
+            val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
+
+            val timestampLabel = new JLabel(timestamp.format(formatter));
+
+            panel2.add(
+                    _SwingUtil.verticalBox(
+                            timestampLabel,
+                            logMessagePane),
+                    BorderLayout.NORTH);
 
             // table rendering
 
diff --git a/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/_SwingUtil.java b/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/_SwingUtil.java
index 5670991..0723561 100644
--- a/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/_SwingUtil.java
+++ b/commons/src/main/java/org/apache/isis/commons/internal/debug/xray/_SwingUtil.java
@@ -21,6 +21,9 @@ package org.apache.isis.commons.internal.debug.xray;
 import java.awt.Component;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
 import java.util.Collections;
 import java.util.function.Consumer;
 
@@ -87,4 +90,20 @@ final class _SwingUtil {
         return canvas;
     }
 
+    public static Component verticalBox(final Component ...components) {
+
+        val panel = new JPanel(new GridBagLayout());
+        val gbc = new GridBagConstraints();
+        gbc.weightx = 1;
+        gbc.fill = GridBagConstraints.HORIZONTAL;
+        gbc.gridwidth = GridBagConstraints.REMAINDER;
+        gbc.insets = new Insets(3, 6, 3, 6);
+
+        for(val component : components) {
+            panel.add(component, gbc);
+        }
+
+        return panel;
+    }
+
 }