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(65, 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);
85 public Signature getSignature() {
94 public BUTTON_PRESSED getResult() {
104 "AddFileTypeSignatureDialog.addButton.title=OK",
105 "AddFileTypeSignatureDialog.cancelButton.title=Cancel"})
106 void display(
boolean add) {
107 setLayout(
new BorderLayout());
112 setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
118 add(this.addFileTypeSigPanel, BorderLayout.PAGE_START);
122 okButton =
new JButton(Bundle.AddFileTypeSignatureDialog_addButton_title());
123 okButton.addActionListener(
new ActionListener() {
125 public void actionPerformed(ActionEvent e) {
126 doButtonAction(
true);
130 okButton.setMaximumSize(BUTTON_SIZE);
131 okButton.setPreferredSize(BUTTON_SIZE);
134 JButton cancelButton =
new JButton(Bundle.AddFileTypeSignatureDialog_cancelButton_title());
135 cancelButton.addActionListener(
new ActionListener() {
137 public void actionPerformed(ActionEvent e) {
138 doButtonAction(
false);
142 cancelButton.setMaximumSize(BUTTON_SIZE);
143 cancelButton.setPreferredSize(BUTTON_SIZE);
146 JPanel buttonPanel =
new JPanel();
147 buttonPanel.setLayout(
new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
148 buttonPanel.add(okButton);
149 buttonPanel.add(
new javax.swing.Box.Filler(
new Dimension(10, 10),
new Dimension(10, 10),
new Dimension(10, 10)));
150 buttonPanel.add(cancelButton);
151 buttonPanel.add(
new javax.swing.Box.Filler(
new Dimension(10, 10),
new Dimension(10, 10),
new Dimension(10, 10)));
152 add(buttonPanel, BorderLayout.LINE_END);
158 this.addWindowListener(
new WindowAdapter() {
160 public void windowClosing(WindowEvent e) {
161 doButtonAction(
false);
179 @Messages({
"AddFileTypeSignatureDialog.invalidSignature.message=Invalid signature"})
180 private void doButtonAction(
boolean okPressed) {
182 Signature sig = addFileTypeSigPanel.getSignature();
184 this.signature = sig;
185 this.result = BUTTON_PRESSED.OK;
189 this.signature = null;
190 this.result = BUTTON_PRESSED.CANCEL;