oshi first
This commit is contained in:
parent
049ea2ac71
commit
1a7b88260f
|
@ -7,10 +7,7 @@ import com.formdev.flatlaf.FlatLightLaf;
|
||||||
import com.formdev.flatlaf.IntelliJTheme;
|
import com.formdev.flatlaf.IntelliJTheme;
|
||||||
import com.luoboduner.moo.info.App;
|
import com.luoboduner.moo.info.App;
|
||||||
import com.luoboduner.moo.info.ui.component.TopMenuBar;
|
import com.luoboduner.moo.info.ui.component.TopMenuBar;
|
||||||
import com.luoboduner.moo.info.ui.form.DetailForm;
|
import com.luoboduner.moo.info.ui.form.*;
|
||||||
import com.luoboduner.moo.info.ui.form.NetworkForm;
|
|
||||||
import com.luoboduner.moo.info.ui.form.OverviewForm;
|
|
||||||
import com.luoboduner.moo.info.ui.form.UsbForm;
|
|
||||||
import com.luoboduner.moo.info.util.SystemUtil;
|
import com.luoboduner.moo.info.util.SystemUtil;
|
||||||
import com.luoboduner.moo.info.util.UIUtil;
|
import com.luoboduner.moo.info.util.UIUtil;
|
||||||
import com.luoboduner.moo.info.util.UpgradeUtil;
|
import com.luoboduner.moo.info.util.UpgradeUtil;
|
||||||
|
@ -207,6 +204,7 @@ public class Init {
|
||||||
ThreadUtil.execute(DetailForm::init);
|
ThreadUtil.execute(DetailForm::init);
|
||||||
ThreadUtil.execute(NetworkForm::init);
|
ThreadUtil.execute(NetworkForm::init);
|
||||||
ThreadUtil.execute(UsbForm::init);
|
ThreadUtil.execute(UsbForm::init);
|
||||||
|
ThreadUtil.execute(VariablesForm::init);
|
||||||
|
|
||||||
// Check the new version
|
// Check the new version
|
||||||
if (App.config.isAutoCheckUpdate()) {
|
if (App.config.isAutoCheckUpdate()) {
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children/>
|
<children/>
|
||||||
</grid>
|
</grid>
|
||||||
<grid id="19d51" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="19d51" binding="VariablesPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<tabbedpane title="Variables"/>
|
<tabbedpane title="Variables"/>
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class MainWindow {
|
||||||
private JPanel networkPanel;
|
private JPanel networkPanel;
|
||||||
private JPanel detailPanel;
|
private JPanel detailPanel;
|
||||||
private JPanel usbPanel;
|
private JPanel usbPanel;
|
||||||
|
private JPanel VariablesPanel;
|
||||||
|
|
||||||
private static MainWindow mainWindow;
|
private static MainWindow mainWindow;
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ public class MainWindow {
|
||||||
mainWindow.getDetailPanel().add(DetailForm.getInstance().getMainPanel(), gridConstraints);
|
mainWindow.getDetailPanel().add(DetailForm.getInstance().getMainPanel(), gridConstraints);
|
||||||
mainWindow.getNetworkPanel().add(NetworkForm.getInstance().getMainPanel(), gridConstraints);
|
mainWindow.getNetworkPanel().add(NetworkForm.getInstance().getMainPanel(), gridConstraints);
|
||||||
mainWindow.getUsbPanel().add(UsbForm.getInstance().getMainPanel(), gridConstraints);
|
mainWindow.getUsbPanel().add(UsbForm.getInstance().getMainPanel(), gridConstraints);
|
||||||
|
mainWindow.getVariablesPanel().add(VariablesForm.getInstance().getMainPanel(), gridConstraints);
|
||||||
mainWindow.getMainPanel().updateUI();
|
mainWindow.getMainPanel().updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,12 +85,12 @@ public class MainWindow {
|
||||||
networkPanel = new JPanel();
|
networkPanel = new JPanel();
|
||||||
networkPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
networkPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
tabbedPane.addTab("Network", networkPanel);
|
tabbedPane.addTab("Network", networkPanel);
|
||||||
|
VariablesPanel = new JPanel();
|
||||||
|
VariablesPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
|
tabbedPane.addTab("Variables", VariablesPanel);
|
||||||
final JPanel panel4 = new JPanel();
|
final JPanel panel4 = new JPanel();
|
||||||
panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
panel4.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
tabbedPane.addTab("Variables", panel4);
|
tabbedPane.addTab("Processes", panel4);
|
||||||
final JPanel panel5 = new JPanel();
|
|
||||||
panel5.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
|
||||||
tabbedPane.addTab("Processes", panel5);
|
|
||||||
usbPanel = new JPanel();
|
usbPanel = new JPanel();
|
||||||
usbPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
usbPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
tabbedPane.addTab("USB Devices", usbPanel);
|
tabbedPane.addTab("USB Devices", usbPanel);
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.info.ui.form.VariablesForm">
|
||||||
|
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<xy x="20" y="20" width="500" height="400"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<grid id="39897" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<grid id="ab64d" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="aff44" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="System environment variables"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<hspacer id="93984">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</hspacer>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
<scrollpane id="e0692">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="7f29" class="javax.swing.JTable" binding="sysEnvVarTable">
|
||||||
|
<constraints/>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</scrollpane>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
</form>
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.luoboduner.moo.info.ui.form;
|
||||||
|
|
||||||
|
import cn.hutool.log.Log;
|
||||||
|
import cn.hutool.log.LogFactory;
|
||||||
|
import com.intellij.uiDesigner.core.GridConstraints;
|
||||||
|
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||||
|
import com.intellij.uiDesigner.core.Spacer;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VariablesForm
|
||||||
|
*
|
||||||
|
* @author <a href="https://github.com/rememberber">RememBerBer</a>
|
||||||
|
* @since 2021/11/12.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class VariablesForm {
|
||||||
|
private static final Log logger = LogFactory.get();
|
||||||
|
|
||||||
|
private static VariablesForm variablesForm;
|
||||||
|
private JPanel mainPanel;
|
||||||
|
private JTable sysEnvVarTable;
|
||||||
|
|
||||||
|
public static VariablesForm getInstance() {
|
||||||
|
if (variablesForm == null) {
|
||||||
|
variablesForm = new VariablesForm();
|
||||||
|
}
|
||||||
|
return variablesForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
variablesForm = getInstance();
|
||||||
|
|
||||||
|
initUi();
|
||||||
|
initInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initUi() {
|
||||||
|
getInstance().getSysEnvVarTable().setShowGrid(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initInfo() {
|
||||||
|
initListTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initListTable() {
|
||||||
|
String[] headerNames = {"Key", "Value"};
|
||||||
|
DefaultTableModel model = new DefaultTableModel(null, headerNames);
|
||||||
|
|
||||||
|
Map<String, String> map = System.getenv();
|
||||||
|
Object[] data;
|
||||||
|
for (Map.Entry<String, String> envEntry : map.entrySet()) {
|
||||||
|
data = new Object[2];
|
||||||
|
data[0] = envEntry.getKey();
|
||||||
|
data[1] = envEntry.getValue();
|
||||||
|
model.addRow(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
getInstance().getSysEnvVarTable().setModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||||
|
// >>> IMPORTANT!! <<<
|
||||||
|
// DO NOT EDIT OR ADD ANY CODE HERE!
|
||||||
|
$$$setupUI$$$();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method generated by IntelliJ IDEA GUI Designer
|
||||||
|
* >>> IMPORTANT!! <<<
|
||||||
|
* DO NOT edit this method OR call it in your code!
|
||||||
|
*
|
||||||
|
* @noinspection ALL
|
||||||
|
*/
|
||||||
|
private void $$$setupUI$$$() {
|
||||||
|
mainPanel = new JPanel();
|
||||||
|
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
|
final JPanel panel1 = new JPanel();
|
||||||
|
panel1.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -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 JPanel panel2 = new JPanel();
|
||||||
|
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
|
panel1.add(panel2, 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("System environment variables");
|
||||||
|
panel2.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();
|
||||||
|
panel2.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
||||||
|
final JScrollPane scrollPane1 = new JScrollPane();
|
||||||
|
panel1.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));
|
||||||
|
sysEnvVarTable = new JTable();
|
||||||
|
scrollPane1.setViewportView(sysEnvVarTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @noinspection ALL
|
||||||
|
*/
|
||||||
|
public JComponent $$$getRootComponent$$$() {
|
||||||
|
return mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue