javafx.collections.transformation.FilteredList Java Examples

The following examples show how to use javafx.collections.transformation.FilteredList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LibraryController.java    From houdoku with MIT License 7 votes vote down vote up
/**
 * Set the predicate of the series table's FilteredList.
 * 
 * <p>This method filters the given list based on the contents of the filterTextField and on the
 * selected category.
 * 
 * <p>This method needs to be called whenever actions which could change the predicate are
 * performed - i.e., clicking a category.
 *
 * @param filteredData the FilteredList of series to set the predicate of
 */
private void setCombinedPredicate(FilteredList<Series> filteredData) {
    filteredData.setPredicate(series -> {
        // check that the series title, author, or artist contains the
        // text filter
        String filter = filterTextField.getText().toLowerCase();
        boolean title_matches = series.getTitle().toLowerCase().contains(filter);
        boolean creator_matches = (series.author != null
                && series.author.toLowerCase().contains(filter))
                || (series.artist != null && series.artist.toLowerCase().contains(filter));

        // check that the series has the selected category
        boolean category_matches = false;
        if (treeView.getSelectionModel().getSelectedItem() != null) {
            TreeItem<Category> selectedTreeCell =
                    treeView.getSelectionModel().getSelectedItem();
            Category category = selectedTreeCell.getValue();
            category_matches = series.getStringCategories().stream()
                    .anyMatch(stringCategory -> stringCategory.equals(category.getName()))
                    || category.equals(library.getRootCategory());
        }

        return (title_matches || creator_matches) && category_matches;
    });
}
 
Example #2
Source File: TableVisualisation.java    From constellation with Apache License 2.0 6 votes vote down vote up
public void populateTable(final List<C> items) {
    final ObservableList<C> tableData = FXCollections.observableArrayList(items);

    final FilteredList<C> filteredData = new FilteredList<>(tableData, predicate -> true);
    filteredData.addListener((Change<? extends C> change) -> table.refresh());
    tableFilter.textProperty().addListener((observable, oldValue, newValue) -> {
        filteredData.setPredicate(item -> {
            if (newValue == null || newValue.isEmpty()) {
                return true;
            }

            final String lowerCaseFilter = newValue.toLowerCase();
            return item.getIdentifier().toLowerCase().contains(lowerCaseFilter);
        });
    });

    final SortedList<C> sortedData = new SortedList<>(filteredData);
    sortedData.comparatorProperty().bind(table.comparatorProperty());

    table.setItems(sortedData);
}
 
Example #3
Source File: ActivityController.java    From PeerWasp with MIT License 6 votes vote down vote up
/**
 * Wires the list view with the items source and configures filtering and sorting of the items.
 */
private void loadItems() {
	// filtering -- default show all
	FilteredList<ActivityItem> filteredItems = new FilteredList<>(activityLogger.getActivityItems(), p -> true);
	txtFilter.textProperty().addListener(new ChangeListener<String>() {
		@Override
		public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
			// filter on predicate
			filteredItems.setPredicate(new ActivityItemFilterPredicate(newValue));
		}
	});

	// sorting
	SortedList<ActivityItem> sortedItems = new SortedList<>(filteredItems, new ActivityItemTimeComparator());

	// set item source
	lstActivityLog.setItems(sortedItems);
	lstActivityLog
			.setCellFactory(new Callback<ListView<ActivityItem>, ListCell<ActivityItem>>() {
				@Override
				public ListCell<ActivityItem> call(ListView<ActivityItem> param) {
					return new ActivityItemCell();
				}
			});
}
 
Example #4
Source File: DbgView.java    From erlyberly with GNU General Public License v3.0 6 votes vote down vote up
private void filterForFunctionTextMatch(String search) {
    String[] split = search.split(":");

    if(split.length == 0)
        return;

    final String moduleName = split[0];
    final String funcName = (split.length > 1) ? split[1] : "";

    if(search.contains(":")) {
        for (TreeItem<ModFunc> treeItem : filteredTreeModules) {
            treeItem.setExpanded(true);
        }
    }

    for (FilteredList<TreeItem<ModFunc>> funcItemList : functionLists.values()) {
        funcItemList.setPredicate((t) -> { return isMatchingModFunc(funcName, t); });
    }

    filteredTreeModules.setPredicate((t) -> { return isMatchingModFunc(moduleName, t) && !t.getChildren().isEmpty(); });
}
 
Example #5
Source File: LibrarySidebarSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates the {@link LibrarySidebarToggleGroup} which contains all known shortcut categories
 */
private LibrarySidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<ShortcutCategoryDTO> filteredShortcutCategories = getControl().getItems()
            .filtered(getControl().getFilter()::filter);

    filteredShortcutCategories.predicateProperty().bind(
            Bindings.createObjectBinding(() -> getControl().getFilter()::filter,
                    getControl().searchTermProperty()));

    final LibrarySidebarToggleGroup categoryView = new LibrarySidebarToggleGroup(tr("Categories"),
            filteredShortcutCategories);

    getControl().selectedShortcutCategoryProperty().bind(categoryView.selectedElementProperty());

    return categoryView;
}
 
Example #6
Source File: ContainerSidebarSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a {@link ContainersSidebarToggleGroup} object containing all installed containers
 */
private ContainersSidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<ContainerCategoryDTO> filteredContainerCategories = getControl().getItems()
            .filtered(getControl().getFilter()::filter);

    filteredContainerCategories.predicateProperty().bind(
            Bindings.createObjectBinding(() -> getControl().getFilter()::filter,
                    getControl().searchTermProperty(),
                    getControl().selectedContainerCategoryProperty()));

    final ContainersSidebarToggleGroup sidebarToggleGroup = new ContainersSidebarToggleGroup(tr("Containers"),
            filteredContainerCategories);

    getControl().selectedContainerCategoryProperty().bind(sidebarToggleGroup.selectedElementProperty());

    return sidebarToggleGroup;
}
 
Example #7
Source File: InstallationSidebarSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates the {@link InstallationsSidebarToggleGroup} which contains all active installation categories
 */
private InstallationsSidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<InstallationCategoryDTO> filteredInstallationCategories = getControl().getItems()
            .filtered(getControl().getFilter()::filter);

    filteredInstallationCategories.predicateProperty().bind(
            Bindings.createObjectBinding(() -> getControl().getFilter()::filter,
                    getControl().searchTermProperty()));

    final InstallationsSidebarToggleGroup categoryView = new InstallationsSidebarToggleGroup(tr("Categories"),
            filteredInstallationCategories);

    getControl().selectedInstallationCategoryProperty().bind(categoryView.selectedElementProperty());

    return categoryView;
}
 
Example #8
Source File: EngineSidebarSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates the {@link EnginesSidebarToggleGroup} which contains all known engine categories
 */
private EnginesSidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<EngineCategoryDTO> filteredEngineCategories = getControl().getItems()
            .filtered(getControl().getFilter()::filter);

    filteredEngineCategories.predicateProperty().bind(
            Bindings.createObjectBinding(() -> getControl().getFilter()::filter,
                    getControl().searchTermProperty(),
                    getControl().showInstalledProperty(),
                    getControl().showNotInstalledProperty()));

    final EnginesSidebarToggleGroup categoryView = new EnginesSidebarToggleGroup(tr("Engines"),
            filteredEngineCategories);

    getControl().selectedEngineCategoryProperty().bind(categoryView.selectedElementProperty());

    return categoryView;
}
 
Example #9
Source File: EngineSubCategoryPanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a {@link FilteredList} object of the engine versions by applying the {@link EnginesFilter} known to the
 * control
 *
 * @return A filtered list of the engine versions
 */
private ObservableList<EngineVersionDTO> createFilteredEngineVersions() {
    final EnginesFilter filter = getControl().getFilter();

    final EngineCategoryDTO engineCategory = getControl().getEngineCategory();
    final EngineSubCategoryDTO engineSubCategory = getControl().getEngineSubCategory();

    final FilteredList<EngineVersionDTO> filteredEngineVersions = FXCollections
            .observableArrayList(engineSubCategory.getPackages())
            .sorted(EngineSubCategoryDTO.comparator().reversed())
            .filtered(filter.createFilter(engineCategory, engineSubCategory));

    filteredEngineVersions.predicateProperty().bind(
            Bindings.createObjectBinding(() -> filter.createFilter(engineCategory, engineSubCategory),
                    filter.searchTermProperty(),
                    filter.selectedEngineCategoryProperty(),
                    filter.showInstalledProperty(),
                    filter.showNotInstalledProperty()));

    return filteredEngineVersions;
}
 
Example #10
Source File: ApplicationSidebarSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
private ApplicationSidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<CategoryDTO> filteredCategories = getControl().getItems()
            .filtered(getControl()::filterCategory);

    filteredCategories.predicateProperty().bind(
            Bindings.createObjectBinding(() -> getControl()::filterCategory,
                    getControl().searchTermProperty(),
                    getControl().fuzzySearchRatioProperty(),
                    getControl().operatingSystemProperty(),
                    getControl().containAllOSCompatibleApplicationsProperty(),
                    getControl().containCommercialApplicationsProperty(),
                    getControl().containRequiresPatchApplicationsProperty(),
                    getControl().containTestingApplicationsProperty()));

    final ApplicationSidebarToggleGroup applicationSidebarToggleGroup = new ApplicationSidebarToggleGroup(
            filteredCategories);

    applicationSidebarToggleGroup.setTitle(tr("Categories"));
    getControl().selectedItemProperty().bind(applicationSidebarToggleGroup.selectedElementProperty());

    return applicationSidebarToggleGroup;
}
 
Example #11
Source File: ConsoleMessageTab.java    From dm3270 with Apache License 2.0 6 votes vote down vote up
private void setFilter (FilteredList<ConsoleMessage> filteredData)
{
  String time = txtTime.getText ();
  String task = txtTask.getText ();
  String code = txtMessageCode.getText ();
  String text = txtMessageText.getText ();

  filteredData.setPredicate (message ->
  {
    boolean p0 = message.getTime ().startsWith (time);
    boolean p1 = message.getTask ().startsWith (task);
    boolean p2 = message.getMessageCode ().startsWith (code);
    boolean p3 = message.getMessage ().contains (text);
    return p0 && p1 && p2 && p3;
  });
}
 
Example #12
Source File: ReplayStage.java    From dm3270 with Apache License 2.0 6 votes vote down vote up
private void change (SessionTable table, FilteredList<SessionRecord> filteredData)
{
  // get the previously selected line
  SessionRecord selectedRecord = table.getSelectionModel ().getSelectedItem ();

  // change the filter predicate
  filteredData.setPredicate (sessionRecord -> sessionRecord.isTN3270 ()
      || (sessionRecord.isTelnet () && showTelnetCB.isSelected ())
      || (sessionRecord.isTN3270Extended () && show3270ECB.isSelected ()));

  // restore the previously selected item (if it is still visible)
  if (selectedRecord != null)
  {
    table.getSelectionModel ().select (selectedRecord);
    table.requestFocus ();
  }
}
 
Example #13
Source File: TreeViewDemo.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
public FilterableTreeItem(T value) {
    super(value);
    this.sourceList = FXCollections.observableArrayList();
    this.filteredList = new FilteredList<>(this.sourceList);
    this.filteredList.predicateProperty().bind(Bindings.createObjectBinding(() -> {
        return child -> {
            // Set the predicate of child items to force filtering
            if (child instanceof FilterableTreeItem) {
                FilterableTreeItem<T> filterableChild = (FilterableTreeItem<T>) child;
                filterableChild.setPredicate(this.predicate.get());
            }
            // If there is no predicate, keep this tree item
            if (this.predicate.get() == null)
                return true;
            // If there are children, keep this tree item
            if (child.getChildren().size() > 0)
                return true;
            // Otherwise ask the TreeItemPredicate
            return this.predicate.get().test(this, child.getValue());
        };
    }, this.predicate));
    setHiddenFieldChildren(this.filteredList);
}
 
Example #14
Source File: ConsoleMessageTab.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
private void setFilter (FilteredList<ConsoleMessage> filteredData)
{
  String time = txtTime.getText ();
  String task = txtTask.getText ();
  String code = txtMessageCode.getText ();
  String text = txtMessageText.getText ();

  filteredData.setPredicate (message ->
  {
    boolean p0 = message.getTime ().startsWith (time);
    boolean p1 = message.getTask ().startsWith (task);
    boolean p2 = message.getMessageCode ().startsWith (code);
    boolean p3 = message.getMessage ().contains (text);
    return p0 && p1 && p2 && p3;
  });
}
 
Example #15
Source File: ReplayStage.java    From xframium-java with GNU General Public License v3.0 6 votes vote down vote up
private void change (SessionTable table, FilteredList<SessionRecord> filteredData)
{
  // get the previously selected line
  SessionRecord selectedRecord = table.getSelectionModel ().getSelectedItem ();

  // change the filter predicate
  filteredData.setPredicate (sessionRecord -> sessionRecord.isTN3270 ()
      || (sessionRecord.isTelnet () && showTelnetCB.isSelected ())
      || (sessionRecord.isTN3270Extended () && show3270ECB.isSelected ()));

  // restore the previously selected item (if it is still visible)
  if (selectedRecord != null)
  {
    table.getSelectionModel ().select (selectedRecord);
    table.requestFocus ();
  }
}
 
Example #16
Source File: FilterableTreeItem.java    From Recaf with MIT License 6 votes vote down vote up
/**
 * @param value
 * 		Item value
 */
public FilterableTreeItem(T value) {
	super(value);
	// Support filtering by using a filtered list backing.
	// - Apply predicate to items
	FilteredList<TreeItem<T>> filteredChildren = new FilteredList<>(sourceChildren);
	filteredChildren.predicateProperty().bind(Bindings.createObjectBinding(() -> child -> {
		if(child instanceof FilterableTreeItem)
			((FilterableTreeItem<T>) child).predicateProperty().set(predicate.get());
		if(predicate.get() == null || !child.getChildren().isEmpty())
			return true;
		return predicate.get().test(child);
	}, predicate));
	// Reflection hackery
	setUnderlyingChildren(filteredChildren);
}
 
Example #17
Source File: CollatedTreeItem.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public CollatedTreeItem() {
    children = FXCollections.observableArrayList();
    filteredChildren = new FilteredList<>(children, new Predicate<TreeItem<T>>() {
        @Override
        public boolean test(TreeItem<T> t) {
            return filter.test(t.getValue());
        }
    });
    sortedChildren = new SortedList<>(filteredChildren);
    ObservableList<TreeItem<T>> original = super.getChildren();
    sortedChildren.addListener(new ListChangeListener<TreeItem<T>>() {
        @Override
        public void onChanged(javafx.collections.ListChangeListener.Change<? extends TreeItem<T>> c) {
            while (c.next()) {
                original.removeAll(c.getRemoved());
                original.addAll(c.getFrom(), c.getAddedSubList());
            }
        }
    });
}
 
Example #18
Source File: FeatureTableFX.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public FeatureTableFX() {
  // add dummy root
  TreeItem<ModularFeatureListRow> root = new TreeItem<>();
  root.setExpanded(true);
  this.setRoot(root);
  this.setShowRoot(false);
  this.setTableMenuButtonVisible(true);
  this.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
  this.getSelectionModel().setCellSelectionEnabled(true);
  setTableEditable(true);

  /*getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue)  -> {
      int io = getRoot().getChildren().indexOf(oldValue);
      int in = getRoot().getChildren().indexOf(newValue);
  });*/

  parameters = MZmineCore.getConfiguration().getModuleParameters(FeatureTableFXModule.class);
  rowTypesParameter = parameters.getParameter(FeatureTableFXParameters.showRowTypeColumns);
  featureTypesParameter = parameters
      .getParameter(FeatureTableFXParameters.showFeatureTypeColumns);

  rowItems = FXCollections.observableArrayList();
  filteredRowItems = new FilteredList<>(rowItems);
  columnMap = new HashMap<>();
}
 
