use of eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata in project dwoss by gg-net.
the class MandatorMetaDataController method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
CustomerGenerator gen = new CustomerGenerator();
MandatorMetadata m = gen.makeMandatorMetadata();
defaultCustomerSalesdata = new DefaultCustomerSalesdata(m.getShippingCondition(), m.getPaymentCondition(), m.getPaymentMethod(), m.getAllowedSalesChannels(), new ArrayList(m.getAllowedSalesChannels()));
this.setDefaultValues(defaultCustomerSalesdata);
saveButton.setDisable(true);
shippingConditionComboBox.getItems().setAll(ShippingCondition.values());
paymentConditionComboBox.getItems().setAll(PaymentCondition.values());
paymentMethodComboBox.getItems().setAll(PaymentMethod.values());
shippingConditionComboBox.setConverter(new StringConverter<ShippingCondition>() {
@Override
public ShippingCondition fromString(String string) {
throw new UnsupportedOperationException("fromString is not supported");
}
@Override
public String toString(ShippingCondition myClassinstance) {
return myClassinstance.toString();
}
});
paymentConditionComboBox.setConverter(new StringConverter<PaymentCondition>() {
@Override
public PaymentCondition fromString(String string) {
throw new UnsupportedOperationException("fromString is not supported");
}
@Override
public String toString(PaymentCondition myClassinstance) {
return myClassinstance.getNote();
}
});
paymentMethodComboBox.setConverter(new StringConverter<PaymentMethod>() {
@Override
public PaymentMethod fromString(String string) {
throw new UnsupportedOperationException("fromString is not supported");
}
@Override
public String toString(PaymentMethod myClassinstance) {
return myClassinstance.getNote();
}
});
paymentConditionComboBox.setCellFactory(new Callback<ListView<PaymentCondition>, ListCell<PaymentCondition>>() {
@Override
public ListCell<PaymentCondition> call(ListView<PaymentCondition> l) {
return new ListCell<PaymentCondition>() {
@Override
public String toString() {
return this.toString();
}
@Override
protected void updateItem(PaymentCondition item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
} else {
setText(item.getNote());
}
}
};
}
});
paymentMethodComboBox.setCellFactory((ListView<PaymentMethod> l) -> new ListCell<PaymentMethod>() {
@Override
protected void updateItem(PaymentMethod item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setGraphic(null);
} else {
setText(item.getNote());
}
}
});
InvalidationListener saveButtonDisablingListener = new InvalidationListener() {
@Override
public void invalidated(javafx.beans.Observable observable) {
if (shippingConditionComboBox.getSelectionModel().isEmpty() && paymentConditionComboBox.getSelectionModel().isEmpty() && paymentMethodComboBox.getSelectionModel().isEmpty() && allowedSalesChannelCheckBoxList.stream().noneMatch(CheckBox::isSelected))
saveButton.setDisable(true);
else
saveButton.setDisable(false);
}
};
shippingConditionComboBox.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
paymentConditionComboBox.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
paymentMethodComboBox.getSelectionModel().selectedItemProperty().addListener(saveButtonDisablingListener);
allowedSalesChannelCheckBoxList.forEach(e -> e.selectedProperty().addListener(saveButtonDisablingListener));
}
use of eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata in project dwoss by gg-net.
the class MandatorMetaDataTryOut method randomTryOut.
private static void randomTryOut() {
CustomerGenerator gen = new CustomerGenerator();
MandatorMetadata mData = gen.makeMandatorMetadata();
Ui.exec(() -> {
Ui.build().fxml().eval(() -> mData, MandatorMetaDataController.class);
});
}
use of eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata in project dwoss by gg-net.
the class MandatorMetadataTest method testGetViolationMessagesNonValidPaymentCondition.
@Test
public void testGetViolationMessagesNonValidPaymentCondition() {
MandatorMetadata makeInValidMandatorMetadata = makeValidMandatorMetadata();
makeInValidMandatorMetadata.setPaymentCondition(null);
assertThat(makeInValidMandatorMetadata.getViolationMessage()).as("MandatorMetadata without PaymentCondition").isNotBlank();
}
use of eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata in project dwoss by gg-net.
the class MandatorMetadataTest method testGetViolationMessagesNonSalesChannels.
@Test
public void testGetViolationMessagesNonSalesChannels() {
MandatorMetadata makeInValidMandatorMetadata = makeValidMandatorMetadata();
makeInValidMandatorMetadata.clearSalesChannels();
assertThat(makeInValidMandatorMetadata.getViolationMessage()).as("MandatorMetadata without Allowed Sales Channels").isNotBlank();
}
use of eu.ggnet.dwoss.customer.ee.entity.MandatorMetadata in project dwoss by gg-net.
the class MandatorMetadataTest method testGetViolationMessages.
@Test
public void testGetViolationMessages() {
MandatorMetadata makeValidMandatorMetadata = makeValidMandatorMetadata();
assertThat(makeValidMandatorMetadata.getViolationMessage()).as("MandatorMetadata with valid values").isNull();
}
Aggregations