simplified about component, extraction to its own package
diff --git a/src/main/java/org/apache/log4j/chainsaw/ChainsawAbout.java b/src/main/java/org/apache/log4j/chainsaw/ChainsawAbout.java
deleted file mode 100644
index 06b1a93..0000000
--- a/src/main/java/org/apache/log4j/chainsaw/ChainsawAbout.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.chainsaw;
-
-import org.apache.log4j.chainsaw.help.HelpManager;
-
-import javax.swing.*;
-import javax.swing.event.HyperlinkEvent;
-import java.awt.*;
-import java.io.IOException;
-
-import org.apache.log4j.chainsaw.logui.LogUI;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-/**
- * A simple About box telling people stuff about this project
- *
- * @author Paul Smith <psmith@apache.org>
- */
-public class ChainsawAbout extends JDialog {
- private static final Logger LOG = LogManager.getLogger();
-
- private final JEditorPane editPane = new JEditorPane("text/html", "");
-
- private final JScrollPane scrollPane = new JScrollPane(editPane,
- ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
-
- private boolean sleep = false;
-
- private final Object guard = new Object();
-
- public ChainsawAbout(LogUI logUI) {
- super(logUI, "About Chainsaw v2", true);
- setBackground(Color.white);
- getContentPane().setLayout(new BorderLayout());
-
- JButton closeButton = new JButton(" Close ");
- closeButton.addActionListener(e -> setVisible(false));
- closeButton.setDefaultCapable(true);
-
- try {
- String url = ChainsawAbout.class.getName().replace('.', '/') + ".html";
- editPane.setPage(this.getClass().getClassLoader().getResource(url));
- } catch (IOException e) {
- throw new RuntimeException("Failed to find the About panel HTML", e);
- }
-
- getContentPane().add(scrollPane, BorderLayout.CENTER);
- getContentPane().add(closeButton, BorderLayout.SOUTH);
-
- JTextComponentFormatter.applySystemFontAndSize(editPane);
-
- editPane.setEditable(false);
- editPane.addHyperlinkListener(
- e -> {
- if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
- HelpManager.getInstance().setHelpURL(e.getURL());
- }
- });
-
- setSize(320, 240);
- new Thread(new Scroller()).start();
- scrollPane.getViewport().setViewPosition(new Point(0, 0));
-
- setLocationRelativeTo(logUI);
- }
-
- private class Scroller implements Runnable {
-
- public void run() {
- while (true) {
- try {
- if (sleep) {
- synchronized (guard) {
- guard.wait();
- }
- SwingUtilities.invokeLater(() -> scrollPane.getViewport().setViewPosition(
- new Point(0, 0)));
- continue;
- }
- SwingUtilities.invokeLater(() -> scrollPane.getViewport().setViewPosition(
- new Point(0, scrollPane.getViewport()
- .getViewPosition().y + 1)));
- Thread.sleep(100);
- } catch (Exception e) {
- LOG.error("Error during scrolling", e);
- }
-
- }
- }
- }
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- sleep = !visible;
- synchronized (guard) {
- guard.notifyAll();
- }
- }
-}
diff --git a/src/main/java/org/apache/log4j/chainsaw/components/about/ChainsawAbout.java b/src/main/java/org/apache/log4j/chainsaw/components/about/ChainsawAbout.java
new file mode 100644
index 0000000..50ae52e
--- /dev/null
+++ b/src/main/java/org/apache/log4j/chainsaw/components/about/ChainsawAbout.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.chainsaw.components.about;
+
+import org.apache.log4j.chainsaw.JTextComponentFormatter;
+import org.apache.log4j.chainsaw.help.HelpManager;
+
+import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
+import java.awt.*;
+import java.io.IOException;
+import java.net.URL;
+
+import org.apache.log4j.chainsaw.logui.LogUI;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ * A simple About box telling people stuff about this project
+ *
+ * @author Paul Smith <psmith@apache.org>
+ */
+public class ChainsawAbout extends JDialog {
+ private static final Logger LOG = LogManager.getLogger(ChainsawAbout.class);
+
+ private final LogUI logUI;
+
+ public ChainsawAbout(LogUI logUI) {
+ super(logUI, "About Chainsaw v2", true);
+ this.logUI = logUI;
+ setBackground(Color.white);
+ getContentPane().setLayout(new BorderLayout());
+
+ JButton closeButton = new JButton(" Close ");
+ closeButton.addActionListener(e -> setVisible(false));
+ closeButton.setDefaultCapable(true);
+
+ JEditorPane editPane = new JEditorPane("text/html", "");
+ try {
+ URL url = ClassLoader.getSystemResource("pages/about.html");
+ editPane.setPage(url);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to find the about panel HTML", e);
+ }
+
+ JScrollPane scrollPane = new JScrollPane(
+ editPane,
+ ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+
+ getContentPane().add(scrollPane, BorderLayout.CENTER);
+ getContentPane().add(closeButton, BorderLayout.SOUTH);
+
+ editPane.setEditable(false);
+ editPane.addHyperlinkListener(
+ e -> {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ HelpManager.getInstance().setHelpURL(e.getURL());
+ }
+ });
+
+ calculateDimentions();
+ scrollPane.getViewport().setViewPosition(new Point(0, 0));
+ setLocationRelativeTo(logUI);
+ }
+
+ /**
+ * Calculates the dimensions of the about panel based on the parents component (logUI).
+ * The default dimensions are 10% smaller than the parent component, except the height/width
+ * are 400 or below. In that case the same dimensions of the parent component are taken.
+ */
+ public void calculateDimentions() {
+ Dimension size = logUI.getSize();
+ double height = size.getHeight();
+ double width = size.getWidth();
+ if (height > 400) {
+ height = height - (height * 0.10);
+ }
+ if (width > 400) {
+ width = width - (width * 0.10);
+ }
+ setSize((int)width, (int)height);
+
+ }
+}
diff --git a/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java
index 323b504..db1380e 100644
--- a/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java
@@ -19,6 +19,7 @@
import org.apache.commons.configuration2.AbstractConfiguration;
import org.apache.log4j.chainsaw.*;
+import org.apache.log4j.chainsaw.components.about.ChainsawAbout;
import org.apache.log4j.chainsaw.components.elements.SmallButton;
import org.apache.log4j.chainsaw.components.logpanel.LogPanel;
import org.apache.log4j.chainsaw.components.tabbedpane.ChainsawTabbedPane;
@@ -413,6 +414,8 @@
public void showAboutBox() {
if (aboutBox == null) {
aboutBox = new ChainsawAbout(this);
+ } else {
+ aboutBox.calculateDimentions();
}
aboutBox.setVisible(true);
diff --git a/src/main/resources/pages/about.html b/src/main/resources/pages/about.html
new file mode 100644
index 0000000..b985288
--- /dev/null
+++ b/src/main/resources/pages/about.html
@@ -0,0 +1,31 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+ <link rel="stylesheet" href="stylesheet.css" type="text/css">
+</head>
+
+<body>
+ <img align="top" src="img/logo.png" border="0" alt="Log4j Logo">
+ <h1>Chainsaw v2</h1>
+ <p>Brought to you by the Apache Logging Services Project team.</p>
+ <p>Please send questions, bug reports and/or feature requests to <b>dev@logging.apache.org</b></p>
+ <p>Website: <b>https://logging.apache.org</b></p>
+</body>
+</html>
diff --git a/src/main/resources/pages/img/logo.png b/src/main/resources/pages/img/logo.png
new file mode 100644
index 0000000..9ad3d2c
--- /dev/null
+++ b/src/main/resources/pages/img/logo.png
Binary files differ
diff --git a/src/main/resources/pages/stylesheet.css b/src/main/resources/pages/stylesheet.css
new file mode 100644
index 0000000..90dd5a5
--- /dev/null
+++ b/src/main/resources/pages/stylesheet.css
@@ -0,0 +1,33 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+ body {
+ font-size: 1.2em;
+ color: #000000;
+ font-family: Helvetica, Arial, sans-serif;
+}
+
+h1 {
+ font-size: 1.5em;
+ font-weight: bold;
+}
+
+h2 {
+ font-size: 1.3em;
+ font-weight: bold;
+}