public void OnSave() { ClusterNetworkModel model = (ClusterNetworkModel) getWindow(); network network = new network(null); if (getEntity() == null) { Cancel(); return; } if (!model.Validate() || getEntity().getstorage_pool_id() == null) { return; } network.setstorage_pool_id(getEntity().getstorage_pool_id()); network.setname((String) model.getName().getEntity()); network.setstp((Boolean) model.getIsStpEnabled().getEntity()); network.setdescription((String) model.getDescription().getEntity()); network.setvlan_id(null); if ((Boolean) model.getHasVLanTag().getEntity()) { network.setvlan_id(Integer.parseInt(model.getVLanTag().getEntity().toString())); } Frontend.RunAction( VdcActionType.AddNetwork, new AddNetworkStoragePoolParameters(network.getstorage_pool_id().getValue(), network), new IFrontendActionAsyncCallback() { @Override public void Executed(FrontendActionAsyncResult result) { Object[] data = (Object[]) result.getState(); ClusterNetworkListModel networkListModel = (ClusterNetworkListModel) data[0]; VdcReturnValueBase retVal = result.getReturnValue(); if (retVal != null && retVal.getSucceeded()) { network tempVar = new network(null); tempVar.setId((Guid) retVal.getActionReturnValue()); tempVar.setname(((network) data[1]).getname()); Frontend.RunAction( VdcActionType.AttachNetworkToVdsGroup, new AttachNetworkToVdsGroupParameter(networkListModel.getEntity(), tempVar)); } networkListModel.Cancel(); } }, new Object[] {this, network}); }
public void New() { if (getWindow() != null) { return; } ClusterNetworkModel clusterModel = new ClusterNetworkModel(); setWindow(clusterModel); clusterModel.setTitle("New Logical Network"); clusterModel.setHashName("new_logical_network"); clusterModel.setIsNew(true); if (getEntity().getstorage_pool_id() != null) { AsyncQuery _asyncQuery = new AsyncQuery(); _asyncQuery.setModel(clusterModel); _asyncQuery.asyncCallback = new INewAsyncCallback() { public void OnSuccess(Object model, Object result) { ClusterNetworkModel clusterNetworkModel = (ClusterNetworkModel) model; storage_pool dataCenter = (storage_pool) result; clusterNetworkModel.setDataCenterName(dataCenter.getname()); } }; AsyncDataProvider.GetDataCenterById(_asyncQuery, getEntity().getstorage_pool_id().getValue()); } UICommand tempVar = new UICommand("OnSave", this); tempVar.setTitle("OK"); tempVar.setIsDefault(true); clusterModel.getCommands().add(tempVar); UICommand tempVar2 = new UICommand("Cancel", this); tempVar2.setTitle("Cancel"); tempVar2.setIsCancel(true); clusterModel.getCommands().add(tempVar2); }