Search in sources :

Example 21 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class StorageDataCenterListModel method postAttachInit.

public void postAttachInit(ArrayList<EntityModel> datacenters) {
    ListModel<EntityModel> model = new ListModel<>();
    model.setHelpTag(HelpTag.attach_storage);
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().attachToDataCenterTitle());
    if (getEntity() != null) {
        switch(getEntity().getStorageDomainType()) {
            case ISO:
                setHelpTag(HelpTag.attach_iso_library);
                break;
            case Data:
                setHelpTag(HelpTag.attach_storage);
                break;
            case ImportExport:
                setHelpTag(HelpTag.attach_export_domain);
                break;
        }
    }
    if (datacenters.isEmpty()) {
        model.setMessage(ConstantsManager.getInstance().getConstants().thereAreNoDataCenterStorageDomainAttachedMsg());
        // $NON-NLS-1$
        UICommand tempVar = new UICommand("Cancel", this);
        tempVar.setTitle(ConstantsManager.getInstance().getConstants().close());
        tempVar.setIsDefault(true);
        tempVar.setIsCancel(true);
        model.getCommands().add(tempVar);
    } else {
        model.setItems(datacenters);
        List<EntityModel> initialSelection = new ArrayList<>();
        initialSelection.add(datacenters.get(0));
        model.setSelectedItems(initialSelection);
        // $NON-NLS-1$
        UICommand tempVar2 = UICommand.createDefaultOkUiCommand("OnAttach", this);
        model.getCommands().add(tempVar2);
        // $NON-NLS-1$
        UICommand tempVar3 = UICommand.createCancelUiCommand("Cancel", this);
        model.getCommands().add(tempVar3);
    }
}
Also used : SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand)

Example 22 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class StorageDataCenterListModel method addToAttachCandidateDatacenters.

public void addToAttachCandidateDatacenters(StoragePool dataCenter, boolean addDatacenter) {
    // Add a new datacenter EntityModel
    EntityModel dcEntityModel = new EntityModel();
    if (addDatacenter) {
        dcEntityModel.setEntity(dataCenter);
    }
    getattachCandidateDatacenters().add(dcEntityModel);
    // If not finished going through the datacenters list - return
    if (getattachCandidateDatacenters().size() != getAvailableDataCenters().size()) {
        return;
    }
    // Filter datacenters list
    ArrayList<EntityModel> datacenters = new ArrayList<>();
    for (EntityModel datacenter : getattachCandidateDatacenters()) {
        if (datacenter.getEntity() != null) {
            datacenters.add(datacenter);
        }
    }
    postAttachInit(datacenters);
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList)

Example 23 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class AttachDiskModel method store.

@Override
public void store(IFrontendActionAsyncCallback callback) {
    if (getProgress() != null || !validate()) {
        return;
    }
    ArrayList<ActionType> actionTypes = new ArrayList<>();
    ArrayList<ActionParametersBase> paramerterList = new ArrayList<>();
    ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
    IFrontendActionAsyncCallback onFinishCallback = callback != null ? callback : result -> {
        NewDiskModel diskModel = (NewDiskModel) result.getState();
        diskModel.stopProgress();
        diskModel.cancel();
    };
    List<EntityModel<DiskModel>> disksToAttach = getSelectedDisks();
    for (int i = 0; i < disksToAttach.size(); i++) {
        DiskModel disk = disksToAttach.get(i).getEntity();
        /*
            IDE disks can be activated only when the VM is down.
            Other disks can be hot plugged.
             */
        boolean activate = false;
        if (getIsPlugged().getEntity()) {
            activate = disk.getDiskInterface().getSelectedItem() == DiskInterface.IDE ? getVm().getStatus() == VMStatus.Down : true;
        }
        DiskVmElement dve = new DiskVmElement(disk.getDisk().getId(), getVm().getId());
        dve.setBoot(disk.getIsBootable().getEntity());
        dve.setDiskInterface(disk.getDiskInterface().getSelectedItem());
        dve.setReadOnly(disk.isReadOnly());
        AttachDetachVmDiskParameters parameters = new AttachDetachVmDiskParameters(dve, activate);
        actionTypes.add(ActionType.AttachDiskToVm);
        paramerterList.add(parameters);
        callbacks.add(i == disksToAttach.size() - 1 ? onFinishCallback : null);
    }
    startProgress();
    Frontend.getInstance().runMultipleActions(actionTypes, paramerterList, callbacks, null, this);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) AttachDetachVmDiskParameters(org.ovirt.engine.core.common.action.AttachDetachVmDiskParameters) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement)

