Gilad Chaplik has uploaded a new change for review.

Change subject: webadmin: allow to extend KeyValueModel
......................................................................

webadmin: allow to extend KeyValueModel

Created a base class for KeyValueModel (BaseKeyModel), that
extracts the logic of key handling.
Each derivative class will handle only values, and the way
it serialize and deserialize its data.
The motivation is to allow a new key model
for vm selection (depending patch).

Change-Id: I92d49a9e3a6099e0e082939bee61ccf484545263
Signed-off-by: Gilad Chaplik <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.ui.xml
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/uicommon/popup/AbstractVmPopupWidget.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
A 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/BaseKeyModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/VnicProfilePopupView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/scheduling/ClusterPolicyPopupView.java
10 files changed, 199 insertions(+), 143 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/26/22926/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.java
index 214f192..1bc63f7 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.java
@@ -19,6 +19,7 @@
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.HasEnabled;
+import com.google.gwt.user.client.ui.HorizontalPanel;
 import com.google.gwt.user.client.ui.Widget;
 
 public class KeyValueLineWidget extends Composite implements 
HasValueChangeHandlers<KeyValueLineModel>, HasEditorDriver<KeyValueLineModel>, 
HasEnabled {
@@ -36,6 +37,10 @@
     WidgetStyle style;
 
     @UiField
+    @Ignore
+    HorizontalPanel panel;
+
+    @UiField
     @Path(value = "keys.selectedItem")
     ListModelListBoxEditor<String> keyField;
 
@@ -49,7 +54,10 @@
 
     private final Driver driver = GWT.create(Driver.class);
 
-    KeyValueLineWidget() {
+    private String rowWidth;
+
+    KeyValueLineWidget(String rowWidth) {
+        this.rowWidth = rowWidth;
         initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this));
         driver.initialize(this);
         addStyles();
@@ -59,6 +67,9 @@
         keyField.addContentWidgetStyleName(style.fieldWidth());
         valueField.addContentWidgetStyleName(style.fieldWidth());
         valuesField.addContentWidgetStyleName(style.fieldWidth());
+        if (rowWidth != null) {
+            panel.setWidth(rowWidth);
+        }
         hideLabels();
     }
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.ui.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.ui.xml
index 0a6eb4d..3c3fe25 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.ui.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/form/key_value/KeyValueLineWidget.ui.xml
@@ -13,7 +13,7 @@
                }
        </ui:style>
 
-       <g:HorizontalPanel height="30px" width="400px">
+       <g:HorizontalPanel ui:field="panel" height="30px" width="400px">
                <e:ListModelListBoxEditor ui:field="keyField" 
addStyleNames="{style.fieldWidth}"/>
                <ge:StringEntityModelTextBoxEditor ui:field="valueField" 
addStyleNames="{style.fieldWidth}"/>
                <e:ListModelListBoxEditor ui:field="valuesField" 
addStyleNames="{style.fieldWidth}"/>
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 40064e3..a036244 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
@@ -3,29 +3,30 @@
 import java.util.LinkedList;
 
 import org.ovirt.engine.ui.common.widget.AddRemoveRowWidget;
+import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.BaseKeyModel;
 import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueLineModel;
-import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.user.client.ui.Widget;
 
-public class KeyValueWidget extends AddRemoveRowWidget<KeyValueModel, 
KeyValueLineModel, KeyValueLineWidget> {
+public class KeyValueWidget<T extends BaseKeyModel> extends 
AddRemoveRowWidget<T, KeyValueLineModel, KeyValueLineWidget> {
 
     interface WidgetUiBinder extends UiBinder<Widget, KeyValueWidget> {
         WidgetUiBinder uiBinder = GWT.create(WidgetUiBinder.class);
     }
 
-    private KeyValueModel model;
+    private T model;
     private final LinkedList<KeyValueLineWidget> widgets = new 
LinkedList<KeyValueLineWidget>();
     private boolean enabled = true;
+    String rowWidth = null;
 
     KeyValueWidget() {
         initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this));
     }
 
     @Override
