19 package org.sleuthkit.autopsy.modules.yara.ui;
21 import java.awt.Component;
22 import java.awt.Desktop;
24 import java.io.IOException;
25 import java.util.List;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import javax.swing.DefaultListCellRenderer;
29 import javax.swing.DefaultListModel;
30 import javax.swing.JList;
31 import javax.swing.JOptionPane;
32 import org.openide.util.NbBundle.Messages;
54 fileListModel =
new DefaultListModel<>();
55 fileList =
new JList<>();
56 fileList.setModel(fileListModel);
68 void setRuleSet(
RuleSet ruleSet) {
69 currentRuleSet = ruleSet;
71 fileListModel.clear();
73 if (ruleSet != null) {
77 for (File file : files) {
78 fileListModel.addElement(file);
92 private static final long serialVersionUID = 1L;
96 super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
98 if (value instanceof File) {
99 File file = (File) value;
100 setText(file.getName());
101 setToolTipText(file.getAbsolutePath());
113 @SuppressWarnings(
"unchecked")
116 java.awt.GridBagConstraints gridBagConstraints;
118 javax.swing.JLabel ruleSetListLabel =
new javax.swing.JLabel();
119 javax.swing.JLabel setDetailsLabel =
new javax.swing.JLabel();
125 setLayout(
new java.awt.GridBagLayout());
127 org.openide.awt.Mnemonics.setLocalizedText(ruleSetListLabel,
org.openide.util.NbBundle.getMessage(
RuleSetDetailsPanel.class,
"RuleSetDetailsPanel.ruleSetListLabel.text"));
128 gridBagConstraints =
new java.awt.GridBagConstraints();
129 gridBagConstraints.gridx = 0;
130 gridBagConstraints.gridy = 3;
131 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
132 gridBagConstraints.insets =
new java.awt.Insets(16, 0, 3, 0);
133 add(ruleSetListLabel, gridBagConstraints);
135 org.openide.awt.Mnemonics.setLocalizedText(setDetailsLabel,
org.openide.util.NbBundle.getMessage(
RuleSetDetailsPanel.class,
"RuleSetDetailsPanel.setDetailsLabel.text"));
136 gridBagConstraints =
new java.awt.GridBagConstraints();
137 gridBagConstraints.gridx = 0;
138 gridBagConstraints.gridy = 0;
139 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
140 gridBagConstraints.insets =
new java.awt.Insets(0, 0, 10, 0);
141 add(setDetailsLabel, gridBagConstraints);
143 openFolderButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/folder-icon-16.png")));
146 public void actionPerformed(java.awt.event.ActionEvent evt) {
150 gridBagConstraints =
new java.awt.GridBagConstraints();
151 gridBagConstraints.gridx = 1;
152 gridBagConstraints.gridy = 5;
153 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
154 gridBagConstraints.insets =
new java.awt.Insets(10, 0, 0, 0);
158 gridBagConstraints =
new java.awt.GridBagConstraints();
159 gridBagConstraints.gridx = 0;
160 gridBagConstraints.gridy = 5;
161 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
162 gridBagConstraints.insets =
new java.awt.Insets(10, 0, 0, 0);
164 gridBagConstraints =
new java.awt.GridBagConstraints();
165 gridBagConstraints.gridx = 0;
166 gridBagConstraints.gridy = 4;
167 gridBagConstraints.gridwidth = 3;
168 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
169 gridBagConstraints.weightx = 1.0;
170 gridBagConstraints.weighty = 1.0;
171 gridBagConstraints.insets =
new java.awt.Insets(5, 0, 0, 0);
174 refreshButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/arrow-circle-double-135.png")));
176 refreshButton.addActionListener(
new java.awt.event.ActionListener() {
177 public void actionPerformed(java.awt.event.ActionEvent evt) {
181 gridBagConstraints =
new java.awt.GridBagConstraints();
182 gridBagConstraints.gridx = 2;
183 gridBagConstraints.gridy = 5;
184 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHEAST;
189 "RuleSetDetailsPanel_failed_to_open_folder_msg=Failed to open new window for rule set file.",
190 "RuleSetDetailsPanel_failed_to_open_folder_title=Open Error"
193 if (currentRuleSet != null) {
194 File file = currentRuleSet.
getPath().toFile();
197 Desktop.getDesktop().open(file);
198 }
catch (IOException ex) {
199 JOptionPane.showMessageDialog(
this,
200 Bundle.RuleSetDetailsPanel_failed_to_open_folder_msg(),
201 Bundle.RuleSetDetailsPanel_failed_to_open_folder_title(),
202 JOptionPane.ERROR_MESSAGE);
203 logger.log(Level.WARNING, String.format(
"Failed to open external file explorer for: %s", currentRuleSet.
getPath().toString()), ex);
210 if (currentRuleSet != null) {
211 fileListModel.clear();
215 for (File file : files) {
216 fileListModel.addElement(file);
javax.swing.JLabel openLabel
static final long serialVersionUID
void openFolderButtonActionPerformed(java.awt.event.ActionEvent evt)
javax.swing.JScrollPane scrollPane
void refreshButtonActionPerformed(java.awt.event.ActionEvent evt)
static final Logger logger
javax.swing.JButton refreshButton
javax.swing.JButton openFolderButton
Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus)
final JList< File > fileList
final DefaultListModel< File > fileListModel
List< File > getRuleFiles()