diff --git a/src/main/java/fr/inra/po2vocabmanager/MainApp.java b/src/main/java/fr/inra/po2vocabmanager/MainApp.java index 2700310310ac026b06b476544f168bd346fcc4cf..de98d0b96e76c011cde3f09ceb8f13045a78a0a2 100644 --- a/src/main/java/fr/inra/po2vocabmanager/MainApp.java +++ b/src/main/java/fr/inra/po2vocabmanager/MainApp.java @@ -906,7 +906,7 @@ public class MainApp extends Application implements Launcher { Stage modelStage = new Stage(); modelStage.setTitle("Search"); - modelStage.initModality(Modality.WINDOW_MODAL); + modelStage.initModality(Modality.NONE); modelStage.initOwner(primaryStage); Scene scene = new Scene(searchOverview); diff --git a/src/main/java/fr/inra/po2vocabmanager/view/ontoView/SearchOverviewController.java b/src/main/java/fr/inra/po2vocabmanager/view/ontoView/SearchOverviewController.java index 15313355041acb0e6f6ed35aa502ff700b2cf602..14c911e2af6e52a40b0eaa4385983ee12aa7966f 100644 --- a/src/main/java/fr/inra/po2vocabmanager/view/ontoView/SearchOverviewController.java +++ b/src/main/java/fr/inra/po2vocabmanager/view/ontoView/SearchOverviewController.java @@ -24,6 +24,7 @@ import fr.inra.po2vocabmanager.utils.TreeItemPredicate; import fr.inrae.po2engine.externalTools.JenaTools; import fr.inrae.po2engine.model.VocabConcept; import javafx.beans.binding.Bindings; +import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.transformation.FilteredList; import javafx.event.EventHandler; @@ -50,11 +51,36 @@ public class SearchOverviewController { private TableColumn<VocabConcept, String> descColumn; @FXML private TreeView<VocabConcept> treeView; + @FXML + private CheckBox checkProcess; + @FXML + private CheckBox checkComponent; + @FXML + private CheckBox checkAttribute; + @FXML + private CheckBox checkMaterial; + @FXML + private CheckBox checkMethod; + @FXML + private CheckBox checkStep; + @FXML + private CheckBox checkScale; + private SimpleStringProperty checked; @FXML private void initialize() { labelColumn.setCellValueFactory(cellData -> cellData.getValue().labsToString()); descColumn.setCellValueFactory(cellData -> cellData.getValue().descToString()); + checked = new SimpleStringProperty(""); + checked.bind(Bindings.concat( + Bindings.when(checkProcess.selectedProperty()).then(checkProcess.textProperty()).otherwise(""), + Bindings.when(checkComponent.selectedProperty()).then(checkComponent.textProperty()).otherwise(""), + Bindings.when(checkAttribute.selectedProperty()).then(checkAttribute.textProperty()).otherwise(""), + Bindings.when(checkMaterial.selectedProperty()).then(checkMaterial.textProperty()).otherwise(""), + Bindings.when(checkMethod.selectedProperty()).then(checkMethod.textProperty()).otherwise(""), + Bindings.when(checkStep.selectedProperty()).then(checkStep.textProperty()).otherwise(""), + Bindings.when(checkScale.selectedProperty()).then(checkScale.textProperty()).otherwise("") + )); tableView.setRowFactory(tv -> { TableRow<VocabConcept> row = new TableRow<>(); @@ -77,7 +103,6 @@ public class SearchOverviewController { } } }); - } public void setMainApp(MainApp mainApp) { @@ -95,15 +120,16 @@ public class SearchOverviewController { public void initTableView() { FilteredList<VocabConcept> filteredList = new FilteredList<>(MainApp.getOntologyControler().getRootItem().getValue().flattened().collect(Collectors.toCollection(FXCollections::observableArrayList)), p -> true); filteredList.predicateProperty().bind(Bindings.createObjectBinding(() -> { - if (textfield.getText() == null || textfield.getText().isEmpty()) + if (textfield.getText() == null || textfield.getText().isEmpty()) { return vocabConcept -> true; + } return vocabConcept -> { - if(vocabConcept == null || vocabConcept.getSearchIn() == null) { + if(vocabConcept == null || vocabConcept.getSearchIn() == null || !checked.get().toLowerCase().contains(vocabConcept.isPO2Node().toLowerCase())) { return false; } return vocabConcept.getSearchIn().toLowerCase().contains(textfield.getText().toLowerCase()); }; - }, textfield.textProperty())); + }, textfield.textProperty(), checked)); tableView.setItems(filteredList); } @@ -147,8 +173,13 @@ public class SearchOverviewController { filterLocalRoot.predicateProperty().bind(Bindings.createObjectBinding(() -> { if (textfield.getText() == null || textfield.getText().isEmpty()) return TreeItemPredicate.create(value -> true); - return TreeItemPredicate.create(value -> value.getSearchIn().toLowerCase().contains(textfield.getText().toLowerCase())); - }, textfield.textProperty())); + return TreeItemPredicate.create(value -> { + if(!checked.get().toLowerCase().contains(value.isPO2Node().toLowerCase())) { + return false; + } + return value.getSearchIn().toLowerCase().contains(textfield.getText().toLowerCase()); + }); + }, textfield.textProperty(), checked)); fakeRoot.getChildren().add(filterLocalRoot); } treeView.setRoot(fakeRoot); diff --git a/src/main/resources/fr/inra/po2vocabmanager/view/ontoView/SearchOverview.fxml b/src/main/resources/fr/inra/po2vocabmanager/view/ontoView/SearchOverview.fxml index b017c2f28237680467da46c775bf2fbb8727f1df..a1425e7ebfabb9b8cdd1d971a0b57f1d280f8893 100644 --- a/src/main/resources/fr/inra/po2vocabmanager/view/ontoView/SearchOverview.fxml +++ b/src/main/resources/fr/inra/po2vocabmanager/view/ontoView/SearchOverview.fxml @@ -19,14 +19,40 @@ --> <?import javafx.scene.control.*?> -<?import javafx.scene.layout.BorderPane?> -<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.*?> <BorderPane xmlns:fx="http://javafx.com/fxml/1" fx:id="borderPane" prefHeight="603.0" prefWidth="803.0" xmlns="http://javafx.com/javafx/21" fx:controller="fr.inra.po2vocabmanager.view.ontoView.SearchOverviewController"> <top> - <HBox prefHeight="41.0" prefWidth="800.0" BorderPane.alignment="CENTER"> + <HBox prefHeight="60.0" prefWidth="800.0" spacing="5.0" BorderPane.alignment="CENTER"> <children> - <Label text="Filter : " /> - <TextField fx:id="textfield" /> + <VBox prefHeight="60.0" prefWidth="160.0" spacing="5.0"> + <children> + <Label text="Filter : " /> + <TextField fx:id="textfield" prefHeight="26.0" prefWidth="180.0" /> + </children> + </VBox> + <VBox prefHeight="60.0" prefWidth="160.0" spacing="5.0"> + <children> + <CheckBox fx:id="checkProcess" mnemonicParsing="false" selected="true" text="Process" /> + <CheckBox fx:id="checkComponent" mnemonicParsing="false" selected="true" text="Component" /> + </children> + </VBox> + <VBox prefHeight="200.0" prefWidth="160.0" spacing="5.0"> + <children> + <CheckBox fx:id="checkAttribute" mnemonicParsing="false" selected="true" text="Attribute" /> + <CheckBox fx:id="checkMaterial" mnemonicParsing="false" selected="true" text="Material" /> + </children> + </VBox> + <VBox prefHeight="200.0" prefWidth="160.0" spacing="5.0"> + <children> + <CheckBox fx:id="checkMethod" mnemonicParsing="false" selected="true" text="Method" /> + <CheckBox fx:id="checkStep" mnemonicParsing="false" selected="true" text="Step" /> + </children> + </VBox> + <VBox prefHeight="200.0" prefWidth="160.0" spacing="5.0"> + <children> + <CheckBox fx:id="checkScale" mnemonicParsing="false" selected="true" text="Scale" /> + </children> + </VBox> </children> </HBox> </top> @@ -35,8 +61,8 @@ <items> <TableView fx:id="tableView"> <columns> - <TableColumn fx:id="labelColumn" editable="false" maxWidth="1.7976931348623157E308" prefWidth="150.0" minWidth="100.0" text="Label" /> - <TableColumn fx:id="descColumn" editable="false" maxWidth="1.7976931348623157E308" prefWidth="150.0" minWidth="100.0" text="Description" /> + <TableColumn fx:id="labelColumn" editable="false" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="150.0" text="Label" /> + <TableColumn fx:id="descColumn" editable="false" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="150.0" text="Description" /> </columns> <columnResizePolicy> <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />