Lior Vernia has uploaded a new change for review. Change subject: webadmin: Have minus button on every row in AddRemoveRowWidget ......................................................................
webadmin: Have minus button on every row in AddRemoveRowWidget Modified AddRemoveRowWidget to have a minus button on every entry, including the last one. This to enable removing the last row without adding a new one first. When removing the last row though, a plus button needs to be added to the previous one. Also made sure to add a new ghost entry if the removed entry was the only one (this is equivalent to reseting the entry's value to a ghost value). Some styling changes were required to properly display two buttons per entry, where this couldn't happen before. Change-Id: I6f6af3c5a94f7786a9b1e6191f1c36d3181983cf Bug-Url: https://bugzilla.redhat.com/1065978 Signed-off-by: Lior Vernia <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.ui.xml M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.ui.xml M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.ui.xml 6 files changed, 52 insertions(+), 22 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/79/26879/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java index a1b3540..b1581c2 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java @@ -4,6 +4,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.ListIterator; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.ui.common.CommonApplicationResources; @@ -139,9 +140,11 @@ final V widget = createWidget(value); Pair<T, V> item = new Pair<T, V>(value, widget); items.add(item); - PushButton button = createButton(item, lastItem); - AddRemoveRowPanel entry = new AddRemoveRowPanel(widget, button); + PushButton removeButton = createButton(item, false); + AddRemoveRowPanel entry = + lastItem ? new AddRemoveRowPanel(widget, removeButton, createButton(item, true)) + : new AddRemoveRowPanel(widget, removeButton); contentPanel.add(entry); final boolean ghost = isGhost(value); @@ -155,7 +158,7 @@ T value = event.getValue(); boolean becomingGhost = isGhost(value); if (becomingGhost != wasGhost) { - setButtonEnabled(widget, !becomingGhost); + setButtonsEnabled(widget, !becomingGhost); toggleGhost(value, widget, becomingGhost); wasGhost = becomingGhost; } @@ -184,7 +187,7 @@ @Override public void onClick(ClickEvent event) { - getEntry(widget).swapButton(createButton(item, false)); + getEntry(widget).removeLastButton(); Pair<T, V> item = addGhostEntry(); onAdd(item.getFirst(), item.getSecond()); } @@ -193,8 +196,19 @@ @Override public void onClick(ClickEvent event) { + ListIterator<Pair<T, V>> last = items.listIterator(items.size()); + if (item == last.previous() && last.hasPrevious()) { + Pair<T, V> previousItem = last.previous(); + getEntry(previousItem.getSecond()).appendButton(createButton(previousItem, true)); + } + removeEntry(item); onRemove(value, widget); + + if (items.isEmpty()) { + Pair<T, V> item = addGhostEntry(); + onAdd(item.getFirst(), item.getSecond()); + } } }); @@ -210,21 +224,24 @@ contentPanel.remove(getEntry(widget)); } - protected void setButtonEnabled(V widget, boolean enabled) { - getEntry(widget).setButtonEnabled(enabled); + protected void setButtonsEnabled(V widget, boolean enabled) { + getEntry(widget).setButtonsEnabled(enabled); } private class AddRemoveRowPanel extends FlowPanel { - private PushButton button; + private List<PushButton> buttons = new LinkedList<PushButton>(); private SimplePanel div = new SimplePanel(); - public AddRemoveRowPanel(Widget widget, PushButton button) { + public AddRemoveRowPanel(Widget widget, PushButton... buttons) { append(widget); - append(button); + this.buttons.clear(); + for (PushButton button : buttons) { + append(button); + this.buttons.add(button); + } div.getElement().getStyle().setClear(Clear.BOTH); add(div); - this.button = button; } private void append(Widget widget) { @@ -232,16 +249,21 @@ add(widget); } - public void setButtonEnabled(boolean enabled) { - button.setEnabled(enabled); + public void setButtonsEnabled(boolean enabled) { + for (PushButton button : buttons) { + button.setEnabled(enabled); + } } - public void swapButton(PushButton newButton) { - remove(button); + public void removeLastButton() { + remove(buttons.remove(buttons.size() - 1)); + } + + public void appendButton(PushButton button) { + buttons.add(button); remove(div); - append(newButton); + append(button); add(div); - button = newButton; } } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.java index dda8e4c..ed46760 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueWidget.java @@ -88,7 +88,7 @@ protected void toggleGhost(KeyValueLineModel value, KeyValueLineWidget widget, boolean becomingGhost) { widget.setEnabled(!becomingGhost && enabled); widget.keyField.setEnabled(enabled); - setButtonEnabled(widget, !becomingGhost && enabled); + setButtonsEnabled(widget, !becomingGhost && enabled); } @Override diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.ui.xml b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.ui.xml index 909a374..c7738e029 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.ui.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.ui.xml @@ -14,10 +14,15 @@ .contentStyle { float: left; } + + .containerStyle { + width: 300px; + margin-right: 20px; + } </ui:style> <g:FlowPanel> - <p:ProfileEditor ui:field="profileEditor" width="300px" /> + <p:ProfileEditor ui:field="profileEditor" addStyleNames="{style.containerStyle}" /> </g:FlowPanel> </ui:UiBinder> diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml index e6ca471..ee9b72d 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml @@ -21,7 +21,7 @@ padding-left: 2px; padding-top: 2px; margin-top: 7px; - margin-left: 50px; + margin-left: 10px; } </ui:style> diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.ui.xml index 5798f7e..c8e8414 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.ui.xml @@ -32,8 +32,12 @@ width: 185px; margin-left: 20px; } + + .containerStyle { + margin-right: 10px; + } </ui:style> - <g:HorizontalPanel> + <g:HorizontalPanel addStyleNames="{style.containerStyle}"> <ge:StringEntityModelTextBoxOnlyEditor ui:field="nameEditor" /> <g:FlowPanel addStyleNames="{style.publicUsePanel}"> <ge:EntityModelCheckBoxEditor ui:field="publicUseEditor" addStyleNames="{style.publicUseElement}"/> diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.ui.xml index f7b13e2..12b5961 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.ui.xml @@ -9,13 +9,12 @@ } .buttonStyle { - margin-right: 7px; width: 9px; height: 10px; padding-left: 2px; padding-top: 2px; margin-top: 7px; - margin-left: 8px; + margin-left: 10px; } </ui:style> -- To view, visit http://gerrit.ovirt.org/26879 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6f6af3c5a94f7786a9b1e6191f1c36d3181983cf Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Lior Vernia <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