Example 24 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel 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;
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) BootSequence(org.ovirt.engine.core.common.businessentities.BootSequence)

Example 25 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class UserListModel method onAdd.

public void onAdd(final boolean closeWindow) {
    AdElementListModel model = (AdElementListModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (model.getSelectedItems() == null) {
        cancel();
        return;
    }
    List<EntityModel<DbUser>> selectedItems = new ArrayList<>();
    for (EntityModel<DbUser> dbUserEntity : model.getItems()) {
        if (dbUserEntity.getIsSelected()) {
            selectedItems.add(dbUserEntity);
        }
    }
    List<ActionType> actionsList = new ArrayList<>(selectedItems.size());
    List<ActionParametersBase> parametersList = new ArrayList<>(selectedItems.size());
    ActionParametersBase parameters = null;
    for (EntityModel<DbUser> item : selectedItems) {
        if (item.getEntity().isGroup()) {
            actionsList.add(ActionType.AddGroup);
            DbGroup grp = new DbGroup();
            grp.setExternalId(item.getEntity().getExternalId());
            grp.setName(item.getEntity().getFirstName());
            grp.setNamespace(item.getEntity().getNamespace());
            grp.setId(item.getEntity().getId());
            grp.setDomain(item.getEntity().getDomain());
            parameters = new AddGroupParameters(grp);
        } else {
            actionsList.add(ActionType.AddUser);
            parameters = new AddUserParameters(item.getEntity());
        }
        parametersList.add(parameters);
    }
    model.startProgress();
    IFrontendActionAsyncCallback lastCallback = result -> {
        AdElementListModel localModel = (AdElementListModel) result.getState();
        localModel.stopProgress();
        // Refresh user list.
        syncSearch();
        if (closeWindow) {
            cancel();
        }
    };
    Collection<EntityModel<DbUser>> currentItems = model.getItems();
    List<IFrontendActionAsyncCallback> callbacksList = new ArrayList<>(selectedItems.size());
    for (EntityModel<DbUser> user : selectedItems) {
        callbacksList.add(nopCallback);
        currentItems.remove(user);
    }
    callbacksList.remove(callbacksList.size() - 1);
    callbacksList.add(lastCallback);
    // Refresh display
    model.setItems(null);
    model.setItems(currentItems);
    Frontend.getInstance().runMultipleActions(actionsList, parametersList, callbacksList, lastCallback, model);
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) QueryType(org.ovirt.engine.core.common.queries.QueryType) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) Guid(org.ovirt.engine.core.compat.Guid) AdSearchType(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel.AdSearchType) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) UserOrGroup(org.ovirt.engine.core.searchbackend.VdcUserConditionFieldAutoCompleter.UserOrGroup) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) IdParameters(org.ovirt.engine.core.common.action.IdParameters) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) ActionType(org.ovirt.engine.core.common.action.ActionType) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) AddGroupParameters(org.ovirt.engine.core.common.action.AddGroupParameters) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Aggregations

EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)105 ArrayList (java.util.ArrayList)56 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)27 List (java.util.List)26 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)23 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)22 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)22 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)22 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)20 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)19 ActionType (org.ovirt.engine.core.common.action.ActionType)18 Frontend (org.ovirt.engine.ui.frontend.Frontend)18 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)17 Guid (org.ovirt.engine.core.compat.Guid)17 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 QueryType (org.ovirt.engine.core.common.queries.QueryType)16 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)13 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)13 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)13