Alexander Wels has uploaded a new change for review. Change subject: webadmin: Form panel label/value width ......................................................................
webadmin: Form panel label/value width - The form panel label width and value width were always at 50%/50%. So if you made one column the width of the entire available space, the spacing between the label and value would be off. So one would decrease the width of the panel. However this can cause some cut offs for really large values, like in the path of the storage general panel. This patch allows the developer more control over how the label/value are distributed allowing for larger columns to not have strange spacing. Change-Id: I43f35cd46116b8d386b86383e97fca9862e7d479 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1230723 Signed-off-by: Alexander Wels <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/AbstractFormPanel.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/FormBuilder.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageGeneralView.java 3 files changed, 33 insertions(+), 23 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/61/42461/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/AbstractFormPanel.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/AbstractFormPanel.java index 6572ba6..d92397b 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/AbstractFormPanel.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/AbstractFormPanel.java @@ -6,7 +6,6 @@ import org.gwtbootstrap3.client.ui.Column; import org.gwtbootstrap3.client.ui.Container; import org.gwtbootstrap3.client.ui.Row; -import org.gwtbootstrap3.client.ui.constants.ColumnSize; import org.ovirt.engine.ui.common.idhandler.HasElementId; import org.ovirt.engine.ui.common.utils.ElementIdUtils; @@ -84,10 +83,14 @@ return row; } + public void addFormItem(FormItem item) { + addFormItem(item, 6, 6); + } + /** * Adds new item to the form panel. */ - public void addFormItem(FormItem item) { + public void addFormItem(FormItem item, int labelWidth, int valueWidth) { // Create item label Label itemLabel = new Label(item.getName()); itemLabel.getElement().setId(ElementIdUtils.createFormGridElementId(elementId, item.getColumn(), @@ -95,14 +98,14 @@ itemLabel.setStyleName(style.formPanelLabel()); Row itemRow = new Row(); - Column labelColumn = new Column(ColumnSize.MD_6); + Column labelColumn = new Column(COL_PREFIX + labelWidth); labelColumn.add(itemLabel); itemRow.add(labelColumn); Column itemColumn = findColumn(item.getRow(), item.getColumn()); itemColumn.add(itemRow); // Update the item - updateFormItem(item); + updateFormItem(item, valueWidth); // Update auto placement data incNextAvailableRow(item.getColumn()); @@ -120,10 +123,13 @@ return result; } + public void updateFormItem(FormItem item) { + updateFormItem(item, 6); + } /** * Updates the value and visibility of the given item. */ - public void updateFormItem(FormItem item) { + public void updateFormItem(FormItem item, int valueWidth) { Widget valueWidget = item.resolveValueWidget(); valueWidget.getElement().setId( ElementIdUtils.createFormGridElementId(elementId, item.getColumn(), item.getRow(), "_value")); //$NON-NLS-1$ @@ -138,7 +144,7 @@ if(itemCellRow.getWidgetCount() > 1) { itemCellRow.remove(1); //Clear out old value. } - Column valueColumn = new Column(ColumnSize.MD_6); + Column valueColumn = new Column(COL_PREFIX + valueWidth); valueColumn.add(valueWidget); itemCellRow.add(valueColumn); } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/FormBuilder.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/FormBuilder.java index 09c14c4..b06aabc 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/FormBuilder.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/FormBuilder.java @@ -40,16 +40,20 @@ formPanel.setRelativeColumnWidth(columnNum, widthInGridColumns); } + public void addFormItem(FormItem item) { + addFormItem(item, 6, 6); + } + /** * Adds new item to the form panel. */ - public void addFormItem(FormItem item) { + public void addFormItem(FormItem item, int labelWidth, int valueWidth) { // Adopt item item.setFormPanel(formPanel); // Validate and add item if (item.isValid()) { - formPanel.addFormItem(item); + formPanel.addFormItem(item, labelWidth, valueWidth); items.add(item); // Update property name mapping, if necessary diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageGeneralView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageGeneralView.java index c21446a..3dc9ae1 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageGeneralView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageGeneralView.java @@ -104,11 +104,11 @@ // Build a form using the FormBuilder formBuilder = new FormBuilder(formPanel, 1, 14); - formBuilder.setRelativeColumnWidth(0, 4); - formBuilder.addFormItem(new FormItem(constants.sizeStorageGeneral(), totalSize, 0, 0)); - formBuilder.addFormItem(new FormItem(constants.availableStorageGeneral(), availableSize, 1, 0)); - formBuilder.addFormItem(new FormItem(constants.usedStorageGeneral(), usedSize, 2, 0)); - formBuilder.addFormItem(new FormItem(constants.allocatedStorageGeneral(), allocatedSize, 3, 0)); + formBuilder.setRelativeColumnWidth(0, 8); + formBuilder.addFormItem(new FormItem(constants.sizeStorageGeneral(), totalSize, 0, 0), 3, 9); + formBuilder.addFormItem(new FormItem(constants.availableStorageGeneral(), availableSize, 1, 0), 3, 9); + formBuilder.addFormItem(new FormItem(constants.usedStorageGeneral(), usedSize, 2, 0), 3, 9); + formBuilder.addFormItem(new FormItem(constants.allocatedStorageGeneral(), allocatedSize, 3, 0), 3, 9); formBuilder.addFormItem(new FormItem(constants.overAllocRatioStorageGeneral(), overAllocationRatio, 4, 0) { @Override public boolean getIsAvailable() { @@ -117,49 +117,49 @@ return !StorageDomainType.ISO.equals(storageDomainType) && !StorageDomainType.ImportExport.equals(storageDomainType); } - }); - formBuilder.addFormItem(new FormItem(5, 0)); // empty cell + }, 3, 9); + formBuilder.addFormItem(new FormItem(5, 0), 3, 9); // empty cell formBuilder.addFormItem(new FormItem(constants.pathStorageGeneral(), path, 6, 0) { @Override public boolean getIsAvailable() { return getDetailModel().getPath() != null; } - }); + }, 3, 9); formBuilder.addFormItem(new FormItem(constants.vfsTypeStorageGeneral(), vfsType, 7, 0) { @Override public boolean getIsAvailable() { return getDetailModel().getIsPosix() && getDetailModel().getVfsType() != null && !getDetailModel().getVfsType().isEmpty(); } - }); + }, 3, 9); formBuilder.addFormItem(new FormItem(constants.mountOptionsGeneral(), mountOptions, 8, 0) { @Override public boolean getIsAvailable() { return getDetailModel().getIsPosix() && getDetailModel().getMountOptions() != null && !getDetailModel().getMountOptions().isEmpty(); } - }); + }, 3, 9); formBuilder.addFormItem(new FormItem(constants.nfsVersionGeneral(), nfsVersion, 9, 0) { @Override public boolean getIsAvailable() { return getDetailModel().getIsNfs() && getDetailModel().getNfsVersion() != null; } - }); + }, 3, 9); formBuilder.addFormItem(new FormItem(constants.nfsRetransmissionsGeneral(), retransmissions, 10, 0) { @Override public boolean getIsAvailable() { return getDetailModel().getIsNfs() && getDetailModel().getRetransmissions() != null; } - }); + }, 3, 9); formBuilder.addFormItem(new FormItem(constants.nfsTimeoutGeneral(), timeout, 11, 0) { @Override public boolean getIsAvailable() { return getDetailModel().getIsNfs() && getDetailModel().getTimeout() != null; } - }); + }, 3, 9); - formBuilder.addFormItem(new FormItem(constants.warningLowSpaceIndicator(), warningLowSpaceIndicator, 12, 0)); - formBuilder.addFormItem(new FormItem(constants.criticalSpaceActionBlocker(), criticalSpaceActionBlocker, 13, 0)); + formBuilder.addFormItem(new FormItem(constants.warningLowSpaceIndicator(), warningLowSpaceIndicator, 12, 0), 3, 9); + formBuilder.addFormItem(new FormItem(constants.criticalSpaceActionBlocker(), criticalSpaceActionBlocker, 13, 0), 3, 9); } @Override -- To view, visit https://gerrit.ovirt.org/42461 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I43f35cd46116b8d386b86383e97fca9862e7d479 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alexander Wels <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
