Search in sources :

Example 1 with DefaultValueCondition

use of org.ovirt.engine.ui.common.widget.form.FormItem.DefaultValueCondition in project ovirt-engine by oVirt.

the class ClusterGeneralModelForm method initialize.

/**
 * Initialize the form. Call this after ID has been set on the form,
 * so that form fields can use the ID as their prefix.
 */
public void initialize() {
    cpuThreads = new BooleanLabel(constants.yes(), constants.no());
    memoryOverCommit = new PercentLabel<>();
    resiliencePolicy = new ResiliencePolicyLabel();
    clusterType = new ClusterTypeLabel();
    driver.initialize(this);
    DefaultValueCondition virtServiceNotSupported = () -> {
        boolean supportsVirtService = getModel().getEntity() != null && getModel().getEntity().supportsVirtService();
        return !supportsVirtService;
    };
    DefaultValueCondition glusterServiceNotSupported = () -> {
        boolean supportsGlusterService = getModel().getEntity() != null && getModel().getEntity().supportsGlusterService();
        return !supportsGlusterService;
    };
    boolean virtSupported = ApplicationModeHelper.isModeSupported(ApplicationMode.VirtOnly);
    boolean glusterSupported = ApplicationModeHelper.isModeSupported(ApplicationMode.GlusterOnly);
    formBuilder.addFormItem(new FormItem(constants.nameCluster(), name, 0, 0));
    formBuilder.addFormItem(new FormItem(constants.descriptionCluster(), description, 1, 0));
    formBuilder.addFormItem(new FormItem(constants.dcCluster(), dataCenterName, 2, 0, virtSupported));
    formBuilder.addFormItem(new FormItem(constants.compatibilityVersionCluster(), compatibilityVersion, 3, 0));
    // Show the cluster type only if the application is running in both the modes
    formBuilder.addFormItem(new FormItem(constants.clusterType(), clusterType, 4, 0, virtSupported && glusterSupported));
    // properties for virt support
    formBuilder.addFormItem(new FormItem(constants.cpuTypeCluster(), cpuType, 0, 1, virtSupported).withDefaultValue(constants.notAvailableLabel(), virtServiceNotSupported));
    formBuilder.addFormItem(new FormItem(constants.cpuThreadsCluster(), cpuThreads, 1, 1, virtSupported).withDefaultValue(constants.notAvailableLabel(), virtServiceNotSupported));
    formBuilder.addFormItem(new FormItem(constants.memoryOptimizationCluster(), memoryOverCommit, 2, 1, virtSupported).withDefaultValue(constants.notAvailableLabel(), virtServiceNotSupported));
    formBuilder.addFormItem(new FormItem(constants.resiliencePolicyCluster(), resiliencePolicy, 3, 1, virtSupported).withDefaultValue(constants.notAvailableLabel(), virtServiceNotSupported));
    formBuilder.addFormItem(new FormItem(constants.emulatedMachine(), emulatedMachine, 4, 1, virtSupported).withDefaultValue(constants.notAvailableLabel(), virtServiceNotSupported));
    formBuilder.addFormItem(new FormItem(constants.numberOfVmsCluster(), numberOfVms, 5, 1, virtSupported).withDefaultValue(constants.notAvailableLabel(), virtServiceNotSupported));
    // properties for gluster support
    formBuilder.addFormItem(new FormItem(constants.clusterVolumesTotalLabel(), noOfVolumesTotal, 0, 2, glusterSupported).withDefaultValue(constants.notAvailableLabel(), glusterServiceNotSupported));
    formBuilder.addFormItem(new FormItem(constants.clusterVolumesUpLabel(), noOfVolumesUp, 1, 2, glusterSupported).withDefaultValue(constants.notAvailableLabel(), glusterServiceNotSupported));
    formBuilder.addFormItem(new FormItem(constants.clusterVolumesDownLabel(), noOfVolumesDown, 2, 2, glusterSupported).withDefaultValue(constants.notAvailableLabel(), glusterServiceNotSupported));
}
Also used : FormItem(org.ovirt.engine.ui.common.widget.form.FormItem) ClusterTypeLabel(org.ovirt.engine.ui.common.widget.label.ClusterTypeLabel) DefaultValueCondition(org.ovirt.engine.ui.common.widget.form.FormItem.DefaultValueCondition) BooleanLabel(org.ovirt.engine.ui.common.widget.label.BooleanLabel) ResiliencePolicyLabel(org.ovirt.engine.ui.common.widget.label.ResiliencePolicyLabel)

Aggregations

FormItem (org.ovirt.engine.ui.common.widget.form.FormItem)1 DefaultValueCondition (org.ovirt.engine.ui.common.widget.form.FormItem.DefaultValueCondition)1 BooleanLabel (org.ovirt.engine.ui.common.widget.label.BooleanLabel)1 ClusterTypeLabel (org.ovirt.engine.ui.common.widget.label.ClusterTypeLabel)1 ResiliencePolicyLabel (org.ovirt.engine.ui.common.widget.label.ResiliencePolicyLabel)1