From 82d2b7d2f20eece0f92b44552c73c069e0c47e21 Mon Sep 17 00:00:00 2001
From: Richard Cordovano <rcordovano@basistech.com>
Date: Tue, 3 Dec 2019 16:51:47 -0500
Subject: [PATCH] Remove JFX dependency in TSK

---
 .../sleuthkit/datamodel/TimelineFilter.java   | 82 ++++++++-----------
 1 file changed, 34 insertions(+), 48 deletions(-)

diff --git a/bindings/java/src/org/sleuthkit/datamodel/TimelineFilter.java b/bindings/java/src/org/sleuthkit/datamodel/TimelineFilter.java
index a518cbe0f..7e4665395 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/TimelineFilter.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/TimelineFilter.java
@@ -30,10 +30,6 @@
 import java.util.stream.Collectors;
 import static java.util.stream.Collectors.joining;
 import java.util.stream.Stream;
-import javafx.beans.property.BooleanProperty;
-import javafx.beans.property.Property;
-import javafx.beans.property.SimpleBooleanProperty;
-import javafx.beans.property.SimpleStringProperty;
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableList;
 import static org.apache.commons.lang3.ObjectUtils.notEqual;
@@ -246,7 +242,7 @@ public String toString() {
 	 */
 	public static final class TagsFilter extends TimelineFilter {
 
-		private final BooleanProperty eventSourcesAreTagged = new SimpleBooleanProperty();
+		private boolean eventSourcesAreTagged;
 
 		/**
 		 * Constructs a timeline events filter used to query for a events where
@@ -266,19 +262,19 @@ public TagsFilter() {
 		 *                            accepted by this filter.
 		 */
 		public TagsFilter(boolean eventSourceIsTagged) {
-			this.eventSourcesAreTagged.set(eventSourceIsTagged);
+			this.eventSourcesAreTagged = eventSourceIsTagged;
 		}
 
 		/**
 		 * Sets whether the direct sources of the events have to be tagged or
 		 * not tagged to be accepted by this filter.
 		 *
-		 * @param eventSourceIsTagged Whether the direct sources of the events
-		 *                            have to be tagged or not tagged to be
-		 *                            accepted by this filter.
+		 * @param eventSourcesAreTagged Whether the direct sources of the events
+		 *                              have to be tagged or not tagged to be
+		 *                              accepted by this filter.
 		 */
-		public synchronized void setEventSourcesAreTagged(boolean eventSourceIsTagged) {
-			this.eventSourcesAreTagged.set(eventSourceIsTagged);
+		public synchronized void setEventSourcesAreTagged(boolean eventSourcesAreTagged) {
+			this.eventSourcesAreTagged = eventSourcesAreTagged;
 		}
 
 		/**
@@ -288,7 +284,7 @@ public synchronized void setEventSourcesAreTagged(boolean eventSourceIsTagged) {
 		 * @return True or false.
 		 */
 		public synchronized boolean getEventSourceAreTagged() {
-			return eventSourcesAreTagged.get();
+			return eventSourcesAreTagged;
 		}
 
 		@Override
@@ -298,7 +294,7 @@ public String getDisplayName() {
 
 		@Override
 		public TagsFilter copyOf() {
-			return new TagsFilter(eventSourcesAreTagged.get());
+			return new TagsFilter(eventSourcesAreTagged);
 		}
 
 		@Override
@@ -307,7 +303,7 @@ public boolean equals(Object obj) {
 				return false;
 			}
 
-			return ((TagsFilter) obj).getEventSourceAreTagged() == eventSourcesAreTagged.get();
+			return ((TagsFilter) obj).getEventSourceAreTagged() == getEventSourceAreTagged();
 		}
 
 		@Override
@@ -320,7 +316,7 @@ public int hashCode() {
 		@Override
 		String getSQLWhere(TimelineManager manager) {
 			String whereStr;
-			if (eventSourcesAreTagged.get()) {
+			if (eventSourcesAreTagged) {
 				whereStr = "tagged = 1";
 			} else {
 				whereStr = "tagged = 0";
@@ -368,7 +364,7 @@ String getSQLWhere(TimelineManager manager) {
 	 */
 	public static final class TextFilter extends TimelineFilter {
 
-		private final SimpleStringProperty descriptionSubstring = new SimpleStringProperty();
+		private String descriptionSubstring;
 
 		/**
 		 * Constructs a timeline events filter used to query for events that
@@ -389,17 +385,7 @@ public TextFilter() {
 		 */
 		public TextFilter(String descriptionSubstring) {
 			super();
-			this.descriptionSubstring.set(descriptionSubstring.trim());
-		}
-
-		/**
-		 * Sets the substring that must be present in one or more of the
-		 * descriptions of each event that passes the filter.
-		 *
-		 * @param descriptionSubstring The substring.
-		 */
-		public synchronized void setDescriptionSubstring(String descriptionSubstring) {
-			this.descriptionSubstring.set(descriptionSubstring.trim());
+			this.descriptionSubstring = descriptionSubstring.trim();
 		}
 
 		@Override
@@ -408,28 +394,28 @@ public String getDisplayName() {
 		}
 
 		/**
-		 * Gets the substring that must be present in one or more of the
+		 * Sets the substring that must be present in one or more of the
 		 * descriptions of each event that passes the filter.
 		 *
-		 * @return The required substring.
+		 * @param descriptionSubstring The substring.
 		 */
-		public synchronized String getSubstring() {
-			return descriptionSubstring.getValue();
+		public synchronized void setDescriptionSubstring(String descriptionSubstring) {
+			this.descriptionSubstring = descriptionSubstring.trim();
 		}
 
 		/**
 		 * Gets the substring that must be present in one or more of the
 		 * descriptions of each event that passes the filter.
 		 *
-		 * @return The required substring as a Property.
+		 * @return The required substring.
 		 */
-		public Property<String> substringProperty() {
+		public synchronized String getDescriptionSubstring() {
 			return descriptionSubstring;
 		}
 
 		@Override
 		public synchronized TextFilter copyOf() {
-			return new TextFilter(getSubstring());
+			return new TextFilter(getDescriptionSubstring());
 		}
 
 		@Override
@@ -441,22 +427,22 @@ public boolean equals(Object obj) {
 				return false;
 			}
 			final TextFilter other = (TextFilter) obj;
-			return Objects.equals(getSubstring(), other.getSubstring());
+			return Objects.equals(getDescriptionSubstring(), other.getDescriptionSubstring());
 		}
 
 		@Override
 		public int hashCode() {
 			int hash = 5;
-			hash = 29 * hash + Objects.hashCode(this.descriptionSubstring.get());
+			hash = 29 * hash + Objects.hashCode(descriptionSubstring);
 			return hash;
 		}
 
 		@Override
 		String getSQLWhere(TimelineManager manager) {
-			if (StringUtils.isNotBlank(this.getSubstring())) {
-				return "((med_description like '%" + escapeSingleQuotes(this.getSubstring()) + "%')" //NON-NLS
-						+ " or (full_description like '%" + escapeSingleQuotes(this.getSubstring()) + "%')" //NON-NLS
-						+ " or (short_description like '%" + escapeSingleQuotes(this.getSubstring()) + "%'))"; //NON-NLS
+			if (StringUtils.isNotBlank(this.getDescriptionSubstring())) {
+				return "((med_description like '%" + escapeSingleQuotes(this.getDescriptionSubstring()) + "%')" //NON-NLS
+						+ " or (full_description like '%" + escapeSingleQuotes(this.getDescriptionSubstring()) + "%')" //NON-NLS
+						+ " or (short_description like '%" + escapeSingleQuotes(this.getDescriptionSubstring()) + "%'))"; //NON-NLS
 			} else {
 				return manager.getSQLWhere(null);
 			}
@@ -464,7 +450,7 @@ String getSQLWhere(TimelineManager manager) {
 
 		@Override
 		public String toString() {
-			return "TextFilter{" + "textProperty=" + descriptionSubstring.getValue() + '}';
+			return "TextFilter{" + "textProperty=" + descriptionSubstring + '}';
 		}
 
 	}
@@ -884,7 +870,7 @@ String getSQLWhere(TimelineManager manager) {
 	 */
 	public static final class HashHitsFilter extends TimelineFilter {
 
-		private final BooleanProperty eventSourcesHaveHashSetHits = new SimpleBooleanProperty();
+		private boolean eventSourcesHaveHashSetHits;
 
 		/**
 		 * Constructs a timeline events filter used to query for events where
@@ -903,7 +889,7 @@ public HashHitsFilter() {
 		 *                   have or do not have hash set hits.
 		 */
 		public HashHitsFilter(boolean hasHashHit) {
-			eventSourcesHaveHashSetHits.set(hasHashHit);
+			eventSourcesHaveHashSetHits = hasHashHit;
 		}
 
 		/**
@@ -913,7 +899,7 @@ public HashHitsFilter(boolean hasHashHit) {
 		 * @param hasHashHit True or false.
 		 */
 		public synchronized void setEventSourcesHaveHashSetHits(boolean hasHashHit) {
-			eventSourcesHaveHashSetHits.set(hasHashHit);
+			eventSourcesHaveHashSetHits = hasHashHit;
 		}
 
 		/**
@@ -923,7 +909,7 @@ public synchronized void setEventSourcesHaveHashSetHits(boolean hasHashHit) {
 		 * @return True or false.
 		 */
 		public synchronized boolean getEventSourcesHaveHashSetHits() {
-			return eventSourcesHaveHashSetHits.get();
+			return eventSourcesHaveHashSetHits;
 		}
 
 		@Override
@@ -933,7 +919,7 @@ public String getDisplayName() {
 
 		@Override
 		public HashHitsFilter copyOf() {
-			return new HashHitsFilter(eventSourcesHaveHashSetHits.get());
+			return new HashHitsFilter(eventSourcesHaveHashSetHits);
 		}
 
 		@Override
@@ -942,7 +928,7 @@ public boolean equals(Object obj) {
 				return false;
 			}
 
-			return ((HashHitsFilter) obj).getEventSourcesHaveHashSetHits() == eventSourcesHaveHashSetHits.get();
+			return ((HashHitsFilter) obj).getEventSourcesHaveHashSetHits() == getEventSourcesHaveHashSetHits();
 		}
 
 		@Override
@@ -955,7 +941,7 @@ public int hashCode() {
 		@Override
 		String getSQLWhere(TimelineManager manager) {
 			String whereStr = "";
-			if (eventSourcesHaveHashSetHits.get()) {
+			if (eventSourcesHaveHashSetHits) {
 				whereStr = "hash_hit = 1";
 			} else {
 				whereStr = "hash_hit = 0";
-- 
GitLab