Autopsy  4.15.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
PersonaDetailsDialog.java
Go to the documentation of this file.
1 /*
2  * Central Repository
3  *
4  * Copyright 2020 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.centralrepository.persona;
20 
21 import java.awt.Component;
22 import java.util.logging.Level;
23 import javax.swing.JDialog;
24 import javax.swing.JFrame;
25 import org.openide.util.NbBundle;
26 import org.openide.windows.WindowManager;
29 
33 @SuppressWarnings("PMD.SingularField") // UI widgets cause lots of false positives
34 public class PersonaDetailsDialog extends JDialog {
35 
36  private static final long serialVersionUID = 1L;
37 
38  private static final Logger logger = Logger.getLogger(PersonaDetailsDialog.class.getName());
39 
41 
42  @NbBundle.Messages({
43  "PersonaDetailsDialogCreateTitle=Create Persona",
44  "PersonaDetailsDialogEditTitle=Edit Persona",
45  "PersonaDetailsDialogViewTitle=View Persona",})
46  public PersonaDetailsDialog(Component parent, PersonaDetailsMode mode, Persona persona, PersonaDetailsDialogCallback callback) {
47  // by default, display the dialog right away
48  this(parent, mode, persona, callback, true);
49  }
50  public PersonaDetailsDialog(Component parent, PersonaDetailsMode mode, Persona persona, PersonaDetailsDialogCallback callback, boolean displayDialog) {
51  super((JFrame) WindowManager.getDefault().getMainWindow(),
52  getTitle(mode),
53  true);
54  this.callback = callback;
55 
56  initComponents();
57 
58  pdp.setMode(parent, mode, persona);
59 
60  if (displayDialog) {
61  display();
62  }
63  }
64 
65  private static String getTitle(PersonaDetailsMode mode) {
66  switch (mode) {
67  case CREATE:
68  return Bundle.PersonaDetailsDialogCreateTitle();
69  case EDIT:
70  return Bundle.PersonaDetailsDialogEditTitle();
71  case VIEW:
72  return Bundle.PersonaDetailsDialogViewTitle();
73  default:
74  logger.log(Level.WARNING, "Unsupported mode: {0}", mode);
75  return Bundle.PersonaDetailsDialogViewTitle();
76  }
77  }
78 
84  @SuppressWarnings("unchecked")
85  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
86  private void initComponents() {
87 
88  cancelBtn = new javax.swing.JButton();
89  okBtn = new javax.swing.JButton();
91 
92  setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
93  setResizable(false);
94 
95  org.openide.awt.Mnemonics.setLocalizedText(cancelBtn, org.openide.util.NbBundle.getMessage(PersonaDetailsDialog.class, "PersonaDetailsDialog.cancelBtn.text")); // NOI18N
96  cancelBtn.setMaximumSize(new java.awt.Dimension(79, 23));
97  cancelBtn.setMinimumSize(new java.awt.Dimension(79, 23));
98  cancelBtn.setPreferredSize(new java.awt.Dimension(79, 23));
99  cancelBtn.addActionListener(new java.awt.event.ActionListener() {
100  public void actionPerformed(java.awt.event.ActionEvent evt) {
101  cancelBtnActionPerformed(evt);
102  }
103  });
104 
105  org.openide.awt.Mnemonics.setLocalizedText(okBtn, org.openide.util.NbBundle.getMessage(PersonaDetailsDialog.class, "PersonaDetailsDialog.okBtn.text")); // NOI18N
106  okBtn.addActionListener(new java.awt.event.ActionListener() {
107  public void actionPerformed(java.awt.event.ActionEvent evt) {
108  okBtnActionPerformed(evt);
109  }
110  });
111 
112  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
113  getContentPane().setLayout(layout);
114  layout.setHorizontalGroup(
115  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
116  .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
117  .addContainerGap()
118  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
119  .addComponent(pdp, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 660, Short.MAX_VALUE)
120  .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
121  .addGap(0, 0, Short.MAX_VALUE)
122  .addComponent(okBtn)
123  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
124  .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
125  .addContainerGap())
126  );
127 
128  layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelBtn, okBtn});
129 
130  layout.setVerticalGroup(
131  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
132  .addGroup(layout.createSequentialGroup()
133  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
134  .addComponent(pdp, javax.swing.GroupLayout.PREFERRED_SIZE, 564, javax.swing.GroupLayout.PREFERRED_SIZE)
135  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
136  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
137  .addComponent(okBtn)
138  .addComponent(cancelBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
139  .addContainerGap())
140  );
141 
142  pack();
143  }// </editor-fold>//GEN-END:initComponents
144 
145  public final void display() {
146  this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
147  setVisible(true);
148  }
149 
150  private void okBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okBtnActionPerformed
151  Persona ret = pdp.okHandler();
152  if (ret != null) {
153  callback.callback(ret);
154  dispose();
155  }
156  }//GEN-LAST:event_okBtnActionPerformed
157 
158  private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
159  dispose();
160  }//GEN-LAST:event_cancelBtnActionPerformed
161 
163  return this.pdp;
164  }
165 
166  // Variables declaration - do not modify//GEN-BEGIN:variables
167  private javax.swing.JButton cancelBtn;
168  private javax.swing.JButton okBtn;
170  // End of variables declaration//GEN-END:variables
171 }
PersonaDetailsDialog(Component parent, PersonaDetailsMode mode, Persona persona, PersonaDetailsDialogCallback callback, boolean displayDialog)
PersonaDetailsDialog(Component parent, PersonaDetailsMode mode, Persona persona, PersonaDetailsDialogCallback callback)
org.sleuthkit.autopsy.centralrepository.persona.PersonaDetailsPanel pdp
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2020 Basis Technology. Generated on: Mon Jul 6 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.