overview form

This commit is contained in:
rememberber 2021-11-21 15:08:02 +08:00
parent 5ced53273c
commit a1f4a332da
2 changed files with 101 additions and 14 deletions

View File

@ -82,8 +82,8 @@
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="9c58e" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<grid id="9c58e" layout-manager="GridLayoutManager" row-count="9" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="20" bottom="10" right="10"/>
<constraints>
<grid row="2" 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>
@ -146,6 +146,22 @@
<text value="SoundCard"/>
</properties>
</component>
<component id="75dd2" class="javax.swing.JLabel" binding="powerSourceLabel" default-binding="true">
<constraints>
<grid row="7" 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="PowerSource"/>
</properties>
</component>
<component id="7aeab" class="javax.swing.JLabel" binding="firmwareLabel" default-binding="true">
<constraints>
<grid row="8" 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="Firmware"/>
</properties>
</component>
<component id="2892f" class="javax.swing.JLabel" binding="cpuInfo">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@ -202,6 +218,22 @@
<text value="SoundCard info"/>
</properties>
</component>
<component id="296a5" class="javax.swing.JLabel" binding="powerSourceInfoLabel" default-binding="true">
<constraints>
<grid row="7" column="1" 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="PowerSource info"/>
</properties>
</component>
<component id="e6b68" class="javax.swing.JLabel" binding="firmwareInfoLabel" default-binding="true">
<constraints>
<grid row="8" column="1" 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="Firmware info"/>
</properties>
</component>
<hspacer id="84083">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
@ -210,7 +242,7 @@
</children>
</grid>
<grid id="b1d65" 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="10" bottom="0" right="0"/>
<margin top="0" left="10" bottom="0" right="10"/>
<constraints>
<grid row="1" 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>

View File

@ -53,6 +53,10 @@ public class OverviewForm {
private JLabel displayLabel;
private JLabel soundCardLabel;
private JLabel soundCardInfoLabel;
private JLabel powerSourceLabel;
private JLabel powerSourceInfoLabel;
private JLabel firmwareInfoLabel;
private JLabel firmwareLabel;
public static OverviewForm getInstance() {
if (overviewForm == null) {
@ -81,6 +85,8 @@ public class OverviewForm {
Style.emphaticLabelFont(overviewForm.getDiskStorageLabel());
Style.emphaticLabelFont(overviewForm.getDisplayLabel());
Style.emphaticLabelFont(overviewForm.getSoundCardLabel());
Style.emphaticLabelFont(overviewForm.getPowerSourceLabel());
Style.emphaticLabelFont(overviewForm.getFirmwareLabel());
}
private static void initInfo() {
@ -101,6 +107,8 @@ public class OverviewForm {
overviewForm.getDiskStorageInfoLabel().setText(getDiskStorageInfo(hardware));
overviewForm.getDisplayInfoLabel().setText(getDisplayInfo(hardware));
overviewForm.getSoundCardInfoLabel().setText(getSoundCardInfo(hardware));
overviewForm.getPowerSourceInfoLabel().setText(getPowerSourceInfo(hardware));
overviewForm.getFirmwareInfoLabel().setText(getFirmware(hardware));
List<NetworkIF> networkIFs = hardware.getNetworkIFs();
for (NetworkIF networkIF : networkIFs) {
@ -111,15 +119,6 @@ public class OverviewForm {
Firmware firmware = hardware.getComputerSystem().getFirmware();
System.err.println(firmware.toString());
List<SoundCard> soundCards = hardware.getSoundCards();
for (SoundCard soundCard : soundCards) {
System.err.println(soundCard.toString());
}
List<PowerSource> powerSources = hardware.getPowerSources();
for (PowerSource powerSource : powerSources) {
System.err.println(powerSource.toString());
}
}
/**
@ -263,6 +262,50 @@ public class OverviewForm {
return StringUtils.join(detailList, " + ");
}
/**
* PowerSourceInfo
*
* @param hardware
* @return
*/
private static String getPowerSourceInfo(HardwareAbstractionLayer hardware) {
List<String> detailList = new ArrayList<>();
StringBuilder detailBuilder;
List<PowerSource> powerSources = hardware.getPowerSources();
for (PowerSource powerSource : powerSources) {
detailBuilder = new StringBuilder();
detailBuilder.append(powerSource.getName());
detailBuilder.append(" ").append(powerSource.getManufacturer());
if (!"unknown".equals(powerSource.getChemistry())) {
detailBuilder.append(" ").append(powerSource.getChemistry());
}
detailBuilder.append(" ").append(powerSource.getMaxCapacity()).append("/").append(powerSource.getDesignCapacity());
detailList.add(detailBuilder.toString());
}
return StringUtils.join(detailList, " + ");
}
/**
* Firmware
*
* @param hardware
* @return
*/
private static String getFirmware(HardwareAbstractionLayer hardware) {
Firmware firmware = hardware.getComputerSystem().getFirmware();
StringBuilder detailBuilder = new StringBuilder();
detailBuilder.append(firmware.getManufacturer());
detailBuilder.append(" ").append(firmware.getName());
detailBuilder.append(" ").append(firmware.getDescription());
detailBuilder.append(" ").append(firmware.getVersion());
detailBuilder.append(" ").append(firmware.getReleaseDate());
return detailBuilder.toString();
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
@ -308,7 +351,7 @@ public class OverviewForm {
final Spacer spacer3 = new Spacer();
panel1.add(spacer3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
final JPanel panel5 = new JPanel();
panel5.setLayout(new GridLayoutManager(7, 3, new Insets(10, 10, 10, 10), -1, -1));
panel5.setLayout(new GridLayoutManager(9, 3, new Insets(10, 20, 10, 10), -1, -1));
panel1.add(panel5, new GridConstraints(2, 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));
cpuLabel = new JLabel();
cpuLabel.setText("CPU");
@ -331,6 +374,12 @@ public class OverviewForm {
soundCardLabel = new JLabel();
soundCardLabel.setText("SoundCard");
panel5.add(soundCardLabel, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
powerSourceLabel = new JLabel();
powerSourceLabel.setText("PowerSource");
panel5.add(powerSourceLabel, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
firmwareLabel = new JLabel();
firmwareLabel.setText("Firmware");
panel5.add(firmwareLabel, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
cpuInfo = new JLabel();
cpuInfo.setText("CPU info");
panel5.add(cpuInfo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
@ -352,10 +401,16 @@ public class OverviewForm {
soundCardInfoLabel = new JLabel();
soundCardInfoLabel.setText("SoundCard info");
panel5.add(soundCardInfoLabel, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
powerSourceInfoLabel = new JLabel();
powerSourceInfoLabel.setText("PowerSource info");
panel5.add(powerSourceInfoLabel, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
firmwareInfoLabel = new JLabel();
firmwareInfoLabel.setText("Firmware info");
panel5.add(firmwareInfoLabel, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer4 = new Spacer();
panel5.add(spacer4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
final JPanel panel6 = new JPanel();
panel6.setLayout(new GridLayoutManager(1, 1, new Insets(0, 10, 0, 0), -1, -1));
panel6.setLayout(new GridLayoutManager(1, 1, new Insets(0, 10, 0, 10), -1, -1));
panel1.add(panel6, new GridConstraints(1, 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 JSeparator separator1 = new JSeparator();
panel6.add(separator1, 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));