use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData in project ovirt-engine by oVirt.
the class ImportVmFromExternalProviderPopupView method initMainTable.
protected void initMainTable() {
this.table = new ListModelObjectCellTable<>();
AbstractCheckboxColumn<ImportVmData> cloneVMColumn = new AbstractCheckboxColumn<ImportVmData>((index, model, value) -> {
model.getClone().setEntity(value);
table.asEditor().edit(importModel);
}) {
@Override
public Boolean getValue(ImportVmData model) {
return model.getClone().getEntity();
}
@Override
protected boolean canEdit(ImportVmData model) {
return model.getClone().getIsChangable();
}
@Override
protected String getDisabledMessage(ImportVmData model) {
return model.getClone().getChangeProhibitionReason();
}
};
// $NON-NLS-1$
table.addColumn(cloneVMColumn, constants.cloneVM(), "50px");
AbstractTextColumn<ImportVmData> nameColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return object.getName();
}
};
// $NON-NLS-1$
table.addColumn(nameColumn, constants.nameVm(), "150px");
AbstractTextColumn<ImportVmData> originColumn = new AbstractEnumColumn<ImportVmData, OriginType>() {
@Override
protected OriginType getRawValue(ImportVmData object) {
return object.getVm().getOrigin();
}
};
// $NON-NLS-1$
table.addColumn(originColumn, constants.originVm(), "100px");
table.addColumn(new AbstractSafeHtmlColumn<ImportVmData>() {
@Override
public SafeHtml getValue(ImportVmData object) {
return VmTypeColumn.getRenderedValue(object.getVm());
}
}, constants.empty(), // $NON-NLS-1$
"30px");
AbstractTextColumn<ImportVmData> memoryColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return messages.megabytes(String.valueOf(object.getVm().getVmMemSizeMb()));
}
};
// $NON-NLS-1$
table.addColumn(memoryColumn, constants.memoryVm(), "100px");
AbstractTextColumn<ImportVmData> cpuColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return String.valueOf(object.getVm().getNumOfCpus());
}
};
// $NON-NLS-1$
table.addColumn(cpuColumn, constants.cpusVm(), "50px");
AbstractTextColumn<ImportVmData> archColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return String.valueOf(object.getVm().getClusterArch());
}
};
// $NON-NLS-1$
table.addColumn(archColumn, constants.architectureVm(), "50px");
AbstractTextColumn<ImportVmData> diskColumn = new AbstractTextColumn<ImportVmData>() {
@Override
public String getValue(ImportVmData object) {
return String.valueOf(object.getVm().getDiskMap().size());
}
};
// $NON-NLS-1$
table.addColumn(diskColumn, constants.disksVm(), "50px");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
splitLayoutPanel.add(sp);
table.getElement().getStyle().setPosition(Position.RELATIVE);
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData in project ovirt-engine by oVirt.
the class ImportVmFromExportDomainPopupView method initMainTable.
protected void initMainTable() {
this.table = new ListModelObjectCellTable<>();
table.enableColumnResizing();
AbstractImageResourceColumn<Object> isProblematicImportVmColumn = new AbstractImageResourceColumn<Object>() {
@Override
public ImageResource getValue(Object object) {
ImportVmData importVmData = (ImportVmData) object;
if (importVmData.getError() != null || importVmData.isNameExistsInTheSystem()) {
return resources.errorImage();
}
if (importVmData.getWarning() != null) {
return resources.alertImage();
}
return null;
}
@Override
public SafeHtml getTooltip(Object object) {
ImportVmData importVmData = (ImportVmData) object;
String problem = null;
if (importVmData.getError() != null) {
problem = importVmData.getError();
} else {
problem = importVmData.isNameExistsInTheSystem() ? ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason() : importVmData.getWarning();
}
return problem != null ? SafeHtmlUtils.fromSafeConstant(problem) : null;
}
};
// $NON-NLS-1$
table.addColumn(isProblematicImportVmColumn, constants.empty(), "30px");
AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
String originalName = ((ImportVmData) object).getName();
String givenName = ((ImportVmData) object).getVm().getName();
return originalName.equals(givenName) ? givenName : // $NON-NLS-1$ //$NON-NLS-2$
givenName + " (" + originalName + ")";
}
};
// $NON-NLS-1$
table.addColumn(nameColumn, constants.nameVm(), "150px");
AbstractCheckboxColumn<Object> collapseSnapshotsColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
((ImportVmData) model).getCollapseSnapshots().setEntity(value);
customSelectionCellFormatType.setEnabled(value);
diskTable.asEditor().edit(importModel.getImportDiskListModel());
}) {
@Override
public Boolean getValue(Object model) {
return ((ImportVmData) model).getCollapseSnapshots().getEntity();
}
@Override
protected boolean canEdit(Object model) {
return ((ImportVmData) model).getCollapseSnapshots().getIsChangable();
}
@Override
protected String getDisabledMessage(Object model) {
return ((ImportVmData) model).getCollapseSnapshots().getChangeProhibitionReason();
}
@Override
public SafeHtml getTooltip(Object object) {
SafeHtml superTooltip = super.getTooltip(object);
if (superTooltip == null) {
return SafeHtmlUtils.fromSafeConstant(constants.importAllocationModifiedCollapse());
}
return superTooltip;
}
};
// $NON-NLS-1$
table.addColumn(collapseSnapshotsColumn, constants.collapseSnapshots(), "130px");
AbstractCheckboxColumn<Object> cloneVMColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
((ImportVmData) model).getClone().setEntity(value);
table.asEditor().edit(importModel);
}) {
@Override
public Boolean getValue(Object model) {
return ((ImportVmData) model).getClone().getEntity();
}
@Override
protected boolean canEdit(Object model) {
return ((ImportVmData) model).getClone().getIsChangable();
}
@Override
protected String getDisabledMessage(Object model) {
return ((ImportVmData) model).getClone().getChangeProhibitionReason();
}
};
// $NON-NLS-1$
table.addColumn(cloneVMColumn, constants.cloneVM(), "50px");
AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {
@Override
protected OriginType getRawValue(Object object) {
return ((ImportVmData) object).getVm().getOrigin();
}
};
// $NON-NLS-1$
table.addColumn(originColumn, constants.originVm(), "100px");
table.addColumn(new AbstractSafeHtmlColumn<Object>() {
@Override
public SafeHtml getValue(Object object) {
return VmTypeColumn.getRenderedValue(((ImportVmData) object).getVm());
}
}, constants.empty(), // $NON-NLS-1$
"30px");
AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return messages.megabytes(String.valueOf(((ImportVmData) object).getVm().getVmMemSizeMb()));
}
};
// $NON-NLS-1$
table.addColumn(memoryColumn, constants.memoryVm(), "90px");
AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportVmData) object).getVm().getNumOfCpus());
}
};
// $NON-NLS-1$
table.addColumn(cpuColumn, constants.cpusVm(), "50px");
AbstractTextColumn<Object> archColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportVmData) object).getVm().getClusterArch());
}
};
// $NON-NLS-1$
table.addColumn(archColumn, constants.architectureVm(), "100px");
AbstractTextColumn<Object> diskColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportVmData) object).getVm().getDiskMap().size());
}
};
// $NON-NLS-1$
table.addColumn(diskColumn, constants.disksVm(), "55px");
isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {
@Override
public ImageResource getValue(Object object) {
return ((ImportVmData) object).isExistsInSystem() ? resources.logNormalImage() : null;
}
};
// $NON-NLS-1$
table.addColumn(isObjectInSystemColumn, constants.vmInSetup(), "100px");
table.getSelectionModel().addSelectionChangeHandler(event -> {
ImportVmData selectedObject = ((SingleSelectionModel<ImportVmData>) event.getSource()).getSelectedObject();
customSelectionCellFormatType.setEnabled(selectedObject.getCollapseSnapshots().getEntity());
});
ScrollPanel sp = new ScrollPanel();
sp.add(table);
splitLayoutPanel.add(sp);
table.getElement().getStyle().setPosition(Position.RELATIVE);
}
use of org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData in project ovirt-engine by oVirt.
the class RegisterVmInfoPanel method updateTabsData.
@Override
public void updateTabsData(ImportEntityData<VM> importEntityData) {
ImportVmData importVmData = (ImportVmData) importEntityData;
VM vm = importVmData.getVm();
vmImportGeneralModel.setEntity(importVmData);
generalView.setMainSelectedItem(vm);
disksTable.setRowData((List) Arrays.asList(vm.getDiskMap().values().toArray()));
nicsTable.setRowData((List) Arrays.asList(vm.getInterfaces().toArray()));
appsTable.setRowData(vm.getAppList() == null ? Collections.emptyList() : // $NON-NLS-1$
(List) Arrays.asList(vm.getAppList().split("[,]", -1)));
}
Aggregations