private void Edit() { if (getWindow() != null) { return; } VmInterfaceModel model = new VmInterfaceModel(); setWindow(model); model.setTitle("Edit Network Interface"); AsyncDataProvider.GetClusterNetworkList( new AsyncQuery( this, new INewAsyncCallback() { @Override public void OnSuccess(Object target, Object returnValue) { TemplateInterfaceListModel vmInterfaceListModel = (TemplateInterfaceListModel) target; java.util.ArrayList<network> network_list = returnValue != null ? (java.util.ArrayList<network>) returnValue : new java.util.ArrayList<network>(); vmInterfaceListModel.PostGetClusterNetworkList_Edit(network_list); } }), getEntityStronglyTyped().getvds_group_id()); }
private void OnSave() { VmInterfaceModel model = (VmInterfaceModel) getWindow(); VmNetworkInterface nic = model.getIsNew() ? new VmNetworkInterface() : (VmNetworkInterface) Cloner.clone((VmNetworkInterface) getSelectedItem()); if (!model.Validate()) { return; } // Save changes. nic.setName((String) model.getName().getEntity()); nic.setNetworkName(((network) model.getNetwork().getSelectedItem()).getname()); if (model.getNicType().getSelectedItem() == null) { nic.setType(null); } else { nic.setType(((VmInterfaceType) model.getNicType().getSelectedItem()).getValue()); } nic.setMacAddress( model.getMAC().getIsChangable() ? (model.getMAC().getEntity() == null ? null : ((String) (model.getMAC().getEntity())).toLowerCase()) : model.getIsNew() ? "" : nic.getMacAddress()); if (model.getIsNew()) { Frontend.RunMultipleAction( VdcActionType.AddVmTemplateInterface, new java.util.ArrayList<VdcActionParametersBase>( java.util.Arrays.asList( new VdcActionParametersBase[] { new AddVmTemplateInterfaceParameters(getEntityStronglyTyped().getId(), nic) })), new IFrontendMultipleActionAsyncCallback() { @Override public void Executed(FrontendMultipleActionAsyncResult result) { Cancel(); } }, null); } else { Frontend.RunMultipleAction( VdcActionType.UpdateVmTemplateInterface, new java.util.ArrayList<VdcActionParametersBase>( java.util.Arrays.asList( new VdcActionParametersBase[] { new AddVmTemplateInterfaceParameters(getEntityStronglyTyped().getId(), nic) })), new IFrontendMultipleActionAsyncCallback() { @Override public void Executed(FrontendMultipleActionAsyncResult result) { Cancel(); } }, null); } }
public void PostGetClusterNetworkList_Edit(java.util.ArrayList<network> network_list) { VmNetworkInterface nic = (VmNetworkInterface) getSelectedItem(); int nicCount = Linq.<VmNetworkInterface>Cast(getItems()).size(); java.util.ArrayList<network> networks = new java.util.ArrayList<network>(); for (network a : network_list) { if (a.getStatus() == NetworkStatus.Operational) { networks.add(a); } } VmInterfaceModel model = (VmInterfaceModel) getWindow(); model.getNetwork().setItems(networks); network network = null; for (network a : networks) { if (StringHelper.stringsEqual(a.getname(), nic.getNetworkName())) { network = a; break; } } model.getNetwork().setSelectedItem(network); Integer selectedNicType = nic.getType(); java.util.ArrayList<VmInterfaceType> nicTypes = DataProvider.GetNicTypeList( getEntityStronglyTyped().getos(), VmInterfaceType.forValue(selectedNicType) == VmInterfaceType.rtl8139_pv); model.getNicType().setItems(nicTypes); if (selectedNicType == null || !nicTypes.contains(VmInterfaceType.forValue(selectedNicType))) { selectedNicType = DataProvider.GetDefaultNicType(getEntityStronglyTyped().getos()).getValue(); } model.getNicType().setSelectedItem(VmInterfaceType.forValue(selectedNicType)); model.getName().setEntity(nic.getName()); model.getMAC().setIsAvailable(false); UICommand tempVar = new UICommand("OnSave", this); tempVar.setTitle("OK"); tempVar.setIsDefault(true); model.getCommands().add(tempVar); UICommand tempVar2 = new UICommand("Cancel", this); tempVar2.setTitle("Cancel"); tempVar2.setIsCancel(true); model.getCommands().add(tempVar2); }
public void PostGetClusterNetworkList_New(java.util.ArrayList<network> network_list) { java.util.ArrayList<network> networks = new java.util.ArrayList<network>(); for (network a : network_list) { if (a.getStatus() == NetworkStatus.Operational) { networks.add(a); } } java.util.ArrayList<VmNetworkInterface> nics = Linq.<VmNetworkInterface>Cast(getItems()); int nicCount = nics.size(); String newNicName = DataProvider.GetNewNicName(nics); VmInterfaceModel model = (VmInterfaceModel) getWindow(); model.getNetwork().setItems(networks); model.getNetwork().setSelectedItem(networks.size() > 0 ? networks.get(0) : null); model .getNicType() .setItems(DataProvider.GetNicTypeList(getEntityStronglyTyped().getos(), false)); model .getNicType() .setSelectedItem(DataProvider.GetDefaultNicType(getEntityStronglyTyped().getos())); model.getName().setEntity(newNicName); model.getMAC().setIsAvailable(false); UICommand tempVar = new UICommand("OnSave", this); tempVar.setTitle("OK"); tempVar.setIsDefault(true); model.getCommands().add(tempVar); UICommand tempVar2 = new UICommand("Cancel", this); tempVar2.setTitle("Cancel"); tempVar2.setIsCancel(true); model.getCommands().add(tempVar2); }