use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method attachStorageInternal.
private void attachStorageInternal(List<StorageDomain> storages, String title) {
ListModel model = new ListModel();
model.setTitle(title);
setWindow(model);
ArrayList<EntityModel> items = new ArrayList<>();
for (StorageDomain sd : storages) {
EntityModel tempVar = new EntityModel();
tempVar.setEntity(sd);
items.add(tempVar);
}
model.setItems(items);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createDefaultOkUiCommand("OnAttachStorage", this);
model.getCommands().add(tempVar2);
// $NON-NLS-1$
UICommand tempVar3 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar3);
}
use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.
the class DataCenterStorageListModel method attachBackup.
public void attachBackup() {
ListModel listModel = new ListModel();
listModel.setTitle(ConstantsManager.getInstance().getConstants().attachExportDomainTitle());
listModel.setHelpTag(HelpTag.attach_export_domain);
// $NON-NLS-1$
listModel.setHashName("attach_export_domain");
attachInternal(listModel, StorageDomainType.ImportExport);
}
use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.
the class DataCenterStorageListModel method attachInternal.
private void attachInternal(ListModel listModel, StorageDomainType storageType) {
if (getWindow() != null) {
return;
}
this.setStorageDomainType(storageType);
setWindow(listModel);
if (storageType == StorageDomainType.ISO) {
AsyncDataProvider.getInstance().getISOStorageDomainList(new AsyncQuery<>(list -> {
Collection<StorageDomain> currItems = getItems() != null ? getItems() : new ArrayList<>();
List<EntityModel> models = list.stream().filter(a -> currItems.stream().noneMatch(new Linq.IdPredicate<>(a.getId()))).map(EntityModel::new).collect(Collectors.toList());
postAttachInternal(models);
}));
} else {
AsyncDataProvider.getInstance().getStorageDomainList(new AsyncQuery<>(list -> {
List<EntityModel> models = new ArrayList<>();
boolean addToList;
Collection<StorageDomain> items1 = getItems() != null ? getItems() : new ArrayList<>();
for (StorageDomain a : list) {
addToList = false;
if (a.getStorageDomainSharedStatus() != StorageDomainSharedStatus.Unattached || items1.stream().anyMatch(new Linq.IdPredicate<>(a.getId()))) {
continue;
}
if (a.getStorageDomainType() == StorageDomainType.Volume) {
addToList = true;
} else if (a.getStorageDomainType() == getStorageDomainType()) {
if (getStorageDomainType() == StorageDomainType.Data) {
if (getEntity().getStoragePoolFormatType() == null) {
addToList = true;
} else if (getEntity().getStoragePoolFormatType().compareTo(a.getStorageStaticData().getStorageFormat()) >= 0) {
addToList = true;
} else {
if (a.getStorageStaticData().getStorageFormat() == StorageFormatType.V1 || a.getStorageStaticData().getStorageFormat() == StorageFormatType.V2) {
addToList = true;
}
}
} else if (getStorageDomainType() == StorageDomainType.ImportExport) {
addToList = true;
}
}
if (addToList) {
EntityModel tempVar2 = new EntityModel();
tempVar2.setEntity(a);
models.add(tempVar2);
}
}
postAttachInternal(models);
}));
}
}
use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.
the class VolumeModel method onAddBricksInternal.
private void onAddBricksInternal() {
VolumeBrickModel volumeBrickModel = (VolumeBrickModel) getWindow();
cancelConfirmation();
if (!volumeBrickModel.validate()) {
return;
}
GlusterVolumeType selectedVolumeType = getTypeList().getSelectedItem();
if (selectedVolumeType.isReplicatedType()) {
getReplicaCount().setEntity(volumeBrickModel.getReplicaCount().getEntity());
}
if (selectedVolumeType.isStripedType()) {
getStripeCount().setEntity(volumeBrickModel.getStripeCount().getEntity());
}
ArrayList<EntityModel<GlusterBrickEntity>> brickList = new ArrayList<>();
brickList.addAll(volumeBrickModel.getBricks().getItems());
volumeBrickModel.getBricks().setItems(null);
ListModel<EntityModel<GlusterBrickEntity>> brickListModel = new ListModel<>();
brickListModel.setItems(brickList);
brickListModel.setSelectedItems(brickList);
setBricks(brickListModel);
setForceAddBricks(volumeBrickModel.getForce().getEntity());
setWindow(null);
}
use of org.ovirt.engine.ui.uicommonweb.models.ListModel in project ovirt-engine by oVirt.
the class ImportNetworksPopupView method initEntityModelCellTables.
void initEntityModelCellTables() {
providerNetworks.addColumn(new AbstractTextColumn<ExternalNetwork>() {
@Override
public String getValue(ExternalNetwork model) {
return model.getDisplayName();
}
}, constants.nameNetworkHeader());
importedNetworks.addColumn(new AbstractEditTextColumn<ExternalNetwork>((index, model, value) -> model.setDisplayName(value)) {
@Override
public String getValue(ExternalNetwork model) {
return model.getDisplayName();
}
}, constants.nameNetworkHeader());
Column<ExternalNetwork, String> idColumn = new AbstractTextColumn<ExternalNetwork>() {
@Override
public String getValue(ExternalNetwork model) {
return model.getNetwork().getProvidedBy().getExternalId();
}
};
providerNetworks.addColumn(idColumn, constants.idNetworkHeader());
importedNetworks.addColumn(idColumn, constants.idNetworkHeader());
dcColumn = new AbstractListModelListBoxColumn<ExternalNetwork, StoragePool>(new NameRenderer<StoragePool>()) {
@Override
public ListModel<StoragePool> getValue(ExternalNetwork network) {
return network.getDataCenters();
}
};
importedNetworks.addColumn(dcColumn, constants.dcNetworkHeader());
AbstractCheckboxHeader publicAllHeader = new AbstractCheckboxHeader() {
@Override
protected void selectionChanged(Boolean value) {
for (ExternalNetwork model : getAllImportedNetworks()) {
model.setPublicUse(value);
}
refreshImportedNetworks();
}
@Override
public Boolean getValue() {
for (ExternalNetwork model : getAllImportedNetworks()) {
if (!model.isPublicUse()) {
return false;
}
}
return true;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public void render(Context context, SafeHtmlBuilder sb) {
super.render(context, sb);
sb.append(ImportNetworksPopupView.templates.tableHeaderInlineImage(SafeHtmlUtils.fromTrustedString(new InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML).toString())));
}
@Override
public SafeHtml getTooltip() {
return ImportNetworksPopupView.templates.textForCheckBoxHeader(constants.publicNetworkTooltip());
}
@Override
public String getLabel() {
return constants.publicNetwork();
}
};
importedNetworks.addColumn(new AbstractCheckboxColumn<ExternalNetwork>((index, model, value) -> {
model.setPublicUse(value);
refreshImportedNetworks();
}) {
@Override
public Boolean getValue(ExternalNetwork model) {
return model.isPublicUse();
}
@Override
protected boolean canEdit(ExternalNetwork model) {
return true;
}
@Override
public void render(Context context, ExternalNetwork object, SafeHtmlBuilder sb) {
super.render(context, object, sb);
// $NON-NLS-1$
sb.append(templates.textForCheckBox(""));
}
}, publicAllHeader, // $NON-NLS-1$
"80px");
}
Aggregations