Patching in Blacklist/Whitelist Default Filters changes
Adds the ability to have default Whitelist/Blacklist filters that apply to all tabs at all times. Whitelist - Only show matches (same as filter bar) Blacklist - Do not show/hide matches Both filter types are OR not AND, so a match on any keyword is considered a match.
This commit is contained in:
parent
c1b8ea99d6
commit
992a58266c
|
@ -44,10 +44,6 @@ public class IgnoreList extends GridPane {
|
||||||
setVgap(10);
|
setVgap(10);
|
||||||
setPadding(new Insets(20, 10, 10, 10));
|
setPadding(new Insets(20, 10, 10, 10));
|
||||||
|
|
||||||
var headline = new Label("Ignore List");
|
|
||||||
headline.getStyleClass().add("settings-group-label");
|
|
||||||
add(headline, 0, 0);
|
|
||||||
|
|
||||||
ignoreListView = new ListView<>();
|
ignoreListView = new ListView<>();
|
||||||
ignoreListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
ignoreListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
ignoreListView.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
|
ignoreListView.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
|
||||||
|
@ -55,7 +51,7 @@ public class IgnoreList extends GridPane {
|
||||||
removeSelectedModels();
|
removeSelectedModels();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
add(ignoreListView, 0, 1);
|
add(ignoreListView, 0, 0);
|
||||||
GridPane.setHgrow(ignoreListView, Priority.ALWAYS);
|
GridPane.setHgrow(ignoreListView, Priority.ALWAYS);
|
||||||
|
|
||||||
var remove = new Button("Remove");
|
var remove = new Button("Remove");
|
||||||
|
|
|
@ -129,6 +129,8 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
private final VariablePlayGroundDialogFactory variablePlayGroundDialogFactory = new VariablePlayGroundDialogFactory();
|
private final VariablePlayGroundDialogFactory variablePlayGroundDialogFactory = new VariablePlayGroundDialogFactory();
|
||||||
private SimpleBooleanProperty checkForUpdates;
|
private SimpleBooleanProperty checkForUpdates;
|
||||||
private PostProcessingStepPanel postProcessingStepPanel;
|
private PostProcessingStepPanel postProcessingStepPanel;
|
||||||
|
private SimpleStringProperty filterBlacklist;
|
||||||
|
private SimpleStringProperty filterWhitelist;
|
||||||
|
|
||||||
public SettingsTab(List<Site> sites, Recorder recorder) {
|
public SettingsTab(List<Site> sites, Recorder recorder) {
|
||||||
this.sites = sites;
|
this.sites = sites;
|
||||||
|
@ -207,6 +209,8 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
dateTimeFormat = new SimpleStringProperty(null, "dateTimeFormat", settings.dateTimeFormat);
|
dateTimeFormat = new SimpleStringProperty(null, "dateTimeFormat", settings.dateTimeFormat);
|
||||||
tabsSortable = new SimpleBooleanProperty(null, "tabsSortable", settings.tabsSortable);
|
tabsSortable = new SimpleBooleanProperty(null, "tabsSortable", settings.tabsSortable);
|
||||||
checkForUpdates = new SimpleBooleanProperty(null, "checkForUpdates", settings.checkForUpdates);
|
checkForUpdates = new SimpleBooleanProperty(null, "checkForUpdates", settings.checkForUpdates);
|
||||||
|
filterBlacklist = new SimpleStringProperty(null, "filterBlacklist", settings.filterBlacklist);
|
||||||
|
filterWhitelist = new SimpleStringProperty(null, "filterWhitelist", settings.filterWhitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGui() {
|
private void createGui() {
|
||||||
|
@ -297,8 +301,13 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
||||||
Setting.of("Steps", postProcessingStepPanel),
|
Setting.of("Steps", postProcessingStepPanel),
|
||||||
Setting.of("", createHelpButton("Post-Processing Help", "http://localhost:5689/docs/PostProcessing.md")),
|
Setting.of("", createHelpButton("Post-Processing Help", "http://localhost:5689/docs/PostProcessing.md")),
|
||||||
Setting.of("", createVariablePlayGroundButton()))),
|
Setting.of("", createVariablePlayGroundButton()))),
|
||||||
Category.of("Events & Actions", new ActionSettingsPanel(recorder)), Category.of("Ignore List", ignoreList),
|
Category.of("Events & Actions", new ActionSettingsPanel(recorder)),
|
||||||
Category.of("Sites", siteCategories.toArray(new Category[0])),
|
Category.of("Filtering",
|
||||||
|
Group.of("Ignore List",
|
||||||
|
Setting.of("", ignoreList)),
|
||||||
|
Group.of("Text Filters",
|
||||||
|
Setting.of("Default Blacklist", filterBlacklist, "Default list of blacklist filters for site views, space seperated"),
|
||||||
|
Setting.of("Default Whitelist", filterWhitelist, "Default list of whitelist filters for site views, space seperated"))), Category.of("Sites", siteCategories.toArray(new Category[0])),
|
||||||
Category.of("Proxy",
|
Category.of("Proxy",
|
||||||
Group.of("Proxy",
|
Group.of("Proxy",
|
||||||
Setting.of("Type", proxyType).needsRestart(),
|
Setting.of("Type", proxyType).needsRestart(),
|
||||||
|
|
|
@ -317,13 +317,29 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
if (updatesSuspended) {
|
if (updatesSuspended) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Model> models = filterIgnoredModels(updateService.getValue());
|
List<Model> models = filterModels(updateService.getValue());
|
||||||
updateGrid(models);
|
updateGrid(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Model> filterIgnoredModels(List<Model> models) {
|
private List<Model> filterModels(List<Model> models) {
|
||||||
List<String> ignored = Config.getInstance().getSettings().ignoredModels;
|
List<String> ignored = Config.getInstance().getSettings().ignoredModels;
|
||||||
return models.stream().filter(m -> !ignored.contains(m.getUrl())).collect(Collectors.toList());
|
String filterBlacklist = Config.getInstance().getSettings().filterBlacklist;
|
||||||
|
String filterWhitelist = Config.getInstance().getSettings().filterWhitelist;
|
||||||
|
if (filterBlacklist.isBlank() && filterWhitelist.isBlank()) {
|
||||||
|
return models.stream()
|
||||||
|
.filter(m -> !ignored.contains(m.getUrl()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
} else if (filterBlacklist.isBlank()) {
|
||||||
|
return models.stream()
|
||||||
|
.filter(m -> !ignored.contains(m.getUrl()))
|
||||||
|
.filter(m -> matches(m, filterWhitelist, true))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return models.stream()
|
||||||
|
.filter(m -> !ignored.contains(m.getUrl()))
|
||||||
|
.filter(m -> !matches(m, filterBlacklist, true))
|
||||||
|
.filter(m -> matches(m, filterWhitelist, true))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateGrid(List<? extends Model> models) {
|
protected void updateGrid(List<? extends Model> models) {
|
||||||
|
@ -633,7 +649,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
var node = iterator.next();
|
var node = iterator.next();
|
||||||
if (node instanceof ThumbCell cell) {
|
if (node instanceof ThumbCell cell) {
|
||||||
var m = cell.getModel();
|
var m = cell.getModel();
|
||||||
if (!matches(m, filter)) {
|
if (!matches(m, filter, false)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
filteredThumbCells.add(cell);
|
filteredThumbCells.add(cell);
|
||||||
cell.setSelected(false);
|
cell.setSelected(false);
|
||||||
|
@ -645,7 +661,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
for (Iterator<ThumbCell> iterator = filteredThumbCells.iterator(); iterator.hasNext(); ) {
|
for (Iterator<ThumbCell> iterator = filteredThumbCells.iterator(); iterator.hasNext(); ) {
|
||||||
var thumbCell = iterator.next();
|
var thumbCell = iterator.next();
|
||||||
var m = thumbCell.getModel();
|
var m = thumbCell.getModel();
|
||||||
if (matches(m, filter)) {
|
if (matches(m, filter, false)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
insert(thumbCell);
|
insert(thumbCell);
|
||||||
}
|
}
|
||||||
|
@ -687,12 +703,14 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matches(Model m, String filter) {
|
private boolean matches(Model m, String filter, Boolean anyMatch) {
|
||||||
try {
|
try {
|
||||||
String[] tokens = filter.split(" ");
|
String[] tokens = filter.split(" ");
|
||||||
var tokensMissing = false;
|
var tokensMissing = false;
|
||||||
for (String token : tokens) {
|
for (String token : tokens) {
|
||||||
if (!modelPropertiesMatchToken(token, m)) {
|
if (anyMatch && modelPropertiesMatchToken(token, m)) {
|
||||||
|
return true;
|
||||||
|
} else if (!modelPropertiesMatchToken(token, m)) {
|
||||||
tokensMissing = true;
|
tokensMissing = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,4 +216,6 @@ public class Settings {
|
||||||
public boolean checkForUpdates = true;
|
public boolean checkForUpdates = true;
|
||||||
public int thumbCacheSize = 16;
|
public int thumbCacheSize = 16;
|
||||||
public boolean dreamcamVR = false;
|
public boolean dreamcamVR = false;
|
||||||
|
public String filterBlacklist = "";
|
||||||
|
public String filterWhitelist = "";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue