From f3af746af3e821844591147c868fa8768f51050e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E6=B3=A2?= Date: Thu, 2 Dec 2021 23:17:35 +0800 Subject: [PATCH 01/16] Set theme jekyll-theme-cayman --- _config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 _config.yml diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file From 9cf5076bab9c9f2c5f5f715a6e3dd09e37b46c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Sat, 13 Jan 2024 12:16:41 +0100 Subject: [PATCH 02/16] update dependencies and set java 21 --- pom.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index f771a58..c39e89b 100644 --- a/pom.xml +++ b/pom.xml @@ -15,23 +15,23 @@ UTF-8 UTF-8 - 17 - 17 + 21 + 21 - 1.4.5 + 1.4.7 7.0.3 - 1.18.24 - 5.9.1 + 1.18.30 + 5.9.2 3.12.0 31.1-jre - 4.10.0 + 5.0.0-alpha.11 3.1.1 3.1.1 3.1.1 - 5.8.11 - 2.0.22 + 5.8.18 + 2.0.32 6.4.4 - 1.5.3 + 1.5.4 From 42a8c75cdf26ba41aee619dd8f1ec6001f959344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Sat, 13 Jan 2024 19:33:21 +0100 Subject: [PATCH 03/16] add Icon Mac Windows --- pom.xml | 20 +- .../moo/info/ui/form/ProcessesForm.java | 486 ++++++++++-------- 2 files changed, 300 insertions(+), 206 deletions(-) diff --git a/pom.xml b/pom.xml index c39e89b..8862e16 100644 --- a/pom.xml +++ b/pom.xml @@ -127,7 +127,25 @@ jfreechart ${jfreechart.version} - + + + org.apache.commons + commons-imaging + 1.0-alpha3 + + + + com.twelvemonkeys.imageio + imageio-icns + 3.10.1 + + + ru.oleg-cherednik.icoman + icon-manager + 1.0 + + + diff --git a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java index 4cb70e0..4b4f3dd 100644 --- a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java +++ b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java @@ -8,15 +8,29 @@ import com.intellij.uiDesigner.core.Spacer; import com.luoboduner.moo.info.App; import com.luoboduner.moo.info.ui.UiConsts; import lombok.Getter; +import org.apache.commons.imaging.ImageReadException; +import org.apache.commons.imaging.formats.icns.IcnsImageParser; +import org.apache.commons.lang3.SystemUtils; import oshi.PlatformEnum; import oshi.SystemInfo; import oshi.software.os.OSProcess; import oshi.software.os.OperatingSystem; import oshi.util.FormatUtil; +import ru.olegcherednik.icoman.IconFile; +import ru.olegcherednik.icoman.IconManager; +import ru.olegcherednik.icoman.exceptions.IconManagerException; +import ru.olegcherednik.icoman.exceptions.IconNotFoundException; +import sun.awt.shell.ShellFolder; +import javax.imageio.ImageIO; import javax.swing.*; +import javax.swing.filechooser.FileSystemView; import javax.swing.table.*; import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -30,176 +44,238 @@ import java.util.Map; */ @Getter public class ProcessesForm { - private static final String[] COLUMNS = {"PID", "PPID", "Threads", "% CPU", "Cumulative", "VSZ", "RSS", "% Memory", - "Process Name"}; - private static final double[] COLUMN_WIDTH_PERCENT = {0.07, 0.07, 0.07, 0.07, 0.09, 0.1, 0.1, 0.08, 0.35}; + private static final String[] COLUMNS = {"ICON", "PID", "PPID", "Threads", "% CPU", "Cumulative", "VSZ", "RSS", "% Memory", + "Process Name"}; + private static final double[] COLUMN_WIDTH_PERCENT = {0.001, 0.07, 0.07, 0.07, 0.07, 0.09, 0.1, 0.1, 0.08, 0.35}; - private transient static Map priorSnapshotMap = new HashMap<>(); + private transient static Map priorSnapshotMap = new HashMap<>(); - private static final Log logger = LogFactory.get(); + private static final Log logger = LogFactory.get(); - private static ProcessesForm processesForm; - private JPanel mainPanel; - private JTable processTable; - private JRadioButton cpuButton; - private JRadioButton cumulativeCpuButton; - private JRadioButton memButton; - private JRadioButton perProc; - private JRadioButton perSystem; + private static ProcessesForm processesForm; + private JPanel mainPanel; + private JTable processTable; + private JRadioButton cpuButton; + private JRadioButton cumulativeCpuButton; + private JRadioButton memButton; + private JRadioButton perProc; + private JRadioButton perSystem; - public static ProcessesForm getInstance() { - if (processesForm == null) { - processesForm = new ProcessesForm(); - } - return processesForm; - } + public static ProcessesForm getInstance() { + if (processesForm == null) { + processesForm = new ProcessesForm(); + } + return processesForm; + } - public static void init() { - processesForm = getInstance(); + public static void init() { + processesForm = getInstance(); - initUi(); - initInfo(); - } + initUi(); + initInfo(); + } - private static void initUi() { - resetCpuPercentButtonGroup(); - resetSortByButtonGroup(); + private static void initUi() { + resetCpuPercentButtonGroup(); + resetSortByButtonGroup(); - processesForm = getInstance(); - if (SystemInfo.getCurrentPlatform().equals(PlatformEnum.WINDOWS)) { - processesForm.perSystem.setSelected(true); - } else { - processesForm.perProc.setSelected(true); - } - processesForm.cpuButton.setSelected(true); + processesForm = getInstance(); + if (SystemInfo.getCurrentPlatform().equals(PlatformEnum.WINDOWS)) { + processesForm.perSystem.setSelected(true); + } else { + processesForm.perProc.setSelected(true); + } + processesForm.cpuButton.setSelected(true); - processesForm.perProc.addActionListener(e -> { - resetCpuPercentButtonGroup(); - processesForm.perProc.setSelected(true); - }); - processesForm.perSystem.addActionListener(e -> { - resetCpuPercentButtonGroup(); - processesForm.perSystem.setSelected(true); - }); + processesForm.perProc.addActionListener(e -> { + resetCpuPercentButtonGroup(); + processesForm.perProc.setSelected(true); + }); + processesForm.perSystem.addActionListener(e -> { + resetCpuPercentButtonGroup(); + processesForm.perSystem.setSelected(true); + }); - processesForm.cpuButton.addActionListener(e -> { - resetSortByButtonGroup(); - processesForm.cpuButton.setSelected(true); - }); - processesForm.cumulativeCpuButton.addActionListener(e -> { - resetSortByButtonGroup(); - processesForm.cumulativeCpuButton.setSelected(true); - }); - processesForm.memButton.addActionListener(e -> { - resetSortByButtonGroup(); - processesForm.memButton.setSelected(true); - }); - } + processesForm.cpuButton.addActionListener(e -> { + resetSortByButtonGroup(); + processesForm.cpuButton.setSelected(true); + }); + processesForm.cumulativeCpuButton.addActionListener(e -> { + resetSortByButtonGroup(); + processesForm.cumulativeCpuButton.setSelected(true); + }); + processesForm.memButton.addActionListener(e -> { + resetSortByButtonGroup(); + processesForm.memButton.setSelected(true); + }); + } - /** - * Codes are copied from oshi and have some modifications. - */ - private static void initInfo() { - OperatingSystem os = App.si.getOperatingSystem(); - TableModel model = new DefaultTableModel(parseProcesses(os.getProcesses(null, null, 0), App.si), COLUMNS); - JTable procTable = getInstance().getProcessTable(); - procTable.setModel(model); - resizeColumns(procTable.getColumnModel()); - procTable.setShowGrid(true); + /** + * Codes are copied from oshi and have some modifications. + */ + private static void initInfo() { + OperatingSystem os = App.si.getOperatingSystem(); + TableModel model = new DefaultTableModel(parseProcesses(os.getProcesses(null, null, 0), App.si), COLUMNS) { + @Override + public Class getColumnClass(int column) { + if (column == 0) return ImageIcon.class; + return Object.class; + } + }; + JTable procTable = getInstance().getProcessTable(); + procTable.setModel(model); + resizeColumns(procTable.getColumnModel()); + procTable.setShowGrid(true); - DefaultTableCellRenderer hr = (DefaultTableCellRenderer) procTable.getTableHeader() - .getDefaultRenderer(); - // The name of header column turn to left - hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); + DefaultTableCellRenderer hr = (DefaultTableCellRenderer) procTable.getTableHeader() + .getDefaultRenderer(); + // The name of header column turn to left + hr.setHorizontalAlignment(DefaultTableCellRenderer.LEFT); - Timer timer = new Timer(UiConsts.REFRESH_SLOW, e -> { - DefaultTableModel tableModel = (DefaultTableModel) procTable.getModel(); - Object[][] newData = parseProcesses(os.getProcesses(null, null, 0), App.si); - int rowCount = tableModel.getRowCount(); - for (int row = 0; row < newData.length; row++) { - if (row < rowCount) { - // Overwrite row - for (int col = 0; col < newData[row].length; col++) { - tableModel.setValueAt(newData[row][col], row, col); - } - } else { - // Add row - tableModel.addRow(newData[row]); - } - } - // Delete any extra rows - for (int row = rowCount - 1; row >= newData.length; row--) { - tableModel.removeRow(row); - } - }); - timer.start(); - } + Timer timer = new Timer(UiConsts.REFRESH_SLOW, e -> { + DefaultTableModel tableModel = (DefaultTableModel) procTable.getModel(); + Object[][] newData = parseProcesses(os.getProcesses(null, null, 0), App.si); + int rowCount = tableModel.getRowCount(); + for (int row = 0; row < newData.length; row++) { + if (row < rowCount) { + // Overwrite row + for (int col = 0; col < newData[row].length; col++) { + tableModel.setValueAt(newData[row][col], row, col); + } + } else { + // Add row + tableModel.addRow(newData[row]); + } + } + // Delete any extra rows + for (int row = rowCount - 1; row >= newData.length; row--) { + tableModel.removeRow(row); + } + }); + timer.start(); + } - /** - * Codes are copied from oshi and have some modifications. - * - * @param list - * @param si - * @return - */ - private static Object[][] parseProcesses(List list, SystemInfo si) { - processesForm = getInstance(); - long totalMem = si.getHardware().getMemory().getTotal(); - int cpuCount = si.getHardware().getProcessor().getLogicalProcessorCount(); - // Build a map with a value for each process to control the sort - Map processSortValueMap = new HashMap<>(); - for (OSProcess p : list) { - int pid = p.getProcessID(); - // Ignore the Idle process on Windows - if (pid > 0 || !SystemInfo.getCurrentPlatform().equals(PlatformEnum.WINDOWS)) { - // Set up for appropriate sort - if (processesForm.cpuButton.isSelected()) { - processSortValueMap.put(p, p.getProcessCpuLoadBetweenTicks(priorSnapshotMap.get(pid))); - } else if (processesForm.cumulativeCpuButton.isSelected()) { - processSortValueMap.put(p, p.getProcessCpuLoadCumulative()); - } else { - processSortValueMap.put(p, (double) p.getResidentSetSize()); - } - } - } - // Now sort the list by the values - List> procList = new ArrayList<>(processSortValueMap.entrySet()); - procList.sort(Map.Entry.comparingByValue()); - // Insert into array in reverse order (lowest sort value last) - int i = procList.size(); - Object[][] procArr = new Object[i][COLUMNS.length]; - // These are in descending CPU order - for (Map.Entry e : procList) { - OSProcess p = e.getKey(); - // Matches order of COLUMNS field - i--; - int pid = p.getProcessID(); - 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()); - } - procArr[i][5] = FormatUtil.formatBytes(p.getVirtualSize()); - procArr[i][6] = FormatUtil.formatBytes(p.getResidentSetSize()); - procArr[i][7] = String.format("%.1f", 100d * p.getResidentSetSize() / totalMem); - procArr[i][8] = p.getName(); - } - // Re-populate snapshot map - priorSnapshotMap.clear(); - for (OSProcess p : list) { - priorSnapshotMap.put(p.getProcessID(), p); - } - return procArr; - } + /** + * Codes are copied from oshi and have some modifications. + * + * @param list + * @param si + * @return + */ + private static Object[][] parseProcesses(List list, SystemInfo si) { + processesForm = getInstance(); + long totalMem = si.getHardware().getMemory().getTotal(); + int cpuCount = si.getHardware().getProcessor().getLogicalProcessorCount(); + // Build a map with a value for each process to control the sort + Map processSortValueMap = new HashMap<>(); + for (OSProcess p : list) { + int pid = p.getProcessID(); + // Ignore the Idle process on Windows + if (pid > 0 || !SystemInfo.getCurrentPlatform().equals(PlatformEnum.WINDOWS)) { + // Set up for appropriate sort + if (processesForm.cpuButton.isSelected()) { + processSortValueMap.put(p, p.getProcessCpuLoadBetweenTicks(priorSnapshotMap.get(pid))); + } else if (processesForm.cumulativeCpuButton.isSelected()) { + processSortValueMap.put(p, p.getProcessCpuLoadCumulative()); + } else { + processSortValueMap.put(p, (double) p.getResidentSetSize()); + } + } + } + // Now sort the list by the values + List> procList = new ArrayList<>(processSortValueMap.entrySet()); + procList.sort(Map.Entry.comparingByValue()); + // Insert into array in reverse order (lowest sort value last) + int i = procList.size(); + Object[][] procArr = new Object[i][COLUMNS.length]; + // These are in descending CPU order + for (Map.Entry e : procList) { + OSProcess p = e.getKey(); + // Matches order of COLUMNS field + i--; + int pid = p.getProcessID(); + procArr[i][0] = getProcessIcon(p.getCommandLine()); + procArr[i][1] = pid; + procArr[i][2] = p.getParentProcessID(); + procArr[i][3] = p.getThreadCount(); + if (processesForm.perProc.isSelected()) { + procArr[i][4] = String.format("%.1f", + 100d * p.getProcessCpuLoadBetweenTicks(priorSnapshotMap.get(pid)) / cpuCount); + procArr[i][5] = String.format("%.1f", 100d * p.getProcessCpuLoadCumulative() / cpuCount); + } else { + procArr[i][4] = String.format("%.1f", + 100d * p.getProcessCpuLoadBetweenTicks(priorSnapshotMap.get(pid))); + procArr[i][5] = String.format("%.1f", 100d * p.getProcessCpuLoadCumulative()); + } + procArr[i][6] = FormatUtil.formatBytes(p.getVirtualSize()); + procArr[i][7] = FormatUtil.formatBytes(p.getResidentSetSize()); + procArr[i][8] = String.format("%.1f", 100d * p.getResidentSetSize() / totalMem); + procArr[i][9] = p.getName(); + } + // Re-populate snapshot map + priorSnapshotMap.clear(); + for (OSProcess p : list) { + priorSnapshotMap.put(p.getProcessID(), p); + } + return procArr; + } - /** + private static Icon getProcessIcon(String fullProcessPathName) { + if (SystemUtils.IS_OS_WINDOWS) { + File file = new File(fullProcessPathName); +// Get metadata and create an icon + Icon icon = FileSystemView.getFileSystemView() + .getSystemIcon(file); +// ShellFolder sf = +// ShellFolder.getShellFolder(file); +// Icon icon = new ImageIcon(sf.getIcon(true)); + return icon; + } + if (SystemUtils.IS_OS_MAC) { + if (fullProcessPathName.contains("MacOS")) { + String iconPath[] = fullProcessPathName.split("MacOS"); + if (iconPath.length > 0) { + //"AppIcon.icns" + String iconFilePath = iconPath[0] + "Resources/AppIcon.icns"; + File file = new File(iconFilePath); + //Imaging.getAllBufferedImages(iconFilePath); + try { + if (file.exists()) { + List is = new IcnsImageParser().getAllBufferedImages(new File(iconFilePath)); + BufferedImage bufferedImage = is.get(0); + + BufferedImage bufferedImageR = resizeImage(bufferedImage, 28, 28); + Icon icon = new ImageIcon(bufferedImageR); + return icon; + } + } catch (ImageReadException | IOException e) { + throw new RuntimeException(e); + } + //return new ImageIcon(Toolkit.getDefaultToolkit().getImage(iconFilePath)); + } + } + } + return null; + } + + /** + * ResizeImage BufferedImage to given targetWidth targetHeight preserve transparency + * + * @param originalImage + * @param targetWidth + * @param targetHeight + * @return resizeImage + */ + public static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws IOException { + BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_ARGB_PRE); + Graphics2D graphics2D = resizedImage.createGraphics(); + graphics2D.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null); + graphics2D.dispose(); + return resizedImage; + } + + + /** * Codes are copied from oshi and have some modifications. * * @param tableColumnModel @@ -230,60 +306,60 @@ public class ProcessesForm { processesForm.perSystem.setSelected(false); } - { + { // GUI initializer generated by IntelliJ IDEA GUI Designer // >>> IMPORTANT!! <<< // DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } + $$$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(2, 1, new Insets(20, 20, 20, 20), -1, -1)); - final JScrollPane scrollPane1 = new JScrollPane(); - 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)); - } + /** + * 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(2, 1, new Insets(20, 20, 20, 20), -1, -1)); + final JScrollPane scrollPane1 = new JScrollPane(); + 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)); + } - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return mainPanel; - } + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return mainPanel; + } } From eae0c128dc118e9b348c4cface3abcfec0618974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= <41398181+hjhgitw@users.noreply.github.com> Date: Sat, 13 Jan 2024 23:51:23 +0100 Subject: [PATCH 04/16] Update README.md Add img.shields.io badges --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1c791c4..11fa657 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,9 @@ Visual implementation of OSHI, to view information about the system and hardware Such as OS, processes, memory, CPU, disks, devices, sensors, etc. ## Supported platforms -Windows • Linux • macOS +![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=A8E4A0) +![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black) +![macOS](https://img.shields.io/badge/mac%20os-000000?style=for-the-badge&logo=macos&logoColor=black) ## Screenshot ![Overview](screenshot/overview_mac.png) @@ -36,4 +38,4 @@ More themes: ## Development considerations Before your first start, **set the IntelliJ IDEA as below**, then **maven clean**: -![considerations](assets/material/gui_build.png) \ No newline at end of file +![considerations](assets/material/gui_build.png) From 34466f488cc5f48ba8255e3b47da59018c939a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= <41398181+hjhgitw@users.noreply.github.com> Date: Sun, 14 Jan 2024 09:02:09 +0100 Subject: [PATCH 05/16] add Icon support for Windows Tested on Win11 Parallels19 --- .../moo/info/ui/form/ProcessesForm.java | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java index 4b4f3dd..e7b6b89 100644 --- a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java +++ b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java @@ -16,20 +16,12 @@ import oshi.SystemInfo; import oshi.software.os.OSProcess; import oshi.software.os.OperatingSystem; import oshi.util.FormatUtil; -import ru.olegcherednik.icoman.IconFile; -import ru.olegcherednik.icoman.IconManager; -import ru.olegcherednik.icoman.exceptions.IconManagerException; -import ru.olegcherednik.icoman.exceptions.IconNotFoundException; -import sun.awt.shell.ShellFolder; - -import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.filechooser.FileSystemView; import javax.swing.table.*; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -44,12 +36,14 @@ import java.util.Map; */ @Getter public class ProcessesForm { - private static final String[] COLUMNS = {"ICON", "PID", "PPID", "Threads", "% CPU", "Cumulative", "VSZ", "RSS", "% Memory", + private static final String[] COLUMNS = {"Icon", "PID", "PPID", "Threads", "% CPU", "Cumulative", "VSZ", "RSS", "% Memory", "Process Name"}; - private static final double[] COLUMN_WIDTH_PERCENT = {0.001, 0.07, 0.07, 0.07, 0.07, 0.09, 0.1, 0.1, 0.08, 0.35}; + private static final double[] COLUMN_WIDTH_PERCENT = {0.01, 0.07, 0.07, 0.07, 0.07, 0.09, 0.1, 0.1, 0.08, 0.35}; private transient static Map priorSnapshotMap = new HashMap<>(); + private static HashMap iconCacheMap = new HashMap<>(); + private static final Log logger = LogFactory.get(); private static ProcessesForm processesForm; @@ -118,13 +112,18 @@ public class ProcessesForm { TableModel model = new DefaultTableModel(parseProcesses(os.getProcesses(null, null, 0), App.si), COLUMNS) { @Override public Class getColumnClass(int column) { - if (column == 0) return ImageIcon.class; + if (column == 0){ + + return ImageIcon.class; + } return Object.class; } }; JTable procTable = getInstance().getProcessTable(); procTable.setModel(model); resizeColumns(procTable.getColumnModel()); + procTable.getColumnModel().getColumn(0).setMaxWidth(32); + procTable.getColumnModel().getColumn(0).setMinWidth(32); procTable.setShowGrid(true); DefaultTableCellRenderer hr = (DefaultTableCellRenderer) procTable.getTableHeader() @@ -194,7 +193,7 @@ public class ProcessesForm { // Matches order of COLUMNS field i--; int pid = p.getProcessID(); - procArr[i][0] = getProcessIcon(p.getCommandLine()); + procArr[i][0] = getProcessIcon(p); // getProcessIcon(p.getCommandLine()); procArr[i][1] = pid; procArr[i][2] = p.getParentProcessID(); procArr[i][3] = p.getThreadCount(); @@ -220,24 +219,38 @@ public class ProcessesForm { return procArr; } - private static Icon getProcessIcon(String fullProcessPathName) { + + private static Icon getProcessIcon(OSProcess p) { + String fullProcessPathName = p.getPath(); + if (iconCacheMap.containsKey(fullProcessPathName)){ + return iconCacheMap.get(fullProcessPathName); + } + File file = new File(fullProcessPathName); + if (!file.exists()){ + //or add default no icon + return null; + } if (SystemUtils.IS_OS_WINDOWS) { - File file = new File(fullProcessPathName); -// Get metadata and create an icon - Icon icon = FileSystemView.getFileSystemView() - .getSystemIcon(file); -// ShellFolder sf = -// ShellFolder.getShellFolder(file); -// Icon icon = new ImageIcon(sf.getIcon(true)); - return icon; + try { + Icon icon = FileSystemView.getFileSystemView().getSystemIcon(file); + iconCacheMap.put(fullProcessPathName,icon); + return icon; + }catch (Exception e){ +// e.printStackTrace(); + } } if (SystemUtils.IS_OS_MAC) { + final javax.swing.JFileChooser fc = new javax.swing.JFileChooser(); + Icon icon = fc.getUI().getFileView(fc).getIcon(new File(fullProcessPathName)); + /* + final javax.swing.JFileChooser fc = new javax.swing.JFileChooser(); + Icon icon = fc.getUI().getFileView(fc).getIcon(file); + * */ if (fullProcessPathName.contains("MacOS")) { String iconPath[] = fullProcessPathName.split("MacOS"); if (iconPath.length > 0) { //"AppIcon.icns" String iconFilePath = iconPath[0] + "Resources/AppIcon.icns"; - File file = new File(iconFilePath); //Imaging.getAllBufferedImages(iconFilePath); try { if (file.exists()) { @@ -245,8 +258,8 @@ public class ProcessesForm { BufferedImage bufferedImage = is.get(0); BufferedImage bufferedImageR = resizeImage(bufferedImage, 28, 28); - Icon icon = new ImageIcon(bufferedImageR); - return icon; + // Icon icon = new ImageIcon(bufferedImageR); + // return icon; } } catch (ImageReadException | IOException e) { throw new RuntimeException(e); From a683062122235f312d542774b0faa0d69ee70d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= <41398181+hjhgitw@users.noreply.github.com> Date: Sun, 14 Jan 2024 09:03:27 +0100 Subject: [PATCH 06/16] switch back to 17 problems running Java 21 on Win11 Parallels MacOS --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8862e16..a7ba8e5 100644 --- a/pom.xml +++ b/pom.xml @@ -15,8 +15,8 @@ UTF-8 UTF-8 - 21 - 21 + 17 + 17 1.4.7 7.0.3 From 1edeae2c66d0bfa04275bae1778af2dc555c7c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Sun, 14 Jan 2024 12:15:37 +0100 Subject: [PATCH 07/16] refactor & add Icon Mac Windows --- pom.xml | 15 +-- .../moo/info/ui/form/ProcessesForm.java | 127 +++++++++++------- 2 files changed, 82 insertions(+), 60 deletions(-) diff --git a/pom.xml b/pom.xml index a7ba8e5..72dc771 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,8 @@ 2.0.32 6.4.4 1.5.4 + 1.0-alpha3 + 1.2.11 @@ -131,18 +133,13 @@ org.apache.commons commons-imaging - 1.0-alpha3 + ${imaging.version} - com.twelvemonkeys.imageio - imageio-icns - 3.10.1 - - - ru.oleg-cherednik.icoman - icon-manager - 1.0 + xmlwise + xmlwise + ${xmlwise.version} diff --git a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java index e7b6b89..47e1d86 100644 --- a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java +++ b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java @@ -8,14 +8,17 @@ import com.intellij.uiDesigner.core.Spacer; import com.luoboduner.moo.info.App; import com.luoboduner.moo.info.ui.UiConsts; import lombok.Getter; -import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.formats.icns.IcnsImageParser; import org.apache.commons.lang3.SystemUtils; +import org.jetbrains.annotations.NotNull; import oshi.PlatformEnum; import oshi.SystemInfo; import oshi.software.os.OSProcess; import oshi.software.os.OperatingSystem; import oshi.util.FormatUtil; +import xmlwise.Plist; + +import javax.swing.Timer; import javax.swing.*; import javax.swing.filechooser.FileSystemView; import javax.swing.table.*; @@ -23,10 +26,10 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; +import java.net.URI; +import java.net.URISyntaxException; import java.util.List; -import java.util.Map; +import java.util.*; /** * ProcessesForm @@ -40,9 +43,9 @@ public class ProcessesForm { "Process Name"}; private static final double[] COLUMN_WIDTH_PERCENT = {0.01, 0.07, 0.07, 0.07, 0.07, 0.09, 0.1, 0.1, 0.08, 0.35}; - private transient static Map priorSnapshotMap = new HashMap<>(); + private final static Map priorSnapshotMap = new HashMap<>(); - private static HashMap iconCacheMap = new HashMap<>(); + private final static HashMap iconCacheMap = new HashMap<>(); private static final Log logger = LogFactory.get(); @@ -112,7 +115,7 @@ public class ProcessesForm { TableModel model = new DefaultTableModel(parseProcesses(os.getProcesses(null, null, 0), App.si), COLUMNS) { @Override public Class getColumnClass(int column) { - if (column == 0){ + if (column == 0) { return ImageIcon.class; } @@ -193,7 +196,7 @@ public class ProcessesForm { // Matches order of COLUMNS field i--; int pid = p.getProcessID(); - procArr[i][0] = getProcessIcon(p); // getProcessIcon(p.getCommandLine()); + procArr[i][0] = getProcessIcon(p.getPath()); procArr[i][1] = pid; procArr[i][2] = p.getParentProcessID(); procArr[i][3] = p.getThreadCount(); @@ -219,56 +222,78 @@ public class ProcessesForm { return procArr; } - - private static Icon getProcessIcon(OSProcess p) { - String fullProcessPathName = p.getPath(); - if (iconCacheMap.containsKey(fullProcessPathName)){ + /** + * Retrieves the executable's associated icon if available, or returns null. + * + * @param fullProcessPathName The full path of the executable process. + * @return The associated icon, or null if not found. + */ + private static Icon getProcessIcon(String fullProcessPathName) { + if (iconCacheMap.containsKey(fullProcessPathName)) { return iconCacheMap.get(fullProcessPathName); } - File file = new File(fullProcessPathName); - if (!file.exists()){ - //or add default no icon - return null; - } - if (SystemUtils.IS_OS_WINDOWS) { - try { - Icon icon = FileSystemView.getFileSystemView().getSystemIcon(file); - iconCacheMap.put(fullProcessPathName,icon); - return icon; - }catch (Exception e){ -// e.printStackTrace(); - } - } - if (SystemUtils.IS_OS_MAC) { - final javax.swing.JFileChooser fc = new javax.swing.JFileChooser(); - Icon icon = fc.getUI().getFileView(fc).getIcon(new File(fullProcessPathName)); - /* - final javax.swing.JFileChooser fc = new javax.swing.JFileChooser(); - Icon icon = fc.getUI().getFileView(fc).getIcon(file); - * */ - if (fullProcessPathName.contains("MacOS")) { - String iconPath[] = fullProcessPathName.split("MacOS"); - if (iconPath.length > 0) { - //"AppIcon.icns" - String iconFilePath = iconPath[0] + "Resources/AppIcon.icns"; - //Imaging.getAllBufferedImages(iconFilePath); - try { - if (file.exists()) { - List is = new IcnsImageParser().getAllBufferedImages(new File(iconFilePath)); - BufferedImage bufferedImage = is.get(0); - BufferedImage bufferedImageR = resizeImage(bufferedImage, 28, 28); - // Icon icon = new ImageIcon(bufferedImageR); - // return icon; - } - } catch (ImageReadException | IOException e) { - throw new RuntimeException(e); + File file = new File(fullProcessPathName); + if (!file.exists()) { + // Alternatively, provide a default icon or return nul + return UIManager.getIcon("FileView.fileIcon"); + } + + try { + if (SystemUtils.IS_OS_WINDOWS) { + Icon icon = FileSystemView.getFileSystemView().getSystemIcon(file); + iconCacheMap.put(fullProcessPathName, icon); + return icon; + } + + // macOS-specific icon retrieval + // maybe find a simple solution + // Todo : fix various icons like VLC ... + if (SystemUtils.IS_OS_MAC && fullProcessPathName.contains("MacOS")) { + String iconPathSplit = fullProcessPathName.split("MacOS")[0]; + String plistFilePath = iconPathSplit + "Info.plist"; + + File pListFile = getFileWithSpaceUri(plistFilePath); + if (pListFile.exists()) { + Map properties = Plist.load(plistFilePath); + String cFBundleIconFile = (String) properties.get("CFBundleIconFile"); + String iconFilePath = iconPathSplit + "Resources/" + cFBundleIconFile; + + // Ensure file path ends with ".icns" + if (!iconFilePath.contains(".icns")) { + iconFilePath += ".icns"; + } + + File iconFile = getFileWithSpaceUri(iconFilePath); + if (iconFile.canRead()) { + List iconImages = new IcnsImageParser().getAllBufferedImages(iconFile); + Optional resultImage = iconImages + .stream().parallel() + .filter(num -> num.getRaster().getHeight() == 32).findAny(); + + if (resultImage.isPresent()) { + BufferedImage bufferedImageR = resizeImage(resultImage.get(), 26, 26); + return new ImageIcon(bufferedImageR); + } + } - //return new ImageIcon(Toolkit.getDefaultToolkit().getImage(iconFilePath)); } } + } catch (Exception e) { } - return null; + return UIManager.getIcon("FileView.fileIcon"); + } + + @NotNull + /** + * Workaround to open folders files with spaces + * @param filePath + * @return file + */ + private static File getFileWithSpaceUri(String filePath) throws URISyntaxException { + URI outputURI = new URI(("file:///" + filePath.replaceAll(" ", "%20"))); + File outputFile = new File(outputURI); + return outputFile; } /** From f9a072dac04d93f1f690d3b345efb063bf104f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Sun, 14 Jan 2024 14:52:22 +0100 Subject: [PATCH 08/16] refactor & add Icon Mac Windows --- .../java/com/luoboduner/moo/info/ui/form/ProcessesForm.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java index 47e1d86..9d7e12b 100644 --- a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java +++ b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java @@ -260,7 +260,7 @@ public class ProcessesForm { String iconFilePath = iconPathSplit + "Resources/" + cFBundleIconFile; // Ensure file path ends with ".icns" - if (!iconFilePath.contains(".icns")) { + if (!iconFilePath.endsWith(".icns")) { iconFilePath += ".icns"; } From 2c40adb4561da7f66aa4e6cc6213f043b25bd61d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Sun, 14 Jan 2024 14:54:44 +0100 Subject: [PATCH 09/16] refactor fix missing cache --- .../java/com/luoboduner/moo/info/ui/form/ProcessesForm.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java index 9d7e12b..ec0a61a 100644 --- a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java +++ b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java @@ -273,7 +273,9 @@ public class ProcessesForm { if (resultImage.isPresent()) { BufferedImage bufferedImageR = resizeImage(resultImage.get(), 26, 26); - return new ImageIcon(bufferedImageR); + Icon icon = new ImageIcon(bufferedImageR); + iconCacheMap.put(fullProcessPathName, icon); + return icon; } } From 905849fadbf3771a54854f79805a482abd962435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Tue, 16 Jan 2024 18:05:06 +0100 Subject: [PATCH 10/16] fix manifest file on windows linux with maven-jar-plugin WIP --- pom.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pom.xml b/pom.xml index 72dc771..64b16ae 100644 --- a/pom.xml +++ b/pom.xml @@ -146,6 +146,21 @@ + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.0 + + + + true + lib/ + com.luoboduner.moo.info.App + + + + io.github.fvarrui javapackager From 6cf9e08b75d2eff11508edf3f7b5e378b2dfbd54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= <41398181+hjhgitw@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:22:40 +0100 Subject: [PATCH 11/16] test logfactory !? --- pom.xml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 64b16ae..7b8dfff 100644 --- a/pom.xml +++ b/pom.xml @@ -141,8 +141,24 @@ xmlwise ${xmlwise.version} + + org.slf4j + slf4j-api + 2.0.5 + + + org.slf4j + slf4j-simple + 2.0.11 + + + + org.slf4j + slf4j-api + 2.0.11 + - + From 19662ae8c76486dd0d5bc8a64f377255d043634e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= <41398181+hjhgitw@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:40:04 +0100 Subject: [PATCH 12/16] revert pom WIP --- pom.xml | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/pom.xml b/pom.xml index 7b8dfff..6afd73e 100644 --- a/pom.xml +++ b/pom.xml @@ -141,42 +141,10 @@ xmlwise ${xmlwise.version} - - org.slf4j - slf4j-api - 2.0.5 - - - org.slf4j - slf4j-simple - 2.0.11 - - - - org.slf4j - slf4j-api - 2.0.11 - - - + - - - org.apache.maven.plugins - maven-jar-plugin - 3.1.0 - - - - true - lib/ - com.luoboduner.moo.info.App - - - - io.github.fvarrui javapackager From 2400d127bceb78e609ddca5c880041a613da5f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Tue, 16 Jan 2024 19:28:18 +0100 Subject: [PATCH 13/16] add autogenerated .editorconfig from IntelliJ 2 define what we need :) uncomment it --- .editorconfig | 321 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fd605f5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,321 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 120 +tab_width = 4 +# ij_continuation_indent_size = 8 +# ij_formatter_off_tag = @formatter:off +# ij_formatter_on_tag = @formatter:on +# ij_formatter_tags_enabled = true +# ij_smart_tabs = false +# ij_visual_guides = +# ij_wrap_on_typing = false + +[*.java] +# ij_java_align_consecutive_assignments = false +# ij_java_align_consecutive_variable_declarations = false +# ij_java_align_group_field_declarations = false +# ij_java_align_multiline_annotation_parameters = false +# ij_java_align_multiline_array_initializer_expression = false +# ij_java_align_multiline_assignment = false +# ij_java_align_multiline_binary_operation = false +# ij_java_align_multiline_chained_methods = false +# ij_java_align_multiline_deconstruction_list_components = true +# ij_java_align_multiline_extends_list = false +# ij_java_align_multiline_for = true +# ij_java_align_multiline_method_parentheses = false +# ij_java_align_multiline_parameters = true +# ij_java_align_multiline_parameters_in_calls = false +# ij_java_align_multiline_parenthesized_expression = false +# ij_java_align_multiline_records = true +# ij_java_align_multiline_resources = true +# ij_java_align_multiline_ternary_operation = false +# ij_java_align_multiline_text_blocks = false +# ij_java_align_multiline_throws_list = false +# ij_java_align_subsequent_simple_methods = false +# ij_java_align_throws_keyword = false +# ij_java_align_types_in_multi_catch = true +# ij_java_annotation_parameter_wrap = off +# ij_java_array_initializer_new_line_after_left_brace = false +# ij_java_array_initializer_right_brace_on_new_line = false +# ij_java_array_initializer_wrap = off +# ij_java_assert_statement_colon_on_next_line = false +# ij_java_assert_statement_wrap = off +# ij_java_assignment_wrap = off +# ij_java_binary_operation_sign_on_next_line = false +# ij_java_binary_operation_wrap = off +# ij_java_blank_lines_after_anonymous_class_header = 0 +# ij_java_blank_lines_after_class_header = 0 +# ij_java_blank_lines_after_imports = 1 +# ij_java_blank_lines_after_package = 1 +# ij_java_blank_lines_around_class = 1 +# ij_java_blank_lines_around_field = 0 +# ij_java_blank_lines_around_field_in_interface = 0 +# ij_java_blank_lines_around_initializer = 1 +# ij_java_blank_lines_around_method = 1 +# ij_java_blank_lines_around_method_in_interface = 1 +# ij_java_blank_lines_before_class_end = 0 +# ij_java_blank_lines_before_imports = 1 +# ij_java_blank_lines_before_method_body = 0 +# ij_java_blank_lines_before_package = 0 +# ij_java_block_brace_style = end_of_line +# ij_java_block_comment_add_space = false +# ij_java_block_comment_at_first_column = true +# ij_java_builder_methods = +# ij_java_call_parameters_new_line_after_left_paren = false +# ij_java_call_parameters_right_paren_on_new_line = false +# ij_java_call_parameters_wrap = off +# ij_java_case_statement_on_separate_line = true +# ij_java_catch_on_new_line = false +# ij_java_class_annotation_wrap = split_into_lines +# ij_java_class_brace_style = end_of_line +# ij_java_class_count_to_use_import_on_demand = 5 +# ij_java_class_names_in_javadoc = 1 +# ij_java_deconstruction_list_wrap = normal +# ij_java_do_not_indent_top_level_class_members = false +# ij_java_do_not_wrap_after_single_annotation = false +# ij_java_do_not_wrap_after_single_annotation_in_parameter = false +# ij_java_do_while_brace_force = never +# ij_java_doc_add_blank_line_after_description = true +# ij_java_doc_add_blank_line_after_param_comments = false +# ij_java_doc_add_blank_line_after_return = false +# ij_java_doc_add_p_tag_on_empty_lines = true +# ij_java_doc_align_exception_comments = true +# ij_java_doc_align_param_comments = true +# ij_java_doc_do_not_wrap_if_one_line = false +# ij_java_doc_enable_formatting = true +# ij_java_doc_enable_leading_asterisks = true +# ij_java_doc_indent_on_continuation = false +# ij_java_doc_keep_empty_lines = true +# ij_java_doc_keep_empty_parameter_tag = true +# ij_java_doc_keep_empty_return_tag = true +# ij_java_doc_keep_empty_throws_tag = true +# ij_java_doc_keep_invalid_tags = true +# ij_java_doc_param_description_on_new_line = false +# ij_java_doc_preserve_line_breaks = false +# ij_java_doc_use_throws_not_exception_tag = true +# ij_java_else_on_new_line = false +# ij_java_enum_constants_wrap = off +# ij_java_extends_keyword_wrap = off +# ij_java_extends_list_wrap = off +# ij_java_field_annotation_wrap = split_into_lines +# ij_java_field_name_prefix = +# ij_java_field_name_suffix = +# ij_java_finally_on_new_line = false +# ij_java_for_brace_force = never +# ij_java_for_statement_new_line_after_left_paren = false +# ij_java_for_statement_right_paren_on_new_line = false +# ij_java_for_statement_wrap = off +# ij_java_generate_final_locals = false +# ij_java_generate_final_parameters = false +# ij_java_if_brace_force = never +# ij_java_imports_layout = *,|,javax.**,java.**,|,$* +# ij_java_indent_case_from_switch = true +# ij_java_insert_inner_class_imports = false +# ij_java_insert_override_annotation = true +# ij_java_keep_blank_lines_before_right_brace = 2 +# ij_java_keep_blank_lines_between_package_declaration_and_header = 2 +# ij_java_keep_blank_lines_in_code = 2 +# ij_java_keep_blank_lines_in_declarations = 2 +# ij_java_keep_builder_methods_indents = false +# ij_java_keep_control_statement_in_one_line = true +# ij_java_keep_first_column_comment = true +# ij_java_keep_indents_on_empty_lines = false +# ij_java_keep_line_breaks = true +# ij_java_keep_multiple_expressions_in_one_line = false +# ij_java_keep_simple_blocks_in_one_line = false +# ij_java_keep_simple_classes_in_one_line = false +# ij_java_keep_simple_lambdas_in_one_line = false +# ij_java_keep_simple_methods_in_one_line = false +# ij_java_label_indent_absolute = false +# ij_java_label_indent_size = 0 +# ij_java_lambda_brace_style = end_of_line +# ij_java_layout_static_imports_separately = true +# ij_java_line_comment_add_space = false +# ij_java_line_comment_add_space_on_reformat = false +# ij_java_line_comment_at_first_column = true +# ij_java_local_variable_name_prefix = +# ij_java_local_variable_name_suffix = +# ij_java_method_annotation_wrap = split_into_lines +# ij_java_method_brace_style = end_of_line +# ij_java_method_call_chain_wrap = off +# ij_java_method_parameters_new_line_after_left_paren = false +# ij_java_method_parameters_right_paren_on_new_line = false +# ij_java_method_parameters_wrap = off +# ij_java_modifier_list_wrap = false +# ij_java_multi_catch_types_wrap = normal +# ij_java_names_count_to_use_import_on_demand = 3 +# ij_java_new_line_after_lparen_in_annotation = false +# ij_java_new_line_after_lparen_in_deconstruction_pattern = true +# ij_java_new_line_after_lparen_in_record_header = false +# ij_java_packages_to_use_import_on_demand = java.awt.*,javax.swing.* +# ij_java_parameter_annotation_wrap = off +# ij_java_parameter_name_prefix = +# ij_java_parameter_name_suffix = +# ij_java_parentheses_expression_new_line_after_left_paren = false +# ij_java_parentheses_expression_right_paren_on_new_line = false +# ij_java_place_assignment_sign_on_next_line = false +# ij_java_prefer_longer_names = true +# ij_java_prefer_parameters_wrap = false +# ij_java_record_components_wrap = normal +# ij_java_repeat_annotations = +# ij_java_repeat_synchronized = true +# ij_java_replace_instanceof_and_cast = false +# ij_java_replace_null_check = true +# ij_java_replace_sum_lambda_with_method_ref = true +# ij_java_resource_list_new_line_after_left_paren = false +# ij_java_resource_list_right_paren_on_new_line = false +# ij_java_resource_list_wrap = off +# ij_java_rparen_on_new_line_in_annotation = false +# ij_java_rparen_on_new_line_in_deconstruction_pattern = true +# ij_java_rparen_on_new_line_in_record_header = false +# ij_java_space_after_closing_angle_bracket_in_type_argument = false +# ij_java_space_after_colon = true +# ij_java_space_after_comma = true +# ij_java_space_after_comma_in_type_arguments = true +# ij_java_space_after_for_semicolon = true +# ij_java_space_after_quest = true +# ij_java_space_after_type_cast = true +# ij_java_space_before_annotation_array_initializer_left_brace = false +# ij_java_space_before_annotation_parameter_list = false +# ij_java_space_before_array_initializer_left_brace = false +# ij_java_space_before_catch_keyword = true +# ij_java_space_before_catch_left_brace = true +# ij_java_space_before_catch_parentheses = true +# ij_java_space_before_class_left_brace = true +# ij_java_space_before_colon = true +# ij_java_space_before_colon_in_foreach = true +# ij_java_space_before_comma = false +# ij_java_space_before_deconstruction_list = false +# ij_java_space_before_do_left_brace = true +# ij_java_space_before_else_keyword = true +# ij_java_space_before_else_left_brace = true +# ij_java_space_before_finally_keyword = true +# ij_java_space_before_finally_left_brace = true +# ij_java_space_before_for_left_brace = true +# ij_java_space_before_for_parentheses = true +# ij_java_space_before_for_semicolon = false +# ij_java_space_before_if_left_brace = true +# ij_java_space_before_if_parentheses = true +# ij_java_space_before_method_call_parentheses = false +# ij_java_space_before_method_left_brace = true +# ij_java_space_before_method_parentheses = false +# ij_java_space_before_opening_angle_bracket_in_type_parameter = false +# ij_java_space_before_quest = true +# ij_java_space_before_switch_left_brace = true +# ij_java_space_before_switch_parentheses = true +# ij_java_space_before_synchronized_left_brace = true +# ij_java_space_before_synchronized_parentheses = true +# ij_java_space_before_try_left_brace = true +# ij_java_space_before_try_parentheses = true +# ij_java_space_before_type_parameter_list = false +# ij_java_space_before_while_keyword = true +# ij_java_space_before_while_left_brace = true +# ij_java_space_before_while_parentheses = true +# ij_java_space_inside_one_line_enum_braces = false +# ij_java_space_within_empty_array_initializer_braces = false +# ij_java_space_within_empty_method_call_parentheses = false +# ij_java_space_within_empty_method_parentheses = false +# ij_java_spaces_around_additive_operators = true +# ij_java_spaces_around_annotation_eq = true +# ij_java_spaces_around_assignment_operators = true +# ij_java_spaces_around_bitwise_operators = true +# ij_java_spaces_around_equality_operators = true +# ij_java_spaces_around_lambda_arrow = true +# ij_java_spaces_around_logical_operators = true +# ij_java_spaces_around_method_ref_dbl_colon = false +# ij_java_spaces_around_multiplicative_operators = true +# ij_java_spaces_around_relational_operators = true +# ij_java_spaces_around_shift_operators = true +# ij_java_spaces_around_type_bounds_in_type_parameters = true +# ij_java_spaces_around_unary_operator = false +# ij_java_spaces_within_angle_brackets = false +# ij_java_spaces_within_annotation_parentheses = false +# ij_java_spaces_within_array_initializer_braces = false +# ij_java_spaces_within_braces = false +# ij_java_spaces_within_brackets = false +# ij_java_spaces_within_cast_parentheses = false +# ij_java_spaces_within_catch_parentheses = false +# ij_java_spaces_within_deconstruction_list = false +# ij_java_spaces_within_for_parentheses = false +# ij_java_spaces_within_if_parentheses = false +# ij_java_spaces_within_method_call_parentheses = false +# ij_java_spaces_within_method_parentheses = false +# ij_java_spaces_within_parentheses = false +# ij_java_spaces_within_record_header = false +# ij_java_spaces_within_switch_parentheses = false +# ij_java_spaces_within_synchronized_parentheses = false +# ij_java_spaces_within_try_parentheses = false +# ij_java_spaces_within_while_parentheses = false +# ij_java_special_else_if_treatment = true +# ij_java_static_field_name_prefix = +# ij_java_static_field_name_suffix = +# ij_java_subclass_name_prefix = +# ij_java_subclass_name_suffix = Impl +# ij_java_ternary_operation_signs_on_next_line = false +# ij_java_ternary_operation_wrap = off +# ij_java_test_name_prefix = +# ij_java_test_name_suffix = Test +# ij_java_throws_keyword_wrap = off +# ij_java_throws_list_wrap = off +# ij_java_use_external_annotations = false +# ij_java_use_fq_class_names = false +# ij_java_use_relative_indents = false +# ij_java_use_single_class_imports = true +# ij_java_variable_annotation_wrap = off +# ij_java_visibility = public +# ij_java_while_brace_force = never +# ij_java_while_on_new_line = false +# ij_java_wrap_comments = false +# ij_java_wrap_first_method_in_call_chain = false +# ij_java_wrap_long_lines = false + +[.editorconfig] +# ij_editorconfig_align_group_field_declarations = false +# ij_editorconfig_space_after_colon = false +# ij_editorconfig_space_after_comma = true +# ij_editorconfig_space_before_colon = false +# ij_editorconfig_space_before_comma = false +# ij_editorconfig_spaces_around_assignment_operators = true + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.jspx,*.pom,*.rng,*.tagx,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] +# ij_xml_align_attributes = true +# ij_xml_align_text = false +# ij_xml_attribute_wrap = normal +# ij_xml_block_comment_add_space = false +# ij_xml_block_comment_at_first_column = true +# ij_xml_keep_blank_lines = 2 +# ij_xml_keep_indents_on_empty_lines = false +# ij_xml_keep_line_breaks = true +# ij_xml_keep_line_breaks_in_text = true +# ij_xml_keep_whitespaces = false +# ij_xml_keep_whitespaces_around_cdata = preserve +# ij_xml_keep_whitespaces_inside_cdata = false +# ij_xml_line_comment_at_first_column = true +# ij_xml_space_after_tag_name = false +# ij_xml_space_around_equals_in_attribute = false +# ij_xml_space_inside_empty_tag = false +# ij_xml_text_wrap = normal + +[{*.markdown,*.md}] +# ij_markdown_force_one_space_after_blockquote_symbol = true +# ij_markdown_force_one_space_after_header_symbol = true +# ij_markdown_force_one_space_after_list_bullet = true +# ij_markdown_force_one_space_between_words = true +# ij_markdown_format_tables = true +# ij_markdown_insert_quote_arrows_on_wrap = true +# ij_markdown_keep_indents_on_empty_lines = false +# ij_markdown_keep_line_breaks_inside_text_blocks = true +# ij_markdown_max_lines_around_block_elements = 1 +# ij_markdown_max_lines_around_header = 1 +# ij_markdown_max_lines_between_paragraphs = 1 +# ij_markdown_min_lines_around_block_elements = 1 +# ij_markdown_min_lines_around_header = 1 +# ij_markdown_min_lines_between_paragraphs = 1 +# ij_markdown_wrap_text_if_long = true +# ij_markdown_wrap_text_inside_blockquotes = true From 50f7dc7c89ce56a9e86e34c5a75ea2e829177d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Tue, 16 Jan 2024 19:39:10 +0100 Subject: [PATCH 14/16] add autogenerated .gitignore from IntelliJ ignore plugin to avoid problems on linuxKali --- .gitignore | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85d1f12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +### Java template +# Compiled class file +*.class +target/* + +# Log file +*.log + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +# IntelliJ project files +.idea +*.iml +out +gen \ No newline at end of file From 7527bcb708b5e243dd9cab68e78b2869f230916c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Tue, 16 Jan 2024 19:42:12 +0100 Subject: [PATCH 15/16] set default values like in https://github.com/JetBrains/intellij-community/blob/master/.editorconfig --- .editorconfig | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index fd605f5..fe4b6e5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,12 +3,20 @@ root = true [*] charset = utf-8 end_of_line = lf -indent_size = 4 +indent_size = 2 indent_style = space insert_final_newline = false -max_line_length = 120 -tab_width = 4 -# ij_continuation_indent_size = 8 +max_line_length = 140 +tab_width = 2 +ij_continuation_indent_size = 2 + +ij_any_else_on_new_line = true +ij_any_catch_on_new_line = true +ij_any_finally_on_new_line = true +ij_any_block_comment_at_first_column = false +ij_any_line_comment_at_first_column = false +ij_javascript_force_semicolon_style = true +ij_javascript_use_semicolon_after_statement = false # ij_formatter_off_tag = @formatter:off # ij_formatter_on_tag = @formatter:on # ij_formatter_tags_enabled = true From f206cf78b57960f034893889e81f207edb02db38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hansj=C3=B6rg=20Hofer?= Date: Tue, 16 Jan 2024 20:10:51 +0100 Subject: [PATCH 16/16] add WIP IS_OS_LINUX --- .../java/com/luoboduner/moo/info/ui/form/ProcessesForm.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java index ec0a61a..e085c50 100644 --- a/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java +++ b/src/main/java/com/luoboduner/moo/info/ui/form/ProcessesForm.java @@ -246,8 +246,12 @@ public class ProcessesForm { return icon; } + if (SystemUtils.IS_OS_LINUX) { + // investigate why getPath or getCommandLine is "" on kali + } + // macOS-specific icon retrieval - // maybe find a simple solution + // maybe find a simpler solution // Todo : fix various icons like VLC ... if (SystemUtils.IS_OS_MAC && fullProcessPathName.contains("MacOS")) { String iconPathSplit = fullProcessPathName.split("MacOS")[0];