use of org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior 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);
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior in project ovirt-engine by oVirt.
the class DataCenterGuideModel method addLocalStorage.
private void addLocalStorage() {
final StorageModel model = new StorageModel(new NewEditStorageModelBehavior());
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().newLocalDomainTitle());
model.setHelpTag(HelpTag.new_local_domain);
// $NON-NLS-1$
model.setHashName("new_local_domain");
LocalStorageModel localStorageModel = new LocalStorageModel();
localStorageModel.setRole(StorageDomainType.Data);
ArrayList<IStorageModel> list = new ArrayList<>();
list.add(localStorageModel);
model.setStorageModels(list);
model.setCurrentStorageItem(list.get(0));
AsyncDataProvider.getInstance().getLocalStorageHost(new AsyncQuery<>(localHost -> {
model.getHost().setItems(new ArrayList<>(Arrays.asList(new VDS[] { localHost })));
model.getHost().setSelectedItem(localHost);
model.getDataCenter().setItems(Collections.singletonList(getEntity()), getEntity());
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnAddStorage", DataCenterGuideModel.this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", DataCenterGuideModel.this);
model.getCommands().add(tempVar2);
}), getEntity().getName());
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.NewEditStorageModelBehavior in project ovirt-engine by oVirt.
the class DataCenterGuideModel method addStorageInternal.
private void addStorageInternal(String title, StorageDomainType type) {
StorageModel model = new StorageModel(new NewEditStorageModelBehavior());
setWindow(model);
model.setTitle(title);
model.setHelpTag(HelpTag.new_domain);
// $NON-NLS-1$
model.setHashName("new_domain");
ArrayList<StoragePool> dataCenters = new ArrayList<>();
dataCenters.add(getEntity());
model.getDataCenter().setItems(dataCenters, getEntity());
model.getDataCenter().setIsChangeable(false);
List<IStorageModel> items = null;
if (type == StorageDomainType.Data) {
items = AsyncDataProvider.getInstance().getDataStorageModels();
} else if (type == StorageDomainType.ISO) {
items = AsyncDataProvider.getInstance().getIsoStorageModels();
}
model.setStorageModels(items);
model.initialize();
// $NON-NLS-1$
UICommand tempVar6 = UICommand.createDefaultOkUiCommand("OnAddStorage", this);
model.getCommands().add(tempVar6);
// $NON-NLS-1$
UICommand tempVar7 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar7);
}
Aggregations