19 package org.sleuthkit.autopsy.modules.yara.ui;
21 import java.awt.Component;
22 import java.awt.event.ActionListener;
23 import java.util.ArrayList;
24 import java.util.Collections;
25 import java.util.List;
26 import javax.swing.DefaultListCellRenderer;
27 import javax.swing.DefaultListModel;
28 import javax.swing.JList;
29 import javax.swing.ListSelectionModel;
30 import javax.swing.event.ListSelectionEvent;
31 import javax.swing.event.ListSelectionListener;
49 ruleSetList =
new JList<>();
50 listModel =
new DefaultListModel<>();
52 ruleSetList.setModel(listModel);
53 ruleSetList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
55 ruleSetList.addListSelectionListener(
new ListSelectionListener() {
57 public void valueChanged(ListSelectionEvent e) {
70 void addSetList(List<RuleSet> newSetList) {
72 List<RuleSet> list =
new ArrayList<>();
73 list.addAll(newSetList);
74 Collections.sort(list);
79 listModel.addElement(set);
88 void addRuleSet(RuleSet set) {
91 List<RuleSet> list = Collections.list(listModel.elements());
96 ruleSetList.setSelectedValue(set,
true);
104 void removeRuleSet(RuleSet set) {
105 listModel.removeElement(set);
113 void addNewRuleListener(ActionListener listener) {
122 void addDeleteRuleListener(ActionListener listener) {
131 void addListSelectionListener(ListSelectionListener listener) {
132 ruleSetList.addListSelectionListener(listener);
140 RuleSet getSelectedRule() {
141 return ruleSetList.getSelectedValue();
149 private static final long serialVersionUID = 1L;
153 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
155 if (value instanceof
RuleSet) {
156 RuleSet set = (RuleSet) value;
170 @SuppressWarnings(
"unchecked")
173 java.awt.GridBagConstraints gridBagConstraints;
175 javax.swing.JTextPane descriptionField =
new javax.swing.JTextPane();
176 javax.swing.JLabel ruleSetListLabel =
new javax.swing.JLabel();
178 javax.swing.JPanel buttonPanel =
new javax.swing.JPanel();
182 setLayout(
new java.awt.GridBagLayout());
184 descriptionField.setEditable(
false);
185 descriptionField.setBorder(javax.swing.BorderFactory.createLineBorder(
new java.awt.Color(0, 0, 0)));
186 descriptionField.setText(
org.openide.util.NbBundle.getMessage(
RuleSetPanel.class,
"RuleSetPanel.descriptionField.text"));
187 descriptionField.setOpaque(
false);
188 gridBagConstraints =
new java.awt.GridBagConstraints();
189 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
190 gridBagConstraints.weightx = 1.0;
191 add(descriptionField, gridBagConstraints);
193 org.openide.awt.Mnemonics.setLocalizedText(ruleSetListLabel,
org.openide.util.NbBundle.getMessage(
RuleSetPanel.class,
"RuleSetPanel.ruleSetListLabel.text"));
194 gridBagConstraints =
new java.awt.GridBagConstraints();
195 gridBagConstraints.gridx = 0;
196 gridBagConstraints.gridy = 1;
197 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
198 gridBagConstraints.insets =
new java.awt.Insets(15, 0, 0, 0);
199 add(ruleSetListLabel, gridBagConstraints);
200 gridBagConstraints =
new java.awt.GridBagConstraints();
201 gridBagConstraints.gridx = 0;
202 gridBagConstraints.gridy = 2;
203 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
204 gridBagConstraints.weightx = 1.0;
205 gridBagConstraints.weighty = 1.0;
206 gridBagConstraints.insets =
new java.awt.Insets(5, 0, 10, 0);
209 buttonPanel.setLayout(
new java.awt.GridLayout(1, 0, 5, 0));
211 newButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/add16.png")));
212 org.openide.awt.Mnemonics.setLocalizedText(
newButton,
org.openide.util.NbBundle.getMessage(
RuleSetPanel.class,
"RuleSetPanel.newButton.text"));
215 deleteButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/delete16.png")));
216 org.openide.awt.Mnemonics.setLocalizedText(
deleteButton,
org.openide.util.NbBundle.getMessage(
RuleSetPanel.class,
"RuleSetPanel.deleteButton.text"));
219 gridBagConstraints =
new java.awt.GridBagConstraints();
220 gridBagConstraints.gridx = 0;
221 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
222 add(buttonPanel, gridBagConstraints);
Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus)
final JList< RuleSet > ruleSetList
javax.swing.JButton newButton
final DefaultListModel< RuleSet > listModel
static final long serialVersionUID
javax.swing.JScrollPane scrollPane
javax.swing.JButton deleteButton