Auto refresh fixed for multi-user cases panel.

This commit is contained in:
U-BASIS\dgrove 2017-10-27 12:23:22 -04:00
parent 2082928e51
commit ad0fe641a7
5 changed files with 141 additions and 80 deletions

View File

@ -55,25 +55,6 @@ public final class CaseOpenMultiUserAction extends CallableSystemAction implemen
private static final String REVIEW_MODE_TITLE = "Open Multi-User Case (" + LOCAL_HOST_NAME + ")";
public CaseOpenMultiUserAction() {}
/**
* Constructs the Multi-User Cases window used by the Open Multi-User Case
* menu item.
*/
private void initMultiUserCasesWindow() {
multiUserCaseWindow = new JDialog(
WindowManager.getDefault().getMainWindow(),
REVIEW_MODE_TITLE,
Dialog.ModalityType.APPLICATION_MODAL);
multiUserCaseWindow.getRootPane().registerKeyboardAction(
e -> {
multiUserCaseWindow.setVisible(false);
},
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
multiUserCaseWindow.add(MultiUserCasesPanel.getInstance());
multiUserCaseWindow.pack();
multiUserCaseWindow.setResizable(false);
}
public static void closeMultiUserCasesWindow() {
if (null != multiUserCaseWindow) {
@ -95,7 +76,7 @@ public final class CaseOpenMultiUserAction extends CallableSystemAction implemen
@Override
public void actionPerformed(ActionEvent event) {
if(multiUserCaseWindow == null) {
initMultiUserCasesWindow();
multiUserCaseWindow = MultiUserCasesDialog.getInstance();
}
multiUserCaseWindow.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
multiUserCaseWindow.setVisible(true);

View File

@ -113,21 +113,6 @@ public class CueBannerPanel extends javax.swing.JPanel {
recentCasesWindow.pack();
recentCasesWindow.setResizable(false);
}
private void initMultiUserCasesWindow() {
multiUserCaseWindow = new JDialog(
WindowManager.getDefault().getMainWindow(),
REVIEW_MODE_TITLE,
Dialog.ModalityType.APPLICATION_MODAL);
multiUserCaseWindow.getRootPane().registerKeyboardAction(
e -> {
multiUserCaseWindow.setVisible(false);
},
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
multiUserCaseWindow.add(MultiUserCasesPanel.getInstance());
multiUserCaseWindow.pack();
multiUserCaseWindow.setResizable(false);
}
private void enableComponents() {
boolean enableOpenRecentCaseButton = (RecentCases.getInstance().getTotalRecentCases() > 0);
@ -304,7 +289,7 @@ public class CueBannerPanel extends javax.swing.JPanel {
private void openMultiUserCaseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openMultiUserCaseButtonActionPerformed
if(multiUserCaseWindow == null) {
initMultiUserCasesWindow();
multiUserCaseWindow = MultiUserCasesDialog.getInstance();
}
multiUserCaseWindow.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
multiUserCaseWindow.setVisible(true);

View File

@ -0,0 +1,81 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011-2017 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.casemodule;
import java.awt.Dialog;
import java.awt.event.KeyEvent;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.KeyStroke;
import org.openide.windows.WindowManager;
/**
* This class extends a JDialog and maintains the MultiUserCasesPanel.
*/
public class MultiUserCasesDialog extends JDialog {
private static final String REVIEW_MODE_TITLE = "Open Multi-User Case";
private final MultiUserCasesPanel multiUserCasesPanel;
private static MultiUserCasesDialog instance;
/**
* Gets the instance of the MultiuserCasesDialog.
*
* @return The instance.
*/
static public MultiUserCasesDialog getInstance() {
if(instance == null) {
instance = new MultiUserCasesDialog();
}
return instance;
}
/**
* Constructs a MultiUserCasesDialog object.
*/
MultiUserCasesDialog() {
super(WindowManager.getDefault().getMainWindow(),
REVIEW_MODE_TITLE,
Dialog.ModalityType.APPLICATION_MODAL);
getRootPane().registerKeyboardAction(
e -> {
setVisible(false);
},
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
multiUserCasesPanel = new MultiUserCasesPanel();
add(multiUserCasesPanel);
pack();
setResizable(false);
}
/**
* Set the dialog visibility. When setting it to visible, the contents will
* refresh.
*
* @param value True or false.
*/
@Override
public void setVisible(boolean value) {
if(value) {
multiUserCasesPanel.refreshCasesTable();
}
super.setVisible(value);
}
}

View File

@ -20,13 +20,16 @@ package org.sleuthkit.autopsy.casemodule;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.EventQueue;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import javax.swing.event.ListSelectionEvent;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
@ -79,26 +82,12 @@ public class MultiUserCasesPanel extends javax.swing.JPanel {
private final String[] columnNames = {CASE_HEADER, CREATEDTIME_HEADER, COMPLETEDTIME_HEADER, STATUS_ICON_HEADER, OUTPUT_FOLDER_HEADER};
private DefaultTableModel caseTableModel;
private Path currentlySelectedCase = null;
private static MultiUserCasesPanel instance;
/*
* Gets the singleton instance of the panel.
*/
static MultiUserCasesPanel getInstance() {
if (instance == null) {
instance = new MultiUserCasesPanel();
}
instance.refreshCasesTable();
return instance;
}
/**
* Constructs a panel that allows a user to open cases created by automated
* ingest.
*
* @param parent The parent dialog for this panel.
*/
private MultiUserCasesPanel() {
MultiUserCasesPanel() {
caseTableModel = new DefaultTableModel(columnNames, 0) {
private static final long serialVersionUID = 1L;
@ -164,36 +153,57 @@ public class MultiUserCasesPanel extends javax.swing.JPanel {
}
setButtons();
});
refreshCasesTable();
}
/**
* Gets the list of cases known to the review mode cases manager and
* refreshes the cases table.
*/
private void refreshCasesTable() {
try {
currentlySelectedCase = getSelectedCase();
MultiUserCaseManager manager = MultiUserCaseManager.getInstance();
List<MultiUserCase> cases = manager.getCases();
cases.sort(REVERSE_DATE_MODIFIED_COMPARATOR);
caseTableModel.setRowCount(0);
long now = new Date().getTime();
for (MultiUserCase autoIngestCase : cases) {
if (passesTimeFilter(now, autoIngestCase.getLastAccessedDate().getTime())) {
caseTableModel.addRow(new Object[]{
autoIngestCase.getCaseName(),
autoIngestCase.getCreationDate(),
autoIngestCase.getLastAccessedDate(),
(MultiUserCase.CaseStatus.OK != autoIngestCase.getStatus()),
autoIngestCase.getMetadataFilePath().toString()});
void refreshCasesTable() {
EventQueue.invokeLater(() -> {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
});
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
try {
currentlySelectedCase = getSelectedCase();
MultiUserCaseManager manager = MultiUserCaseManager.getInstance();
List<MultiUserCase> cases = manager.getCases();
cases.sort(REVERSE_DATE_MODIFIED_COMPARATOR);
caseTableModel.setRowCount(0);
long now = new Date().getTime();
for (MultiUserCase autoIngestCase : cases) {
if (passesTimeFilter(now, autoIngestCase.getLastAccessedDate().getTime())) {
caseTableModel.addRow(new Object[]{
autoIngestCase.getCaseName(),
autoIngestCase.getCreationDate(),
autoIngestCase.getLastAccessedDate(),
(MultiUserCase.CaseStatus.OK != autoIngestCase.getStatus()),
autoIngestCase.getMetadataFilePath().toString()});
}
}
setSelectedCase(currentlySelectedCase);
setButtons();
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Unexpected exception while refreshing the table.", ex); //NON-NLS
}
return null;
}
@Override
protected void done() {
super.done();
setCursor(null);
try {
get();
} catch (InterruptedException | ExecutionException ex) {
LOGGER.log(Level.SEVERE, "Unexpected exception while refreshing the table.", ex); //NON-NLS
}
}
setSelectedCase(currentlySelectedCase);
setButtons();
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, "Unexpected exception in refreshCasesTable", ex); //NON-NLS
}
}.execute();
}
/**

View File

@ -32,7 +32,6 @@ import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.StartupWindowProvider;
import org.sleuthkit.autopsy.core.UserPreferences;
import static org.sleuthkit.autopsy.core.UserPreferences.SETTINGS_PROPERTIES;
import static org.sleuthkit.autopsy.core.UserPreferences.setMode;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
@ -74,13 +73,18 @@ public class Installer extends ModuleInstall {
super.uninstalled();
}
/**
* If the mode in the configuration file is 'REVIEW' (2, now invalid), this
* method will set it to 'STANDALONE' (0) and disable auto ingest.
*/
private void updateConfig() {
// If mode is 'REVIEW' (2, now invalid), set it to 'STANDALONE' (0).
int ordinal = Integer.parseInt(ModuleSettings.getConfigSetting(SETTINGS_PROPERTIES, "AutopsyMode"));
if(ordinal > 1) {
setMode(UserPreferences.SelectedMode.STANDALONE);
ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, "JoinAutoModeCluster", Boolean.toString(false));
ordinal = 0;
String mode = ModuleSettings.getConfigSetting(SETTINGS_PROPERTIES, "AutopsyMode");
if(mode != null) {
int ordinal = Integer.parseInt(mode);
if(ordinal > 1) {
UserPreferences.setMode(UserPreferences.SelectedMode.STANDALONE);
ModuleSettings.setConfigSetting(UserPreferences.SETTINGS_PROPERTIES, "JoinAutoModeCluster", Boolean.toString(false));
}
}
}