19 package org.sleuthkit.autopsy.modules.fileextmismatch;
21 import java.awt.Color;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Collections;
25 import java.util.HashMap;
26 import java.util.logging.Level;
27 import javax.swing.JOptionPane;
28 import javax.swing.ListSelectionModel;
29 import javax.swing.event.ListSelectionEvent;
30 import javax.swing.event.ListSelectionListener;
31 import javax.swing.table.AbstractTableModel;
33 import org.openide.util.NbBundle;
42 final class FileExtMismatchSettingsPanel
extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
44 private static final Logger logger = Logger.getLogger(FileExtMismatchSettingsPanel.class.getName());
45 private HashMap<String, String[]> editableMap =
new HashMap<>();
46 private ArrayList<String> mimeList = null;
47 private ArrayList<String> currentExtensions = null;
48 private MimeTableModel mimeTableModel;
49 private ExtTableModel extTableModel;
50 private final String EXT_HEADER_LABEL = NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
51 "AddFileExtensionAction.extHeaderLbl.text");
52 private String selectedMime =
"";
53 private String selectedExt =
"";
54 ListSelectionModel lsm = null;
55 private FileTypeDetector fileTypeDetector;
57 public FileExtMismatchSettingsPanel() {
58 mimeTableModel =
new MimeTableModel();
59 extTableModel =
new ExtTableModel();
62 fileTypeDetector =
new FileTypeDetector();
63 }
catch (FileTypeDetector.FileTypeDetectorInitException ex) {
64 logger.log(Level.SEVERE,
"Failed to create file type detector", ex);
65 fileTypeDetector = null;
69 customizeComponents();
72 private void customizeComponents() {
73 setName(NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.name.text"));
76 lsm = mimeTable.getSelectionModel();
77 lsm.addListSelectionListener(
new ListSelectionListener() {
79 public void valueChanged(ListSelectionEvent e) {
80 ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
81 if (!listSelectionModel.isSelectionEmpty()) {
82 int index = listSelectionModel.getMinSelectionIndex();
83 listSelectionModel.setSelectionInterval(index, index);
85 selectedMime = mimeList.get(index);
86 String labelStr = EXT_HEADER_LABEL + selectedMime +
":";
87 if (labelStr.length() > 80) {
88 labelStr = labelStr.substring(0, 80);
90 extHeaderLabel.setText(labelStr);
93 extTableModel.resync();
97 currentExtensions = null;
98 extTableModel.resync();
106 ListSelectionModel extLsm = extTable.getSelectionModel();
107 extLsm.addListSelectionListener(
new ListSelectionListener() {
109 public void valueChanged(ListSelectionEvent e) {
110 ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource();
111 if (!listSelectionModel.isSelectionEmpty()) {
112 int index = listSelectionModel.getMinSelectionIndex();
113 listSelectionModel.setSelectionInterval(index, index);
115 selectedExt = currentExtensions.get(index);
120 extRemoveErrLabel.setText(
" ");
127 private void clearErrLabels() {
128 mimeErrLabel.setText(
" ");
129 mimeRemoveErrLabel.setText(
" ");
130 extRemoveErrLabel.setText(
" ");
131 extErrorLabel.setText(
" ");
132 saveMsgLabel.setText(
" ");
141 private void initComponents() {
143 jScrollPane1 =
new javax.swing.JScrollPane();
144 jPanel1 =
new javax.swing.JPanel();
145 saveButton =
new javax.swing.JButton();
146 jSplitPane1 =
new javax.swing.JSplitPane();
147 mimePanel =
new javax.swing.JPanel();
148 jLabel1 =
new javax.swing.JLabel();
149 jScrollPane2 =
new javax.swing.JScrollPane();
150 mimeTable =
new javax.swing.JTable();
151 userTypeTextField =
new javax.swing.JTextField();
152 addTypeButton =
new javax.swing.JButton();
153 removeTypeButton =
new javax.swing.JButton();
154 mimeErrLabel =
new javax.swing.JLabel();
155 mimeRemoveErrLabel =
new javax.swing.JLabel();
156 extensionPanel =
new javax.swing.JPanel();
157 userExtTextField =
new javax.swing.JTextField();
158 addExtButton =
new javax.swing.JButton();
159 jScrollPane3 =
new javax.swing.JScrollPane();
160 extTable =
new javax.swing.JTable();
161 removeExtButton =
new javax.swing.JButton();
162 extHeaderLabel =
new javax.swing.JLabel();
163 extErrorLabel =
new javax.swing.JLabel();
164 extRemoveErrLabel =
new javax.swing.JLabel();
165 saveMsgLabel =
new javax.swing.JLabel();
167 jPanel1.setPreferredSize(
new java.awt.Dimension(687, 450));
169 saveButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/modules/fileextmismatch/save16.png")));
170 saveButton.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.saveButton.text"));
171 saveButton.setEnabled(
false);
172 saveButton.addActionListener(
new java.awt.event.ActionListener() {
173 public void actionPerformed(java.awt.event.ActionEvent evt) {
174 saveButtonActionPerformed(evt);
178 jSplitPane1.setDividerLocation(430);
180 jLabel1.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.jLabel1.text"));
182 mimeTable.setModel(mimeTableModel);
183 jScrollPane2.setViewportView(mimeTable);
185 userTypeTextField.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.userTypeTextField.text"));
186 userTypeTextField.addFocusListener(
new java.awt.event.FocusAdapter() {
187 public void focusGained(java.awt.event.FocusEvent evt) {
188 userTypeTextFieldFocusGained(evt);
192 addTypeButton.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.addTypeButton.text"));
193 addTypeButton.addActionListener(
new java.awt.event.ActionListener() {
194 public void actionPerformed(java.awt.event.ActionEvent evt) {
195 addTypeButtonActionPerformed(evt);
199 removeTypeButton.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.removeTypeButton.text"));
200 removeTypeButton.addActionListener(
new java.awt.event.ActionListener() {
201 public void actionPerformed(java.awt.event.ActionEvent evt) {
202 removeTypeButtonActionPerformed(evt);
206 mimeErrLabel.setForeground(
new java.awt.Color(255, 0, 0));
207 mimeErrLabel.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.mimeErrLabel.text"));
209 mimeRemoveErrLabel.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.mimeRemoveErrLabel.text"));
211 javax.swing.GroupLayout mimePanelLayout =
new javax.swing.GroupLayout(mimePanel);
212 mimePanel.setLayout(mimePanelLayout);
213 mimePanelLayout.setHorizontalGroup(
214 mimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
215 .addGroup(mimePanelLayout.createSequentialGroup()
217 .addGroup(mimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
218 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
219 .addGroup(mimePanelLayout.createSequentialGroup()
220 .addGroup(mimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
221 .addComponent(jLabel1)
222 .addGroup(mimePanelLayout.createSequentialGroup()
223 .addComponent(userTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
224 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
225 .addComponent(addTypeButton))
226 .addComponent(removeTypeButton))
227 .addGap(0, 196, Short.MAX_VALUE))
228 .addComponent(mimeErrLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
229 .addComponent(mimeRemoveErrLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
232 mimePanelLayout.setVerticalGroup(
233 mimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
234 .addGroup(mimePanelLayout.createSequentialGroup()
236 .addComponent(jLabel1)
237 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
238 .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
239 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
240 .addGroup(mimePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
241 .addComponent(userTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
242 .addComponent(addTypeButton))
244 .addComponent(mimeErrLabel)
245 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
246 .addComponent(removeTypeButton)
247 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
248 .addComponent(mimeRemoveErrLabel)
249 .addContainerGap(47, Short.MAX_VALUE))
252 jSplitPane1.setLeftComponent(mimePanel);
254 userExtTextField.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.userExtTextField.text"));
255 userExtTextField.addFocusListener(
new java.awt.event.FocusAdapter() {
256 public void focusGained(java.awt.event.FocusEvent evt) {
257 userExtTextFieldFocusGained(evt);
261 addExtButton.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.addExtButton.text"));
262 addExtButton.addActionListener(
new java.awt.event.ActionListener() {
263 public void actionPerformed(java.awt.event.ActionEvent evt) {
264 addExtButtonActionPerformed(evt);
268 extTable.setModel(extTableModel);
269 jScrollPane3.setViewportView(extTable);
271 removeExtButton.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.removeExtButton.text"));
272 removeExtButton.addActionListener(
new java.awt.event.ActionListener() {
273 public void actionPerformed(java.awt.event.ActionEvent evt) {
274 removeExtButtonActionPerformed(evt);
278 extHeaderLabel.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.extHeaderLabel.text"));
280 extErrorLabel.setForeground(
new java.awt.Color(255, 0, 0));
281 extErrorLabel.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.extErrorLabel.text"));
283 extRemoveErrLabel.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.extRemoveErrLabel.text"));
285 javax.swing.GroupLayout extensionPanelLayout =
new javax.swing.GroupLayout(extensionPanel);
286 extensionPanel.setLayout(extensionPanelLayout);
287 extensionPanelLayout.setHorizontalGroup(
288 extensionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
289 .addGroup(extensionPanelLayout.createSequentialGroup()
291 .addGroup(extensionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
292 .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
293 .addComponent(extHeaderLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
294 .addGroup(extensionPanelLayout.createSequentialGroup()
295 .addGroup(extensionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
296 .addComponent(removeExtButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
297 .addGroup(extensionPanelLayout.createSequentialGroup()
298 .addComponent(userExtTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
299 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
300 .addComponent(addExtButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
301 .addGap(0, 46, Short.MAX_VALUE))
302 .addComponent(extErrorLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
303 .addComponent(extRemoveErrLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
306 extensionPanelLayout.setVerticalGroup(
307 extensionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
308 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, extensionPanelLayout.createSequentialGroup()
310 .addComponent(extHeaderLabel)
311 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
312 .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 285, javax.swing.GroupLayout.PREFERRED_SIZE)
313 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
314 .addGroup(extensionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
315 .addComponent(userExtTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
316 .addComponent(addExtButton))
318 .addComponent(extErrorLabel)
319 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
320 .addComponent(removeExtButton)
321 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
322 .addComponent(extRemoveErrLabel)
323 .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
326 jSplitPane1.setRightComponent(extensionPanel);
328 saveMsgLabel.setForeground(
new java.awt.Color(0, 0, 255));
329 saveMsgLabel.setText(
org.openide.util.NbBundle.getMessage(FileExtMismatchSettingsPanel.class,
"FileExtMismatchSettingsPanel.saveMsgLabel.text"));
331 javax.swing.GroupLayout jPanel1Layout =
new javax.swing.GroupLayout(jPanel1);
332 jPanel1.setLayout(jPanel1Layout);
333 jPanel1Layout.setHorizontalGroup(
334 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
335 .addGroup(jPanel1Layout.createSequentialGroup()
337 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
338 .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 667, Short.MAX_VALUE)
339 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
340 .addGap(0, 0, Short.MAX_VALUE)
341 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
342 .addComponent(saveButton, javax.swing.GroupLayout.Alignment.TRAILING)
343 .addComponent(saveMsgLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))))
346 jPanel1Layout.setVerticalGroup(
347 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
348 .addGroup(jPanel1Layout.createSequentialGroup()
350 .addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
351 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
352 .addComponent(saveButton)
353 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
354 .addComponent(saveMsgLabel)
358 jScrollPane1.setViewportView(jPanel1);
360 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
361 this.setLayout(layout);
362 layout.setHorizontalGroup(
363 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
364 .addComponent(jScrollPane1)
366 layout.setVerticalGroup(
367 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
368 .addGroup(layout.createSequentialGroup()
369 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 482, javax.swing.GroupLayout.PREFERRED_SIZE)
370 .addGap(0, 8, Short.MAX_VALUE))
375 private void addExtButtonActionPerformed(java.awt.event.ActionEvent evt) {
376 String newExt = userExtTextField.getText();
377 if (newExt.isEmpty()) {
378 extErrorLabel.setForeground(Color.red);
379 extErrorLabel.setText(
380 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.addExtButton.errLabel.empty"));
384 if (selectedMime.isEmpty()) {
385 extErrorLabel.setForeground(Color.red);
386 extErrorLabel.setText(
387 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.addExtButton.errLabel.noMimeType"));
391 if (currentExtensions.contains(newExt)) {
392 extErrorLabel.setForeground(Color.red);
393 extErrorLabel.setText(
394 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.addExtButton.errLabel.extExists"));
398 ArrayList<String> editedExtensions =
new ArrayList<>(Arrays.asList(editableMap.get(selectedMime)));
399 editedExtensions.add(newExt);
402 editableMap.put(selectedMime, editedExtensions.toArray(
new String[0]));
406 extTableModel.resync();
409 extErrorLabel.setForeground(Color.blue);
410 extErrorLabel.setText(
411 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.addExtButton.errLabel.extAdded",
413 extRemoveErrLabel.setText(
" ");
414 userExtTextField.setText(
"");
418 private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
422 private void addTypeButtonActionPerformed(java.awt.event.ActionEvent evt) {
423 String newMime = userTypeTextField.getText();
424 if (newMime.isEmpty()) {
425 mimeErrLabel.setForeground(Color.red);
426 mimeErrLabel.setText(NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.addTypeButton.empty"));
429 if (newMime.equals(
"application/octet-stream")) {
430 mimeErrLabel.setForeground(Color.red);
431 mimeErrLabel.setText(NbBundle.getMessage(
this.getClass(),
432 "FileExtMismatchConfigPanel.addTypeButton.mimeTypeNotSupported"));
435 if (mimeList.contains(newMime)) {
436 mimeErrLabel.setForeground(Color.red);
437 mimeErrLabel.setText(
438 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.addTypeButton.mimeTypeExists"));
442 boolean mimeTypeDetectable = (null != fileTypeDetector) ? fileTypeDetector.isDetectable(newMime) :
false;
443 if (!mimeTypeDetectable) {
444 mimeErrLabel.setForeground(Color.red);
445 mimeErrLabel.setText(NbBundle.getMessage(
this.getClass(),
446 "FileExtMismatchConfigPanel.addTypeButton.mimeTypeNotDetectable"));
450 editableMap.put(newMime,
new String[0]);
454 mimeTableModel.resync();
458 mimeErrLabel.setForeground(Color.blue);
459 mimeErrLabel.setText(
460 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.addTypeButton.mimeTypeAdded", newMime));
461 mimeRemoveErrLabel.setText(
" ");
462 userTypeTextField.setText(
"");
466 private void userExtTextFieldFocusGained(java.awt.event.FocusEvent evt) {
467 extErrorLabel.setText(
" ");
470 private void userTypeTextFieldFocusGained(java.awt.event.FocusEvent evt) {
471 mimeErrLabel.setText(
" ");
474 private void removeTypeButtonActionPerformed(java.awt.event.ActionEvent evt) {
475 if (selectedMime.isEmpty()) {
476 mimeRemoveErrLabel.setForeground(Color.red);
477 mimeRemoveErrLabel.setText(
478 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.removeTypeButton.noneSelected"));
482 editableMap.remove(selectedMime);
483 String deadMime = selectedMime;
487 mimeTableModel.resync();
490 mimeRemoveErrLabel.setForeground(Color.blue);
491 mimeRemoveErrLabel.setText(
492 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.remoteTypeButton.deleted", deadMime));
496 private void removeExtButtonActionPerformed(java.awt.event.ActionEvent evt) {
497 if (selectedExt.isEmpty()) {
498 extRemoveErrLabel.setForeground(Color.red);
499 extRemoveErrLabel.setText(
500 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.removeExtButton.noneSelected"));
504 if (selectedMime.isEmpty()) {
505 extErrorLabel.setForeground(Color.red);
506 extErrorLabel.setText(NbBundle.getMessage(
this.getClass(),
507 "FileExtMismatchConfigPanel.removeExtButton.noMimeTypeSelected"));
511 ArrayList<String> editedExtensions =
new ArrayList<>(Arrays.asList(editableMap.get(selectedMime)));
512 editedExtensions.remove(selectedExt);
513 String deadExt = selectedExt;
516 editableMap.put(selectedMime, editedExtensions.toArray(
new String[0]));
520 extTableModel.resync();
523 extRemoveErrLabel.setForeground(Color.blue);
524 extRemoveErrLabel.setText(
525 NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.removeExtButton.deleted", deadExt));
529 private void updateMimeList() {
530 mimeList =
new ArrayList<>(editableMap.keySet());
531 if (mimeList.size() > 0) {
532 Collections.sort(mimeList);
536 private void updateExtList() {
537 String[] temp = editableMap.get(selectedMime);
539 currentExtensions =
new ArrayList<>(Arrays.asList(temp));
540 if (temp.length > 0) {
541 Collections.sort(currentExtensions);
544 currentExtensions = null;
549 public void saveSettings() {
550 if (FileExtMismatchXML.getDefault().save(editableMap)) {
551 mimeErrLabel.setText(
" ");
552 mimeRemoveErrLabel.setText(
" ");
553 extRemoveErrLabel.setText(
" ");
554 extErrorLabel.setText(
" ");
556 saveMsgLabel.setText(NbBundle.getMessage(
this.getClass(),
"FileExtMismatchConfigPanel.store.msg"));
557 saveButton.setEnabled(
false);
560 JOptionPane.showMessageDialog(
this,
561 NbBundle.getMessage(
this.getClass(),
562 "FileExtMismatchConfigPanel.store.msgDlg.msg"),
563 NbBundle.getMessage(
this.getClass(),
564 "FileExtMismatchConfigPanel.save.msgDlg.title"),
565 JOptionPane.ERROR_MESSAGE);
573 editableMap = FileExtMismatchXML.getDefault().load();
579 public void store() {
583 private void setIsModified() {
584 saveButton.setEnabled(
true);
585 saveMsgLabel.setText(
" ");
588 public void cancel() {
595 if (saveButton.isEnabled()) {
596 int choice = JOptionPane.showConfirmDialog(
this,
597 NbBundle.getMessage(
this.getClass(),
598 "FileExtMismatchConfigPanel.ok.confDlg.msg"),
599 NbBundle.getMessage(
this.getClass(),
600 "FileExtMismatchConfigPanel.confDlg.title"),
601 JOptionPane.YES_NO_OPTION);
602 if (choice == JOptionPane.YES_OPTION) {
614 private javax.swing.JButton addExtButton;
615 private javax.swing.JButton addTypeButton;
616 private javax.swing.JLabel extErrorLabel;
617 private javax.swing.JLabel extHeaderLabel;
618 private javax.swing.JLabel extRemoveErrLabel;
619 private javax.swing.JTable extTable;
620 private javax.swing.JPanel extensionPanel;
621 private javax.swing.JLabel jLabel1;
622 private javax.swing.JPanel jPanel1;
623 private javax.swing.JScrollPane jScrollPane1;
624 private javax.swing.JScrollPane jScrollPane2;
625 private javax.swing.JScrollPane jScrollPane3;
626 private javax.swing.JSplitPane jSplitPane1;
627 private javax.swing.JLabel mimeErrLabel;
628 private javax.swing.JPanel mimePanel;
629 private javax.swing.JLabel mimeRemoveErrLabel;
630 private javax.swing.JTable mimeTable;
631 private javax.swing.JButton removeExtButton;
632 private javax.swing.JButton removeTypeButton;
633 private javax.swing.JButton saveButton;
634 private javax.swing.JLabel saveMsgLabel;
635 private javax.swing.JTextField userExtTextField;
636 private javax.swing.JTextField userTypeTextField;
648 return editableMap == null ? 0 : editableMap.size();
653 String colName = null;
657 colName = NbBundle.getMessage(this.getClass(),
"FileExtMismatchConfigPanel.mimeTableModel.colName");
669 if ((mimeList == null) || (rowIndex > mimeList.size())) {
672 String word = mimeList.get(rowIndex);
673 switch (columnIndex) {
678 logger.log(Level.SEVERE,
"Invalid table column index: {0}", columnIndex);
690 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
699 fireTableDataChanged();
712 return currentExtensions == null ? 0 : currentExtensions.size();
717 String colName = null;
721 colName = NbBundle.getMessage(this.getClass(),
"FileExtMismatchConfigPanel.extTableModel.colName");
734 if ((currentExtensions == null) || (currentExtensions.isEmpty()) || (rowIndex > currentExtensions.size())) {
737 String word = currentExtensions.get(rowIndex);
738 switch (columnIndex) {
743 logger.log(Level.SEVERE,
"Invalid table column index: {0}", columnIndex);
755 public void setValueAt(Object aValue,
int rowIndex,
int columnIndex) {
764 fireTableDataChanged();
String getColumnName(int column)
boolean isCellEditable(int rowIndex, int columnIndex)
Class<?> getColumnClass(int c)
void setValueAt(Object aValue, int rowIndex, int columnIndex)
Class<?> getColumnClass(int c)
void setValueAt(Object aValue, int rowIndex, int columnIndex)
boolean isCellEditable(int rowIndex, int columnIndex)
Object getValueAt(int rowIndex, int columnIndex)
Object getValueAt(int rowIndex, int columnIndex)
String getColumnName(int column)