19 package org.sleuthkit.autopsy.modules.filetypeid;
21 import java.awt.BorderLayout;
22 import java.awt.Dimension;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.awt.event.WindowAdapter;
26 import java.awt.event.WindowEvent;
27 import javax.swing.BoxLayout;
28 import javax.swing.JButton;
29 import javax.swing.JDialog;
30 import javax.swing.JPanel;
31 import org.openide.util.NbBundle;
32 import org.openide.util.NbBundle.Messages;
33 import org.openide.windows.WindowManager;
41 @SuppressWarnings(
"PMD.SingularField")
42 final class AddFileTypeSignatureDialog extends JDialog {
44 private static final long serialVersionUID = 1L;
45 private static final Dimension BUTTON_SIZE =
new Dimension(85, 23);
46 private final AddFileTypeSignaturePanel addFileTypeSigPanel;
47 private static final String TITLE = NbBundle.getMessage(RunIngestModulesAction.class,
"RunIngestModulesAction.name");
48 private Signature signature;
49 private BUTTON_PRESSED result;
63 AddFileTypeSignatureDialog() {
64 super(WindowManager.getDefault().getMainWindow(), TITLE,
true);
65 this.addFileTypeSigPanel =
new AddFileTypeSignaturePanel();
74 AddFileTypeSignatureDialog(Signature toEdit) {
75 super(WindowManager.getDefault().getMainWindow(), TITLE,
true);
76 this.addFileTypeSigPanel =
new AddFileTypeSignaturePanel(toEdit);
81 setLayout(
new BorderLayout());
87 add(this.addFileTypeSigPanel, BorderLayout.PAGE_START);
91 okButton =
new JButton(Bundle.AddFileTypeSignatureDialog_addButton_title());
92 okButton.addActionListener(
new ActionListener() {
94 public void actionPerformed(ActionEvent e) {
99 okButton.setMaximumSize(BUTTON_SIZE);
100 okButton.setPreferredSize(BUTTON_SIZE);
103 JButton cancelButton =
new JButton(Bundle.AddFileTypeSignatureDialog_cancelButton_title());
104 cancelButton.addActionListener(
new ActionListener() {
106 public void actionPerformed(ActionEvent e) {
107 doButtonAction(
false);
111 cancelButton.setMaximumSize(BUTTON_SIZE);
112 cancelButton.setPreferredSize(BUTTON_SIZE);
115 JPanel buttonPanel =
new JPanel();
116 buttonPanel.setLayout(
new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
117 buttonPanel.add(okButton);
118 buttonPanel.add(
new javax.swing.Box.Filler(
new Dimension(10, 35),
new Dimension(10, 35),
new Dimension(10, 35)));
119 buttonPanel.add(cancelButton);
120 buttonPanel.add(
new javax.swing.Box.Filler(
new Dimension(10, 35),
new Dimension(10, 35),
new Dimension(10, 35)));
121 buttonPanel.validate();
122 add(buttonPanel, BorderLayout.LINE_END);
128 this.addWindowListener(
new WindowAdapter() {
130 public void windowClosing(WindowEvent e) {
131 doButtonAction(
false);
143 public Signature getSignature() {
152 public BUTTON_PRESSED getResult() {
162 "AddFileTypeSignatureDialog.addButton.title=OK",
163 "AddFileTypeSignatureDialog.cancelButton.title=Cancel"})
164 void display(
boolean add) {
168 setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
181 @Messages({
"AddFileTypeSignatureDialog.invalidSignature.message=Invalid signature"})
182 private void doButtonAction(
boolean okPressed) {
184 Signature sig = addFileTypeSigPanel.getSignature();
186 this.signature = sig;
187 this.result = BUTTON_PRESSED.OK;
191 this.signature = null;
192 this.result = BUTTON_PRESSED.CANCEL;