19 package org.sleuthkit.autopsy.corecomponents;
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.openide.nodes.Node;
24 import org.openide.util.NbBundle;
32 @SuppressWarnings(
"PMD.SingularField")
33 final class SortChooser extends javax.swing.JPanel {
38 private final List<Node.Property<?>> availableProps;
44 private final ArrayList<CriterionChooser> choosers =
new ArrayList<>();
52 SortChooser(List<Node.Property<?>> availableProps, List<SortCriterion> criteria) {
56 this.availableProps = availableProps;
57 criteria.forEach(this::addCriterionChooser);
65 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
66 List<SortCriterion> getCriteria() {
67 List<SortCriterion> list =
new ArrayList<>();
68 for (
int i = 0; i < choosers.size(); i++) {
69 list.add(choosers.get(i).getCriterion(i));
74 @NbBundle.Messages({
"SortChooser.dialogTitle=Choose Sort Criteria"})
75 String getDialogTitle() {
76 return Bundle.SortChooser_dialogTitle();
84 @SuppressWarnings(
"unchecked")
86 private
void initComponents() {
88 jScrollPane1 =
new javax.swing.JScrollPane();
89 scrollContent =
new javax.swing.JPanel();
90 addCriteriaButton =
new javax.swing.JButton();
92 scrollContent.setLayout(
new javax.swing.BoxLayout(scrollContent, javax.swing.BoxLayout.Y_AXIS));
93 jScrollPane1.setViewportView(scrollContent);
95 org.openide.awt.Mnemonics.setLocalizedText(addCriteriaButton,
org.openide.util.NbBundle.getMessage(SortChooser.class,
"SortChooser.addCriteriaButton.text"));
96 addCriteriaButton.addActionListener(
new java.awt.event.ActionListener() {
97 public void actionPerformed(java.awt.event.ActionEvent evt) {
98 addCriteriaButtonActionPerformed(evt);
102 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
103 this.setLayout(layout);
104 layout.setHorizontalGroup(
105 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
106 .addGroup(layout.createSequentialGroup()
108 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
110 .addGroup(layout.createSequentialGroup()
111 .addComponent(addCriteriaButton)
112 .addGap(0, 0, Short.MAX_VALUE)))
115 layout.setVerticalGroup(
116 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
117 .addGroup(layout.createSequentialGroup()
119 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
120 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
121 .addComponent(addCriteriaButton)
127 private void addCriteriaButtonActionPerformed(java.awt.event.ActionEvent evt) {
128 addCriterionChooser(null);
138 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
139 private
void addCriterionChooser(SortCriterion criterion) {
140 final CriterionChooser chooser =
new CriterionChooser(criterion, availableProps, this::removeCriterionChooser);
141 choosers.add(chooser);
142 scrollContent.add(chooser);
151 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
152 private
void removeCriterionChooser(CriterionChooser chooser) {
153 choosers.remove(chooser);
154 scrollContent.remove(chooser);
161 private javax.swing.JButton addCriteriaButton;
162 private javax.swing.JScrollPane jScrollPane1;
163 private javax.swing.JPanel scrollContent;