use of org.ovirt.engine.ui.uicompat.UIConstants in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotListModel method editSnapshotSchedule.
public void editSnapshotSchedule() {
if (getWindow() != null) {
return;
}
final UIConstants constants = ConstantsManager.getInstance().getConstants();
final GlusterVolumeSnapshotModel snapshotModel = new GlusterVolumeSnapshotModel(true, true);
snapshotModel.setHelpTag(HelpTag.edit_volume_snapshot_schedule);
// $NON-NLS-1$
snapshotModel.setHashName("edit_volume_snapshot_schedule");
snapshotModel.setTitle(constants.editVolumeSnapshotScheduleTitle());
setWindow(snapshotModel);
snapshotModel.startProgress();
AsyncDataProvider.getInstance().getVolumeSnapshotSchedule(new AsyncQuery<>(new AsyncCallback<GlusterVolumeSnapshotSchedule>() {
@Override
public void onSuccess(final GlusterVolumeSnapshotSchedule schedule) {
if (schedule == null) {
snapshotModel.setMessage(ConstantsManager.getInstance().getConstants().unableToFetchVolumeSnapshotSchedule());
return;
}
snapshotModel.getSnapshotName().setEntity(schedule.getSnapshotNamePrefix());
snapshotModel.getDescription().setEntity(schedule.getSnapshotDescription());
snapshotModel.getRecurrence().setSelectedItem(schedule.getRecurrence());
if (schedule.getEndByDate() == null) {
snapshotModel.getEndByOptions().setSelectedItem(EndDateOptions.NoEndDate);
} else {
snapshotModel.getEndByOptions().setSelectedItem(EndDateOptions.HasEndDate);
snapshotModel.getEndDate().setEntity(schedule.getEndByDate());
}
if (schedule.getRecurrence() != GlusterVolumeSnapshotScheduleRecurrence.UNKNOWN) {
Map<String, String> timeZones = TimeZoneType.GENERAL_TIMEZONE.getTimeZoneList();
snapshotModel.getTimeZones().setSelectedItem(Linq.firstOrNull(timeZones.entrySet(), item -> item.getKey().startsWith(schedule.getTimeZone())));
}
switch(schedule.getRecurrence()) {
case INTERVAL:
snapshotModel.getInterval().setSelectedItem(String.valueOf(schedule.getInterval()));
break;
case HOURLY:
break;
case DAILY:
snapshotModel.getExecutionTime().setEntity(getExecutionTimeValue(schedule));
break;
case WEEKLY:
List<DayOfWeek> daysList = new ArrayList<>();
for (String day : schedule.getDays().split(",")) {
// $NON-NLS-1$
daysList.add(getDayOfWeek(day));
}
snapshotModel.getDaysOfTheWeek().setSelectedItem(daysList);
snapshotModel.getExecutionTime().setEntity(getExecutionTimeValue(schedule));
break;
case MONTHLY:
snapshotModel.getDaysOfMonth().setSelectedItem(schedule.getDays());
snapshotModel.getExecutionTime().setEntity(getExecutionTimeValue(schedule));
break;
}
snapshotModel.getStartAt().setEntity(schedule.getStartDate());
snapshotModel.stopProgress();
}
private DayOfWeek getDayOfWeek(String day) {
switch(day) {
case // $NON-NLS-1$
"Sun":
return DayOfWeek.Sunday;
case // $NON-NLS-1$
"Mon":
return DayOfWeek.Monday;
case // $NON-NLS-1$
"Tue":
return DayOfWeek.Tuesday;
case // $NON-NLS-1$
"Wed":
return DayOfWeek.Wednesday;
case // $NON-NLS-1$
"Thu":
return DayOfWeek.Thursday;
case // $NON-NLS-1$
"Fri":
return DayOfWeek.Friday;
case // $NON-NLS-1$
"Sat":
return DayOfWeek.Saturday;
default:
return null;
}
}
private Date getExecutionTimeValue(GlusterVolumeSnapshotSchedule schedule) {
Date dt = new Date();
dt.setHours(schedule.getExecutionTime().getHours());
dt.setMinutes(schedule.getExecutionTime().getMinutes());
return dt;
}
}), getEntity().getId());
snapshotModel.getClusterName().setEntity(getEntity().getClusterName());
snapshotModel.getVolumeName().setEntity(getEntity().getName());
// $NON-NLS-1$
UICommand okCommand = UICommand.createDefaultOkUiCommand("onEditSnapshotSchedule", this);
snapshotModel.getCommands().add(okCommand);
// $NON-NLS-1$
UICommand cancelCommand = UICommand.createCancelUiCommand("cancel", this);
snapshotModel.getCommands().add(cancelCommand);
}
use of org.ovirt.engine.ui.uicompat.UIConstants in project ovirt-engine by oVirt.
the class SparsifyDiskModel method initialize.
public void initialize(VM vm, List<Disk> disksToSparsify, ICommandTarget target) {
this.disksToSparsify = disksToSparsify;
UIConstants uiConstants = ConstantsManager.getInstance().getConstants();
setTitle(uiConstants.sparsifyDisksTitle());
setMessage(uiConstants.sparsifyConfirmationPopupMessage());
setHelpTag(HelpTag.sparsify_disk);
// $NON-NLS-1$
setHashName("sparsify_disk");
List<DiskModel> items = new ArrayList<>();
for (Disk disk : disksToSparsify) {
DiskModel diskModel = new DiskModel();
diskModel.setDisk(disk);
diskModel.setVm(vm);
items.add(diskModel);
}
setItems(items);
UICommand okCommand = UICommand.createDefaultOkUiCommand(ON_SPARSIFY, target);
getCommands().add(okCommand);
cancelCommand = UICommand.createCancelUiCommand(CANCEL_SPARSIFY, target);
getCommands().add(cancelCommand);
}
use of org.ovirt.engine.ui.uicompat.UIConstants in project ovirt-engine by oVirt.
the class HostListModel method restart.
public void restart(String uiCommand) {
final UIConstants constants = ConstantsManager.getInstance().getConstants();
final UIMessages messages = ConstantsManager.getInstance().getMessages();
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(constants.restartHostsTitle());
model.setHelpTag(HelpTag.restart_host);
// $NON-NLS-1$
model.setHashName("restart_host");
model.setMessage(constants.areYouSureYouWantToRestartTheFollowingHostsMsg());
ArrayList<String> items = new ArrayList<>();
for (Object item : getSelectedItems()) {
VDS vds = (VDS) item;
int runningVms = vds.getVmCount();
if (runningVms > 0) {
items.add(messages.hostNumberOfRunningVms(vds.getName(), runningVms));
} else {
items.add(vds.getName());
}
}
model.setItems(items);
// $NON-NLS-1$
UICommand tempVar = new UICommand(uiCommand, this);
tempVar.setTitle(constants.ok());
tempVar.setIsDefault(true);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = new UICommand("Cancel", this);
tempVar2.setTitle(constants.cancel());
tempVar2.setIsCancel(true);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.ui.uicompat.UIConstants in project ovirt-engine by oVirt.
the class EditHostModel method setAllowChangeHostPlacementPropertiesWhenNotInMaintenance.
@Override
protected void setAllowChangeHostPlacementPropertiesWhenNotInMaintenance() {
UIConstants constants = ConstantsManager.getInstance().getConstants();
getDataCenter().setIsChangeable(false);
getDataCenter().setChangeProhibitionReason(constants.dcCanOnlyBeChangedWhenHostInMaintMode());
getCluster().setIsChangeable(false);
getCluster().setChangeProhibitionReason(constants.clusterCanOnlyBeChangedWhenHostInMaintMode());
}
use of org.ovirt.engine.ui.uicompat.UIConstants in project ovirt-engine by oVirt.
the class VmListModel method shutdown.
private void shutdown() {
UIConstants constants = ConstantsManager.getInstance().getConstants();
powerAction(SHUTDOWN, constants.shutdownVirtualMachinesTitle(), constants.areYouSureYouWantToShutDownTheFollowingVirtualMachinesMsg());
}
Aggregations