use of org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn in project ovirt-engine by oVirt.
the class ImportTemplatePopupView method initMainTable.
@Override
protected void initMainTable() {
this.table = new ListModelObjectCellTable<>();
AbstractCheckboxColumn<Object> cloneTemplateColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
((ImportTemplateData) model).getClone().setEntity(value);
table.asEditor().edit(importModel);
}) {
@Override
public Boolean getValue(Object model) {
return ((ImportTemplateData) model).getClone().getEntity();
}
@Override
protected boolean canEdit(Object model) {
return ((ImportTemplateData) model).getClone().getIsChangable();
}
};
// $NON-NLS-1$
table.addColumn(cloneTemplateColumn, constants.cloneVM(), "50px");
AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return ((ImportTemplateData) object).getTemplate().getName();
}
};
// $NON-NLS-1$
table.addColumn(nameColumn, constants.nameTemplate(), "150px");
AbstractTextColumn<Object> versionNameColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
VmTemplate template = ((ImportTemplateData) object).getTemplate();
if (template.isBaseTemplate()) {
// $NON-NLS-1$
return "";
}
return // $NON-NLS-1$
StringFormat.format(// $NON-NLS-1$
"%s (%s)", // $NON-NLS-1$
template.getTemplateVersionName() != null ? template.getTemplateVersionName() : "", template.getTemplateVersionNumber());
}
};
// $NON-NLS-1$
table.addColumn(versionNameColumn, constants.versionTemplate(), "150px");
AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {
@Override
protected OriginType getRawValue(Object object) {
return ((ImportTemplateData) object).getTemplate().getOrigin();
}
};
// $NON-NLS-1$
table.addColumn(originColumn, constants.originTemplate(), "100px");
AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return messages.megabytes(String.valueOf(((ImportTemplateData) object).getTemplate().getMemSizeMb()));
}
};
// $NON-NLS-1$
table.addColumn(memoryColumn, constants.memoryTemplate(), "100px");
AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportTemplateData) object).getTemplate().getNumOfCpus());
}
};
// $NON-NLS-1$
table.addColumn(cpuColumn, constants.cpusTemplate(), "50px");
AbstractTextColumn<Object> archColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportTemplateData) object).getTemplate().getClusterArch());
}
};
// $NON-NLS-1$
table.addColumn(archColumn, constants.architectureTemplate(), "50px");
AbstractTextColumn<Object> diskColumn = new AbstractTextColumn<Object>() {
@Override
public String getValue(Object object) {
return String.valueOf(((ImportTemplateData) object).getTemplate().getDiskList().size());
}
};
// $NON-NLS-1$
table.addColumn(diskColumn, constants.disksTemplate(), "50px");
isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {
@Override
public ImageResource getValue(Object object) {
return ((ImportTemplateData) object).isExistsInSystem() ? resources.logNormalImage() : null;
}
};
// $NON-NLS-1$
table.addColumn(isObjectInSystemColumn, constants.templateInSetup(), "60px");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
splitLayoutPanel.add(sp);
table.getElement().getStyle().setPosition(Position.RELATIVE);
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn in project ovirt-engine by oVirt.
the class VmDiskAttachPopupWidget method getReadOnlyCheckBoxColumn.
private AbstractCheckboxColumn<EntityModel> getReadOnlyCheckBoxColumn() {
AbstractCheckboxColumn<EntityModel> readOnlyCheckboxColumn = new AbstractCheckboxColumn<EntityModel>((idx, object, value) -> {
DiskModel diskModel = (DiskModel) object.getEntity();
diskModel.setReadOnly(value);
}) {
@Override
protected boolean canEdit(EntityModel object) {
DiskModel diskModel = (DiskModel) object.getEntity();
Disk disk = diskModel.getDisk();
boolean isScsiPassthrough = disk.isScsiPassthrough();
boolean ideLimitation = diskModel.getDiskInterface().getSelectedItem() == DiskInterface.IDE;
return !isScsiPassthrough && !ideLimitation;
}
@Override
public Boolean getValue(EntityModel object) {
DiskModel diskModel = (DiskModel) object.getEntity();
return diskModel.isReadOnly();
}
};
return readOnlyCheckboxColumn;
}
use of org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn 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.common.widget.table.column.AbstractCheckboxColumn 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.common.widget.table.column.AbstractCheckboxColumn in project ovirt-engine by oVirt.
the class SubTabNetworkClusterView method initTable.
private void initTable() {
getTable().enableColumnResizing();
AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> nameColumn = new AbstractLinkColumn<PairQueryable<Cluster, NetworkCluster>>(new FieldUpdater<PairQueryable<Cluster, NetworkCluster>, String>() {
@Override
public void update(int index, PairQueryable<Cluster, NetworkCluster> cluster, String value) {
Map<String, String> parameters = new HashMap<>();
parameters.put(FragmentParams.NAME.getName(), cluster.getFirst().getName());
getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
}
}) {
@Override
public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
return object.getFirst().getName();
}
};
nameColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(nameColumn, constants.nameCluster(), "400px");
AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> versionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {
@Override
public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
return object.getFirst().getCompatibilityVersion().getValue();
}
};
versionColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(versionColumn, constants.comptVersCluster(), "130px");
AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> attachedColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {
@Override
public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
return object.getSecond() != null;
}
@Override
protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
return false;
}
};
attachedColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(attachedColumn, constants.attachedNetworkCluster(), "120px");
NetworkClusterStatusColumn statusColumn = new NetworkClusterStatusColumn();
statusColumn.makeSortable(new SimpleStatusColumnComparator<>(statusColumn));
// $NON-NLS-1$
getTable().addColumn(statusColumn, constants.networkStatus(), "120px");
AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> netRequiredColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {
@Override
public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
if (object.getSecond() != null) {
return object.getSecond().isRequired();
}
return false;
}
@Override
protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
return false;
}
};
netRequiredColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(netRequiredColumn, constants.requiredNetCluster(), "120px");
AbstractSafeHtmlColumn<PairQueryable<Cluster, NetworkCluster>> netRoleColumn = createNetRoleColumn();
netRoleColumn.makeSortable(new NetRoleColumnComparator());
// $NON-NLS-1$
getTable().addColumn(netRoleColumn, constants.roleNetCluster(), "120px");
AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> descriptionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {
@Override
public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
return object.getFirst().getDescription();
}
};
descriptionColumn.makeSortable();
// $NON-NLS-1$
getTable().addColumn(descriptionColumn, constants.descriptionCluster(), "400px");
}
Aggregations