Search in sources :

Example 11 with UIConstants

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);
}
Also used : Time(java.sql.Time) TimeZoneType(org.ovirt.engine.core.common.TimeZoneType) Date(java.util.Date) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) DayOfWeek(org.ovirt.engine.core.compat.DayOfWeek) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) GlusterVolumeSnapshotSchedule(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule) ScheduleGlusterVolumeSnapshotParameters(org.ovirt.engine.core.common.action.gluster.ScheduleGlusterVolumeSnapshotParameters) GlusterSnapshotStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterSnapshotStatus) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) GlusterVolumeParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters) GlusterVolumeSnapshotEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity) GlusterVolumeSnapshotActionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeSnapshotActionParameters) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) CreateGlusterVolumeSnapshotParameters(org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeSnapshotParameters) GlusterVolumeSnapshotScheduleRecurrence(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotScheduleRecurrence) Linq(org.ovirt.engine.ui.uicommonweb.Linq) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus) List(java.util.List) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) Comparator(java.util.Comparator) Collections(java.util.Collections) EndDateOptions(org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterVolumeSnapshotModel.EndDateOptions) DayOfWeek(org.ovirt.engine.core.compat.DayOfWeek) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) ArrayList(java.util.ArrayList) Date(java.util.Date) GlusterVolumeSnapshotSchedule(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotSchedule) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants)

Example 12 with UIConstants

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);
}
Also used : ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 13 with UIConstants

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);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) ArrayList(java.util.ArrayList) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) HostMaintenanceConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.HostMaintenanceConfirmationModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants)

Example 14 with UIConstants

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());
}
Also used : UIConstants(org.ovirt.engine.ui.uicompat.UIConstants)

Example 15 with UIConstants

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());
}
Also used : UIConstants(org.ovirt.engine.ui.uicompat.UIConstants)

Aggregations

UIConstants (org.ovirt.engine.ui.uicompat.UIConstants)21 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11 ArrayList (java.util.ArrayList)10 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)7 List (java.util.List)6 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)6 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)4 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)4 ActionType (org.ovirt.engine.core.common.action.ActionType)4 GlusterVolumeParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters)4 GlusterStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus)4 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)4 Guid (org.ovirt.engine.core.compat.Guid)4 Frontend (org.ovirt.engine.ui.frontend.Frontend)4 Inject (com.google.inject.Inject)3 Arrays (java.util.Arrays)3 CreateGlusterVolumeParameters (org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeParameters)3 GlusterVolumeActionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeActionParameters)3 GlusterVolumeOptionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters)3 GlusterVolumeRebalanceParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRebalanceParameters)3