+ @Override
+ public void updateAvailableFilterOptions(String VIEWS_FILTER,
+ List<FilterOption> xtantOptions, Collection<FTSData> tdbEntries)
+ {
+ if (tdbEntries != null && lastTdbRequest != null)
+ {
+ boolean hasPDBe = false;
+ for (FTSData _row : tdbEntries)
+ {
+ // tdb returns custom object
+ TDB_FTSData row = (TDB_FTSData) _row;
+ String provider = row.getProvider();
+ FilterOption providerOpt = new FilterOption(
+ "3DB Provider - " + provider,
+ FILTER_SOURCE_PREFIX + provider, VIEWS_FILTER, false, this);
+ if (!xtantOptions.contains(providerOpt))
+ {
+ xtantOptions.add(1, providerOpt);
+ tdBeaconsFilters.add(FILTER_SOURCE_PREFIX + provider);
+ if ("PDBe".equalsIgnoreCase(provider))
+ {
+ hasPDBe = true;
+ }
+ }
+ }
+ if (!hasPDBe)
+ {
+ // remove the PDBe options from the available filters
+ int op = 0;
+ while (op < xtantOptions.size())
+ {
+ FilterOption filter = xtantOptions.get(op);
+ if (filter
+ .getQuerySource() instanceof PDBStructureChooserQuerySource)
+ {
+ xtantOptions.remove(op);
+ }
+ else
+ {
+ op++;
+ }
+ }
+ }
+ }
+
+ }
+
+ private boolean tdBeaconsFilter(String fieldToFilterBy)
+ {
+ return tdBeaconsFilters != null
+ && tdBeaconsFilters.contains(fieldToFilterBy);
+ }
+
+ private String remove_prefix(String fieldToFilterBy)
+ {
+ if (tdBeaconsFilters != null
+ && tdBeaconsFilters.contains(fieldToFilterBy)
+ && !defaultFilters.contains(fieldToFilterBy))
+ {
+ return fieldToFilterBy.substring(FILTER_SOURCE_PREFIX.length());
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Override
+ public boolean needsRefetch(FilterOption selectedFilterOpt)
+ {
+ return selectedFilterOpt == null
+ || !tdBeaconsFilter(selectedFilterOpt.getValue())
+ && lastPdbRequest != lastTdbRequest;
+ }
+