list, SystemInfo si) {
procArr[i][0] = pid;
procArr[i][1] = p.getParentProcessID();
procArr[i][2] = p.getThreadCount();
- {
+ if (processesForm.perProc.isSelected()) {
+ procArr[i][3] = String.format("%.1f",
+ 100d * p.getProcessCpuLoadBetweenTicks(priorSnapshotMap.get(pid)) / cpuCount);
+ procArr[i][4] = String.format("%.1f", 100d * p.getProcessCpuLoadCumulative() / cpuCount);
+ } else {
procArr[i][3] = String.format("%.1f",
100d * p.getProcessCpuLoadBetweenTicks(priorSnapshotMap.get(pid)));
procArr[i][4] = String.format("%.1f", 100d * p.getProcessCpuLoadCumulative());
@@ -166,6 +215,21 @@ private static void resizeColumns(TableColumnModel tableColumnModel) {
}
}
+ private static void resetSortByButtonGroup() {
+ processesForm = getInstance();
+
+ processesForm.cpuButton.setSelected(false);
+ processesForm.cumulativeCpuButton.setSelected(false);
+ processesForm.memButton.setSelected(false);
+ }
+
+ private static void resetCpuPercentButtonGroup() {
+ processesForm = getInstance();
+
+ processesForm.perProc.setSelected(false);
+ processesForm.perSystem.setSelected(false);
+ }
+
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
@@ -182,11 +246,37 @@ private static void resizeColumns(TableColumnModel tableColumnModel) {
*/
private void $$$setupUI$$$() {
mainPanel = new JPanel();
- mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(20, 20, 20, 20), -1, -1));
+ mainPanel.setLayout(new GridLayoutManager(2, 1, new Insets(20, 20, 20, 20), -1, -1));
final JScrollPane scrollPane1 = new JScrollPane();
- mainPanel.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
+ mainPanel.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
processTable = new JTable();
scrollPane1.setViewportView(processTable);
+ final JPanel panel1 = new JPanel();
+ panel1.setLayout(new GridLayoutManager(1, 8, new Insets(0, 0, 10, 0), -1, -1));
+ mainPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
+ final JLabel label1 = new JLabel();
+ label1.setText("Sort by: ");
+ panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ final Spacer spacer1 = new Spacer();
+ panel1.add(spacer1, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
+ final JLabel label2 = new JLabel();
+ label2.setText("CPU %: ");
+ panel1.add(label2, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ cpuButton = new JRadioButton();
+ cpuButton.setText("CPU %");
+ panel1.add(cpuButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ cumulativeCpuButton = new JRadioButton();
+ cumulativeCpuButton.setText("Cumulative CPU");
+ panel1.add(cumulativeCpuButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ memButton = new JRadioButton();
+ memButton.setText("Memory %");
+ panel1.add(memButton, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ perProc = new JRadioButton();
+ perProc.setText("of one Processor");
+ panel1.add(perProc, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ perSystem = new JRadioButton();
+ perSystem.setText("of System");
+ panel1.add(perSystem, new GridConstraints(0, 7, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
}
/**
diff --git a/src/main/java/com/luoboduner/moo/info/util/ConsoleUtil.java b/src/main/java/com/luoboduner/moo/info/util/ConsoleUtil.java
new file mode 100644
index 0000000..af7979b
--- /dev/null
+++ b/src/main/java/com/luoboduner/moo/info/util/ConsoleUtil.java
@@ -0,0 +1,36 @@
+package com.luoboduner.moo.info.util;
+
+import cn.hutool.log.Log;
+import cn.hutool.log.LogFactory;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import javax.swing.*;
+import java.util.Date;
+
+/**
+ *
+ * ConsoleUtil to print text into textarea
+ *
+ *
+ * @author RememBerBer
+ * @since 2021/12/15.
+ */
+@Slf4j
+public class ConsoleUtil {
+
+ private static final Log logger = LogFactory.get();
+
+ public static void consoleWithLog(JTextArea textArea, String log) {
+ textArea.append(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS") + " ");
+ textArea.append(log + "\n");
+ textArea.setCaretPosition(textArea.getText().length());
+ logger.warn(log);
+ }
+
+ public static void consoleOnly(JTextArea textArea, String log) {
+ textArea.append(log + "\n");
+ textArea.setCaretPosition(textArea.getText().length());
+ }
+
+}
diff --git a/src/main/java/com/luoboduner/moo/info/util/DateTimeUtil.java b/src/main/java/com/luoboduner/moo/info/util/DateTimeUtil.java
new file mode 100644
index 0000000..2dc8bef
--- /dev/null
+++ b/src/main/java/com/luoboduner/moo/info/util/DateTimeUtil.java
@@ -0,0 +1,14 @@
+package com.luoboduner.moo.info.util;
+
+public class DateTimeUtil {
+
+ public static String toReadableTime(long seconds) {
+ String readableTime;
+ int hours = (int) (seconds / 3600);
+ int minutes = (int) (seconds % 3600 / 60);
+ readableTime = String.format("%dh:%02dmin", hours, minutes);
+
+ return readableTime;
+ }
+
+}
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index 19f778a..d29c463 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -13,6 +13,11 @@
%date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} :%line - %msg%n
+
+ ERROR
+ ACCEPT
+ DENY
+
diff --git a/src/main/resources/version_summary.json b/src/main/resources/version_summary.json
index 8acae24..ecc3d99 100644
--- a/src/main/resources/version_summary.json
+++ b/src/main/resources/version_summary.json
@@ -1,8 +1,9 @@
{
- "currentVersion": "1.0.0",
+ "currentVersion": "1.1.0",
"versionIndex": {
"0.0.0": "0",
- "1.0.0": "1"
+ "1.0.0": "1",
+ "1.1.0": "2"
},
"versionDetailList": [
{
@@ -14,6 +15,11 @@
"version": "1.0.0",
"title": "The first version",
"log": "The first version\n"
+ },
+ {
+ "version": "1.1.0",
+ "title": "Some minor features and optimizations",
+ "log": "● update oshi-core to 5.8.6\n● update flatlaf to 2.0-rc1(Support Windows 11 snap layouts menu, macOS screen menu optimization)\n● processes sort method added same as the oshi's demo\n● add cpu usage chart\n● make System Boot Time and Uptime readable\n● add System Info Test function menu same as oshi-core\n"
}
]
}
\ No newline at end of file