-    protected void init(KeyValueModel model) {
+    protected void init(T model) {
         this.model = model;
         widgets.clear();
         super.init(model);
@@ -35,7 +36,7 @@
     }
 
     @Override
-    public KeyValueModel flush() {
+    public T flush() {
         super.flush();
         for (KeyValueLineWidget lineWidget : widgets) {
             lineWidget.flush();
@@ -52,7 +53,7 @@
 
     @Override
     protected KeyValueLineWidget createWidget(KeyValueLineModel value) {
-        KeyValueLineWidget keyValueLineWidget = new KeyValueLineWidget();
+        KeyValueLineWidget keyValueLineWidget = new 
KeyValueLineWidget(rowWidth);
         keyValueLineWidget.edit(value);
         widgets.add(keyValueLineWidget);
         return keyValueLineWidget;
@@ -82,4 +83,8 @@
         widgets.remove(widget);
     }
 
+    public void updateRowWidth(String rowWidth) {
+        this.rowWidth = rowWidth;
+    }
+
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
index c1f7ca3..627f7d3 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
@@ -83,6 +83,7 @@
 import org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel;
 import org.ovirt.engine.ui.uicommonweb.models.vms.TimeZoneModel;
 import org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel;
+import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel;
 import org.ovirt.engine.ui.uicompat.EnumTranslator;
 import org.ovirt.engine.ui.uicompat.Event;
 import org.ovirt.engine.ui.uicompat.EventArgs;
@@ -614,7 +615,7 @@
 
     @UiField
     @Ignore
-    protected KeyValueWidget customPropertiesSheetEditor;
+    protected KeyValueWidget<KeyValueModel> customPropertiesSheetEditor;
 
     private final CommonApplicationMessages messages;
 
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
index 7d9d496..30dff9a 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmRunOncePopupWidget.java
@@ -19,6 +19,7 @@
 import org.ovirt.engine.ui.uicommonweb.models.EntityModel;
 import org.ovirt.engine.ui.uicommonweb.models.vms.BootSequenceModel;
 import org.ovirt.engine.ui.uicommonweb.models.vms.RunOnceModel;
+import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel;
 import org.ovirt.engine.ui.uicompat.Event;
 import org.ovirt.engine.ui.uicompat.EventArgs;
 import org.ovirt.engine.ui.uicompat.IEventListener;
@@ -122,7 +123,7 @@
 
     @UiField
     @Ignore
-    KeyValueWidget customPropertiesSheetEditor;
+    KeyValueWidget<KeyValueModel> customPropertiesSheetEditor;
 
     @UiField
     @Path(value = "isoImage.selectedItem")
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/BaseKeyModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/BaseKeyModel.java
new file mode 100644
index 0000000..fc65108
--- /dev/null
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/BaseKeyModel.java
@@ -0,0 +1,146 @@
+package org.ovirt.engine.ui.uicommonweb.models.vms.key_value;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.ovirt.engine.ui.uicommonweb.models.ListModel;
+import org.ovirt.engine.ui.uicompat.Event;
+import org.ovirt.engine.ui.uicompat.EventArgs;
+import org.ovirt.engine.ui.uicompat.IEventListener;
+
+public abstract class BaseKeyModel extends ListModel<KeyValueLineModel> {
+    private final String selectKey;
+    private final String noKeys;
+    boolean disableEvent = false;
+
+    Set<String> allKeys = new HashSet<String>();
+    Set<String> usedKeys = new HashSet<String>();
+
+    public BaseKeyModel(String selectKey, String noKeys) {
+        this.selectKey = selectKey;
+        this.noKeys = noKeys;
+    }
+
+    protected void init(Set<String> allKeys, Set<String> usedKeys) {
+        this.allKeys = new HashSet<String>(allKeys);
+        this.usedKeys = new HashSet<String>(usedKeys);
+        List<KeyValueLineModel> list = new ArrayList<KeyValueLineModel>();
+        KeyValueLineModel lineModel;
+        disableEvent = true;
+        for (String key : usedKeys) {
+            lineModel = createNewLineModel(key);
+            lineModel.getKeys().setSelectedItem(key);
+            fillLineModel(lineModel, key);
+            list.add(lineModel);
+        }
+        disableEvent = false;
+        setItems(list);
+    }
+
+    protected abstract void initLineModel(KeyValueLineModel lineModel, String 
key);
+
+    protected abstract void fillLineModel(KeyValueLineModel lineModel, String 
key);
+
+    public final IEventListener keyChangedListener = new IEventListener() {
+
+        @Override
+        public void eventRaised(Event ev, Object sender, EventArgs args) {
+            if (disableEvent) {
+                return;
+            }
+            ListModel<String> listModel = (ListModel<String>) sender;
+            String key = null;
+            if (listModel.getSelectedItem() != null) {
+                key = listModel.getSelectedItem();
+            }
+            for (KeyValueLineModel lineModel : getItems()) {
+                if (lineModel.getKeys().getSelectedItem().equals(key)) {
+                    initLineModel(lineModel, key);
+                }
+            }
+            updateKeys();
+        }
+    };
+
+    public KeyValueLineModel createNewLineModel() {
+        return createNewLineModel(null);
+    }
+
+    public KeyValueLineModel createNewLineModel(String key) {
+        KeyValueLineModel lineModel = new KeyValueLineModel();
+        lineModel.getKeys().setItems(key == null ? getAvailableKeys() : 
getAvailableKeys(key));
+        
lineModel.getKeys().getSelectedItemChangedEvent().addListener(keyChangedListener);
+        initLineModel(lineModel, key);
+        return lineModel;
+    }
+
+    public boolean isKeyValid(String key) {
+        return !(key == null || key.equals(selectKey) || key.equals(noKeys));
+    }
+
+    public List<String> getAvailableKeys(String key) {
+        List<String> list = getAvailableKeys();
+        boolean realKey = isKeyValid(key);
+        if (realKey && !list.contains(key)) {
+            list.add(0, key);
+        }
+
+        list.remove(selectKey);
+        list.remove(noKeys);
+
+        if (!realKey) {
+            if (list.size() > 0) {
+                list.add(0, selectKey);
+            } else {
+                list.add(noKeys);
+            }
+        }
+
+        return list;
+    }
+
+    public List<String> getAvailableKeys() {
+        List<String> list =
+                (allKeys == null) ? new LinkedList<String>() : new 
LinkedList<String>(allKeys);
+        list.removeAll(getUsedKeys());
+        if (list.size() > 0) {
+            list.add(0, selectKey);
+        } else {
+            list.add(noKeys);
+        }
+
+        return list;
+    }
+
+    private List<String> getUsedKeys() {
+        if (usedKeys == null) {
+            return new ArrayList<String>();
+        } else {
+            return new ArrayList<String>(usedKeys);
+        }
+    }
+
+    public int possibleKeysCount() {
+        return allKeys == null ? 0 : allKeys.size();
+    }
+
+    public void updateKeys() {
+        if (getItems() != null && usedKeys != null) {
+            disableEvent = true;
+            usedKeys.clear();
+            for (KeyValueLineModel lineModel : getItems()) {
+                String key = lineModel.getKeys().getSelectedItem();
+                usedKeys.add(key);
+            }
+            for (KeyValueLineModel lineModel : getItems()) {
+                String key = lineModel.getKeys().getSelectedItem();
+                lineModel.getKeys().setItems(getAvailableKeys(key));
+                
lineModel.getKeys().setSelectedItem(lineModel.getKeys().getItems().iterator().next());
+            }
+            disableEvent = false;
+        }
+    }
+}
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java
index a200613..a5ed295 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java
@@ -1,58 +1,32 @@
 package org.ovirt.engine.ui.uicommonweb.models.vms.key_value;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
 import org.ovirt.engine.core.compat.StringHelper;
-import org.ovirt.engine.ui.uicommonweb.models.ListModel;
 import org.ovirt.engine.ui.uicommonweb.validation.IValidation;
 import org.ovirt.engine.ui.uicommonweb.validation.RegexValidation;
 import org.ovirt.engine.ui.uicommonweb.validation.ValidationResult;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
-import org.ovirt.engine.ui.uicompat.Event;
-import org.ovirt.engine.ui.uicompat.EventArgs;
-import org.ovirt.engine.ui.uicompat.IEventListener;
 
-public class KeyValueModel extends ListModel<KeyValueLineModel> {
+public class KeyValueModel extends BaseKeyModel {
 
-    public final static String SELECT_KEY = 
ConstantsManager.getInstance().getConstants().pleaseSelectKey();
-    public final static String NO_KEYS = 
ConstantsManager.getInstance().getConstants().noKeyAvailable();
     public final static String PROPERTIES_DELIMETER = ";"; //$NON-NLS-1$
     public final static String KEY_VALUE_DELIMETER = "="; //$NON-NLS-1$
+    private String saveEntity;
 
+    public KeyValueModel() {
+        super(ConstantsManager.getInstance().getConstants().pleaseSelectKey(), 
ConstantsManager.getInstance().getConstants().noKeyAvailable());
+    }
     Map<String, String> allKeyValueMap;
     Map<String, List<String>> allRegExKeys;
     private Map<String, String> keyValueMap_used = new HashMap<String, 
String>();
-    boolean disableEvent = false;
-    private String saveEntity;
 
-    public final IEventListener keyChangedListener = new IEventListener() {
-
-        @Override
-        public void eventRaised(Event ev, Object sender, EventArgs args) {
-            if (disableEvent) {
-                return;
-            }
-            ListModel<String> listModel = (ListModel<String>) sender;
-            String key = null;
-            if (listModel.getSelectedItem() != null) {
-                key = listModel.getSelectedItem();
-            }
-            for (KeyValueLineModel keyValueLineModel : getItems()) {
-                if (keyValueLineModel.getKeys().getSelectedItem().equals(key)) 
{
-                    initLineModel(keyValueLineModel, key);
-                }
-            }
-            updateKeys();
-        }
-    };
-
-    private void initLineModel(KeyValueLineModel keyValueLineModel, String 
key) {
+    @Override
+    protected void initLineModel(KeyValueLineModel keyValueLineModel, String 
key) {
         if (isKeyValid(key)) {
             boolean constrainedValue = allRegExKeys.containsKey(key);
             keyValueLineModel.getValue().setIsAvailable(!constrainedValue);
@@ -69,20 +43,13 @@
         }
     }
 
-    private KeyValueLineModel createNewLineModel(String key) {
-        KeyValueLineModel lineModel = new KeyValueLineModel();
-        lineModel.getKeys().setItems(key == null ? getAvailableKeys() : 
getAvailableKeys(key));
-        
lineModel.getKeys().getSelectedItemChangedEvent().addListener(keyChangedListener);
-        initLineModel(lineModel, key);
-        return lineModel;
-    }
-
-    public KeyValueLineModel createNewLineModel() {
-        return createNewLineModel(null);
-    }
-
-    public boolean isKeyValid(String key) {
-        return !(key == null || key.equals(SELECT_KEY) || key.equals(NO_KEYS));
+    @Override
+    protected void fillLineModel(KeyValueLineModel lineModel, String key) {
+        if (allRegExKeys.containsKey(key)) {
+            lineModel.getValues().setSelectedItem(keyValueMap_used.get(key));
+        } else {
+            lineModel.getValue().setEntity(keyValueMap_used.get(key));
+        }
     }
 
     public void deserialize(String value) {
@@ -90,9 +57,6 @@
             saveEntity = value;
             return;
         }
-        List<KeyValueLineModel> list = new ArrayList<KeyValueLineModel>();
-        KeyValueLineModel lineModel;
-
         if (value != null) {
             if (value.isEmpty()) {
                 return;
@@ -112,21 +76,8 @@
                     keyValueMap_used.put(key, splitLine[1]);
                 }
             }
-
-            disableEvent = true;
-            for (Map.Entry<String, String> entry : 
keyValueMap_used.entrySet()) {
-                lineModel = createNewLineModel(entry.getKey());
-                lineModel.getKeys().setSelectedItem(entry.getKey());
-                if (allRegExKeys.containsKey(entry.getKey())) {
-                    lineModel.getValues().setSelectedItem(entry.getValue());
-                } else {
-                    lineModel.getValue().setEntity(entry.getValue());
-                }
-                list.add(lineModel);
-            }
-            disableEvent = false;
         }
-        setItems(list);
+        init(allKeyValueMap.keySet(), keyValueMap_used.keySet());
     }
 
     public void setKeyValueString(List<String> lines) {
@@ -157,76 +108,13 @@
         deserialize(saveEntity);
     }
 
-    public List<String> getAvailableKeys(String key) {
-        List<String> list = getAvailableKeys();
-        boolean realKey = isKeyValid(key);
-        if (realKey && !list.contains(key)) {
-            list.add(0, key);
-        }
-
-        list.remove(SELECT_KEY);
-        list.remove(NO_KEYS);
-
-        if (!realKey) {
-            if (list.size() > 0) {
-                list.add(0, SELECT_KEY);
-            } else {
-                list.add(NO_KEYS);
-            }
-        }
-
-        return list;
-    }
-
-    public List<String> getAvailableKeys() {
-        List<String> list =
-                (allKeyValueMap == null) ? new LinkedList<String>() : new 
LinkedList<String>(allKeyValueMap.keySet());
-        list.removeAll(getUsedKeys());
-        if (list.size() > 0) {
-            list.add(0, SELECT_KEY);
-        } else {
-            list.add(NO_KEYS);
-        }
-
-        return list;
-    }
-
-    private List<String> getUsedKeys() {
-        if (keyValueMap_used == null) {
-            return new ArrayList<String>();
-        } else {
-            return new ArrayList<String>(keyValueMap_used.keySet());
-        }
-    }
-
-    public int possibleKeysCount() {
-        return allKeyValueMap == null ? 0 : allKeyValueMap.size();
-    }
-
-    public void updateKeys() {
-        if (getItems() != null && keyValueMap_used != null) {
-            disableEvent = true;
-            keyValueMap_used.clear();
-            for (KeyValueLineModel keyValueLineModel : getItems()) {
-                String key = (String) 
keyValueLineModel.getKeys().getSelectedItem();
-                keyValueMap_used.put(key, "");
-            }
-            for (KeyValueLineModel keyValueLineModel : getItems()) {
-                String key = (String) 
keyValueLineModel.getKeys().getSelectedItem();
-                keyValueLineModel.getKeys().setItems(getAvailableKeys(key));
-                
keyValueLineModel.getKeys().setSelectedItem(keyValueLineModel.getKeys().getItems().iterator().next());
-            }
-            disableEvent = false;
-        }
-    }
-
     public String serialize() {
         StringBuilder builder = new StringBuilder();
         if (getItems() == null) {
             return "";
         }
         for (KeyValueLineModel keyValueLineModel : (List<KeyValueLineModel>) 
getItems()) {
-            String key = (String) 
keyValueLineModel.getKeys().getSelectedItem();
+            String key = keyValueLineModel.getKeys().getSelectedItem();
             if (!isKeyValid(key)) {
                 continue;
             }
@@ -248,7 +136,7 @@
             return isValid;
         }
         for (KeyValueLineModel keyValueLineModel : (List<KeyValueLineModel>) 
getItems()) {
-            String key = (String) 
keyValueLineModel.getKeys().getSelectedItem();
+            String key = keyValueLineModel.getKeys().getSelectedItem();
             if (!isKeyValid(key)) {
                 continue;
             }
@@ -310,4 +198,5 @@
         }
         return sb.toString();
     }
+
 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
index c107edf..08ca949 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java
@@ -15,10 +15,10 @@
 import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel;
 import org.ovirt.engine.ui.common.widget.dialog.tab.DialogTab;
 import org.ovirt.engine.ui.common.widget.dialog.tab.DialogTabPanel;
+import org.ovirt.engine.ui.common.widget.editor.EntityModelLabel;
 import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor;
 import 
org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor;
 import 
org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxOnlyEditor;
-import org.ovirt.engine.ui.common.widget.editor.EntityModelLabel;
 import 
org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor;
 import 
org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelPasswordBoxEditor;
 import 
org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextAreaLabelEditor;
@@ -27,6 +27,7 @@
 import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer;
 import org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper;
 import org.ovirt.engine.ui.uicommonweb.models.clusters.ClusterModel;
+import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel;
 import org.ovirt.engine.ui.uicompat.Event;
 import org.ovirt.engine.ui.uicompat.EventArgs;
 import org.ovirt.engine.ui.uicompat.IEventListener;
@@ -254,7 +255,7 @@
 
     @UiField
     @Ignore
-    protected KeyValueWidget customPropertiesSheetEditor;
+    protected KeyValueWidget<KeyValueModel> customPropertiesSheetEditor;
 
     @UiField(provided = true)
     @Path(value = "enableBallooning.entity")
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/VnicProfilePopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/VnicProfilePopupView.java
index 4c99924..8869400 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/VnicProfilePopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/VnicProfilePopupView.java
@@ -13,6 +13,7 @@
 import org.ovirt.engine.ui.common.widget.form.key_value.KeyValueWidget;
 import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer;
 import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel;
+import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel;
 import org.ovirt.engine.ui.uicompat.Event;
 import org.ovirt.engine.ui.uicompat.EventArgs;
 import org.ovirt.engine.ui.uicompat.IEventListener;
@@ -75,7 +76,7 @@
 
     @UiField
     @Ignore
-    public KeyValueWidget customPropertiesSheetEditor;
+    public KeyValueWidget<KeyValueModel> customPropertiesSheetEditor;
 
     @UiField(provided = true)
     @Path(value = "publicUse.entity")
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 48a0945..a08aedf 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
@@ -15,6 +15,7 @@
 import org.ovirt.engine.ui.common.widget.form.key_value.KeyValueWidget;
 import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer;
 import 
org.ovirt.engine.ui.uicommonweb.models.configure.scheduling.NewClusterPolicyModel;
+import org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel;
 import org.ovirt.engine.ui.uicompat.Event;
 import org.ovirt.engine.ui.uicompat.EventArgs;
 import org.ovirt.engine.ui.uicompat.IEventListener;
@@ -67,7 +68,7 @@
 
     @UiField
     @Ignore
-    protected KeyValueWidget customPropertiesSheetEditor;
+    protected KeyValueWidget<KeyValueModel> customPropertiesSheetEditor;
 
     @UiField(provided = true)
     PolicyUnitListPanel usedFilterPanel;


-- 
To view, visit http://gerrit.ovirt.org/22926
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I92d49a9e3a6099e0e082939bee61ccf484545263
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Gilad Chaplik <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to