use of org.ovirt.engine.ui.uicommonweb.models.storage.IscsiStorageModel in project ovirt-engine by oVirt.
the class AsyncDataProvider method getBlockDataStorageModels.
public List<IStorageModel> getBlockDataStorageModels() {
ArrayList<IStorageModel> models = new ArrayList<>();
IscsiStorageModel iscsiDataModel = new IscsiStorageModel();
iscsiDataModel.setIsGroupedByTarget(true);
models.add(iscsiDataModel);
FcpStorageModel fcpDataModel = new FcpStorageModel();
models.add(fcpDataModel);
addTypeToStorageModels(StorageDomainType.Data, models);
return models;
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.IscsiStorageModel in project ovirt-engine by oVirt.
the class VmDiskPopupWidget method edit.
@Override
@SuppressWarnings("unchecked")
public void edit(final AbstractDiskModel disk) {
driver.edit(disk);
disk.getIsDirectLunDiskAvaialable().getEntityChangedEvent().addListener((ev, sender, args) -> {
boolean isDirectLunDiskAvaialable = ((EntityModel<Boolean>) sender).getEntity();
externalDiskPanel.setVisible(isDirectLunDiskAvaialable);
});
disk.getIsUsingScsiReservation().getPropertyChangedEvent().addListener((ev, sender, args) -> {
if ("Entity".equals(args.propertyName) || "IsAvailable".equals(args.propertyName)) {
// $NON-NLS-1$ $NON-NLS-2$
EntityModel<Boolean> entity = disk.getIsUsingScsiReservation();
scsiReservationInfoIcon.setVisible(entity.getEntity() && entity.getIsAvailable());
}
});
disk.getIsVirtioScsiEnabled().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (disk.getVm() == null) {
// not relevant for floating disks
return;
}
boolean isVirtioScsiEnabled = ((EntityModel<Boolean>) sender).getEntity();
// Show the info icon if VirtIO-SCSI is supported by the cluster but disabled for the VM
interfaceInfoIcon.setVisible(!isVirtioScsiEnabled);
// Make room for it by making the control widget narrower
interfaceEditor.removeWidgetColSize(isVirtioScsiEnabled ? ColumnSize.SM_7 : ColumnSize.SM_8);
interfaceEditor.addWidgetColSize(!isVirtioScsiEnabled ? ColumnSize.SM_7 : ColumnSize.SM_8);
});
disk.getCinderVolumeType().getItemsChangedEvent().addListener((ev, sender, args) -> {
Collection<String> volumeTypes = disk.getCinderVolumeType().getItems();
boolean showIcon = volumeTypes == null || volumeTypes.isEmpty();
cinderVolumeTypeInfoIcon.setVisible(showIcon);
cinderVolumeTypeEditor.removeWidgetColSize(!showIcon ? ColumnSize.SM_7 : ColumnSize.SM_8);
cinderVolumeTypeEditor.addWidgetColSize(showIcon ? ColumnSize.SM_7 : ColumnSize.SM_8);
});
disk.getIsModelDisabled().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (disk.getIsModelDisabled().getEntity()) {
disableWidget(getWidget());
enableWidget(radioButtonPanel);
enableWidget(datacenterEditor);
disk.getDefaultCommand().setIsExecutionAllowed(false);
disk.setIsChangeable(false);
} else {
enableWidget(getWidget());
disk.getDefaultCommand().setIsExecutionAllowed(true);
disk.setIsChangeable(true);
driver.edit(disk);
}
});
radioButtonPanel.addRadioButton(constants.imageDisk(), disk.getDisk() == null || disk.getDisk().getDiskStorageType() == DiskStorageType.IMAGE, disk.getIsNew(), event -> {
if (disk.getIsNew()) {
disk.getDiskStorageType().setEntity(DiskStorageType.IMAGE);
revealDiskPanel(disk);
}
});
radioButtonPanel.addRadioButton(constants.directLunDisk(), disk.getDisk() != null && disk.getDisk().getDiskStorageType() == DiskStorageType.LUN, disk.getIsNew(), event -> {
if (disk.getIsNew()) {
disk.getDiskStorageType().setEntity(DiskStorageType.LUN);
revealStorageView(disk);
revealDiskPanel(disk);
}
});
radioButtonPanel.addRadioButton(constants.cinderDisk(), disk.getDisk() != null && disk.getDisk().getDiskStorageType() == DiskStorageType.CINDER, disk.getIsNew(), event -> {
if (disk.getIsNew()) {
disk.getDiskStorageType().setEntity(DiskStorageType.CINDER);
revealDiskPanel(disk);
}
});
if (disk.getStorageModel() == null) {
storageModel = new StorageModel(new NewEditStorageModelBehavior());
// Create IscsiStorageModel
iscsiStorageModel = new IscsiStorageModel();
iscsiStorageModel.setContainer(storageModel);
iscsiStorageModel.setIsGroupedByTarget(true);
iscsiStorageModel.setIgnoreGrayedOut(true);
// Create FcpStorageModel
fcpStorageModel = new FcpStorageModel();
fcpStorageModel.setContainer(storageModel);
fcpStorageModel.setIsGroupedByTarget(false);
fcpStorageModel.setIgnoreGrayedOut(true);
// Set 'StorageModel' items
ArrayList<IStorageModel> items = new ArrayList<>();
items.add(iscsiStorageModel);
items.add(fcpStorageModel);
storageModel.setStorageModels(items);
storageModel.setHost(disk.getHost());
disk.setStorageModel(storageModel);
} else {
storageModel = disk.getStorageModel();
iscsiStorageModel = Linq.findByType(storageModel.getStorageModels(), IscsiStorageModel.class);
iscsiStorageModel.getPropertyChangedEvent().clearListeners();
fcpStorageModel = Linq.findByType(storageModel.getStorageModels(), FcpStorageModel.class);
fcpStorageModel.getPropertyChangedEvent().clearListeners();
}
iscsiStorageView = new IscsiStorageView(false, 196, 304, 244, 275, 142, 55, -67);
iscsiStorageView.setBarTop(0, Unit.PX);
iscsiStorageView.edit(iscsiStorageModel);
fcpStorageView = new FcpStorageView(false, 278, 240);
fcpStorageView.edit(fcpStorageModel);
// SelectedItemChangedEvent handlers
disk.getStorageType().getSelectedItemChangedEvent().addListener((ev, sender, args) -> revealStorageView(disk));
disk.getHost().getSelectedItemChangedEvent().addListener((ev, sender, args) -> revealStorageView(disk));
disk.getDiskStorageType().getPropertyChangedEvent().addListener((ev, sender, args) -> {
String propName = args.propertyName;
if ("IsChangable".equals(propName)) {
// $NON-NLS-1$
if (disk.getDiskStorageType().getIsChangable() && disk.isEditEnabled()) {
enableWidget(radioButtonPanel);
} else {
disableWidget(radioButtonPanel);
}
}
});
revealStorageView(disk);
revealDiskPanel(disk);
}
Aggregations