Skip to content

Commit

Permalink
Merge pull request #6 from FHNW-IP5-IP6/master
Browse files Browse the repository at this point in the history
Bugfixing and Changes of Visibility for Inheritance
  • Loading branch information
dlemmermann authored Dec 6, 2017
2 parents 24b10f2 + 6313f39 commit 81c9e03
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ boolean validate() {
/**
* {@inheritDoc}
*/
void translate(TranslationService service) {
public void translate(TranslationService service) {
super.translate(service);

updateElement(formatError, formatErrorKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public F span(ColSpan newValue) {
* @param newValue
* The new service to use for translating translatable values.
*/
void translate(TranslationService newValue) {
public void translate(TranslationService newValue) {
translationService = newValue;

if (!isI18N()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class Group {

final List<Field> fields = new ArrayList<>();
protected final List<Field> fields = new ArrayList<>();

/**
* The group acts as a proxy for its contained fields' {@code changed}
Expand All @@ -52,7 +52,7 @@ public class Group {
* The translation service is passed down from the containing form. It
* is used to translate all translatable values of the field.
*/
TranslationService translationService;
protected TranslationService translationService;

/**
* Internal constructor for the {@code Group} class. To create new
Expand All @@ -64,7 +64,7 @@ public class Group {
* A varargs list of fields that are contained in this
* group.
*/
Group(Field... fields) {
protected Group(Field... fields) {
Collections.addAll(this.fields, fields);

// If any of the fields are marked as changed, the group is updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
import com.dlsc.formsfx.model.validators.ValidationResult;
import com.dlsc.formsfx.model.validators.Validator;
import com.dlsc.formsfx.view.controls.SimpleListViewControl;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javafx.beans.binding.Bindings;
import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
* This class provides an implementation of a {@link MultiSelectionField}
* allowing for multi-selection.
Expand Down Expand Up @@ -84,7 +83,7 @@ public class MultiSelectionField<V> extends SelectionField<V, MultiSelectionFiel
// marked as changed until Field::persist or Field::reset are called
// or the selection is back to the persistent selection.

changed.bind(Bindings.createBooleanBinding(() -> !persistentSelection.equals(this.selection), persistentSelection, this.selection));
changed.bind(Bindings.createBooleanBinding(() -> !persistentSelection.equals(this.selection), this.selection, persistentSelection));

// Changes to the user input are reflected in the value only if the new
// user input is valid.
Expand Down Expand Up @@ -201,7 +200,7 @@ public MultiSelectionField<V> deselect(int index) {
*/
public MultiSelectionField<V> bind(ListProperty<V> itemsBinding, ListProperty<V> selectionBinding) {
items.bindBidirectional(itemsBinding);
persistentSelection.unbindBidirectional(selectionBinding);
selection.bindBidirectional(selectionBinding);

return this;
}
Expand All @@ -220,7 +219,7 @@ public MultiSelectionField<V> bind(ListProperty<V> itemsBinding, ListProperty<V>
*/
public MultiSelectionField<V> unbind(ListProperty<V> itemsBinding, ListProperty<V> selectionBinding) {
items.unbindBidirectional(itemsBinding);
persistentSelection.unbindBidirectional(selectionBinding);
selection.unbindBidirectional(selectionBinding);

return this;
}
Expand Down Expand Up @@ -264,7 +263,7 @@ void reset() {
* {@inheritDoc}
*/
boolean validateRequired() {
return !isRequired() || selection.size() > 0;
return !isRequired() || (isRequired() && selection.size() > 0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
import com.dlsc.formsfx.model.validators.ValidationResult;
import com.dlsc.formsfx.model.validators.Validator;
import com.dlsc.formsfx.view.controls.SimpleComboBoxControl;
import javafx.beans.binding.Bindings;
import javafx.beans.property.ListProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import javafx.beans.binding.Bindings;
import javafx.beans.property.ListProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;

/**
* This class provides an implementation of a {@link SelectionField} allowing
Expand Down Expand Up @@ -80,7 +79,7 @@ public class SingleSelectionField<V> extends SelectionField<V, SingleSelectionFi
// marked as changed until Field::persist or Field::reset are called
// or the selection is back to the persistent selection.

changed.bind(Bindings.createBooleanBinding(() -> persistentSelection.get() == null ? this.selection.get() != null : !persistentSelection.get().equals(this.selection.get()), persistentSelection, this.selection));
changed.bind(Bindings.createBooleanBinding(() -> persistentSelection.get() == null ? this.selection.get() != null : !persistentSelection.get().equals(this.selection.get()), this.selection, persistentSelection));

// Changes to the user input are reflected in the value only if the new
// user input is valid.
Expand Down Expand Up @@ -198,7 +197,7 @@ public SingleSelectionField<V> deselect() {
*/
public SingleSelectionField<V> bind(ListProperty<V> itemsBinding, ObjectProperty<V> selectionBinding) {
items.bindBidirectional(itemsBinding);
persistentSelection.unbindBidirectional(selectionBinding);
selection.bindBidirectional(selectionBinding);

return this;
}
Expand All @@ -217,7 +216,7 @@ public SingleSelectionField<V> bind(ListProperty<V> itemsBinding, ObjectProperty
*/
public SingleSelectionField<V> unbind(ListProperty<V> itemsBinding, ObjectProperty<V> selectionBinding) {
items.unbindBidirectional(itemsBinding);
persistentSelection.unbindBidirectional(selectionBinding);
selection.unbindBidirectional(selectionBinding);

return this;
}
Expand Down Expand Up @@ -261,7 +260,7 @@ void reset() {
* {@inheritDoc}
*/
boolean validateRequired() {
return !isRequired() || selection.get() != null;
return !isRequired() || (isRequired() && selection.get() != null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,19 @@ protected void updateStyle(PseudoClass pseudo, boolean newValue) {
pseudoClassStateChanged(pseudo, newValue);
}

/**
* Adds a style class to the control.
* @param name of the style class to be added to the control
*/
public void addStyleClass(String name) {
getStyleClass().add(name);
}

/**
* Removes a style class from the control.
* @param name of the class to be removed from the control
*/
public void removeStyleClass(String name) {
getStyleClass().remove(name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class SimpleNumberControl<F extends DataField, D extends Number>
* - The readOnlyLabel is the label to put over editableSpinner.
*/
private Label fieldLabel;
Spinner<D> editableSpinner;
protected Spinner<D> editableSpinner;
private Label readOnlyLabel;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public abstract class GroupRendererBase<V extends Group> extends StackPane imple
* - SPACING is used to set the spacing of the section as well as the
* spacing for vertical/horizontal gaps between controls.
*/
final int SPACING = 10;
protected final int SPACING = 10;

GridPane grid;
protected GridPane grid;

V element;
protected V element;

/**
*
Expand Down

0 comments on commit 81c9e03

Please sign in to comment.