diff --git a/.travis.yml b/.travis.yml index c7b249780..6eaff79f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,8 @@ deploy: script: bash .ci/deploy-snapshot.sh skip_cleanup: true on: - condition: $TRAVIS_BRANCH =~ ^master|9.0.0$ + all_branches: true + condition: $TRAVIS_BRANCH =~ master|9.0.0 # Deploy releases on every tag push - provider: script diff --git a/controlsfx-samples/src/main/java/org/controlsfx/samples/HelloValidation.java b/controlsfx-samples/src/main/java/org/controlsfx/samples/HelloValidation.java index 323f4f29a..f0ba54bf3 100644 --- a/controlsfx-samples/src/main/java/org/controlsfx/samples/HelloValidation.java +++ b/controlsfx-samples/src/main/java/org/controlsfx/samples/HelloValidation.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2014, ControlsFX + * Copyright (c) 2014, 2019 ControlsFX * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,9 +63,9 @@ public class HelloValidation extends ControlsFXSample { - TextField textField = new TextField(); + private TextField textField = new TextField(); + private ValidationSupport validationSupport = new ValidationSupport(); - @Override public String getSampleName() { return "Component Validation"; } @@ -78,8 +78,6 @@ public class HelloValidation extends ControlsFXSample { return "Component Validation"; } - ValidationSupport validationSupport = new ValidationSupport(); - @Override public Node getPanel(final Stage stage) { GridPane root = new GridPane(); root.setVgap(10); @@ -94,18 +92,11 @@ public class HelloValidation extends ControlsFXSample { } }); - - // final ListView messageList = new ListView<>(); - // validationSupport.validationResultProperty().addListener( (o, oldValue, validationResult) -> { - // messageList.getItems().setAll(validationResult.getMessages()); - // } - // ); - - int row = 0; // text field validationSupport.registerValidator(textField, Validator.createEmptyValidator("Text is required")); + root.add(new Label("TextField"), 0, row); root.add(textField, 1, row); GridPane.setHgrow(textField, Priority.ALWAYS); @@ -114,7 +105,12 @@ public class HelloValidation extends ControlsFXSample { row++; ComboBox combobox = new ComboBox(); combobox.getItems().addAll("Item A", "Item B", "Item C"); - validationSupport.registerValidator(combobox, Validator.createEmptyValidator( "ComboBox Selection required")); + validationSupport.registerValidator(combobox, (Control c, String newValue) -> + ValidationResult.fromErrorIf(combobox, "ComboBox Selection required", newValue == null || newValue.isEmpty()) + .addInfoIf(combobox, "Item A is the first item", "Item A".equals(newValue)) + .addInfoIf(combobox, "Item B is the second item", "Item B".equals(newValue)) + .addInfoIf(combobox, "Item C is the third item", "Item C".equals(newValue)) + ); root.add(new Label("ComboBox"), 0, row); root.add(combobox, 1, row); @@ -128,14 +124,14 @@ public class HelloValidation extends ControlsFXSample { root.add(new Label("ChoiceBox"), 0, row); root.add(choiceBox, 1, row); - GridPane.setHgrow(combobox, Priority.ALWAYS); + GridPane.setHgrow(choiceBox, Priority.ALWAYS); //checkbox row++; CheckBox checkBox = new CheckBox(); - validationSupport.registerValidator(checkBox, (Control c, Boolean newValue) -> - ValidationResult.fromErrorIf( c, "Checkbox should be checked", !newValue) - ); + validationSupport.registerValidator(checkBox, (Control c, Boolean newValue) -> + ValidationResult.fromErrorIf(c, "Checkbox should be checked", !newValue)); + root.add(new Label("CheckBox"), 0, row); root.add(checkBox, 1, row); GridPane.setHgrow(checkBox, Priority.ALWAYS); @@ -144,46 +140,37 @@ public class HelloValidation extends ControlsFXSample { row++; Slider slider = new Slider(-50d, 50d, -10d); slider.setShowTickLabels(true); - validationSupport.registerValidator(slider, (Control c, Double newValue) -> - ValidationResult.fromErrorIf( slider, "Slider value should be > 0", newValue <= 0 )); + validationSupport.registerValidator(slider, (Control c, Double newValue) -> + ValidationResult.fromErrorIf(slider, "Slider value should be > 0", newValue <= 0)); root.add(new Label("Slider"), 0, row); root.add(slider, 1, row); - GridPane.setHgrow(checkBox, Priority.ALWAYS); + GridPane.setHgrow(slider, Priority.ALWAYS); // color picker row++; ColorPicker colorPicker = new ColorPicker(Color.RED); - validationSupport.registerValidator(colorPicker, + validationSupport.registerValidator(colorPicker, Validator.createEqualsValidator("Color should be WHITE or BLACK", Arrays.asList(Color.WHITE, Color.BLACK))); root.add(new Label("Color Picker"), 0, row); root.add(colorPicker, 1, row); - GridPane.setHgrow(checkBox, Priority.ALWAYS); + GridPane.setHgrow(colorPicker, Priority.ALWAYS); // date picker row++; DatePicker datePicker = new DatePicker(); - validationSupport.registerValidator(datePicker, false, (Control c, LocalDate newValue) -> - ValidationResult.fromWarningIf( datePicker, "The date should be today", !LocalDate.now().equals(newValue))); + validationSupport.registerValidator(datePicker, false, (Control c, LocalDate newValue) -> + ValidationResult.fromWarningIf(datePicker, "The date should be today", !LocalDate.now().equals(newValue))); root.add(new Label("Date Picker"), 0, row); root.add(datePicker, 1, row); - GridPane.setHgrow(checkBox, Priority.ALWAYS); - - // // validation results - // row++; - // TitledPane pane = new TitledPane("Validation Results", messageList); - // pane.setCollapsible(false); - // root.add(pane, 0, row, 2, 1); - // GridPane.setHgrow(pane, Priority.ALWAYS); + GridPane.setHgrow(datePicker, Priority.ALWAYS); - //root.setTop(grid); ScrollPane scrollPane = new ScrollPane(root); return scrollPane; } - @Override public Node getControlPanel() { GridPane grid = new GridPane(); grid.setVgap(10); @@ -195,7 +182,7 @@ public class HelloValidation extends ControlsFXSample { ValidationDecoration compoundDecorator = new CompoundValidationDecoration(cssDecorator, iconDecorator); int row = 0; - + // --- validation decorator Callback, ListCell> cellFactory = listView -> new ListCell() { @Override protected void updateItem(ValidationDecoration decorator, boolean empty) { @@ -229,14 +216,12 @@ public class HelloValidation extends ControlsFXSample { grid.add(validationDecoratorLabel, 0, row); grid.add(decoratorBox, 1, row); GridPane.setHgrow(decoratorBox, Priority.ALWAYS); - + row++; ToggleButton btnToggleRequired = new ToggleButton("Toggle TextField required status"); btnToggleRequired.setSelected(ValidationSupport.isRequired(textField)); btnToggleRequired.setOnAction(e -> { -// boolean required = ValidationSupport.isRequired(textField); - System.out.println("Is required: " + btnToggleRequired.isSelected()); - ValidationSupport.setRequired(textField, btnToggleRequired.isSelected()); + ValidationSupport.setRequired(textField, btnToggleRequired.isSelected()); }); grid.add(btnToggleRequired, 1, row, 1, 1); @@ -246,5 +231,4 @@ public class HelloValidation extends ControlsFXSample { public static void main(String[] args) { launch(args); } - } \ No newline at end of file diff --git a/controlsfx-samples/src/main/java/org/controlsfx/samples/tableview/HelloTableFilter.java b/controlsfx-samples/src/main/java/org/controlsfx/samples/tableview/HelloTableFilter.java new file mode 100644 index 000000000..551e14dbc --- /dev/null +++ b/controlsfx-samples/src/main/java/org/controlsfx/samples/tableview/HelloTableFilter.java @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2016, 2019 ControlsFX + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of ControlsFX, any associated website, nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CONTROLSFX BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.controlsfx.samples.tableview; + +import javafx.beans.property.SimpleStringProperty; +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.stage.Stage; +import org.controlsfx.ControlsFXSample; +import org.controlsfx.control.table.TableFilter; + +public class HelloTableFilter extends ControlsFXSample { + @Override + public String getSampleName() { + return "TableFilter"; + } + + @Override + @SuppressWarnings("unchecked") + public Node getPanel(Stage stage) { + TableView tableView = new TableView(); + + TableColumn firstNameCol = new TableColumn<>("First Name"); + firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); + + TableColumn lastNameCol = new TableColumn<>("Last Name"); + lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); + + TableColumn emailCol = new TableColumn<>("Email"); + emailCol.setCellValueFactory(new PropertyValueFactory<>("email")); + + tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol); + + tableView.getItems().add(new Person("Jacob", "Smith", "jacob.smith@example.com")); + tableView.getItems().add(new Person("Isabella", "Johnson", "isabella.johnson@example.com")); + tableView.getItems().add(new Person("Ethan", "Williams", "ethan.williams@example.com")); + tableView.getItems().add(new Person("Emma", "Jones", "emma.jones@example.com")); + tableView.getItems().add(new Person("Michael", "Brown", "michael.brown@example.com")); + tableView.getItems().add(new Person("Isabella", "Smith", "isabella.smith@example.com")); + + // apply filter + TableFilter.forTableView(tableView).apply(); + + return tableView; + } + + @Override + public String getJavaDocURL() { + return "org/controlsfx/control/table/TableFilter.html"; + } + + @Override + public String getSampleDescription() { + return "Applies a filtering control to a provided TableView instance. " + + "The filter will be applied immediately on construction, " + + "and can be made visible by right-clicking the desired column to filter on."; + } + + public static void main(String[] args) { + launch(args); + } + + public static class Person { + + private final SimpleStringProperty firstName; + private final SimpleStringProperty lastName; + private final SimpleStringProperty email; + + public Person(String firstName, String lastName, String email) { + this.firstName = new SimpleStringProperty(firstName); + this.lastName = new SimpleStringProperty(lastName); + this.email = new SimpleStringProperty(email); + } + + public String getFirstName() { + return firstName.get(); + } + + public void setFirstName(String firstName) { + this.firstName.set(firstName); + } + + public String getLastName() { + return lastName.get(); + } + + public void setLastName(String lastName) { + this.lastName.set(lastName); + } + + public String getEmail() { + return email.get(); + } + + public void setEmail(String fName) { + email.set(fName); + } + } +} diff --git a/controlsfx-samples/src/main/resources/org/controlsfx/samples/validation.css b/controlsfx-samples/src/main/resources/org/controlsfx/samples/validation.css index 6c3352cd9..b55f89ff2 100644 --- a/controlsfx-samples/src/main/resources/org/controlsfx/samples/validation.css +++ b/controlsfx-samples/src/main/resources/org/controlsfx/samples/validation.css @@ -7,5 +7,5 @@ } .info { - -fx-effect: dropshadow(three-pass-box, rgba(196, 208, 239, 0.7), 14, 0, 0, 0); + -fx-effect: dropshadow(three-pass-box, skyblue, 14, 0, 0, 0); } \ No newline at end of file diff --git a/controlsfx/src/main/java/org/controlsfx/control/CheckComboBox.java b/controlsfx/src/main/java/org/controlsfx/control/CheckComboBox.java index 5c495d492..44669a7c5 100644 --- a/controlsfx/src/main/java/org/controlsfx/control/CheckComboBox.java +++ b/controlsfx/src/main/java/org/controlsfx/control/CheckComboBox.java @@ -86,7 +86,10 @@ * // selected items change). * checkComboBox.getCheckModel().getCheckedItems().addListener(new ListChangeListener() { * public void onChanged(ListChangeListener.Change c) { - * System.out.println(checkComboBox.getCheckModel().getSelectedItems()); + * while(c.next()) { + * //do something with changes here + * } + * System.out.println(checkComboBox.getCheckModel().getCheckedItems()); * } * });} * } diff --git a/controlsfx/src/main/java/org/controlsfx/control/table/FilterPanel.java b/controlsfx/src/main/java/org/controlsfx/control/table/FilterPanel.java index 9031df10d..c46419737 100644 --- a/controlsfx/src/main/java/org/controlsfx/control/table/FilterPanel.java +++ b/controlsfx/src/main/java/org/controlsfx/control/table/FilterPanel.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015, 2016, ControlsFX + * Copyright (c) 2015, 2019, ControlsFX * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,7 +69,7 @@ public final class FilterPanel extends VBox { // This collection will reference column header listeners. References must be kept locally because weak listeners are registered private final Collection columnHeadersChangeListeners = new ArrayList(); - private static final Image filterIcon = new Image("/impl/org/controlsfx/table/filter.png"); + private static final Image filterIcon = new Image(FilterPanel.class.getResource("/impl/org/controlsfx/table/filter.png").toExternalForm()); private static final Supplier filterImageView = () -> { ImageView imageView = new ImageView(filterIcon); diff --git a/controlsfx/src/main/java/org/controlsfx/control/table/TableFilter.java b/controlsfx/src/main/java/org/controlsfx/control/table/TableFilter.java index db14147e8..a474b5b40 100644 --- a/controlsfx/src/main/java/org/controlsfx/control/table/TableFilter.java +++ b/controlsfx/src/main/java/org/controlsfx/control/table/TableFilter.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015, ControlsFX + * Copyright (c) 2015, 2019, ControlsFX * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -78,7 +78,7 @@ private TableFilter(TableView tableView, boolean isLazy) { tableView.setItems(sortedControlList); applyForAllColumns(); - tableView.getStylesheets().add("/impl/org/controlsfx/table/tablefilter.css"); + tableView.getStylesheets().add(TableFilter.class.getResource("/impl/org/controlsfx/table/tablefilter.css").toExternalForm()); if (!isLazy) { columnFilters.forEach(ColumnFilter::initialize); diff --git a/controlsfx/src/main/java/org/controlsfx/glyphfont/FontAwesome.java b/controlsfx/src/main/java/org/controlsfx/glyphfont/FontAwesome.java index df46aea42..c495c2518 100644 --- a/controlsfx/src/main/java/org/controlsfx/glyphfont/FontAwesome.java +++ b/controlsfx/src/main/java/org/controlsfx/glyphfont/FontAwesome.java @@ -32,9 +32,8 @@ /** * Defines a {@link GlyphFont} for the FontAwesome font set (see - * the FontAwesome website - * for more details). Note that at present the FontAwesome font is not distributed - * with ControlsFX, and is, by default, instead loaded from a CDN at runtime. + * the FontAwesome website + * for more details). * *

To use FontAwesome (or indeed any glyph font) in your JavaFX application, * you firstly have to get access to the FontAwesome glyph font. You do this by