Example #19
Source File: SaveRequestDialog.java    From milkman with MIT License 6 votes vote down vote up
public void initialize() {
	requestName.setText(request.getName());
	List<String> collectionNames = getCollectionStrings();
	FilteredList<String> filteredList = new FilteredList<String>(FXCollections.observableList(collectionNames));
	collectionName.textProperty().addListener(obs-> {
        String filter = collectionName.getText(); 
        if(filter == null || filter.length() == 0) {
        	Platform.runLater(() -> filteredList.setPredicate(s -> true));
        }
        else {
        	Platform.runLater(() -> filteredList.setPredicate(s -> StringUtils.containsLettersInOrder(s, filter)));
        }
	});
	collectionList.setItems(filteredList);
	
	
	collectionList.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
	collectionList.getSelectionModel().selectedItemProperty().addListener((obs, o, n) -> { 
		if (n != null && n.length() > 0)
			collectionName.setText(n);
	});
}
 
Example #20
Source File: ApplicationInformationPanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a filtered version of <code>scripts</code>
 *
 * @return A filtered version of the scripts list
 */
private FilteredList<ScriptDTO> createFilteredScripts() {
    final FilteredList<ScriptDTO> filteredScripts = scripts.filtered(getControl()::filterScript);

    filteredScripts.predicateProperty().bind(
            Bindings.createObjectBinding(() -> getControl()::filterScript,
                    getControl().operatingSystemProperty(),
                    getControl().containAllOSCompatibleApplicationsProperty(),
                    getControl().containCommercialApplicationsProperty(),
                    getControl().containRequiresPatchApplicationsProperty(),
                    getControl().containTestingApplicationsProperty()));

    return filteredScripts;
}
 
Example #21
Source File: DbgTraceView.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
public DbgTraceView(DbgController aDbgController) {
    dbgController = aDbgController;
    sortedTtraces = new SortedList<TraceLog>(dbgController.getTraceLogs());
    filteredTraces = new FilteredList<TraceLog>(sortedTtraces);

    setSpacing(5d);
    setStyle("-fx-background-insets: 5;");
    setMaxHeight(Double.MAX_VALUE);

    tracesBox = new TableView<TraceLog>();
    tracesBox.getStyleClass().add("trace-log-table");
    tracesBox.setOnMouseClicked(this::onTraceClicked);
    tracesBox.setMaxHeight(Double.MAX_VALUE);
    VBox.setVgrow(tracesBox, Priority.ALWAYS);

    putTableColumns();

    // #47 double wrapping the filtered list in another sorted list, otherwise
    // the table cannot be sorted on columns. Binding the items will throw exceptions
    // when sorting on columns.
    // see http://code.makery.ch/blog/javafx-8-tableview-sorting-filtering/
    SortedList<TraceLog> sortedData = new SortedList<>(filteredTraces);
    sortedData.comparatorProperty().bind(tracesBox.comparatorProperty());
    tracesBox.setItems(sortedData);

    putTraceContextMenu();

    Parent p = traceLogFloatySearchControl();

    getChildren().addAll(p, tracesBox);
}
 
Example #22
Source File: DbgView.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
private void createModuleTreeItem(OtpErlangTuple tuple) {
    boolean isExported;
    OtpErlangAtom moduleNameAtom = (OtpErlangAtom) tuple.elementAt(0);
    OtpErlangList exportedFuncs = (OtpErlangList) tuple.elementAt(1);
    OtpErlangList localFuncs = (OtpErlangList) tuple.elementAt(2);

    TreeItem<ModFunc> moduleItem;

    ModFunc module = ModFunc.toModule(moduleNameAtom);
    moduleItem = new TreeItem<ModFunc>(module);
    moduleItem.setGraphic(treeIcon(AwesomeIcon.CUBE));

    ObservableList<TreeItem<ModFunc>> modFuncs = FXCollections.observableArrayList();

    SortedList<TreeItem<ModFunc>> sortedFuncs = new SortedList<TreeItem<ModFunc>>(modFuncs);

    FilteredList<TreeItem<ModFunc>> filteredFuncs = new FilteredList<TreeItem<ModFunc>>(sortedFuncs);

    sortedFuncs.setComparator(treeItemModFuncComparator());

    isExported = true;
    addTreeItems(toModFuncs(moduleNameAtom, exportedFuncs, isExported), modFuncs);

    isExported = false;
    addTreeItems(toModFuncs(moduleNameAtom, localFuncs, isExported), modFuncs);
    functionLists.put(module, filteredFuncs);

    Bindings.bindContentBidirectional(moduleItem.getChildren(), filteredFuncs);

    ArrayList<TreeItem<ModFunc>> treeModulesCopy = new ArrayList<>(treeModules);
    for (TreeItem<ModFunc> treeItem : treeModulesCopy) {
        if(treeItem.getValue().equals(module)) {
            treeModules.remove(treeItem);
        }
    }
    treeModules.add(moduleItem);
}
 
