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;
@ -466,7 +468,22 @@ public class TimeLineController {
} }
} }
synchronized public void pushDescrLOD(DescriptionLOD newLOD) { synchronized public boolean pushDescrLOD(DescriptionLOD newLOD) {
Map<EventType, Long> eventCounts = filteredEvents.getEventCounts(filteredEvents.getRequestedZoomParamters().get().getTimeRange());
final Long count = eventCounts.values().stream().reduce(0l, Long::sum);
boolean shouldContinue = true;
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(); ZoomParams currentZoom = filteredEvents.getRequestedZoomParamters().get();
if (currentZoom == null) { if (currentZoom == null) {
advance(InitialZoomState.withDescrLOD(newLOD)); advance(InitialZoomState.withDescrLOD(newLOD));
@ -474,6 +491,8 @@ public class TimeLineController {
advance(currentZoom.withDescrLOD(newLOD)); advance(currentZoom.withDescrLOD(newLOD));
} }
} }
return shouldContinue;
}
synchronized public void pushTimeAndType(Interval timeRange, EventTypeZoomLevel typeZoom) { synchronized public void pushTimeAndType(Interval timeRange, EventTypeZoomLevel typeZoom) {
// timeRange = this.filteredEvents.getSpanningInterval().overlap(timeRange); // timeRange = this.filteredEvents.getSpanningInterval().overlap(timeRange);

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());