CategoryProductEditorController.java 文件源码

java
阅读 16 收藏 0 点赞 0 评论 0

项目:dwoss 作者:
/**
     * Create a CategoryProductFx based on the values from cp. Bind the
     * CategoryProductFx with the ui components.
     *
     * @param cp received categoryProduct.
     */
    public void setCategoryProduct(CategoryProduct cp) {

        // Bind in initialze and update via mapper would be much better.
        // CategoryProductFxMapper.INSTANCE.update(categoryProductFx, cp);
        categoryProductFx = CategoryProductFxMapper.INSTANCE.from(cp);

// Old show lucas, jens and jacob
//        categoryProductFx = new CategoryProductFx(cp.getId(), cp.getName(),
//                cp.getDescription(),
//                cp.getSalesChannel(),
//                cp.getProducts()
//                        .stream()
//                        .map(p -> new PicoProduct(p.getId(), p.getName()))
//                        .collect(Collectors.toList()),
//                cp.getPrices());
        name.textProperty().bindBidirectional(categoryProductFx.getNameProperty());
        description.textProperty().bindBidirectional(categoryProductFx.getDescriptionProperty());
        salesChannel.valueProperty().bindBidirectional(categoryProductFx.getSalesChannelProperty());

// TODO: Looks wrong. must be binded ? - ask lucas.
        // listViewProducts.itemsProperty().bind(categoryProductFx.getProductsProperty());
        // listViewPrices.itemsProperty().bind(categoryProductFx.getPricesProperty().entrySet());
        listViewProducts.setItems(categoryProductFx.getProductsProperty());

        listViewPrices.setItems(FXCollections.observableArrayList(categoryProductFx.getPricesProperty().entrySet()));

        categoryProductFx.getPricesProperty().addListener((MapChangeListener<PriceType, Double>)change -> {
            listViewPrices.getItems().clear();
            listViewPrices.getItems().addAll(categoryProductFx.getPricesProperty().entrySet());
        });
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号