oshi first
This commit is contained in:
parent
ea3b1c8a69
commit
049ea2ac71
|
@ -10,6 +10,7 @@ import com.luoboduner.moo.info.ui.component.TopMenuBar;
|
|||
import com.luoboduner.moo.info.ui.form.DetailForm;
|
||||
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.UIUtil;
|
||||
import com.luoboduner.moo.info.util.UpgradeUtil;
|
||||
|
@ -205,6 +206,7 @@ public class Init {
|
|||
ThreadUtil.execute(OverviewForm::init);
|
||||
ThreadUtil.execute(DetailForm::init);
|
||||
ThreadUtil.execute(NetworkForm::init);
|
||||
ThreadUtil.execute(UsbForm::init);
|
||||
|
||||
// Check the new version
|
||||
if (App.config.isAutoCheckUpdate()) {
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<grid row="0" 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"/>
|
||||
<border type="empty"/>
|
||||
<children>
|
||||
<grid id="1b97f" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="10" left="10" bottom="10" right="10"/>
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.intellij.uiDesigner.core.GridLayoutManager;
|
|||
import lombok.Getter;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.DefaultTreeModel;
|
||||
import java.awt.*;
|
||||
|
@ -94,6 +95,7 @@ public class DetailForm {
|
|||
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -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));
|
||||
scrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
|
||||
final JPanel panel1 = new JPanel();
|
||||
panel1.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
|
||||
scrollPane1.setViewportView(panel1);
|
||||
|
@ -107,4 +109,5 @@ public class DetailForm {
|
|||
public JComponent $$$getRootComponent$$$() {
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<grid id="3362e" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="3362e" binding="usbPanel" 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>
|
||||
<tabbedpane title="USB Devices"/>
|
||||
|
|
|
@ -20,6 +20,7 @@ public class MainWindow {
|
|||
private JPanel overviewPanel;
|
||||
private JPanel networkPanel;
|
||||
private JPanel detailPanel;
|
||||
private JPanel usbPanel;
|
||||
|
||||
private static MainWindow mainWindow;
|
||||
|
||||
|
@ -40,6 +41,7 @@ public class MainWindow {
|
|||
mainWindow.getOverviewPanel().add(OverviewForm.getInstance().getMainPanel(), gridConstraints);
|
||||
mainWindow.getDetailPanel().add(DetailForm.getInstance().getMainPanel(), gridConstraints);
|
||||
mainWindow.getNetworkPanel().add(NetworkForm.getInstance().getMainPanel(), gridConstraints);
|
||||
mainWindow.getUsbPanel().add(UsbForm.getInstance().getMainPanel(), gridConstraints);
|
||||
mainWindow.getMainPanel().updateUI();
|
||||
}
|
||||
|
||||
|
@ -87,9 +89,9 @@ public class MainWindow {
|
|||
final JPanel panel5 = new JPanel();
|
||||
panel5.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
tabbedPane.addTab("Processes", panel5);
|
||||
final JPanel panel6 = new JPanel();
|
||||
panel6.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
tabbedPane.addTab("USB Devices", panel6);
|
||||
usbPanel = new JPanel();
|
||||
usbPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
tabbedPane.addTab("USB Devices", usbPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
<children>
|
||||
<component id="82246" class="javax.swing.JTextPane" binding="parametersTextPane">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="50"/>
|
||||
</grid>
|
||||
<grid row="0" 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/>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
|
|
|
@ -177,7 +177,8 @@ public class NetworkForm {
|
|||
paramatersPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||
panel1.add(paramatersPanel, 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));
|
||||
parametersTextPane = new JTextPane();
|
||||
paramatersPanel.add(parametersTextPane, 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, new Dimension(150, 50), null, 0, false));
|
||||
parametersTextPane.setEditable(false);
|
||||
paramatersPanel.add(parametersTextPane, 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));
|
||||
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));
|
||||
interfacesTable = new JTable();
|
||||
|
@ -190,4 +191,5 @@ public class NetworkForm {
|
|||
public JComponent $$$getRootComponent$$$() {
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,9 @@
|
|||
<preferred-size width="150" height="50"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="b5a0f">
|
||||
<constraints>
|
||||
|
@ -69,7 +71,9 @@
|
|||
<preferred-size width="150" height="50"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="dc4a9">
|
||||
<constraints>
|
||||
|
|
|
@ -99,6 +99,7 @@ public class OverviewForm {
|
|||
final Spacer spacer1 = new Spacer();
|
||||
panel2.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
osTextPane = new JTextPane();
|
||||
osTextPane.setEditable(false);
|
||||
panel2.add(osTextPane, new GridConstraints(0, 1, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
|
||||
final Spacer spacer2 = new Spacer();
|
||||
panel2.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
|
@ -106,6 +107,7 @@ public class OverviewForm {
|
|||
label2.setText("Processor");
|
||||
panel2.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||
procTextPane = new JTextPane();
|
||||
procTextPane.setEditable(false);
|
||||
panel2.add(procTextPane, new GridConstraints(2, 1, 2, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 50), null, 0, false));
|
||||
final Spacer spacer3 = new Spacer();
|
||||
panel2.add(spacer3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?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.UsbForm">
|
||||
<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="cc196" layout-manager="GridLayoutManager" row-count="1" 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="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<scrollpane id="ae2ac">
|
||||
<constraints>
|
||||
<grid row="0" 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="c473" class="javax.swing.JTextPane" binding="infoPane">
|
||||
<constraints/>
|
||||
<properties>
|
||||
<editable value="false"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
|
@ -0,0 +1,100 @@
|
|||
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.luoboduner.moo.info.App;
|
||||
import lombok.Getter;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.hardware.UsbDevice;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* UsbForm
|
||||
*
|
||||
* @author <a href="https://github.com/rememberber">RememBerBer</a>
|
||||
* @since 2021/11/12.
|
||||
*/
|
||||
@Getter
|
||||
public class UsbForm {
|
||||
|
||||
private static final Log logger = LogFactory.get();
|
||||
|
||||
private static UsbForm usbForm;
|
||||
private JPanel mainPanel;
|
||||
private JTextPane infoPane;
|
||||
|
||||
public static UsbForm getInstance() {
|
||||
if (usbForm == null) {
|
||||
usbForm = new UsbForm();
|
||||
}
|
||||
return usbForm;
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
usbForm = getInstance();
|
||||
|
||||
initUi();
|
||||
initInfo();
|
||||
}
|
||||
|
||||
private static void initUi() {
|
||||
}
|
||||
|
||||
private static void initInfo() {
|
||||
JTextPane infoPane = getInstance().getInfoPane();
|
||||
infoPane.setText(getUsbString(App.si.getHardware()));
|
||||
}
|
||||
|
||||
private static String getUsbString(HardwareAbstractionLayer hal) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (UsbDevice usbDevice : hal.getUsbDevices(true)) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
sb.append('\n');
|
||||
}
|
||||
sb.append(usbDevice);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
{
|
||||
// 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(1, 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_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||
final JScrollPane scrollPane1 = new JScrollPane();
|
||||
panel1.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));
|
||||
infoPane = new JTextPane();
|
||||
infoPane.setEditable(false);
|
||||
scrollPane1.setViewportView(infoPane);
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection ALL
|
||||
*/
|
||||
public JComponent $$$getRootComponent$$$() {
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue