use of org.ovirt.engine.ui.common.widget.uicommon.storage.FcpStorageView in project ovirt-engine by oVirt.
the class StoragePopupView method revealStorageView.
@SuppressWarnings("unchecked")
private void revealStorageView(StorageModel object) {
StorageType storageType = storageTypeListEditor.asEditor().getActualEditor().getValue();
StorageDomainType storageDomainType = domainFunctionListEditor.asEditor().getActualEditor().getValue();
if (storageType == null || storageDomainType == null) {
return;
}
switch(storageType) {
case NFS:
storageView = new NfsStorageView();
break;
case LOCALFS:
storageView = new LocalStorageView();
break;
case POSIXFS:
storageView = new PosixStorageView();
break;
case GLUSTERFS:
storageView = new GlusterStorageView();
break;
case FCP:
if (!object.getBehavior().isImport()) {
storageView = new FcpStorageView(true);
} else {
storageView = new ImportFcpStorageView();
}
break;
case ISCSI:
if (!object.getBehavior().isImport()) {
storageView = new IscsiStorageView(true);
} else {
storageView = new ImportIscsiStorageView();
}
break;
default:
break;
}
updateStorageItem(object);
IStorageModel model = object.getCurrentStorageItem();
// Re-apply element IDs on 'storageView' change
ViewIdHandler.idHandler.generateAndSetIds(this);
// Clear the current storage view
specificStorageTypePanel.clear();
// Add the new storage view and call focus on it if needed
if (storageView != null && model != null) {
storageView.edit(model);
specificStorageTypePanel.add(storageView);
if (!nameEditor.isVisible()) {
storageView.focus();
}
}
}
use of org.ovirt.engine.ui.common.widget.uicommon.storage.FcpStorageView 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