Example #23
Source File: DbgView.java    From erlyberly with GNU General Public License v3.0 5 votes vote down vote up
private void filterForTracedFunctions() {
    for (FilteredList<TreeItem<ModFunc>> funcItemList : functionLists.values()) {
        funcItemList.setPredicate((t) -> { return dbgController.isTraced(t.getValue()); });
    }

    filteredTreeModules.setPredicate((t) -> { return !t.getChildren().isEmpty(); });
}
 
Example #24
Source File: RequestCollectionComponent.java    From milkman with MIT License 5 votes vote down vote up
public TreeItem<Node> buildTree(Collection collection){
	SettableTreeItem<Node> item = new SettableTreeItem<Node>();
	HBox collEntry = createCollectionEntry(collection, item);
	item.setValue(collEntry);
	item.getValue().setUserData(collection);
	item.setExpanded(expansionCache.getOrDefault(collection.getId(), false));
	item.expandedProperty().addListener((obs, o, n) -> {
		expansionCache.put(collection.getId(), n);
	});

	
	List<RequestContainer> collectionRequests = new LinkedList<>(collection.getRequests());
	
	List<TreeItem<Node>> children = new LinkedList<TreeItem<Node>>();
	for (Folder f : collection.getFolders()) {
		SettableTreeItem<Node> folderItm = buildTreeForFolder(collection, f, collectionRequests);
		children.add(folderItm);
	}
	
	
	for (RequestContainer r : collectionRequests) {
		TreeItem<Node> requestTreeItem = new TreeItem<Node>(createRequestEntry(collection, r));
		requestTreeItem.getValue().setUserData(r);
		children.add(requestTreeItem);
	}
	item.setChildren(new FilteredList<TreeItem<Node>>(FXCollections.observableList(children)));
	return item;
}
 
Example #25
Source File: SelectCharacter_PopupController.java    From Path-of-Leveling with MIT License 5 votes vote down vote up
/**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        assert (m_characterList != null);
        Set<String> leagueList = new LinkedHashSet<>();
        leagueList.add("All");
        for (int i = 0; i < m_characterList.size(); i++) { //this might require to update the buildsLoaded on each new build added and removed
            CharacterInfo ci = m_characterList.get(i);
            leagueList.add(ci.league);
            FXMLLoader loader = new FXMLLoader(getClass().getResource("characterEntry.fxml"));
            try {
                Node n = loader.load();
//                n.managedProperty().bind(n.visibleProperty());
                m_NodeToLeague.put(n, ci.league);
                //this will add the AnchorPane to the VBox
//                charactersBox.getItems().add(n);
                allNodes.add(n);
            } catch (IOException ex) {
                Logger.getLogger(SelectBuild_PopupController.class.getName()).log(Level.SEVERE, null, ex);
            }
            CharacterEntry_Controller cec = loader.getController(); //add controller to the linker class
            cec.init_for_popup(ci, i, this::update);
        }
        cmbLeagueFilter.getItems().addAll(leagueList);
        cmbLeagueFilter.setOnAction(event -> filterChanged());
        FilteredList<Node> filtered = new FilteredList<>(allNodes, node -> node.visibleProperty().get());
        charactersBox.setItems(filtered);


    }
 
Example #26
Source File: FilterableTreeItem.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link FilterableTreeItem}.
 *
 * @param value the value of the {@link FilterableTreeItem}
 */
