use of org.ovirt.engine.core.common.utils.PairQueryable in project ovirt-engine by oVirt.
the class NetworkVmListModel method remove.
private void remove() {
if (getWindow() != null) {
return;
}
List<VmNetworkInterface> vnics = new ArrayList<>();
for (Object item : getSelectedItems()) {
PairQueryable<VmNetworkInterface, VM> pair = (PairQueryable<VmNetworkInterface, VM>) item;
vnics.add(pair.getFirst());
}
RemoveVmInterfaceModel model = new RemoveVmInterfaceModel(this, vnics, true);
setWindow(model);
}
use of org.ovirt.engine.core.common.utils.PairQueryable in project ovirt-engine by oVirt.
the class NetworkVmListModel method syncSearch.
@Override
protected void syncSearch() {
if (getEntity() == null) {
return;
}
GetVmsAndNetworkInterfacesByNetworkIdParameters params = new GetVmsAndNetworkInterfacesByNetworkIdParameters(getEntity().getId(), NetworkVmFilter.running.equals(getViewFilterType()));
params.setRefresh(getIsQueryFirstTime());
final NetworkVmFilter filter = getViewFilterType();
Frontend.getInstance().runQuery(QueryType.GetVmsAndNetworkInterfacesByNetworkId, params, new AsyncQuery<QueryReturnValue>(returnValue -> {
if (filter.equals(getViewFilterType())) {
setItems((Collection<PairQueryable<VmNetworkInterface, VM>>) returnValue.getReturnValue());
}
}));
}
use of org.ovirt.engine.core.common.utils.PairQueryable in project ovirt-engine by oVirt.
the class NetworkVmListModel method updateActionAvailability.
private void updateActionAvailability() {
ArrayList<VM> vms = new ArrayList<>();
Iterable<PairQueryable<VmNetworkInterface, VM>> selectedItems = getSelectedItems() != null ? getSelectedItems() : new ArrayList();
for (PairQueryable<VmNetworkInterface, VM> item : selectedItems) {
vms.add(item.getSecond());
}
getRemoveCommand().setIsExecutionAllowed(ActionUtils.canExecute(vms, VM.class, ActionType.RemoveVmInterface) && getSelectedItems() != null && !getSelectedItems().isEmpty() && canRemoveVnics());
}
use of org.ovirt.engine.core.common.utils.PairQueryable in project ovirt-engine by oVirt.
the class NetworkHostListModel method updateActionAvailability.
private void updateActionAvailability() {
Collection<PairQueryable<VdsNetworkInterface, VDS>> selectedItems = getSelectedItems() != null ? getSelectedItems() : new ArrayList();
getSetupNetworksCommand().setIsExecutionAllowed(selectedItems.size() == 1);
}
use of org.ovirt.engine.core.common.utils.PairQueryable in project ovirt-engine by oVirt.
the class NetworkHostListModel method syncSearch.
@Override
protected void syncSearch() {
if (getEntity() == null) {
return;
}
final NetworkHostFilter filter = getViewFilterType();
AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
if (filter.equals(getViewFilterType())) {
final Iterable returnList = returnValue.getReturnValue();
if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
final List<PairQueryable<VdsNetworkInterface, VDS>> items = new ArrayList<>();
for (Object obj : returnList) {
items.add(new PairQueryable<VdsNetworkInterface, VDS>(null, (VDS) obj));
}
setItems(items);
} else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
initAttachedInterfaces((Collection<PairQueryable<VdsNetworkInterface, VDS>>) returnList);
}
}
});
IdQueryParameters params = new IdQueryParameters(getEntity().getId());
params.setRefresh(getIsQueryFirstTime());
if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
Frontend.getInstance().runQuery(QueryType.GetVdsWithoutNetwork, params, asyncQuery);
} else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
Frontend.getInstance().runQuery(QueryType.GetVdsAndNetworkInterfacesByNetworkId, params, asyncQuery);
}
setIsQueryFirstTime(false);
}
Aggregations