Lior Vernia has uploaded a new change for review. Change subject: webadmin: Remove unsafe List casts from vNIC Profile tabs ......................................................................
webadmin: Remove unsafe List casts from vNIC Profile tabs Removed all unsafe casts of Collections into Lists in the vNIC Profiles main tab and subtabs. Change-Id: Ic69467f0e805a70a2ea0979df2adddc2a1b6cb57 Signed-off-by: Lior Vernia <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileTemplateListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileVmListModel.java 3 files changed, 16 insertions(+), 45 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/78/28678/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileListModel.java index c075987..16aa6a9 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileListModel.java @@ -3,8 +3,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; -import java.util.List; import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.network.Network; @@ -44,12 +42,14 @@ public VnicProfileListModel() { setTitle(ConstantsManager.getInstance().getConstants().vnicProfilesTitle()); setHelpTag(HelpTag.vnicProfiles); - setHashName("vnicProfiles"); //$NON-NLS-1$ + setHashName("vnicProfiles"); //$NON-NLS-1$) setDefaultSearchString("VnicProfile:"); //$NON-NLS-1$ setSearchString(getDefaultSearchString()); // setSearchObjects(new String[] { SearchObjects.PROFILE_OBJ_NAME, SearchObjects.PROFILE_PLU_OBJ_NAME }); setAvailableInModes(ApplicationMode.VirtOnly); + + setComparator(new Linq.VnicProfileViewComparator()); setNewCommand(new UICommand("New", this)); //$NON-NLS-1$ setEditCommand(new UICommand("Edit", this)); //$NON-NLS-1$ @@ -135,8 +135,8 @@ @Override public void onSuccess(Object model, Object ReturnValue) { - ArrayList<Network> networks = - (ArrayList<Network>) ((VdcQueryReturnValue) ReturnValue).getReturnValue(); + Collection<Network> networks = + (Collection<Network>) ((VdcQueryReturnValue) ReturnValue).getReturnValue(); profileModel.getNetwork().setItems(networks); @@ -158,7 +158,7 @@ } } - private Network findNetwork(Guid networkId, List<Network> networks) { + private Network findNetwork(Guid networkId, Iterable<Network> networks) { for (Network network : networks) { if (networkId.equals(network.getId())) { return network; @@ -209,7 +209,7 @@ @Override public void onSuccess(Object model, Object returnValue) { - setItems((List<VnicProfileView>) returnValue); + setItems((Collection<VnicProfileView>) returnValue); } }; AsyncDataProvider.getVnicProfilesByNetworkId(asyncQuery, network.getId()); @@ -227,7 +227,7 @@ @Override public void onSuccess(Object model, Object returnValue) { - setItems((List<VnicProfileView>) returnValue); + setItems((Collection<VnicProfileView>) returnValue); } }; AsyncDataProvider.getVnicProfilesByDcId(asyncQuery, dc.getId()); @@ -247,9 +247,8 @@ } private void updateActionAvailability() { - List tempVar = getSelectedItems(); - ArrayList selectedItems = - (ArrayList) ((tempVar != null) ? tempVar : new ArrayList()); + Collection<VnicProfileView> tempVar = getSelectedItems(); + Collection<VnicProfileView> selectedItems = ((tempVar != null) ? tempVar : new ArrayList()); getEditCommand().setIsExecutionAllowed(selectedItems.size() == 1); getRemoveCommand().setIsExecutionAllowed(selectedItems.size() > 0); @@ -295,14 +294,6 @@ @Override public VnicProfileView getEntity() { return (VnicProfileView) super.getEntity(); - } - - @Override - public void setItems(Collection value) { - if (value != null) { - Collections.sort((List<VnicProfileView>) value, new Linq.VnicProfileViewComparator()); - } - super.setItems(value); } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileTemplateListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileTemplateListModel.java index 2831dec..211518f 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileTemplateListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileTemplateListModel.java @@ -1,8 +1,6 @@ package org.ovirt.engine.ui.uicommonweb.models.profiles; import java.util.Collection; -import java.util.Collections; -import java.util.List; import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.network.VnicProfileView; @@ -19,7 +17,6 @@ import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; -@SuppressWarnings("unused") public class VnicProfileTemplateListModel extends SearchableListModel { @@ -27,6 +24,8 @@ setTitle(ConstantsManager.getInstance().getConstants().templatesTitle()); setHelpTag(HelpTag.templates); setHashName("templates"); //$NON-NLS-1$ + + setComparator(new Linq.VmTemplateComparator()); updateActionAvailability(); } @@ -44,15 +43,6 @@ protected void onEntityChanged() { super.onEntityChanged(); getSearchCommand().execute(); - } - - @Override - public void setItems(Collection value) { - if (value != null) { - List<VmTemplate> itemList = (List<VmTemplate>) value; - Collections.sort(itemList, new Linq.VmTemplateComparator()); - } - super.setItems(value); } @Override @@ -75,7 +65,7 @@ @Override public void onSuccess(Object model, Object ReturnValue) { - VnicProfileTemplateListModel.this.setItems((List<VmTemplate>) ((VdcQueryReturnValue) ReturnValue).getReturnValue()); + setItems((Collection<VmTemplate>) ((VdcQueryReturnValue) ReturnValue).getReturnValue()); } }; diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileVmListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileVmListModel.java index 9c796ab..d5bc11f 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileVmListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileVmListModel.java @@ -1,8 +1,6 @@ package org.ovirt.engine.ui.uicommonweb.models.profiles; import java.util.Collection; -import java.util.Collections; -import java.util.List; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.network.VnicProfileView; @@ -19,7 +17,6 @@ import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; -@SuppressWarnings("unused") public class VnicProfileVmListModel extends SearchableListModel { @@ -27,6 +24,8 @@ setTitle(ConstantsManager.getInstance().getConstants().virtualMachinesTitle()); setHelpTag(HelpTag.virtual_machines); setHashName("virtual_machines"); //$NON-NLS-1$ + + setComparator(new Linq.VmComparator()); updateActionAvailability(); } @@ -44,15 +43,6 @@ protected void onEntityChanged() { super.onEntityChanged(); getSearchCommand().execute(); - } - - @Override - public void setItems(Collection value) { - if (value != null) { - List<VM> itemList = (List<VM>) value; - Collections.sort(itemList, new Linq.VmComparator()); - } - super.setItems(value); } @Override @@ -75,7 +65,7 @@ @Override public void onSuccess(Object model, Object ReturnValue) { - VnicProfileVmListModel.this.setItems((List<VM>) ((VdcQueryReturnValue) ReturnValue).getReturnValue()); + setItems((Collection<VM>) ((VdcQueryReturnValue) ReturnValue).getReturnValue()); } }; -- To view, visit http://gerrit.ovirt.org/28678 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic69467f0e805a70a2ea0979df2adddc2a1b6cb57 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
