Autopsy  4.5.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
SortChooser.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-17 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.corecomponents;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.openide.nodes.Node;
24 import org.openide.util.NbBundle;
27 
32 final class SortChooser extends javax.swing.JPanel {
33 
37  private final List<Node.Property<?>> availableProps;
38 
43  private final ArrayList<CriterionChooser> choosers = new ArrayList<>();
44 
51  SortChooser(List<Node.Property<?>> availableProps, List<SortCriterion> criteria) {
52  super();
53  initComponents();
54 
55  this.availableProps = availableProps;
56  criteria.forEach(this::addCriterionChooser);
57  }
58 
64  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
65  List<SortCriterion> getCriteria() {
66  List<SortCriterion> list = new ArrayList<>();
67  for (int i = 0; i < choosers.size(); i++) {
68  list.add(choosers.get(i).getCriterion(i));
69  }
70  return list;
71  }
72 
73  @NbBundle.Messages({"SortChooser.dialogTitle=Choose Sort Criteria"})
74  String getDialogTitle() {
75  return Bundle.SortChooser_dialogTitle();
76  }
77 
83  @SuppressWarnings("unchecked")
84  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
85  private void initComponents() {
86 
87  jScrollPane1 = new javax.swing.JScrollPane();
88  scrollContent = new javax.swing.JPanel();
89  addCriteriaButton = new javax.swing.JButton();
90 
91  scrollContent.setLayout(new javax.swing.BoxLayout(scrollContent, javax.swing.BoxLayout.Y_AXIS));
92  jScrollPane1.setViewportView(scrollContent);
93 
94  org.openide.awt.Mnemonics.setLocalizedText(addCriteriaButton, org.openide.util.NbBundle.getMessage(SortChooser.class, "SortChooser.addCriteriaButton.text")); // NOI18N
95  addCriteriaButton.addActionListener(new java.awt.event.ActionListener() {
96  public void actionPerformed(java.awt.event.ActionEvent evt) {
97  addCriteriaButtonActionPerformed(evt);
98  }
99  });
100 
101  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
102  this.setLayout(layout);
103  layout.setHorizontalGroup(
104  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
105  .addGroup(layout.createSequentialGroup()
106  .addContainerGap()
107  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
108  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
109  .addGroup(layout.createSequentialGroup()
110  .addComponent(addCriteriaButton)
111  .addGap(0, 0, Short.MAX_VALUE)))
112  .addContainerGap())
113  );
114  layout.setVerticalGroup(
115  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
116  .addGroup(layout.createSequentialGroup()
117  .addContainerGap()
118  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
119  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
120  .addComponent(addCriteriaButton)
121  .addContainerGap())
122  );
123  }// </editor-fold>//GEN-END:initComponents
124 
125 
126  private void addCriteriaButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addCriteriaButtonActionPerformed
127  addCriterionChooser(null);
128 
129  }//GEN-LAST:event_addCriteriaButtonActionPerformed
130 
137  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
138  private void addCriterionChooser(SortCriterion criterion) {
139  final CriterionChooser chooser = new CriterionChooser(criterion, availableProps, this::removeCriterionChooser);
140  choosers.add(chooser); // keep a reference
141  scrollContent.add(chooser); // add to GUI
142  revalidate(); //needed to force repaint.
143  }
144 
150  @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
151  private void removeCriterionChooser(CriterionChooser chooser) {
152  choosers.remove(chooser); //remove from internal list
153  scrollContent.remove(chooser);// remove from GUI
154  revalidate(); //repaint
155  repaint();
156  }
157 
158 
159  // Variables declaration - do not modify//GEN-BEGIN:variables
160  private javax.swing.JButton addCriteriaButton;
161  private javax.swing.JScrollPane jScrollPane1;
162  private javax.swing.JPanel scrollContent;
163  // End of variables declaration//GEN-END:variables
164 
165 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.