mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Add separator between physial drives and partitions
This commit is contained in:
parent
bd0bb21330
commit
0e94bbdf32
@ -18,11 +18,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.casemodule;
|
package org.sleuthkit.autopsy.casemodule;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.beans.PropertyChangeSupport;
|
import java.beans.PropertyChangeSupport;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JSeparator;
|
||||||
|
import javax.swing.ListCellRenderer;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
import javax.swing.event.ListDataListener;
|
import javax.swing.event.ListDataListener;
|
||||||
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
import org.sleuthkit.autopsy.coreutils.PlatformUtil;
|
||||||
|
|
||||||
@ -34,6 +42,7 @@ public class LocalDiskPanel extends ImageTypePanel {
|
|||||||
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||||
private List<LocalDisk> disks;
|
private List<LocalDisk> disks;
|
||||||
private LocalDiskModel model;
|
private LocalDiskModel model;
|
||||||
|
private int separatorIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new form LocalDiskPanel
|
* Creates new form LocalDiskPanel
|
||||||
@ -62,6 +71,7 @@ public class LocalDiskPanel extends ImageTypePanel {
|
|||||||
disks = new ArrayList<LocalDisk>();
|
disks = new ArrayList<LocalDisk>();
|
||||||
List<LocalDisk> physical = PlatformUtil.getPhysicalDrives();
|
List<LocalDisk> physical = PlatformUtil.getPhysicalDrives();
|
||||||
List<LocalDisk> partitions = PlatformUtil.getPartitions();
|
List<LocalDisk> partitions = PlatformUtil.getPartitions();
|
||||||
|
separatorIndex = physical.size() - 1;
|
||||||
if(physical.isEmpty()) {
|
if(physical.isEmpty()) {
|
||||||
errorLabel.setText("Physical drives were not detected. On some systems it requires admin permissions (or \"Run as administrator\").");
|
errorLabel.setText("Physical drives were not detected. On some systems it requires admin permissions (or \"Run as administrator\").");
|
||||||
}
|
}
|
||||||
@ -70,6 +80,7 @@ public class LocalDiskPanel extends ImageTypePanel {
|
|||||||
disks.addAll(partitions);
|
disks.addAll(partitions);
|
||||||
model = new LocalDiskModel();
|
model = new LocalDiskModel();
|
||||||
diskComboBox.setModel(model);
|
diskComboBox.setModel(model);
|
||||||
|
diskComboBox.setRenderer(model);
|
||||||
|
|
||||||
if(physical.isEmpty() && partitions.isEmpty()) {
|
if(physical.isEmpty() && partitions.isEmpty()) {
|
||||||
if(PlatformUtil.isWindowsOS()) {
|
if(PlatformUtil.isWindowsOS()) {
|
||||||
@ -193,7 +204,7 @@ public class LocalDiskPanel extends ImageTypePanel {
|
|||||||
pcs.removePropertyChangeListener(pcl);
|
pcs.removePropertyChangeListener(pcl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LocalDiskModel implements ComboBoxModel {
|
private class LocalDiskModel implements ComboBoxModel, ListCellRenderer {
|
||||||
LocalDisk selected;
|
LocalDisk selected;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -224,5 +235,31 @@ public class LocalDiskPanel extends ImageTypePanel {
|
|||||||
@Override
|
@Override
|
||||||
public void removeListDataListener(ListDataListener l) {
|
public void removeListDataListener(ListDataListener l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
JPanel panel = new JPanel(new BorderLayout());
|
||||||
|
panel.setBorder(new EmptyBorder(0, 2, 0, 2));
|
||||||
|
JLabel label = new JLabel();
|
||||||
|
if(index == separatorIndex) {
|
||||||
|
panel.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);
|
||||||
|
}
|
||||||
|
if (isSelected) {
|
||||||
|
label.setBackground(list.getSelectionBackground());
|
||||||
|
label.setForeground(list.getSelectionForeground());
|
||||||
|
panel.setBackground(list.getSelectionBackground());
|
||||||
|
panel.setForeground(list.getSelectionForeground());
|
||||||
|
} else {
|
||||||
|
label.setBackground(list.getBackground());
|
||||||
|
label.setForeground(list.getForeground());
|
||||||
|
panel.setBackground(list.getBackground());
|
||||||
|
panel.setForeground(list.getForeground());
|
||||||
|
}
|
||||||
|
label.setText(value.toString());
|
||||||
|
label.setOpaque(true);
|
||||||
|
|
||||||
|
panel.add(label, BorderLayout.CENTER);
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user