FilterableTreeItem(T value) {
  super(value);
  internalChildren = FXCollections.observableArrayList();

  final FilteredList<FilterableTreeItem<T>> filteredList = new FilteredList<>(internalChildren);
  filteredList.predicateProperty().bind(
      createObjectBinding(() -> treeItemPredicate, predicateProperty())
  );

  // set the children in the super class
  setChildren(FXCollections.unmodifiableObservableList(filteredList));
  filteredList.addListener(getChildrenListener());
}
 
Example #27
Source File: PersonsController.java    From examples-javafx-repos1 with Apache License 2.0 5 votes vote down vote up
protected void doFilterTable(TextField tf) {
	String criteria = tf.getText();
	
	if( logger.isLoggable(Level.FINE) ) {
		logger.fine( "[FILTER] filtering on=" + criteria );
	}
	
	if( criteria == null || criteria.isEmpty() ) {
		tblPersons.setItems( personsActiveRecord );
		return;
	}
	
	FilteredList<Person> fl = new FilteredList<>(personsActiveRecord, p -> true);
	
	fl.setPredicate(person -> {

		if (criteria == null || criteria.isEmpty()) {
             return true;
         }

         String lcCriteria = criteria.toLowerCase();

         if (person.getFirstName().toLowerCase().contains(lcCriteria)) {
             return true; // Filter matches first name.
         } else if (person.getLastName().toLowerCase().contains(lcCriteria)) {
             return true; // Filter matches last name.
         } else if (person.getEmail().toLowerCase().contains(lcCriteria)) {
        	 return true;  // 	matches email
         }
         
         return false; // Does not match.
     });
	
	 SortedList<Person> sortedData = new SortedList<>(fl);
	 sortedData.comparatorProperty().bind(tblPersons.comparatorProperty());  // ?    	
	 tblPersons.setItems(sortedData);
}
 
Example #28
Source File: NotesPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void initialize() {
    notes.setShowTransitionFactory(BounceInLeftTransition::new);
    notes.showingProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue) {
            AppBar appBar = getApp().getAppBar();
            appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> 
                    getApp().getDrawer().open()));
            appBar.setTitleText("Notes");
            appBar.getActionItems().add(MaterialDesignIcon.FILTER_LIST.button(e -> {
                getApp().showLayer(NotesApp.POPUP_FILTER_NOTES);
            }));
        }
    });
    
    lstNotes.setCellFactory(p -> new NoteCell(service, this::edit, this::remove));
    lstNotes.setHeadersFunction(t -> t.getCreationDate().toLocalDate());
    lstNotes.setHeaderCellFactory(p -> new HeaderCell());
    lstNotes.setPlaceholder(new Label("There are no notes"));
    
    service.notesProperty().addListener((ListChangeListener.Change<? extends Note> c) -> {
        filteredList = new FilteredList(c.getList());
        lstNotes.setItems(filteredList);
        lstNotes.setComparator((n1, n2) -> n1.getCreationDate().compareTo(n2.getCreationDate()));
    });
    
    final FloatingActionButton floatingActionButton = new FloatingActionButton();
    floatingActionButton.setOnAction(e -> edit(null));
    floatingActionButton.showOn(notes);
    
    getApp().addLayerFactory(NotesApp.POPUP_FILTER_NOTES, () -> { 
        GluonView filterView = new GluonView(FilterPresenter.class);
        FilterPresenter filterPresenter = (FilterPresenter) filterView.getPresenter();
        
        SidePopupView sidePopupView = new SidePopupView(filterView.getView(), Side.TOP, true);
        sidePopupView.showingProperty().addListener((obs, ov, nv) -> {
            if (ov && !nv) {
                filteredList.setPredicate(filterPresenter.getPredicate());
            }
        });
        
        return sidePopupView; 
    });
    
    service.retrieveNotes();
    
    service.settingsProperty().addListener((obs, ov, nv) -> updateSettings());
    
    updateSettings();
}
 
