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.logging.Logger;
30 import java.util.stream.Collectors;
31 import java.util.stream.Stream;
32 import javax.swing.JPanel;
33 import org.netbeans.spi.options.OptionsPanelController;
34 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()))
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 contentPane.add(disclaimerPanel, disclaimerConstraints);
84 for (
int i = 0; i < subPanels.size(); i++) {
87 subPanel.addPropertyChangeListener(
new PropertyChangeListener() {
89 public void propertyChange(PropertyChangeEvent evt) {
90 if (evt.getPropertyName().equals(OptionsPanelController.PROP_CHANGED)) {
91 CTOptionsPanel.this.firePropertyChange(OptionsPanelController.PROP_CHANGED, null, null);
96 GridBagConstraints gridBagConstraints =
new GridBagConstraints();
97 gridBagConstraints.gridx = 0;
98 gridBagConstraints.gridy = i + 1;
99 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
100 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
101 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
102 gridBagConstraints.weighty = 0;
103 gridBagConstraints.weightx = 0;
108 GridBagConstraints verticalConstraints =
new GridBagConstraints();
109 verticalConstraints.gridx = 0;
110 verticalConstraints.gridy = subPanels.size() + 1;
111 verticalConstraints.weighty = 1;
112 verticalConstraints.weightx = 0;
114 JPanel verticalSpacer =
new JPanel();
116 verticalSpacer.setMinimumSize(
new Dimension(MAX_SUBPANEL_WIDTH, 0));
117 verticalSpacer.setPreferredSize(
new Dimension(MAX_SUBPANEL_WIDTH, 0));
118 verticalSpacer.setMaximumSize(
new Dimension(MAX_SUBPANEL_WIDTH, Short.MAX_VALUE));
119 contentPane.add(verticalSpacer, verticalConstraints);
121 GridBagConstraints horizontalConstraints =
new GridBagConstraints();
122 horizontalConstraints.gridx = 1;
123 horizontalConstraints.gridy = 0;
124 horizontalConstraints.weighty = 0;
125 horizontalConstraints.weightx = 1;
127 JPanel horizontalSpacer =
new JPanel();
128 contentPane.add(horizontalSpacer, horizontalConstraints);
136 @SuppressWarnings(
"unchecked")
140 javax.swing.JScrollPane scrollPane =
new javax.swing.JScrollPane();
143 setLayout(
new java.awt.BorderLayout());
145 contentPane.setLayout(
new java.awt.GridBagLayout());
148 add(scrollPane, java.awt.BorderLayout.CENTER);
153 subPanels.forEach(panel -> panel.saveSettings());
157 subPanels.forEach(panel -> panel.loadSettings());
161 return subPanels.stream().allMatch(panel -> panel.valid());
javax.swing.JPanel contentPane
static final int MAX_SUBPANEL_WIDTH
static final Logger logger
final List< CTOptionsSubPanel > subPanels
void addSubOptionsPanels(JPanel disclaimerPanel, List< CTOptionsSubPanel > subPanels)
synchronized static Logger getLogger(String name)