19 package com.basistech.df.cybertriage.autopsy.ctoptions;
22 import java.awt.Dimension;
23 import java.awt.GridBagConstraints;
24 import java.beans.PropertyChangeEvent;
25 import java.beans.PropertyChangeListener;
26 import java.util.Collection;
27 import java.util.Comparator;
28 import java.util.List;
29 import java.util.stream.Collectors;
30 import java.util.stream.Stream;
31 import javax.swing.JPanel;
32 import org.netbeans.spi.options.OptionsPanelController;
33 import org.openide.util.Lookup;
54 Collection<? extends CTOptionsSubPanel> coll = Lookup.getDefault().lookupAll(
CTOptionsSubPanel.class);
55 Stream<? extends CTOptionsSubPanel> panelStream = coll != null ? coll.stream() : Stream.empty();
56 this.subPanels = panelStream
62 }
catch (Exception ex) {
66 .filter(item -> item != null)
67 .sorted(Comparator.comparing(p -> p.getClass().getSimpleName().toUpperCase()).reversed())
68 .collect(Collectors.toList());
73 GridBagConstraints disclaimerConstraints =
new GridBagConstraints();
74 disclaimerConstraints.gridx = 0;
75 disclaimerConstraints.gridy = 0;
76 disclaimerConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
77 disclaimerConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
78 disclaimerConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
79 disclaimerConstraints.weighty = 0;
80 disclaimerConstraints.weightx = 0;
82 for (
int i = 0; i < subPanels.size(); i++) {
85 subPanel.addPropertyChangeListener(
new PropertyChangeListener() {
87 public void propertyChange(PropertyChangeEvent evt) {
88 if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
89 CTOptionsPanel.this.firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
94 GridBagConstraints gridBagConstraints =
new GridBagConstraints();
95 gridBagConstraints.gridx = 0;
96 gridBagConstraints.gridy = i + 1;
97 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
98 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
99 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
100 gridBagConstraints.weighty = 0;
101 gridBagConstraints.weightx = 0;
106 GridBagConstraints verticalConstraints =
new GridBagConstraints();
107 verticalConstraints.gridx = 0;
108 verticalConstraints.gridy = subPanels.size() + 1;
109 verticalConstraints.weighty = 1;
110 verticalConstraints.weightx = 0;
112 JPanel verticalSpacer =
new JPanel();
114 verticalSpacer.setMinimumSize(
new Dimension(MAX_SUBPANEL_WIDTH, 0));
115 verticalSpacer.setPreferredSize(
new Dimension(MAX_SUBPANEL_WIDTH, 0));
116 verticalSpacer.setMaximumSize(
new Dimension(MAX_SUBPANEL_WIDTH, Short.MAX_VALUE));
117 contentPane.add(verticalSpacer, verticalConstraints);
119 GridBagConstraints horizontalConstraints =
new GridBagConstraints();
120 horizontalConstraints.gridx = 1;
121 horizontalConstraints.gridy = 0;
122 horizontalConstraints.weighty = 0;
123 horizontalConstraints.weightx = 1;
125 JPanel horizontalSpacer =
new JPanel();
126 contentPane.add(horizontalSpacer, horizontalConstraints);
134 @SuppressWarnings(
"unchecked")
138 javax.swing.JScrollPane scrollPane =
new javax.swing.JScrollPane();
141 setLayout(
new java.awt.BorderLayout());
143 contentPane.setLayout(
new java.awt.GridBagLayout());
146 add(scrollPane, java.awt.BorderLayout.CENTER);
151 subPanels.forEach(panel -> panel.saveSettings());
155 subPanels.forEach(panel -> panel.loadSettings());
159 return subPanels.stream().allMatch(panel -> panel.valid());
javax.swing.JPanel contentPane
static final int MAX_SUBPANEL_WIDTH
void addSubOptionsPanels(List< CTOptionsSubPanel > subPanels)
static final Logger logger
final List< CTOptionsSubPanel > subPanels
synchronized static Logger getLogger(String name)