Martin Sivák has uploaded a new change for review. Change subject: webadmin: Hide custom policy properties section if empty ......................................................................
webadmin: Hide custom policy properties section if empty This patch updates the Cluster policy popup dialog used to configure ClusterPolicy. The section for custom parameters stays hidden if there are no parameters set and none are announced by the currently used PolicyUnits. Change-Id: I41cc951ad977f24821d81e909ba958064695903e Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1064397 Signed-off-by: Martin Sivak <[email protected]> --- M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.ui.xml 2 files changed, 54 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/87/25087/1 diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.java index a08aedf..2534cdb 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; +import com.google.gwt.user.client.ui.FlowPanel; import org.ovirt.engine.core.common.scheduling.PolicyUnit; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; @@ -101,6 +102,9 @@ @Ignore Label externalLabel; + @UiField + FlowPanel clusterPolicyPropertiesZone; + @Inject public ClusterPolicyPopupView(EventBus eventBus, ApplicationResources resources, @@ -145,16 +149,47 @@ descriptionEditor.setLabel(constants.clusterPolicyDescriptionLabel()); } + public boolean showClusterPolicyPropertiesZone(final NewClusterPolicyModel model) { + if (!model.getCustomProperties().isEmpty()) { + return true; + } + + if (model.getUsedFilters() != null) { + for (PolicyUnit policyUnit: model.getUsedFilters()) { + if (policyUnit.getParameterRegExMap() != null + && !policyUnit.getParameterRegExMap().isEmpty()) { + return true; + } + } + } + if (model.getUsedFunctions() != null) { + for (Pair<PolicyUnit, Integer> policyUnit: model.getUsedFunctions()) { + if (policyUnit.getFirst().getParameterRegExMap() != null + && !policyUnit.getFirst().getParameterRegExMap().isEmpty()) { + return true; + } + } + } + if (model.getLoadBalanceList().getSelectedItem() != null) { + PolicyUnit policyUnit = (PolicyUnit)model.getLoadBalanceList().getSelectedItem(); + if (policyUnit.getParameterRegExMap() != null + && !policyUnit.getParameterRegExMap().isEmpty()) { + return true; + } + } + + return false; + } + public void edit(final NewClusterPolicyModel model) { driver.edit(model); setPanelModel(model); updateFilters(model); model.getFiltersChangedEvent().addListener(new IEventListener() { - @Override public void eventRaised(Event ev, Object sender, EventArgs args) { updateFilters(model); - + clusterPolicyPropertiesZone.setVisible(showClusterPolicyPropertiesZone(model)); } }); updateFunctions(model); @@ -163,18 +198,21 @@ @Override public void eventRaised(Event ev, Object sender, EventArgs args) { updateFunctions(model); - + clusterPolicyPropertiesZone.setVisible(showClusterPolicyPropertiesZone(model)); } }); if (model.getClusterPolicy().isLocked()) { customPropertiesSheetEditor.setEnabled(false); } customPropertiesSheetEditor.edit(model.getCustomPropertySheet()); + + clusterPolicyPropertiesZone.setVisible(showClusterPolicyPropertiesZone(model)); updateTooltips(model); model.getLoadBalanceList().getSelectedItemChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { updateTooltips(model); + clusterPolicyPropertiesZone.setVisible(showClusterPolicyPropertiesZone(model)); } }); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.ui.xml index 9ff1872..23d41af 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.ui.xml @@ -167,17 +167,19 @@ <g:Label ui:field="externalLabel" addStyleNames="{style.externalLabel}"/> </g:HorizontalPanel> </g:FlowPanel> - <g:HorizontalPanel> - <g:Label addStyleNames="{style.sectionLabel}" - text="{constants.clusterPolicyPropertiesLabel}" /> - <d:InfoIcon ui:field="propertiesInfoIcon" addStyleNames="{style.iconInfoStyle}"/> - </g:HorizontalPanel> - <g:HTML> - <hr style="width:100%;" /> - </g:HTML> - <g:ScrollPanel height="100px"> - <k:KeyValueWidget ui:field="customPropertiesSheetEditor" /> - </g:ScrollPanel> + <g:FlowPanel ui:field="clusterPolicyPropertiesZone"> + <g:HorizontalPanel> + <g:Label addStyleNames="{style.sectionLabel}" + text="{constants.clusterPolicyPropertiesLabel}" /> + <d:InfoIcon ui:field="propertiesInfoIcon" addStyleNames="{style.iconInfoStyle}"/> + </g:HorizontalPanel> + <g:HTML> + <hr style="width:100%;" /> + </g:HTML> + <g:ScrollPanel height="100px"> + <k:KeyValueWidget ui:field="customPropertiesSheetEditor" /> + </g:ScrollPanel> + </g:FlowPanel> </g:VerticalPanel> </d:content> </d:SimpleDialogPanel> -- To view, visit http://gerrit.ovirt.org/25087 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I41cc951ad977f24821d81e909ba958064695903e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Sivák <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
