show confirmation dialog when (globaly) switching to full descriptions for > 10,000 events

This commit is contained in:
jmillman 2014-10-23 17:22:48 -04:00
parent dd1a67747d
commit 941d6c8295
3 changed files with 51 additions and 27 deletions

View File

@ -23,8 +23,10 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.NumberFormat;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
import java.util.Map;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
@ -92,7 +94,7 @@ import org.sleuthkit.datamodel.TskCoreException;
* </li> * </li>
* <ul> * <ul>
*/ */
public class TimeLineController { public class TimeLineController {
private static final Logger LOGGER = Logger.getLogger(TimeLineController.class.getName()); private static final Logger LOGGER = Logger.getLogger(TimeLineController.class.getName());
@ -221,9 +223,9 @@ public class TimeLineController {
filteredEvents = eventsRepository.getEventsModel(); filteredEvents = eventsRepository.getEventsModel();
InitialZoomState = new ZoomParams(filteredEvents.getSpanningInterval(), InitialZoomState = new ZoomParams(filteredEvents.getSpanningInterval(),
EventTypeZoomLevel.BASE_TYPE, EventTypeZoomLevel.BASE_TYPE,
Filter.getDefaultFilter(), Filter.getDefaultFilter(),
DescriptionLOD.SHORT); DescriptionLOD.SHORT);
historyManager.advance(InitialZoomState); historyManager.advance(InitialZoomState);
//persistent listener instances //persistent listener instances
@ -466,13 +468,30 @@ public class TimeLineController {
} }
} }
synchronized public void pushDescrLOD(DescriptionLOD newLOD) { synchronized public boolean pushDescrLOD(DescriptionLOD newLOD) {
ZoomParams currentZoom = filteredEvents.getRequestedZoomParamters().get(); Map<EventType, Long> eventCounts = filteredEvents.getEventCounts(filteredEvents.getRequestedZoomParamters().get().getTimeRange());
if (currentZoom == null) { final Long count = eventCounts.values().stream().reduce(0l, Long::sum);
advance(InitialZoomState.withDescrLOD(newLOD));
} else if (currentZoom.hasDescrLOD(newLOD) == false) { boolean shouldContinue = true;
advance(currentZoom.withDescrLOD(newLOD)); if (newLOD == DescriptionLOD.FULL && count > 10_000) {
int showConfirmDialog = JOptionPane.showConfirmDialog(mainFrame,
"You are about to show details for " + NumberFormat.getInstance().format(count) + " events. This might be very slow or even crash Autopsy.\n\nDo you want to continue?",
"",
JOptionPane.YES_NO_OPTION);
shouldContinue = (showConfirmDialog == JOptionPane.YES_OPTION);
} }
if (shouldContinue) {
ZoomParams currentZoom = filteredEvents.getRequestedZoomParamters().get();
if (currentZoom == null) {
advance(InitialZoomState.withDescrLOD(newLOD));
} else if (currentZoom.hasDescrLOD(newLOD) == false) {
advance(currentZoom.withDescrLOD(newLOD));
}
}
return shouldContinue;
} }
synchronized public void pushTimeAndType(Interval timeRange, EventTypeZoomLevel typeZoom) { synchronized public void pushTimeAndType(Interval timeRange, EventTypeZoomLevel typeZoom) {
@ -599,35 +618,35 @@ public class TimeLineController {
*/ */
synchronized public boolean outOfDatePromptAndRebuild() { synchronized public boolean outOfDatePromptAndRebuild() {
return showOutOfDateConfirmation() == JOptionPane.YES_OPTION return showOutOfDateConfirmation() == JOptionPane.YES_OPTION
? rebuildRepo() ? rebuildRepo()
: false; : false;
} }
synchronized int showLastPopulatedWhileIngestingConfirmation() { synchronized int showLastPopulatedWhileIngestingConfirmation() {
return JOptionPane.showConfirmDialog(mainFrame, return JOptionPane.showConfirmDialog(mainFrame,
DO_REPOPULATE_MESSAGE, DO_REPOPULATE_MESSAGE,
"re populate events?", "re populate events?",
JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE); JOptionPane.QUESTION_MESSAGE);
} }
synchronized int showOutOfDateConfirmation() throws MissingResourceException, HeadlessException { synchronized int showOutOfDateConfirmation() throws MissingResourceException, HeadlessException {
return JOptionPane.showConfirmDialog(mainFrame, return JOptionPane.showConfirmDialog(mainFrame,
NbBundle.getMessage(TimeLineController.class, NbBundle.getMessage(TimeLineController.class,
"Timeline.propChg.confDlg.timelineOOD.msg"), "Timeline.propChg.confDlg.timelineOOD.msg"),
NbBundle.getMessage(TimeLineController.class, NbBundle.getMessage(TimeLineController.class,
"Timeline.propChg.confDlg.timelineOOD.details"), "Timeline.propChg.confDlg.timelineOOD.details"),
JOptionPane.YES_NO_OPTION); JOptionPane.YES_NO_OPTION);
} }
synchronized int showIngestConfirmation() throws MissingResourceException, HeadlessException { synchronized int showIngestConfirmation() throws MissingResourceException, HeadlessException {
return JOptionPane.showConfirmDialog(mainFrame, return JOptionPane.showConfirmDialog(mainFrame,
NbBundle.getMessage(TimeLineController.class, NbBundle.getMessage(TimeLineController.class,
"Timeline.initTimeline.confDlg.genBeforeIngest.msg"), "Timeline.initTimeline.confDlg.genBeforeIngest.msg"),
NbBundle.getMessage(TimeLineController.class, NbBundle.getMessage(TimeLineController.class,
"Timeline.initTimeline.confDlg.genBeforeIngest.details"), "Timeline.initTimeline.confDlg.genBeforeIngest.details"),
JOptionPane.YES_NO_OPTION); JOptionPane.YES_NO_OPTION);
} }
private class AutopsyIngestModuleListener implements PropertyChangeListener { private class AutopsyIngestModuleListener implements PropertyChangeListener {

View File

@ -259,4 +259,7 @@ public class FilteredEventsModel {
// requestedLOD.set(zCrumb.getDescrLOD()); // requestedLOD.set(zCrumb.getDescrLOD());
// } // }
// } // }
public DescriptionLOD getDescriptionLOD() {
return requestedLOD.get();
}
} }

View File

@ -130,7 +130,9 @@ public class ZoomSettingsPane extends TitledPane implements TimeLineView {
initializeSlider(descrLODSlider, initializeSlider(descrLODSlider,
() -> { () -> {
DescriptionLOD newLOD = DescriptionLOD.values()[Math.round(descrLODSlider.valueProperty().floatValue())]; DescriptionLOD newLOD = DescriptionLOD.values()[Math.round(descrLODSlider.valueProperty().floatValue())];
controller.pushDescrLOD(newLOD); if (controller.pushDescrLOD(newLOD) == false) {
descrLODSlider.setValue(new DescrLODConverter().fromString(filteredEvents.getDescriptionLOD().toString()));
}
}, this.filteredEvents.descriptionLOD(), }, this.filteredEvents.descriptionLOD(),
() -> { () -> {
descrLODSlider.setValue(this.filteredEvents.descriptionLOD().get().ordinal()); descrLODSlider.setValue(this.filteredEvents.descriptionLOD().get().ordinal());