Example #29
Source File: NameEditor.java    From OpenLabeler with Apache License 2.0 4 votes vote down vote up
public NameEditor(String label) {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/NameEditor.fxml"), bundle);
    loader.setRoot(this);
    loader.setController(this);

    try {
        loader.load();
        setupClearButtonField(text);
    }
    catch (Exception ex) {
        LOG.log(Level.SEVERE, "Unable to load FXML", ex);
    }


    List<String> labels = IteratorUtils.toList(Settings.recentNamesProperty.stream().map(NameColor::getName).iterator());
    FilteredList<String> filtered = new FilteredList<>(FXCollections.observableArrayList(labels), s -> true);
    text.textProperty().addListener(obs -> {
        String filter = text.getText();
        if (filter == null || filter.length() == 0) {
            filtered.setPredicate(s -> true);
        }
        else {
            filtered.setPredicate(s -> s.startsWith(filter));
        }
    });

    list.setCellFactory(param -> new ListCell<>() {
        @Override
        protected void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
            setText(empty ? null : item);

            setOnMouseClicked(value -> {
                if (!empty && value.getClickCount() == 2) {
                    text.setText(item);
                    ((Stage) getScene().getWindow()).close();
                }
            });
        }
    });

    list.setItems(filtered);
    text.setText(label);
    text.selectAll();
}
 
Example #30
Source File: ReplayStage.java    From xframium-java with GNU General Public License v3.0 4 votes vote down vote up
public ReplayStage (Session session, Path path, Preferences prefs, Screen screen)
{
  this.prefs = prefs;

  final Label label = session.getHeaderLabel ();
  label.setFont (new Font ("Arial", 20));
  label.setPadding (new Insets (10, 10, 10, 10));                 // trbl

  boolean showTelnet = prefs.getBoolean ("ShowTelnet", false);
  boolean showExtended = prefs.getBoolean ("ShowExtended", false);

  final HBox checkBoxes = new HBox ();
  checkBoxes.setSpacing (15);
  checkBoxes.setPadding (new Insets (10, 10, 10, 10));            // trbl
  checkBoxes.getChildren ().addAll (showTelnetCB, show3270ECB);

  SessionTable sessionTable = new SessionTable ();
  CommandPane commandPane =
      new CommandPane (sessionTable, CommandPane.ProcessInstruction.DoProcess);

  //    commandPane.setScreen (session.getScreen ());
  commandPane.setScreen (screen);

  setTitle ("Replay Commands - " + path.getFileName ());

  ObservableList<SessionRecord> masterData = session.getDataRecords ();
  FilteredList<SessionRecord> filteredData = new FilteredList<> (masterData, p -> true);

  ChangeListener<? super Boolean> changeListener =
      (observable, oldValue, newValue) -> change (sessionTable, filteredData);

  showTelnetCB.selectedProperty ().addListener (changeListener);
  show3270ECB.selectedProperty ().addListener (changeListener);

  if (true)         // this sucks - remove it when java works properly
  {
    showTelnetCB.setSelected (true);          // must be a bug
    show3270ECB.setSelected (true);
  }

  showTelnetCB.setSelected (showTelnet);
  show3270ECB.setSelected (showExtended);

  SortedList<SessionRecord> sortedData = new SortedList<> (filteredData);
  sortedData.comparatorProperty ().bind (sessionTable.comparatorProperty ());
  sessionTable.setItems (sortedData);

  displayFirstScreen (session, sessionTable);

  setOnCloseRequest (e -> Platform.exit ());

  windowSaver = new WindowSaver (prefs, this, "Replay");
  if (!windowSaver.restoreWindow ())
  {
    primaryScreenBounds = javafx.stage.Screen.getPrimary ().getVisualBounds ();
    setX (800);
    setY (primaryScreenBounds.getMinY ());
    double height = primaryScreenBounds.getHeight ();
    setHeight (Math.min (height, 1200));
  }

  BorderPane borderPane = new BorderPane ();
  borderPane.setLeft (sessionTable);      // fixed size
  borderPane.setCenter (commandPane);     // expands to fill window
  borderPane.setTop (label);
  borderPane.setBottom (checkBoxes);

  Scene scene = new Scene (borderPane);
  setScene (scene);
}