mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 07:56:16 +00:00
comments and minor cleanup in EventStripeNode
This commit is contained in:
parent
f041783a19
commit
a1eea710a9
@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.timeline.ui.detailview;
|
package org.sleuthkit.autopsy.timeline.ui.detailview;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
@ -31,40 +32,52 @@ import org.controlsfx.control.action.ActionUtils;
|
|||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.timeline.datamodel.EventCluster;
|
import org.sleuthkit.autopsy.timeline.datamodel.EventCluster;
|
||||||
import org.sleuthkit.autopsy.timeline.datamodel.EventStripe;
|
import org.sleuthkit.autopsy.timeline.datamodel.EventStripe;
|
||||||
|
import org.sleuthkit.autopsy.timeline.datamodel.SingleEvent;
|
||||||
import static org.sleuthkit.autopsy.timeline.ui.detailview.EventNodeBase.configureActionButton;
|
import static org.sleuthkit.autopsy.timeline.ui.detailview.EventNodeBase.configureActionButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node used in {@link EventDetailsChart} to represent an EventStripe.
|
* Node used in DetailsChart to represent an EventStripe.
|
||||||
*/
|
*/
|
||||||
final public class EventStripeNode extends MultiEventNodeBase<EventStripe, EventCluster, EventClusterNode> {
|
final public class EventStripeNode extends MultiEventNodeBase<EventStripe, EventCluster, EventClusterNode> {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(EventStripeNode.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(EventStripeNode.class.getName());
|
||||||
|
|
||||||
private Action newHideAction() {
|
/**
|
||||||
return new HideDescriptionAction(getDescription(), getEvent().getDescriptionLoD(), chartLane.getParentChart());
|
* The button to expand hide stripes with this description, created lazily.
|
||||||
}
|
*/
|
||||||
private Button hideButton;
|
private Button hideButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param chartLane the DetailsChartLane this node belongs to
|
||||||
|
* @param eventStripe the EventStripe represented by this node
|
||||||
|
* @param parentNode the EventClusterNode that is the parent of this node.
|
||||||
|
*/
|
||||||
EventStripeNode(DetailsChartLane<?> chartLane, EventStripe eventStripe, EventClusterNode parentNode) {
|
EventStripeNode(DetailsChartLane<?> chartLane, EventStripe eventStripe, EventClusterNode parentNode) {
|
||||||
super(chartLane, eventStripe, parentNode);
|
super(chartLane, eventStripe, parentNode);
|
||||||
setMinHeight(24);
|
|
||||||
//setup description label
|
//setup description label
|
||||||
descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
|
descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
|
||||||
descrLabel.setPrefWidth(USE_COMPUTED_SIZE);
|
descrLabel.setPrefWidth(USE_COMPUTED_SIZE);
|
||||||
|
|
||||||
|
setMinHeight(24);
|
||||||
setAlignment(subNodePane, Pos.BOTTOM_LEFT);
|
setAlignment(subNodePane, Pos.BOTTOM_LEFT);
|
||||||
|
|
||||||
if (eventStripe.getClusters().size() > 1) {
|
if (eventStripe.getClusters().size() > 1) {
|
||||||
for (EventCluster cluster : eventStripe.getClusters()) {
|
for (EventCluster cluster : eventStripe.getClusters()) {
|
||||||
subNodes.add(createChildNode(cluster.withParent(eventStripe)));
|
subNodes.add(createChildNode(cluster.withParent(eventStripe)));
|
||||||
}
|
}
|
||||||
|
//stack componenets vertically
|
||||||
getChildren().addAll(new VBox(infoHBox, subNodePane));
|
getChildren().addAll(new VBox(infoHBox, subNodePane));
|
||||||
} else {
|
} else {
|
||||||
|
//if the stripe only has one cluster, use alternate simpler layout
|
||||||
EventNodeBase<?> childNode;
|
EventNodeBase<?> childNode;
|
||||||
EventCluster cluster = Iterables.getOnlyElement(eventStripe.getClusters()).withParent(eventStripe);
|
EventCluster cluster = Iterables.getOnlyElement(eventStripe.getClusters()).withParent(eventStripe);
|
||||||
if (cluster.getEventIDs().size() == 1) {
|
if (cluster.getEventIDs().size() == 1) {
|
||||||
childNode = createChildNode(cluster);
|
childNode = createChildNode(cluster);
|
||||||
} else {
|
} else {
|
||||||
|
//if the cluster has more than one event, add the clusters controls to this stripe node directly.
|
||||||
EventClusterNode eventClusterNode = (EventClusterNode) createChildNode(cluster);
|
EventClusterNode eventClusterNode = (EventClusterNode) createChildNode(cluster);
|
||||||
eventClusterNode.installActionButtons();
|
eventClusterNode.installActionButtons();
|
||||||
controlsHBox.getChildren().addAll(eventClusterNode.getNewCollapseButton(), eventClusterNode.getNewExpandButton());
|
controlsHBox.getChildren().addAll(eventClusterNode.getNewCollapseButton(), eventClusterNode.getNewExpandButton());
|
||||||
@ -72,22 +85,31 @@ final public class EventStripeNode extends MultiEventNodeBase<EventStripe, Event
|
|||||||
childNode = eventClusterNode;
|
childNode = eventClusterNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//hide the cluster description
|
||||||
childNode.setDescriptionVisibility(DescriptionVisibility.HIDDEN);
|
childNode.setDescriptionVisibility(DescriptionVisibility.HIDDEN);
|
||||||
|
|
||||||
subNodes.add(childNode);
|
subNodes.add(childNode);
|
||||||
|
//stack componenet in z rather than vertically
|
||||||
getChildren().addAll(infoHBox, subNodePane);
|
getChildren().addAll(infoHBox, subNodePane);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventStripe getEventStripe() {
|
/**
|
||||||
return getEvent();
|
* Get a new Action that hides stripes with the same description as this
|
||||||
|
* one.
|
||||||
|
*
|
||||||
|
* @return a new Action that hides stripes with the same description as this
|
||||||
|
* one.
|
||||||
|
*/
|
||||||
|
private Action newHideAction() {
|
||||||
|
return new HideDescriptionAction(getDescription(), getEvent().getDescriptionLoD(), chartLane.getParentChart());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void installActionButtons() {
|
void installActionButtons() {
|
||||||
super.installActionButtons();
|
super.installActionButtons();
|
||||||
if (chartLane.quickHideFiltersEnabled() && hideButton == null) {
|
if (chartLane.quickHideFiltersEnabled() && hideButton == null) {
|
||||||
hideButton = ActionUtils.createButton(newHideAction(),
|
hideButton = ActionUtils.createButton(newHideAction(), ActionUtils.ActionTextBehavior.HIDE);
|
||||||
ActionUtils.ActionTextBehavior.HIDE);
|
|
||||||
configureActionButton(hideButton);
|
configureActionButton(hideButton);
|
||||||
|
|
||||||
controlsHBox.getChildren().add(hideButton);
|
controlsHBox.getChildren().add(hideButton);
|
||||||
@ -96,8 +118,10 @@ final public class EventStripeNode extends MultiEventNodeBase<EventStripe, Event
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
EventNodeBase<?> createChildNode(EventCluster cluster) {
|
EventNodeBase<?> createChildNode(EventCluster cluster) {
|
||||||
if (cluster.getEventIDs().size() == 1) {
|
ImmutableSet<Long> eventIDs = cluster.getEventIDs();
|
||||||
return new SingleEventNode(getChartLane(), getChartLane().getController().getEventsModel().getEventById(Iterables.getOnlyElement(cluster.getEventIDs())).withParent(cluster), this);
|
if (eventIDs.size() == 1) {
|
||||||
|
SingleEvent singleEvent = getController().getEventsModel().getEventById(Iterables.getOnlyElement(eventIDs)).withParent(cluster);
|
||||||
|
return new SingleEventNode(getChartLane(), singleEvent, this);
|
||||||
} else {
|
} else {
|
||||||
return new EventClusterNode(getChartLane(), cluster, this);
|
return new EventClusterNode(getChartLane(), cluster, this);
|
||||||
}
|
}
|
||||||
@ -106,6 +130,7 @@ final public class EventStripeNode extends MultiEventNodeBase<EventStripe, Event
|
|||||||
@Override
|
@Override
|
||||||
EventHandler<MouseEvent> getDoubleClickHandler() {
|
EventHandler<MouseEvent> getDoubleClickHandler() {
|
||||||
return mouseEvent -> {
|
return mouseEvent -> {
|
||||||
|
//no-op
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +140,5 @@ final public class EventStripeNode extends MultiEventNodeBase<EventStripe, Event
|
|||||||
super.getActions(),
|
super.getActions(),
|
||||||
Arrays.asList(newHideAction())
|
Arrays.asList(newHideAction())
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user