use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class VmDiskAttachPopupWidget method getBootCheckBoxColumn.
private AbstractCheckboxColumn<EntityModel> getBootCheckBoxColumn() {
AbstractCheckboxColumn<EntityModel> bootCheckboxColumn = new AbstractCheckboxColumn<EntityModel>((idx, object, value) -> {
DiskModel diskModel = (DiskModel) object.getEntity();
diskModel.getIsBootable().setEntity(value);
}) {
@Override
public SafeHtml getTooltip(EntityModel object) {
EntityModel<Boolean> bootModel = ((DiskModel) object.getEntity()).getIsBootable();
return bootModel.getChangeProhibitionReason() == null ? null : SafeHtmlUtils.fromString(bootModel.getChangeProhibitionReason());
}
@Override
protected boolean canEdit(EntityModel object) {
EntityModel<Boolean> bootModel = ((DiskModel) object.getEntity()).getIsBootable();
return bootModel.getIsChangable() || bootModel.getEntity();
}
@Override
public Boolean getValue(EntityModel object) {
DiskModel diskModel = (DiskModel) object.getEntity();
return diskModel.getIsBootable().getEntity();
}
};
return bootCheckboxColumn;
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class VmDiskAttachPopupWidget method initLunDisksTable.
private void initLunDisksTable() {
lunDiskTable.enableColumnResizing();
AbstractTextColumn<EntityModel> aliasColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getDiskAlias();
}
};
// $NON-NLS-1$
lunDiskTable.addColumn(aliasColumn, constants.aliasVmDiskTable(), "60px");
AbstractTextColumn<EntityModel> descriptionColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getDiskDescription();
}
};
// $NON-NLS-1$
lunDiskTable.addColumn(descriptionColumn, constants.descriptionVmDiskTable(), "85px");
AbstractTextColumn<EntityModel> lunIdColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getLun().getLUNId();
}
};
// $NON-NLS-1$
lunDiskTable.addColumn(lunIdColumn, constants.lunIdSanStorage(), "60px");
AbstractTextColumn<EntityModel> idColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getId().toString();
}
};
// $NON-NLS-1$
lunDiskTable.addColumn(idColumn, constants.idVmDiskTable(), "60px");
AbstractDiskSizeColumn<EntityModel> sizeColumn = new AbstractDiskSizeColumn<EntityModel>(SizeConverter.SizeUnit.GiB) {
@Override
protected Long getRawValue(EntityModel object) {
LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk();
return (long) disk.getLun().getDeviceSize();
}
};
// $NON-NLS-1$
lunDiskTable.addColumn(sizeColumn, constants.devSizeSanStorage(), "70px");
AbstractTextColumn<EntityModel> pathColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk();
return String.valueOf(disk.getLun().getPathCount());
}
};
// $NON-NLS-1$
lunDiskTable.addColumn(pathColumn, constants.pathSanStorage(), "40px");
AbstractTextColumn<EntityModel> vendorIdColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getLun().getVendorId();
}
};
// $NON-NLS-1$
lunDiskTable.addColumn(vendorIdColumn, constants.vendorIdSanStorage(), "70px");
AbstractTextColumn<EntityModel> productIdColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getLun().getProductId();
}
};
// $NON-NLS-1$
lunDiskTable.addColumn(productIdColumn, constants.productIdSanStorage(), "70px");
AbstractTextColumn<EntityModel> serialColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
LunDisk disk = (LunDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getLun().getSerial();
}
};
// $NON-NLS-1$
lunDiskTable.addColumn(serialColumn, constants.serialSanStorage(), "70px");
// $NON-NLS-1$
lunDiskTable.addColumn(getDiskInterfaceSelectionColumn(), constants.interfaceVmDiskPopup(), "115px");
lunDiskTable.addColumn(getReadOnlyCheckBoxColumn(), new ImageResourceHeader(resources.readOnlyDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.readOnly())), // $NON-NLS-1$
"30px");
lunDiskTable.addColumn(getBootCheckBoxColumn(), new ImageResourceHeader(resources.bootableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.bootableDisk())), // $NON-NLS-1$
"30px");
lunDiskTable.addColumn(new AbstractImageResourceColumn<EntityModel>() {
@Override
public ImageResource getValue(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
return disk.isShareable() ? resources.shareableDiskIcon() : null;
}
@Override
public SafeHtml getTooltip(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
if (disk.isShareable()) {
return SafeHtmlUtils.fromSafeConstant(constants.shareable());
}
return null;
}
}, new ImageResourceHeader(resources.shareableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.shareable())), // $NON-NLS-1$
"30px");
// $NON-NLS-1$
lunDiskTable.setWidth("100%");
lunDiskTable.setEmptyTableWidget(new NoItemsLabel());
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.
the class VmDiskAttachPopupWidget method initCinderDisksTable.
private void initCinderDisksTable() {
cinderDiskTable.enableColumnResizing();
AbstractTextColumn<EntityModel> aliasColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getDiskAlias();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(aliasColumn, constants.aliasVmDiskTable(), "100px");
AbstractTextColumn<EntityModel> descriptionColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getDiskDescription();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(descriptionColumn, constants.descriptionVmDiskTable(), "100px");
AbstractDiskSizeColumn<EntityModel> sizeColumn = new AbstractDiskSizeColumn<EntityModel>(SizeConverter.SizeUnit.GiB) {
@Override
protected Long getRawValue(EntityModel object) {
CinderDisk disk = (CinderDisk) ((DiskModel) object.getEntity()).getDisk();
return disk.getSizeInGigabytes();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(sizeColumn, constants.provisionedSizeVmDiskTable(), "100px");
// $NON-NLS-1$
cinderDiskTable.addColumn(getDiskInterfaceSelectionColumn(), constants.interfaceVmDiskPopup(), "115px");
AbstractTextColumn<EntityModel> cinderVolumeTypeColumn = new AbstractTextColumn<EntityModel>() {
@Override
public String getValue(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
return disk.getCinderVolumeType();
}
};
// $NON-NLS-1$
cinderDiskTable.addColumn(cinderVolumeTypeColumn, constants.cinderVolumeTypeDisk(), "90px");
cinderDiskTable.addColumn(getReadOnlyCheckBoxColumn(), new ImageResourceHeader(resources.readOnlyDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.readOnly())), // $NON-NLS-1$
"30px");
cinderDiskTable.addColumn(getBootCheckBoxColumn(), new ImageResourceHeader(resources.bootableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.bootableDisk())), // $NON-NLS-1$
"30px");
cinderDiskTable.addColumn(new AbstractImageResourceColumn<EntityModel>() {
@Override
public ImageResource getValue(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
return disk.isShareable() ? resources.shareableDiskIcon() : null;
}
@Override
public SafeHtml getTooltip(EntityModel object) {
Disk disk = ((DiskModel) object.getEntity()).getDisk();
if (disk.isShareable()) {
return SafeHtmlUtils.fromSafeConstant(constants.shareable());
}
return null;
}
}, new ImageResourceHeader(resources.shareableDiskIcon(), SafeHtmlUtils.fromTrustedString(constants.shareable())), // $NON-NLS-1$
"30px");
// $NON-NLS-1$
cinderDiskTable.setWidth("100%");
cinderDiskTable.setEmptyTableWidget(new NoItemsLabel());
}
use of org.ovirt.engine.ui.uicommonweb.models.EntityModel 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.EntityModel in project ovirt-engine by oVirt.
the class VmSnapshotInfoPanel method initNicsTable.
private void initNicsTable() {
nicsTable = new EntityModelCellTable<>(false, true);
nicsTable.enableColumnResizing();
AbstractTextColumn<VmNetworkInterface> nameColumn = new AbstractTextColumn<VmNetworkInterface>() {
@Override
public String getValue(VmNetworkInterface object) {
return object.getName();
}
};
// $NON-NLS-1$
nicsTable.addColumn(nameColumn, constants.nameInterface(), "80px");
AbstractTextColumn<VmNetworkInterface> networkNameColumn = new AbstractTextColumn<VmNetworkInterface>() {
@Override
public String getValue(VmNetworkInterface object) {
return object.getNetworkName();
}
};
// $NON-NLS-1$
nicsTable.addColumn(networkNameColumn, constants.networkNameInterface(), "80px");
AbstractTextColumn<VmNetworkInterface> profileNameColumn = new AbstractTextColumn<VmNetworkInterface>() {
@Override
public String getValue(VmNetworkInterface object) {
return object.getVnicProfileName();
}
};
// $NON-NLS-1$
nicsTable.addColumn(profileNameColumn, constants.profileNameInterface(), "80px");
AbstractTextColumn<VmNetworkInterface> typeColumn = new AbstractEnumColumn<VmNetworkInterface, VmInterfaceType>() {
@Override
protected VmInterfaceType getRawValue(VmNetworkInterface object) {
return VmInterfaceType.forValue(object.getType());
}
};
// $NON-NLS-1$
nicsTable.addColumn(typeColumn, constants.typeInterface(), "80px");
AbstractTextColumn<VmNetworkInterface> macColumn = new AbstractTextColumn<VmNetworkInterface>() {
@Override
public String getValue(VmNetworkInterface object) {
return object.getMacAddress();
}
};
// $NON-NLS-1$
nicsTable.addColumn(macColumn, constants.macInterface(), "80px");
AbstractTextColumn<VmNetworkInterface> speedColumn = new AbstractTextColumn<VmNetworkInterface>() {
@Override
public String getValue(VmNetworkInterface object) {
if (object.getSpeed() != null) {
return object.getSpeed().toString();
} else {
return null;
}
}
};
// $NON-NLS-1$
nicsTable.addColumn(speedColumn, templates.sub(constants.speedInterface(), constants.mbps()), "80px");
AbstractTextColumn<VmNetworkInterface> rxColumn = new AbstractRxTxRateColumn<VmNetworkInterface>() {
@Override
protected Double getRate(VmNetworkInterface object) {
return object.getStatistics().getReceiveRate();
}
@Override
protected Double getSpeed(VmNetworkInterface object) {
if (object.getSpeed() != null) {
return object.getSpeed().doubleValue();
} else {
return null;
}
}
};
// $NON-NLS-1$
nicsTable.addColumn(rxColumn, templates.sub(constants.rxRate(), constants.mbps()), "80px");
AbstractTextColumn<VmNetworkInterface> txColumn = new AbstractRxTxRateColumn<VmNetworkInterface>() {
@Override
protected Double getRate(VmNetworkInterface object) {
return object.getStatistics().getTransmitRate();
}
@Override
protected Double getSpeed(VmNetworkInterface object) {
if (object.getSpeed() != null) {
return object.getSpeed().doubleValue();
} else {
return null;
}
}
};
// $NON-NLS-1$
nicsTable.addColumn(txColumn, templates.sub(constants.txRate(), constants.mbps()), "80px");
AbstractTextColumn<VmNetworkInterface> dropsColumn = new AbstractSumUpColumn<VmNetworkInterface>() {
@Override
protected Double[] getRawValue(VmNetworkInterface object) {
Double receiveDropRate = object != null ? object.getStatistics().getReceiveDropRate() : null;
Double transmitDropRate = object != null ? object.getStatistics().getTransmitDropRate() : null;
return new Double[] { receiveDropRate, transmitDropRate };
}
};
// $NON-NLS-1$
nicsTable.addColumn(dropsColumn, templates.sub(constants.dropsInterface(), constants.pkts()), "80px");
nicsTable.setRowData(new ArrayList<EntityModel>());
// $NON-NLS-1$
nicsTable.setWidth("100%");
nicsTable.setSelectionModel(new NoSelectionModel());
}
Aggregations