All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.tentackle.fx.rdc.search.DefaultPdoFinder Maven / Gradle / Ivy

There is a newer version: 21.16.1.0
Show newest version
/*
 * Tentackle - https://tentackle.org.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

package org.tentackle.fx.rdc.search;

import javafx.beans.property.ObjectProperty;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;

import org.tentackle.fx.CaseConversion;
import org.tentackle.fx.FxControllerService;
import org.tentackle.fx.component.FxTextField;
import org.tentackle.fx.rdc.PdoFinder;
import org.tentackle.pdo.PersistentDomainObject;

import java.util.List;

/**
 * The simple default finder.
* Provides normtext-search criteria (if entity provides a normtext). * If no normtext, all PDOs are selected immediately. * * @author harald * @param the PDO type */ @FxControllerService(binding = FxControllerService.BINDING.NO) public class DefaultPdoFinder> extends PdoFinder { private T pdo; @FXML private FxTextField patternField; @Override public List runSearch() { if (pdo != null && pdo.isNormTextProvided()) { return getPdo().selectByNormText(patternField.getText()); } return getPdo().selectAllCached(); } @FXML private void initialize() { patternField.setCaseConversion(CaseConversion.UPPER_CASE); } @Override public T getPdo() { return pdo; } @Override public void setPdo(T pdo) { this.pdo = pdo; patternField.clear(); // no preset of search criteria } @Override public boolean isSearchRunningImmediately() { return super.isSearchRunningImmediately() || (pdo != null && !pdo.isNormTextProvided()); } @Override public boolean isVisible() { return super.isVisible() && pdo != null && pdo.isNormTextProvided() && !isSearchRunningImmediately(); } @Override public void requestInitialFocus() { if (pdo != null && pdo.isNormTextProvided()) { patternField.requestFocus(); } } @Override public ObjectProperty> getSearchActionProperty() { return patternField.onActionProperty(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy