/**
 *
 * Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); You may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.speedment.internal.ui.config.trait;

import com.speedment.Speedment;
import com.speedment.config.db.parameters.OrderType;
import com.speedment.config.db.trait.*;
import com.speedment.internal.ui.config.DocumentProperty;
import com.speedment.internal.ui.property.EnumPropertyItem;
import java.util.stream.Stream;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.StringProperty;
import javafx.util.StringConverter;
import org.controlsfx.control.PropertySheet;

/**
 *
 * @author Emil Forslund
 */
public interface HasOrderTypeProperty extends DocumentProperty, HasOrderType {
    
    default ObjectProperty<OrderType> orderTypeProperty() {
        final String defaultValue = HasOrderType.super.getOrderType().name();
        final StringProperty strProperty = stringPropertyOf(HasOrderType.ORDER_TYPE, () -> defaultValue);
        final ObjectProperty<OrderType> objProperty = new SimpleObjectProperty<>(OrderType.valueOf(defaultValue));
        
        strProperty.bindBidirectional(objProperty, new StringConverter<OrderType>() {
            @Override
            public String toString(OrderType object) {
                return object.name();
            }

            @Override
            public OrderType fromString(String string) {
                return OrderType.valueOf(string);
            }
        });
        
        return objProperty;
    }

    @Override
    default OrderType getOrderType() {
        return orderTypeProperty().get();
    }

    @Override
    default Stream<PropertySheet.Item> getUiVisibleProperties(Speedment speedment) {
        return Stream.of(
            new EnumPropertyItem<>(
                OrderType.class,
                orderTypeProperty(),
                "Order Type",
                "The order in which elements will be considered."
            )
        );
    }
}
@@ -997,140 +997,8 @@
 ty;%0A
-import javafx.beans.property.SimpleObjectProperty;%0Aimport javafx.beans.property.StringProperty;%0Aimport javafx.util.StringConverter;%0A
 impo
@@ -1038,16 +1038,16 @@
 ySheet;%0A
+
 %0A/**%0A *%0A
@@ -1231,714 +1231,107 @@
     
-final String defaultValue = HasOrderType.super.getOrderType().name();%0A        final StringProperty strProperty = stringPropertyOf(HasOrderType.ORDER_TYPE, () -%3E defaultValue);%0A        final ObjectProperty%3COrderType%3E objProperty = new SimpleObjectProperty%3C%3E(OrderType.valueOf(defaultValue));%0A        %0A        strProperty.bindBidirectional(objProperty, new StringConverter%3COrderType%3E() %7B%0A            @Override%0A            public String toString(OrderType object) %7B%0A                return object.name();%0A            %7D%0A%0A            @Override%0A            public OrderType fromString(String string) %7B%0A                return OrderType.valueOf(string);%0A            %7D%0A        %7D);%0A        %0A        return objProperty
+return objectPropertyOf(HasOrderType.ORDER_TYPE, OrderType.class, HasOrderType.super::getOrderType)
 ;%0A  

Fix ClassCastException on OrderType