19 package org.sleuthkit.autopsy.actions;
21 import java.awt.Component;
22 import java.awt.Window;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.KeyEvent;
25 import java.util.logging.Level;
26 import java.util.HashSet;
28 import javax.swing.AbstractAction;
29 import javax.swing.ActionMap;
30 import javax.swing.DefaultListCellRenderer;
31 import javax.swing.InputMap;
32 import javax.swing.JComponent;
33 import javax.swing.JDialog;
34 import javax.swing.JList;
35 import javax.swing.KeyStroke;
36 import org.openide.util.NbBundle;
37 import org.openide.windows.WindowManager;
81 return doDialog(WindowManager.getDefault().getMainWindow());
105 ModalityType.APPLICATION_MODAL);
111 tagCombo.setRenderer(
new DefaultListCellRenderer() {
112 private static final long serialVersionUID = 1L;
114 public Component getListCellRendererComponent(JList<?> list, Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
116 String newValue = ((TagName) value).getDisplayName() + status;
117 return super.getListCellRendererComponent(list, newValue, index, isSelected, cellHasFocus);
121 String cancelName = NbBundle.getMessage(this.getClass(),
"GetTagNameAndCommentDialog.cancelName");
122 InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
124 inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName);
125 ActionMap actionMap = getRootPane().getActionMap();
127 actionMap.put(cancelName,
new AbstractAction() {
128 private static final long serialVersionUID = 1L;
131 public void actionPerformed(ActionEvent e) {
147 .getName()).log(Level.SEVERE,
"Failed to get tag names", ex);
149 for (TagName tag : tagNamesSet) {
155 this.setLocationRelativeTo(this.getOwner());
164 @SuppressWarnings(
"unchecked")
168 okButton =
new javax.swing.JButton();
170 tagCombo =
new javax.swing.JComboBox<TagName>();
171 tagLabel =
new javax.swing.JLabel();
176 addWindowListener(
new java.awt.event.WindowAdapter() {
177 public void windowClosing(java.awt.event.WindowEvent evt) {
183 okButton.addActionListener(
new java.awt.event.ActionListener() {
184 public void actionPerformed(java.awt.event.ActionEvent evt) {
190 cancelButton.addActionListener(
new java.awt.event.ActionListener() {
191 public void actionPerformed(java.awt.event.ActionEvent evt) {
198 org.openide.awt.Mnemonics.setLocalizedText(tagLabel,
org.openide.util.NbBundle.getMessage(
GetTagNameAndCommentDialog.class,
"GetTagNameAndCommentDialog.tagLabel.text"));
206 newTagButton.addActionListener(
new java.awt.event.ActionListener() {
207 public void actionPerformed(java.awt.event.ActionEvent evt) {
212 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(getContentPane());
213 getContentPane().setLayout(layout);
214 layout.setHorizontalGroup(
215 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
216 .addGroup(layout.createSequentialGroup()
218 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
219 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
221 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 165, Short.MAX_VALUE)
222 .addComponent(
okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
223 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
225 .addGroup(layout.createSequentialGroup()
226 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228 .addComponent(tagLabel))
229 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
230 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
232 .addComponent(
tagCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
236 layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
new java.awt.Component[] {cancelButton, okButton});
238 layout.setVerticalGroup(
239 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
240 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
242 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
243 .addComponent(
tagCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
244 .addComponent(tagLabel))
245 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
246 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
248 .addComponent(
commentText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
249 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
250 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
257 getRootPane().setDefaultButton(
okButton);
263 TagName tagNameFromCombo = (TagName)
tagCombo.getSelectedItem();
269 tagNameAndComment = null;
274 tagNameAndComment = null;
280 if (newTagName != null) {
281 tagNamesSet.add(newTagName);
283 tagCombo.setSelectedItem(newTagName);
static Case getOpenCase()
TagsManager getTagsManager()
synchronized static Logger getLogger(String name)
static TagName doDialog()