use of org.ovirt.engine.core.common.businessentities.BootSequence in project ovirt-engine by oVirt.
the class BootSequenceModel method getSequence.
public BootSequence getSequence() {
StringBuilder str = new StringBuilder();
for (EntityModel a : getItems()) {
if (a.getIsChangable()) {
BootSequence bs = (BootSequence) a.getEntity();
str.append(bs.toString());
}
}
// $NON-NLS-1$
return !str.toString().equals("") ? BootSequence.valueOf(str.toString()) : null;
}
use of org.ovirt.engine.core.common.businessentities.BootSequence in project ovirt-engine by oVirt.
the class UnitVmModel method setBootSequence.
public void setBootSequence(BootSequence value) {
ArrayList<BootSequence> items = new ArrayList<>();
for (char a : value.toString().toCharArray()) {
items.add(BootSequence.valueOf(String.valueOf(a)));
}
EntityModel<BootSequence> firstBootDevice = null;
for (EntityModel<BootSequence> item : getFirstBootDevice().getItems()) {
if (item.getEntity() == Linq.firstOrNull(items)) {
firstBootDevice = item;
}
}
getFirstBootDevice().setSelectedItem(firstBootDevice);
Iterable<EntityModel<BootSequence>> secondDeviceOptions = getSecondBootDevice().getItems();
if (items.size() > 1) {
BootSequence last = items.get(items.size() - 1);
for (EntityModel<BootSequence> a : secondDeviceOptions) {
if (a.getEntity() != null && a.getEntity() == last) {
getSecondBootDevice().setSelectedItem(a);
break;
}
}
} else {
for (EntityModel<BootSequence> a : secondDeviceOptions) {
if (a.getEntity() == null) {
getSecondBootDevice().setSelectedItem(a);
break;
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.BootSequence in project ovirt-engine by oVirt.
the class AbstractVmPopupWidget method initListBoxEditors.
@SuppressWarnings({ "rawtypes", "unchecked" })
private void initListBoxEditors() {
// General tab
dataCenterWithClusterEditor = new GroupedListModelListBoxEditor<>(new GroupedListModelListBox<DataCenterWithCluster>(new NameRenderer<>()) {
@Override
public String getModelLabel(DataCenterWithCluster model) {
return model.getCluster().getName();
}
@Override
public String getGroupLabel(DataCenterWithCluster model) {
return messages.hostDataCenter(model.getDataCenter().getName());
}
public Comparator<DataCenterWithCluster> getComparator() {
return Comparator.comparing((DataCenterWithCluster d) -> d.getDataCenter().getName(), Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER)).thenComparing(d -> d.getCluster().getName(), Comparator.nullsLast(String.CASE_INSENSITIVE_ORDER));
}
});
quotaEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<Quota>() {
@Override
public String getReplacementStringNullSafe(Quota data) {
return data.getQuotaName();
}
@Override
public String getDisplayStringNullSafe(Quota data) {
return typeAheadNameDescriptionTemplateNullSafe(data.getQuotaName(), data.getDescription());
}
}, new ModeSwitchingVisibilityRenderer());
baseTemplateEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<VmTemplate>() {
@Override
public String getReplacementStringNullSafe(VmTemplate data) {
return data.getName();
}
@Override
public String getDisplayStringNullSafe(VmTemplate data) {
return typeAheadNameDescriptionTemplateNullSafe(data.getName(), data.getDescription());
}
}, new ModeSwitchingVisibilityRenderer());
templateWithVersionEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<TemplateWithVersion>() {
@Override
public String getReplacementStringNullSafe(TemplateWithVersion templateWithVersion) {
return getFirstColumn(templateWithVersion) + // $NON-NLS-1$
" | " + getSecondColumn(templateWithVersion);
}
@Override
public String getDisplayStringNullSafe(TemplateWithVersion templateWithVersion) {
return typeAheadNameDescriptionTemplateNullSafe(getFirstColumn(templateWithVersion), getSecondColumn(templateWithVersion));
}
private String getFirstColumn(TemplateWithVersion templateWithVersion) {
return templateWithVersion.getBaseTemplate().getName();
}
private String getSecondColumn(TemplateWithVersion templateWithVersion) {
final VmTemplate versionTemplate = templateWithVersion.getTemplateVersion();
final String versionName = versionTemplate.getTemplateVersionName() == null ? // $NON-NLS-1$
"" : // $NON-NLS-1$
versionTemplate.getTemplateVersionName() + " ";
return templateWithVersion.isLatest() ? constants.latest() : // $NON-NLS-1$
versionName + "(" + versionTemplate.getTemplateVersionNumber() + // $NON-NLS-1$
")";
}
}, new ModeSwitchingVisibilityRenderer(), new SuggestionMatcher.ContainsSuggestionMatcher());
oSTypeEditor = new ListModelListBoxEditor<>(new AbstractRenderer<Integer>() {
@Override
public String render(Integer object) {
return AsyncDataProvider.getInstance().getOsName(object);
}
}, new ModeSwitchingVisibilityRenderer());
vmTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<VmType>(), new ModeSwitchingVisibilityRenderer());
instanceTypesEditor = new ListModelTypeAheadListBoxEditor<>(new ListModelTypeAheadListBoxEditor.NullSafeSuggestBoxRenderer<InstanceType>() {
@Override
public String getReplacementStringNullSafe(InstanceType data) {
return data.getName();
}
@Override
public String getDisplayStringNullSafe(InstanceType data) {
return typeAheadNameDescriptionTemplateNullSafe(data.getName(), data.getDescription());
}
}, new ModeSwitchingVisibilityRenderer());
emulatedMachine = new ListModelTypeAheadChangeableListBoxEditor(new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() {
@Override
public String getDisplayStringNullSafe(String data) {
if (data == null || data.trim().isEmpty()) {
data = getDefaultEmulatedMachineLabel();
}
return typeAheadNameTemplateNullSafe(data);
}
}, false, new ModeSwitchingVisibilityRenderer(), constants.clusterDefaultOption());
customCpu = new ListModelTypeAheadChangeableListBoxEditor(new ListModelTypeAheadChangeableListBoxEditor.NullSafeSuggestBoxRenderer() {
@Override
public String getDisplayStringNullSafe(String data) {
if (data == null || data.trim().isEmpty()) {
data = getDefaultCpuTypeLabel();
}
return typeAheadNameTemplateNullSafe(data);
}
}, false, new ModeSwitchingVisibilityRenderer(), constants.clusterDefaultOption());
numOfSocketsEditor = new ListModelListBoxEditor<>(new ModeSwitchingVisibilityRenderer());
numOfSocketsEditorWithDetachable = new EntityModelDetachableWidgetWithLabel(numOfSocketsEditor);
corePerSocketEditor = new ListModelListBoxEditor<>(new ModeSwitchingVisibilityRenderer());
corePerSocketEditorWithDetachable = new EntityModelDetachableWidgetWithLabel(corePerSocketEditor);
initThreadsPerCore();
// Pools
poolTypeEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<EntityModel<VmPoolType>>() {
@Override
public String renderNullSafe(EntityModel<VmPoolType> object) {
return object.getTitle();
}
}, new ModeSwitchingVisibilityRenderer());
timeZoneEditor = new ListModelListBoxOnlyEditor<>(new NullSafeRenderer<TimeZoneModel>() {
@Override
public String renderNullSafe(TimeZoneModel timeZone) {
if (timeZone.isDefault()) {
return messages.defaultTimeZoneCaption(timeZone.getDisplayValue());
} else {
return timeZone.getDisplayValue();
}
}
}, new ModeSwitchingVisibilityRenderer());
EnableableFormLabel label = new EnableableFormLabel();
label.setText(constants.timeZoneVm());
timeZoneEditorWithInfo = new EntityModelWidgetWithInfo(label, timeZoneEditor);
timeZoneEditorWithInfo.setExplanation(templates.italicText(constants.timeZoneInfo()));
// Console tab
displayTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<DisplayType>(), new ModeSwitchingVisibilityRenderer());
graphicsTypeEditor = new ListModelListBoxEditor<>(new EnumRenderer<UnitVmModel.GraphicsTypes>());
usbSupportEditor = new ListModelListBoxEditor<>(new EnumRenderer<UsbPolicy>(), new ModeSwitchingVisibilityRenderer());
consoleDisconnectActionEditor = new ListModelListBoxEditor<>(new EnumRenderer<ConsoleDisconnectAction>(), new ModeSwitchingVisibilityRenderer());
numOfMonitorsEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<Integer>() {
@Override
public String renderNullSafe(Integer object) {
return object.toString();
}
}, new ModeSwitchingVisibilityRenderer());
numOfMonitorsEditor.hideLabel();
vncKeyboardLayoutEditor = new ListModelListBoxEditor<>(new VncKeyMapRenderer(), new ModeSwitchingVisibilityRenderer());
// Host Tab
// $NON-NLS-1$
specificHost = new EntityModelRadioButtonEditor("runVmOnHostGroup", new ModeSwitchingVisibilityRenderer());
isAutoAssignEditor = // $NON-NLS-1$
new EntityModelRadioButtonEditor("runVmOnHostGroup", new ModeSwitchingVisibilityRenderer());
defaultHostEditor = new ListModelMultipleSelectListBoxEditor<>(new NameRenderer<VDS>(), new ModeSwitchingVisibilityRenderer());
defaultHostEditor.hideLabel();
migrationModeEditor = new ListModelListBoxEditor<>(new EnumRenderer<MigrationSupport>(), new ModeSwitchingVisibilityRenderer());
migrationModeEditor.hideLabel();
overrideMigrationDowntimeEditor = new EntityModelCheckBoxEditor(Align.RIGHT, new ModeSwitchingVisibilityRenderer());
migrationDowntimeEditor = new IntegerEntityModelTextBoxOnlyEditor(new ModeSwitchingVisibilityRenderer());
overrideMigrationPolicyEditor = new EntityModelCheckBoxEditor(Align.RIGHT, new ModeSwitchingVisibilityRenderer());
migrationPolicyEditor = new ListModelListBoxOnlyEditor<>(new NameRenderer<MigrationPolicy>(), new ModeSwitchingVisibilityRenderer());
autoConvergeEditor = new ListModelListBoxEditor<>(new BooleanRendererWithNullText(constants.autoConverge(), constants.dontAutoConverge(), constants.inheritFromCluster()), new ModeSwitchingVisibilityRenderer());
migrateCompressedEditor = new ListModelListBoxEditor<>(new BooleanRendererWithNullText(constants.compress(), constants.dontCompress(), constants.inheritFromCluster()), new ModeSwitchingVisibilityRenderer());
// Resource Allocation
provisioningThinEditor = // $NON-NLS-1$
new EntityModelRadioButtonEditor("provisioningGroup", new ModeSwitchingVisibilityRenderer());
provisioningCloneEditor = // $NON-NLS-1$
new EntityModelRadioButtonEditor("provisioningGroup", new ModeSwitchingVisibilityRenderer());
// Boot Options Tab
firstBootDeviceEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<EntityModel<BootSequence>>() {
@Override
public String renderNullSafe(EntityModel<BootSequence> object) {
return object.getTitle();
}
}, new ModeSwitchingVisibilityRenderer());
secondBootDeviceEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<EntityModel<BootSequence>>() {
@Override
public String renderNullSafe(EntityModel<BootSequence> object) {
return object.getTitle();
}
}, new ModeSwitchingVisibilityRenderer());
cdImageEditor = new ListModelListBoxEditor<>(new NullSafeRenderer<RepoImage>() {
@Override
public String renderNullSafe(RepoImage object) {
// For old ISO images from an ISO domain the image name is empty
if (StringHelper.isNullOrEmpty(object.getRepoImageName())) {
return object.getRepoImageId();
}
return object.getRepoImageName();
}
}, new ModeSwitchingVisibilityRenderer());
cdImageEditor.hideLabel();
cpuProfilesEditor = new ListModelListBoxEditor<>(new NameRenderer<CpuProfile>());
cpuSharesAmountSelectionEditor = new ListModelListBoxOnlyEditor<>(new EnumRenderer<UnitVmModel.CpuSharesAmount>(), new ModeSwitchingVisibilityRenderer());
numaTuneMode = new ListModelListBoxEditor<>(new EnumRenderer(), new ModeSwitchingVisibilityRenderer());
providersEditor = new ListModelListBoxEditor<>(new NameRenderer<Provider<OpenstackNetworkProviderProperties>>());
providersEditor.setLabel(constants.providerLabel());
}
use of org.ovirt.engine.core.common.businessentities.BootSequence in project ovirt-engine by oVirt.
the class UnitVmModel method firstBootDevice_SelectedItemChanged.
private void firstBootDevice_SelectedItemChanged(Object sender, EventArgs args) {
EntityModel<BootSequence> entityModel = getFirstBootDevice().getSelectedItem();
BootSequence firstDevice = entityModel.getEntity();
EntityModel<BootSequence> prevItem = null;
List<EntityModel<BootSequence>> list = new ArrayList<>();
for (EntityModel<BootSequence> item : getFirstBootDevice().getItems()) {
if (item.getEntity() != firstDevice) {
list.add(item);
if (getSecondBootDevice().getSelectedItem() != null && item.getEntity() == getSecondBootDevice().getSelectedItem().getEntity()) {
prevItem = item;
}
}
}
EntityModel<BootSequence> tempVar = new EntityModel<>();
tempVar.setTitle(ConstantsManager.getInstance().getConstants().noneTitle());
EntityModel<BootSequence> noneOption = tempVar;
list.add(0, noneOption);
getSecondBootDevice().setItems(list);
if (prevItem != null) {
getSecondBootDevice().setSelectedItem(prevItem);
} else {
getSecondBootDevice().setSelectedItem(noneOption);
}
}
Aggregations