mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 02:07:42 +00:00
182 lines
8.3 KiB
Java
182 lines
8.3 KiB
Java
/*
|
|
* Autopsy Forensic Browser
|
|
*
|
|
* Copyright 2020-2020 Basis Technology Corp.
|
|
* Contact: carrier <at> sleuthkit <dot> org
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
package org.sleuthkit.autopsy.experimental.autoingest;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import javax.swing.JFrame;
|
|
import org.openide.windows.WindowManager;
|
|
import org.openide.util.NbBundle.Messages;
|
|
|
|
/**
|
|
* This dialog shows the system administrator the orphaned znodes to be deleted.
|
|
* If 'OK' is selected, isOkSelected() will return true.
|
|
*/
|
|
class DeleteOrphanCaseNodesDialog extends javax.swing.JDialog {
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
private static final String NEW_LINE = System.getProperty("line.separator");
|
|
|
|
private boolean okSelected = false;
|
|
|
|
/**
|
|
* Creates new form DeleteOrphanCaseNodesDialog
|
|
*
|
|
* @param zNodeCases The list of cases with nodes to be deleted
|
|
*/
|
|
DeleteOrphanCaseNodesDialog(Collection<String> zNodeCases) {
|
|
super((JFrame) WindowManager.getDefault().getMainWindow(), null, true);
|
|
initComponents();
|
|
additionalInit(zNodeCases);
|
|
}
|
|
|
|
/**
|
|
* displays this dialog as child of main window.
|
|
*/
|
|
void display() {
|
|
this.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
|
|
setVisible(true);
|
|
}
|
|
|
|
@Messages({
|
|
"# {0} - item count",
|
|
"DeleteOrphanCaseNodesDialog.additionalInit.lblNodeCount.text=Znodes found: {0}",
|
|
"# {0} - item count",
|
|
"DeleteOrphanCaseNodesDialog.additionalInit.znodesTextArea.countMessage=ZNODES FOUND: {0}"
|
|
})
|
|
private void additionalInit(Collection<String> zNodeCases) {
|
|
List<String> casesList = (zNodeCases == null) ? new ArrayList<>() : new ArrayList<>(zNodeCases);
|
|
int count = casesList.size();
|
|
casesList.sort(Comparator.comparing(String::toString));
|
|
String textAreaText = Bundle.DeleteOrphanCaseNodesDialog_additionalInit_znodesTextArea_countMessage(count)
|
|
+ NEW_LINE
|
|
+ NEW_LINE
|
|
+ String.join(NEW_LINE, casesList);
|
|
|
|
znodesTextArea.setText(textAreaText);
|
|
|
|
lblNodeCount.setText(Bundle.DeleteOrphanCaseNodesDialog_additionalInit_lblNodeCount_text(count));
|
|
}
|
|
|
|
/**
|
|
* This method is called from within the constructor to initialize the form.
|
|
* WARNING: Do NOT modify this code. The content of this method is always
|
|
* regenerated by the Form Editor.
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
private void initComponents() {
|
|
|
|
javax.swing.JLabel descriptionText = new javax.swing.JLabel();
|
|
javax.swing.JScrollPane jScrollPane = new javax.swing.JScrollPane();
|
|
znodesTextArea = new javax.swing.JTextArea();
|
|
javax.swing.JButton cancelButton = new javax.swing.JButton();
|
|
javax.swing.JButton okButton = new javax.swing.JButton();
|
|
lblNodeCount = new javax.swing.JLabel();
|
|
|
|
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
|
setTitle(org.openide.util.NbBundle.getMessage(DeleteOrphanCaseNodesDialog.class, "DeleteOrphanCaseNodesDialog.titleText.text")); // NOI18N
|
|
setMinimumSize(new java.awt.Dimension(535, 226));
|
|
|
|
org.openide.awt.Mnemonics.setLocalizedText(descriptionText, org.openide.util.NbBundle.getMessage(DeleteOrphanCaseNodesDialog.class, "DeleteOrphanCaseNodesDialog.descriptionText.text")); // NOI18N
|
|
descriptionText.setVerticalAlignment(javax.swing.SwingConstants.TOP);
|
|
|
|
znodesTextArea.setEditable(false);
|
|
znodesTextArea.setColumns(20);
|
|
znodesTextArea.setLineWrap(true);
|
|
znodesTextArea.setRows(5);
|
|
jScrollPane.setViewportView(znodesTextArea);
|
|
|
|
org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(DeleteOrphanCaseNodesDialog.class, "DeleteOrphanCaseNodesDialog.cancelButton.text")); // NOI18N
|
|
cancelButton.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
cancelButtonActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(DeleteOrphanCaseNodesDialog.class, "DeleteOrphanCaseNodesDialog.okButton.text")); // NOI18N
|
|
okButton.addActionListener(new java.awt.event.ActionListener() {
|
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
okButtonActionPerformed(evt);
|
|
}
|
|
});
|
|
|
|
org.openide.awt.Mnemonics.setLocalizedText(lblNodeCount, org.openide.util.NbBundle.getMessage(DeleteOrphanCaseNodesDialog.class, "DeleteOrphanCaseNodesDialog.lblNodeCount.text")); // NOI18N
|
|
|
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
|
getContentPane().setLayout(layout);
|
|
layout.setHorizontalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addContainerGap()
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addComponent(jScrollPane, javax.swing.GroupLayout.Alignment.TRAILING)
|
|
.addComponent(descriptionText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
|
.addComponent(lblNodeCount, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
.addComponent(okButton)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
.addComponent(cancelButton)))
|
|
.addContainerGap())
|
|
);
|
|
layout.setVerticalGroup(
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
.addGroup(layout.createSequentialGroup()
|
|
.addContainerGap()
|
|
.addComponent(descriptionText)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
.addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
.addComponent(cancelButton)
|
|
.addComponent(okButton)
|
|
.addComponent(lblNodeCount))
|
|
.addContainerGap())
|
|
);
|
|
|
|
pack();
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
|
okSelected = true;
|
|
dispose();
|
|
}//GEN-LAST:event_okButtonActionPerformed
|
|
|
|
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
|
|
dispose();
|
|
}//GEN-LAST:event_cancelButtonActionPerformed
|
|
|
|
/**
|
|
* If the system administrator selected OK.
|
|
*
|
|
* @return Whether or not 'OK' was selected by the system administrator.
|
|
*/
|
|
boolean isOkSelected() {
|
|
return okSelected;
|
|
}
|
|
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
private javax.swing.JLabel lblNodeCount;
|
|
private javax.swing.JTextArea znodesTextArea;
|
|
// End of variables declaration//GEN-END:variables
|
|
}
|