Skip to content

Commit

Permalink
webadmin: Move updateBondOptions to SetupNetworksBondModel
Browse files Browse the repository at this point in the history
SetupNetworksBondPopupView.updateBondOptions() updates the value of
customBondEditor manually via the view. Setting the value this way
doesn't fire any event. Therefore, the model is not updated during
initialization.

Moving updateBondOptions() and its registration to
SetupNetworksBondModel fixes this behavior.

Change-Id: I6a16a729633c3e1bd90a47689dbaffa9d5e813d8
Bug-Url: https://bugzilla.redhat.com/1424813
Signed-off-by: Dominik Holler <dholler@redhat.com>
  • Loading branch information
dominikholler authored and pkliczewski committed Feb 24, 2017
1 parent e624add commit d33523d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,34 @@ public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs
}
}
});
onBondingOptionsSelectionChange();
getBondingOptions().getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() {
@Override
public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
onBondingOptionsSelectionChange();
}
});
}

public boolean validate() {
getBond().validateSelectedItem(new IValidation[] { new NotEmptyValidation(),
new LengthValidation(BusinessEntitiesDefinitions.HOST_NIC_NAME_LENGTH), new BondNameValidation() });

getCustomBondEditor().setIsValid(true);
if (getBondingOptions().getSelectedItem().getKey().equals(CUSTOM_BONDING_MODE)) {
getCustomBondEditor().validateEntity(new IValidation[] { new KeyValueFormatValidation() });
}

return getBond().getIsValid() && getCustomBondEditor().getIsValid();
}

private void onBondingOptionsSelectionChange() {
Map.Entry<String, EntityModel<String>> pair = getBondingOptions().getSelectedItem();
if (CUSTOM_BONDING_MODE.equals(pair.getKey())) { //$NON-NLS-1$
customBondEditor.setIsChangeable(true);
String entity = pair.getValue().getEntity();
customBondEditor.setEntity(entity == null ? "" : entity); //$NON-NLS-1$
} else {
customBondEditor.setIsChangeable(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
import org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor;
import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer;
import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
import org.ovirt.engine.ui.uicommonweb.models.ListModel;
import org.ovirt.engine.ui.uicommonweb.models.hosts.SetupNetworksBondModel;
import org.ovirt.engine.ui.uicompat.Event;
import org.ovirt.engine.ui.uicompat.EventArgs;
import org.ovirt.engine.ui.uicompat.IEventListener;
import org.ovirt.engine.ui.webadmin.ApplicationConstants;
import org.ovirt.engine.ui.webadmin.gin.AssetProvider;
import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.host.SetupNetworksBondPopupPresenterWidget;
Expand Down Expand Up @@ -80,16 +76,6 @@ protected String renderNullSafe(Map.Entry<String, EntityModel<String>> pair) {
@Override
public void edit(final SetupNetworksBondModel object) {
driver.edit(object);

updateBondOptions(object.getBondingOptions());

object.getBondingOptions().getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() {
@Override
public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
ListModel<Map.Entry<String, EntityModel<String>>> list = (ListModel<Map.Entry<String, EntityModel<String>>>) sender;
updateBondOptions(list);
}
});
}

@Override
Expand All @@ -106,15 +92,4 @@ public void cleanup() {
public void focusInput() {
bondSuggestEditor.setFocus(true);
}

private void updateBondOptions(ListModel<Map.Entry<String, EntityModel<String>>> list) {
Map.Entry<String, EntityModel<String>> pair = list.getSelectedItem();
if ("custom".equals(pair.getKey())) { //$NON-NLS-1$
customBondEditor.setEnabled(true);
String entity = pair.getValue().getEntity();
customBondEditor.asEditor().getSubEditor().setValue(entity == null ? "" : entity); //$NON-NLS-1$
} else {
customBondEditor.setEnabled(false);
}
}
}

0 comments on commit d33523d

Please sign in to comment.