Gilad Chaplik has uploaded a new change for review. Change subject: webadmin: introduce disk profiles ......................................................................
webadmin: introduce disk profiles * Disk Profiles subtab under Storage main tab. Shows disk profiles attached to selected storage domain. * Create/update/remove disk profile dialog. Allows to invoke all disk profiles associated actions, from disk profiles subtab * Backend integration in GUI. For more information see http://www.ovirt.org/Features/blkio-support Change-Id: Ibe5cea3c563cf68efca0468749338a532894f709 Signed-off-by: Gilad Chaplik <gchap...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/DiskProfileBaseModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/DiskProfileListModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditDiskProfileModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NewDiskProfileModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/RemoveDiskProfileModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/ClientGinjectorExtension.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/StorageModule.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/profile/DiskProfilePopupPresenterWidget.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/storage/SubTabStorageDiskProfilePresenter.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/storage/SubTabStoragePermissionPresenter.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/DiskProfilePopupView.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/DiskProfilePopupView.ui.xml A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageDiskProfileView.java 20 files changed, 1,015 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/32/31832/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java index 22f1e02..7a2b7cd 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java @@ -486,7 +486,15 @@ remove_disk_snapshot("remove_disk_snapshot", HelpTagType.WEBADMIN, "Storage Tab > Snapshots Sub-Tab > Remove Disk Snapshot(s)"), //$NON-NLS-1$ //$NON-NLS-2$ - storage_qos("storage_qos", HelpTagType.UNKNOWN); //$NON-NLS-1$ + storage_qos("storage_qos", HelpTagType.UNKNOWN), //$NON-NLS-1$ + + disk_profiles("disk profiles", HelpTagType.UNKNOWN), //$NON-NLS-1$ + + new_disk_profile("new_disk_profile", HelpTagType.WEBADMIN, "Storage Tab > Disk Profiles sub-tab -> New Disk Profile dialog"), //$NON-NLS-1$ //$NON-NLS-2$ + + edit_disk_profile("edit_disk_profile", HelpTagType.WEBADMIN, "Storage Tab > Disk Profiles sub-tab -> Edit Disk Profile dialog"), //$NON-NLS-1$ //$NON-NLS-2$ + + remove_disk_profile("remove_disk_profile", HelpTagType.WEBADMIN, "Storage Tab > Disk Profiles sub-tab -> Remove Disk Profile dialog"); //$NON-NLS-1$ //$NON-NLS-2$ public final String name; diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java index 85f4e39..13cf08f 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java @@ -22,6 +22,7 @@ import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; import org.ovirt.engine.core.common.businessentities.network.Network; import org.ovirt.engine.core.common.businessentities.network.VnicProfile; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; import org.ovirt.engine.core.common.queries.GetPermissionsForObjectParameters; import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.core.compat.Guid; @@ -384,6 +385,9 @@ if (getEntity() instanceof VnicProfile){ return VdcObjectType.VnicProfile; } + if (getEntity() instanceof DiskProfile) { + return VdcObjectType.DiskProfile; + } return VdcObjectType.Unknown; } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/DiskProfileBaseModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/DiskProfileBaseModel.java new file mode 100644 index 0000000..fa9c738 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/DiskProfileBaseModel.java @@ -0,0 +1,217 @@ +package org.ovirt.engine.ui.uicommonweb.models.profiles; + +import java.util.ArrayList; +import java.util.List; + +import org.ovirt.engine.core.common.action.DiskProfileParameters; +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.action.VdcReturnValueBase; +import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; +import org.ovirt.engine.core.common.businessentities.qos.QosType; +import org.ovirt.engine.core.common.businessentities.qos.StorageQos; +import org.ovirt.engine.core.common.queries.QosQueryParameterBase; +import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; +import org.ovirt.engine.core.common.queries.VdcQueryType; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.ui.frontend.AsyncQuery; +import org.ovirt.engine.ui.frontend.Frontend; +import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.UICommand; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; +import org.ovirt.engine.ui.uicommonweb.models.ListModel; +import org.ovirt.engine.ui.uicommonweb.models.Model; +import org.ovirt.engine.ui.uicommonweb.validation.IValidation; +import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; +import org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation; +import org.ovirt.engine.ui.uicompat.ConstantsManager; +import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult; +import org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback; + +public abstract class DiskProfileBaseModel extends Model { + private final static StorageQos EMPTY_QOS; + + static { + EMPTY_QOS = new StorageQos(); + EMPTY_QOS.setName(ConstantsManager.getInstance().getConstants().unlimitedQoSTitle()); + EMPTY_QOS.setId(Guid.Empty); + } + + private EntityModel<String> name; + private EntityModel<String> description; + private final EntityModel sourceModel; + private ListModel<StorageDomain> storageDomains; + private ListModel<StorageQos> qos; + private DiskProfile diskProfile; + private final Guid defaultQosId; + private final VdcActionType vdcActionType; + + public EntityModel<String> getName() + { + return name; + } + + private void setName(EntityModel<String> value) + { + name = value; + } + + public EntityModel<String> getDescription() { + return description; + } + + public void setDescription(EntityModel<String> description) { + this.description = description; + } + + public ListModel<StorageDomain> getStorageDomains() { + return storageDomains; + } + + public void setStorageDomains(ListModel<StorageDomain> storageDomains) { + this.storageDomains = storageDomains; + } + + public void setDiskProfile(DiskProfile diskProfile) { + this.diskProfile = diskProfile; + } + + public DiskProfile getDiskProfile() { + return diskProfile; + } + + public ListModel<StorageQos> getQos() { + return qos; + } + + public void setQos(ListModel<StorageQos> qos) { + this.qos = qos; + } + + public DiskProfileBaseModel(EntityModel sourceModel, + Guid dcId, + Guid defaultQosId, + VdcActionType vdcActionType) { + this.sourceModel = sourceModel; + this.defaultQosId = defaultQosId; + this.vdcActionType = vdcActionType; + + setName(new EntityModel<String>()); + setDescription(new EntityModel<String>()); + setStorageDomains(new ListModel<StorageDomain>()); + setQos(new ListModel<StorageQos>()); + + initStorageQosList(dcId); + initCommands(); + } + + protected void initCommands() { + UICommand okCommand = new UICommand("OnSave", this); //$NON-NLS-1$ + okCommand.setTitle(ConstantsManager.getInstance().getConstants().ok()); + okCommand.setIsDefault(true); + getCommands().add(okCommand); + UICommand cancelCommand = new UICommand("Cancel", this); //$NON-NLS-1$ + cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel()); + cancelCommand.setIsCancel(true); + getCommands().add(cancelCommand); + } + + private void onSave() { + if (getProgress() != null) { + return; + } + + if (!validate()) { + return; + } + + // Save changes. + flush(); + + startProgress(null); + + Frontend.getInstance().runAction(vdcActionType, + new DiskProfileParameters(diskProfile, diskProfile.getId()), + new IFrontendActionAsyncCallback() { + @Override + public void executed(FrontendActionAsyncResult result) { + VdcReturnValueBase returnValue = result.getReturnValue(); + stopProgress(); + + if (returnValue != null && returnValue.getSucceeded()) { + cancel(); + } + } + }, + this); + } + + public void flush() { + if (diskProfile == null) { + diskProfile = new DiskProfile(); + } + diskProfile.setName(getName().getEntity()); + diskProfile.setDescription(getDescription().getEntity()); + StorageDomain storageDomain = getStorageDomains().getSelectedItem(); + diskProfile.setStorageDomainId(storageDomain != null ? storageDomain.getId() : null); + StorageQos storageQos = getQos().getSelectedItem(); + diskProfile.setQosId(storageQos != null + && storageQos.getId() != null + && !storageQos.getId().equals(Guid.Empty) + ? storageQos.getId() : null); + } + + private void cancel() { + sourceModel.setWindow(null); + } + + @Override + public void executeCommand(UICommand command) { + super.executeCommand(command); + + if ("OnSave".equals(command.getName())) { //$NON-NLS-1$ + onSave(); + } + else if ("Cancel".equals(command.getName())) {//$NON-NLS-1$ + cancel(); + } + } + + public void initStorageQosList(Guid dataCenterId) { + if (dataCenterId == null) { + return; + } + + Frontend.getInstance().runQuery(VdcQueryType.GetAllQosByStoragePoolIdAndType, + new QosQueryParameterBase(dataCenterId, QosType.STORAGE), + new AsyncQuery(new INewAsyncCallback() { + + @Override + public void onSuccess(Object model, Object returnValue) { + DiskProfileBaseModel.this.initQosList(returnValue == null ? new ArrayList<StorageQos>() + : (List<StorageQos>) ((VdcQueryReturnValue) returnValue).getReturnValue()); + } + + })); + } + + private void initQosList(List<StorageQos> qosList) { + qosList.add(0, EMPTY_QOS); + getQos().setItems(qosList); + if (defaultQosId != null) { + for (StorageQos storageQos : qosList) { + if (defaultQosId.equals(storageQos.getId())) { + getQos().setSelectedItem(storageQos); + break; + } + } + } + } + + public boolean validate() { + getName().validateEntity(new IValidation[] { new NotEmptyValidation(), new SpecialAsciiI18NOrNoneValidation() }); + + return getName().getIsValid(); + } + +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/DiskProfileListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/DiskProfileListModel.java new file mode 100644 index 0000000..80550b6 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/DiskProfileListModel.java @@ -0,0 +1,233 @@ +package org.ovirt.engine.ui.uicommonweb.models.profiles; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; +import org.ovirt.engine.core.common.businessentities.qos.QosType; +import org.ovirt.engine.core.common.businessentities.qos.StorageQos; +import org.ovirt.engine.core.common.queries.IdQueryParameters; +import org.ovirt.engine.core.common.queries.QosQueryParameterBase; +import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; +import org.ovirt.engine.core.common.queries.VdcQueryType; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.ui.frontend.AsyncQuery; +import org.ovirt.engine.ui.frontend.Frontend; +import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.UICommand; +import org.ovirt.engine.ui.uicommonweb.help.HelpTag; +import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel; +import org.ovirt.engine.ui.uicompat.ConstantsManager; +import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; + +public class DiskProfileListModel extends SearchableListModel +{ + private UICommand newCommand; + private UICommand editCommand; + private UICommand removeCommand; + private Map<Guid, StorageQos> qosMap; + + public DiskProfileListModel() { + setTitle(ConstantsManager.getInstance().getConstants().diskProfilesTitle()); + setHelpTag(HelpTag.disk_profiles); + setHashName("disk_profiles"); //$NON-NLS-1$ + + setNewCommand(new UICommand("New", this)); //$NON-NLS-1$ + setEditCommand(new UICommand("Edit", this)); //$NON-NLS-1$ + setRemoveCommand(new UICommand("Remove", this)); //$NON-NLS-1$ + + updateActionAvailability(); + } + + public void newProfile() { + if (getWindow() != null) { + return; + } + + NewDiskProfileModel model = new NewDiskProfileModel(this, + getEntity().getStoragePoolId()); + setWindow(model); + + initProfileStorageDomains(model); + } + + public void edit() { + if (getWindow() != null) { + return; + } + + EditDiskProfileModel model = + new EditDiskProfileModel(this, (DiskProfile) getSelectedItem(), getEntity().getStoragePoolId()); + setWindow(model); + + initProfileStorageDomains(model); + } + + public void remove() { + if (getWindow() != null) { + return; + } + + RemoveDiskProfileModel model = new RemoveDiskProfileModel(this, getSelectedItems()); + setWindow(model); + } + + private void initProfileStorageDomains(DiskProfileBaseModel model) { + model.getStorageDomains().setItems(Arrays.<StorageDomain> asList(getEntity())); + model.getStorageDomains().setSelectedItem(getEntity()); + model.getStorageDomains().setIsChangable(false); + } + + public void cancel() { + setWindow(null); + } + + @Override + protected void onEntityChanged() { + super.onEntityChanged(); + + if (getEntity() != null) { + getSearchCommand().execute(); + } + + updateActionAvailability(); + } + + @Override + public void search() { + if (getEntity() != null) { + super.search(); + } + } + + @Override + protected void syncSearch() { + if (getEntity() == null) { + return; + } + Guid dcId = getEntity().getStoragePoolId(); + if (dcId == null) { // not attached to data center + fetchDiskProfiles(); + } else { + Frontend.getInstance().runQuery(VdcQueryType.GetAllQosByStoragePoolIdAndType, + new QosQueryParameterBase(dcId, QosType.STORAGE), + new AsyncQuery(new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object returnValue) { + List<StorageQos> qosList = + (ArrayList<StorageQos>) ((VdcQueryReturnValue) returnValue).getReturnValue(); + qosMap = new HashMap<Guid, StorageQos>(); + if (qosList != null) { + for (StorageQos storageQos : qosList) { + qosMap.put(storageQos.getId(), storageQos); + } + } + fetchDiskProfiles(); + } + })); + } + } + + private void fetchDiskProfiles() { + Frontend.getInstance().runQuery(VdcQueryType.GetDiskProfilesByStorageDomainId, + new IdQueryParameters(DiskProfileListModel.this.getEntity().getId()), + new AsyncQuery(new INewAsyncCallback() { + + @Override + public void onSuccess(Object model1, Object returnValue1) { + DiskProfileListModel.this.setItems((List<DiskProfile>) ((VdcQueryReturnValue) returnValue1).getReturnValue()); + } + })); + } + + @Override + protected void entityPropertyChanged(Object sender, PropertyChangedEventArgs e) { + super.entityPropertyChanged(sender, e); + + if (e.propertyName.equals("name")) { //$NON-NLS-1$ + getSearchCommand().execute(); + } + } + + private void updateActionAvailability() { + StorageDomain storageDomain = getEntity(); + + getNewCommand().setIsExecutionAllowed(storageDomain != null); + getEditCommand().setIsExecutionAllowed((getSelectedItems() != null && getSelectedItems().size() == 1)); + getRemoveCommand().setIsExecutionAllowed((getSelectedItems() != null && getSelectedItems().size() > 0)); + } + + @Override + protected void onSelectedItemChanged() { + super.onSelectedItemChanged(); + updateActionAvailability(); + } + + @Override + protected void selectedItemsChanged() { + super.selectedItemsChanged(); + updateActionAvailability(); + } + + @Override + public void executeCommand(UICommand command) { + super.executeCommand(command); + + if (command == getNewCommand()) { + newProfile(); + } + else if (command == getEditCommand()) { + edit(); + } + else if (command == getRemoveCommand()) { + remove(); + } + else if ("Cancel".equals(command.getName())) { //$NON-NLS-1$ + cancel(); + } + } + + public UICommand getNewCommand() { + return newCommand; + } + + private void setNewCommand(UICommand value) { + newCommand = value; + } + + @Override + public UICommand getEditCommand() { + return editCommand; + } + + private void setEditCommand(UICommand value) { + editCommand = value; + } + + public UICommand getRemoveCommand() { + return removeCommand; + } + + private void setRemoveCommand(UICommand value) { + removeCommand = value; + } + + @Override + public StorageDomain getEntity() { + return (StorageDomain) ((super.getEntity() instanceof StorageDomain) ? super.getEntity() : null); + } + + public StorageQos getStorageQos(Guid qosId) { + return qosMap.get(qosId); + } + + @Override + protected String getListName() { + return "DiskProfileListModel"; //$NON-NLS-1$ + } + +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditDiskProfileModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditDiskProfileModel.java new file mode 100644 index 0000000..2b38c47 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditDiskProfileModel.java @@ -0,0 +1,33 @@ +package org.ovirt.engine.ui.uicommonweb.models.profiles; + +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.ui.uicommonweb.help.HelpTag; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; +import org.ovirt.engine.ui.uicompat.ConstantsManager; + +public class EditDiskProfileModel extends DiskProfileBaseModel { + + public EditDiskProfileModel(EntityModel sourceModel, + DiskProfile profile, + Guid dataCenterId) { + super(sourceModel, + dataCenterId, + profile.getQosId(), + VdcActionType.UpdateDiskProfile); + setTitle(ConstantsManager.getInstance().getConstants().diskProfileTitle()); + setHelpTag(HelpTag.edit_disk_profile); + setHashName("edit_disk_profile"); //$NON-NLS-1$ + + setDiskProfile(profile); + + getName().setEntity(profile.getName()); + getDescription().setEntity(profile.getDescription()); + } + + public EditDiskProfileModel(DiskProfile profile) { + this(null, profile, null); + } + +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NewDiskProfileModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NewDiskProfileModel.java new file mode 100644 index 0000000..e85d2e2 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NewDiskProfileModel.java @@ -0,0 +1,23 @@ +package org.ovirt.engine.ui.uicommonweb.models.profiles; + +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.ui.uicommonweb.help.HelpTag; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; +import org.ovirt.engine.ui.uicompat.ConstantsManager; + +public class NewDiskProfileModel extends DiskProfileBaseModel { + + public NewDiskProfileModel(EntityModel sourceModel, + Guid dcId) { + super(sourceModel, dcId, null, VdcActionType.AddDiskProfile); + setTitle(ConstantsManager.getInstance().getConstants().diskProfileTitle()); + setHelpTag(HelpTag.new_disk_profile); + setHashName("new_disk_profile"); //$NON-NLS-1$ + } + + public NewDiskProfileModel() { + this(null, null); + } + +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/RemoveDiskProfileModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/RemoveDiskProfileModel.java new file mode 100644 index 0000000..6c9c104 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/RemoveDiskProfileModel.java @@ -0,0 +1,95 @@ +package org.ovirt.engine.ui.uicommonweb.models.profiles; + +import java.util.ArrayList; +import java.util.List; + +import org.ovirt.engine.core.common.action.DiskProfileParameters; +import org.ovirt.engine.core.common.action.VdcActionParametersBase; +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; +import org.ovirt.engine.ui.frontend.Frontend; +import org.ovirt.engine.ui.uicommonweb.UICommand; +import org.ovirt.engine.ui.uicommonweb.help.HelpTag; +import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel; +import org.ovirt.engine.ui.uicommonweb.models.ListModel; +import org.ovirt.engine.ui.uicompat.ConstantsManager; +import org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult; +import org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback; + +public class RemoveDiskProfileModel extends ConfirmationModel { + + private final List<DiskProfile> profiles; + private final ListModel sourceListModel; + + public RemoveDiskProfileModel(ListModel sourceListModel, List<DiskProfile> profiles) { + setHelpTag(HelpTag.remove_disk_profile); + setTitle(ConstantsManager.getInstance().getConstants().removeDiskProfileTitle()); + setHashName("remove_disk_prfoile"); //$NON-NLS-1$ + + this.sourceListModel = sourceListModel; + this.profiles = profiles; + + ArrayList<String> items = new ArrayList<String>(); + for (DiskProfile profile : profiles) { + items.add(profile.getName()); + } + setItems(items); + + getCommands().add(new UICommand("OnRemove", this).setTitle(ConstantsManager.getInstance().getConstants().ok()) //$NON-NLS-1$ + .setIsDefault(true)); + getCommands().add(new UICommand("Cancel", this).setTitle(ConstantsManager.getInstance().getConstants().cancel()) //$NON-NLS-1$ + .setIsCancel(true)); + } + + private void onRemove() { + if (getProgress() != null) { + return; + } + + ArrayList<VdcActionParametersBase> vdcActionParametersBaseList = new ArrayList<VdcActionParametersBase>(); + for (DiskProfile profile : getProfiles()) { + VdcActionParametersBase parameters = getRemoveDiskProfileParams(profile); + vdcActionParametersBaseList.add(parameters); + + } + + startProgress(null); + + Frontend.getInstance().runMultipleAction(VdcActionType.RemoveDiskProfile, vdcActionParametersBaseList, + new IFrontendMultipleActionAsyncCallback() { + + @Override + public void executed(FrontendMultipleActionAsyncResult result) { + stopProgress(); + cancel(); + + } + }, null); + } + + protected VdcActionParametersBase getRemoveDiskProfileParams(DiskProfile profile) { + return new DiskProfileParameters(profile, profile.getId()); + } + + public List<DiskProfile> getProfiles() { + return profiles; + } + + private void cancel() { + sourceListModel.setWindow(null); + sourceListModel.setConfirmWindow(null); + } + + @Override + public void executeCommand(UICommand command) { + super.executeCommand(command); + + if ("Cancel".equals(command.getName())) {//$NON-NLS-1$ + cancel(); + } + else if ("OnRemove".equals(command.getName())) {//$NON-NLS-1$ + onRemove(); + } + } + +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java index f438aee..d7420ba 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageListModel.java @@ -50,6 +50,7 @@ import org.ovirt.engine.ui.uicommonweb.models.SystemTreeItemModel; import org.ovirt.engine.ui.uicommonweb.models.SystemTreeItemType; import org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel; +import org.ovirt.engine.ui.uicommonweb.models.profiles.DiskProfileListModel; import org.ovirt.engine.ui.uicommonweb.models.reports.ReportModel; import org.ovirt.engine.ui.uicommonweb.validation.IValidation; import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; @@ -197,6 +198,7 @@ private ListModel isoListModel; private ListModel diskListModel; private ListModel snapshotListModel; + private ListModel diskProfileListModel; public StorageDomainStatic storageDomain; public TaskContext context; @@ -249,6 +251,9 @@ snapshotListModel = new StorageSnapshotListModel(); snapshotListModel.setIsAvailable(false); + diskProfileListModel = new DiskProfileListModel(); + diskProfileListModel.setIsAvailable(false); + ObservableCollection<EntityModel> list = new ObservableCollection<EntityModel>(); list.add(generalModel); list.add(dcListModel); @@ -261,6 +266,7 @@ list.add(isoListModel); list.add(diskListModel); list.add(snapshotListModel); + list.add(diskProfileListModel); list.add(new StorageEventListModel()); list.add(new PermissionListModel()); setDetailModels(list); @@ -1082,6 +1088,7 @@ templateRegisterListModel.setIsAvailable(isRegisterSubtabsAvailable); diskListModel.setIsAvailable(isDataStorage); snapshotListModel.setIsAvailable(isDataStorage); + diskProfileListModel.setIsAvailable(isDataStorage); isoListModel.setIsAvailable(isImageStorage); } diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index 0083cb1..86acbbe 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -2353,5 +2353,14 @@ @DefaultStringValue("Custom") String customMtu(); + + @DefaultStringValue("Disk Profiles") + String diskProfilesTitle(); + + @DefaultStringValue("Disk Profile") + String diskProfileTitle(); + + @DefaultStringValue("Remove Disk Profile(s)") + String removeDiskProfileTitle(); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java index f7868e4..f06f44f 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java @@ -3299,7 +3299,7 @@ @DefaultStringValue("Name") String networkQoSName(); - @DefaultStringValue("Name") + @DefaultStringValue("QoS Name") String storageQosName(); @DefaultStringValue("In Average") @@ -3827,4 +3827,28 @@ @DefaultStringValue("Count") String iopsCountLabelQosPopup(); + + @DefaultStringValue("QoS") + String diskProfileQosLabel(); + + @DefaultStringValue("Disk Profiles") + String diskProfilesSubTabLabel(); + + @DefaultStringValue("Storage Domain") + String diskProfileStorageDomainLabel(); + + @DefaultStringValue("Name") + String diskProfileNameLabel(); + + @DefaultStringValue("Description") + String diskProfileDescriptionLabel(); + + @DefaultStringValue("New") + String newDiskProfile(); + + @DefaultStringValue("Edit") + String editDiskProfile(); + + @DefaultStringValue("Remove") + String removeDiskProfile(); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/ClientGinjectorExtension.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/ClientGinjectorExtension.java index 3bdf4c5..08e416b 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/ClientGinjectorExtension.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/ClientGinjectorExtension.java @@ -33,6 +33,7 @@ import org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface; import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; import org.ovirt.engine.core.common.businessentities.network.VnicProfileView; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; import org.ovirt.engine.core.common.businessentities.qos.StorageQos; import org.ovirt.engine.core.common.scheduling.AffinityGroup; import org.ovirt.engine.core.common.utils.PairQueryable; @@ -90,6 +91,7 @@ import org.ovirt.engine.ui.uicommonweb.models.pools.PoolGeneralModel; import org.ovirt.engine.ui.uicommonweb.models.pools.PoolListModel; import org.ovirt.engine.ui.uicommonweb.models.pools.PoolVmListModel; +import org.ovirt.engine.ui.uicommonweb.models.profiles.DiskProfileListModel; import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileListModel; import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileTemplateListModel; import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileVmListModel; @@ -245,6 +247,8 @@ SearchableDetailModelProvider<AuditLog, StorageListModel, StorageEventListModel> getSubTabStorageEventModelProvider(); + SearchableDetailModelProvider<DiskProfile, StorageListModel, DiskProfileListModel> getSubTabStorageDiskProfileModelProvider(); + // Cluster DetailModelProvider<ClusterListModel, ClusterGeneralModel> getSubTabClusterGeneralModelProvider(); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java index 4cff6d7..28317c5 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java @@ -67,6 +67,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.instancetypes.InstanceTypesPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.pool.PoolEditPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.pool.PoolNewPopupPresenterWidget; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.profile.DiskProfilePopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.profile.VnicProfilePopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.provider.ExternalSubnetPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.provider.ImportNetworksPopupPresenterWidget; @@ -199,6 +200,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.storage.StorageSubTabPanelPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.storage.SubTabStorageDataCenterPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.storage.SubTabStorageDiskPresenter; +import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.storage.SubTabStorageDiskProfilePresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.storage.SubTabStorageEventPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.storage.SubTabStorageGeneralPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.storage.SubTabStorageIsoPresenter; @@ -296,6 +298,7 @@ import org.ovirt.engine.ui.webadmin.section.main.view.popup.networkQoS.NetworkQoSPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.pool.PoolEditPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.pool.PoolNewPopupView; +import org.ovirt.engine.ui.webadmin.section.main.view.popup.profile.DiskProfilePopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.profile.VnicProfilePopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.provider.ExternalSubnetPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.provider.ImportNetworksPopupView; @@ -430,6 +433,7 @@ import org.ovirt.engine.ui.webadmin.section.main.view.tab.quota.SubTabQuotaVmView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.storage.StorageSubTabPanelView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.storage.SubTabStorageDataCenterView; +import org.ovirt.engine.ui.webadmin.section.main.view.tab.storage.SubTabStorageDiskProfileView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.storage.SubTabStorageDiskView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.storage.SubTabStorageEventView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.storage.SubTabStorageGeneralView; @@ -695,6 +699,10 @@ SubTabStorageEventPresenter.ViewDef.class, SubTabStorageEventView.class, SubTabStorageEventPresenter.ProxyDef.class); + bindPresenter(SubTabStorageDiskProfilePresenter.class, + SubTabStorageDiskProfilePresenter.ViewDef.class, + SubTabStorageDiskProfileView.class, + SubTabStorageDiskProfilePresenter.ProxyDef.class); // Cluster bindPresenter(ClusterSubTabPanelPresenter.class, @@ -1435,6 +1443,9 @@ bindPresenterWidget(VnicProfilePopupPresenterWidget.class, VnicProfilePopupPresenterWidget.ViewDef.class, VnicProfilePopupView.class); + bindPresenterWidget(DiskProfilePopupPresenterWidget.class, + DiskProfilePopupPresenterWidget.ViewDef.class, + DiskProfilePopupView.class); // External Subnet bindPresenterWidget(ExternalSubnetPopupPresenterWidget.class, diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/StorageModule.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/StorageModule.java index b17df7e..d5e9296 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/StorageModule.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/StorageModule.java @@ -7,6 +7,7 @@ import org.ovirt.engine.core.common.businessentities.StorageDomain; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VmTemplate; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; import org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget; import org.ovirt.engine.ui.common.presenter.ModelBoundPresenterWidget; import org.ovirt.engine.ui.common.presenter.popup.DefaultConfirmationPopupPresenterWidget; @@ -23,6 +24,7 @@ import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel; import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel; +import org.ovirt.engine.ui.uicommonweb.models.profiles.DiskProfileListModel; import org.ovirt.engine.ui.uicommonweb.models.storage.ImportCloneModel; import org.ovirt.engine.ui.uicommonweb.models.storage.StorageDataCenterListModel; import org.ovirt.engine.ui.uicommonweb.models.storage.StorageDiskListModel; @@ -40,6 +42,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.ReportPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.PermissionsPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.event.EventPopupPresenterWidget; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.profile.DiskProfilePopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.storage.FindMultiDcPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.storage.FindSingleDcPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.storage.ImportExportImagePopupPresenterWidget; @@ -414,6 +417,43 @@ }; } + @Provides + @Singleton + public SearchableDetailModelProvider<DiskProfile, StorageListModel, DiskProfileListModel> getStorageDiskProfileListProvider(EventBus eventBus, + Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, + final Provider<DiskProfilePopupPresenterWidget> newProfilePopupProvider, + final Provider<DiskProfilePopupPresenterWidget> editProfilePopupProvider, + final Provider<RemoveConfirmationPopupPresenterWidget> removeConfirmPopupProvider) { + return new SearchableDetailTabModelProvider<DiskProfile, StorageListModel, DiskProfileListModel>(eventBus, + defaultConfirmPopupProvider, + StorageListModel.class, + DiskProfileListModel.class) { + @Override + public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(DiskProfileListModel source, + UICommand lastExecutedCommand, + Model windowModel) { + if (lastExecutedCommand == getModel().getNewCommand()) { + return newProfilePopupProvider.get(); + } else if (lastExecutedCommand == getModel().getEditCommand()) { + return editProfilePopupProvider.get(); + } else { + return super.getModelPopup(source, lastExecutedCommand, windowModel); + } + } + + @Override + public AbstractModelBoundPopupPresenterWidget<? extends ConfirmationModel, ?> getConfirmModelPopup(DiskProfileListModel source, + UICommand lastExecutedCommand) { + if (lastExecutedCommand == getModel().getRemoveCommand()) { //$NON-NLS-1$ + return removeConfirmPopupProvider.get(); + } else { + return super.getConfirmModelPopup(source, lastExecutedCommand); + } + } + + }; + } + @Override protected void configure() { } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java index 03947c5..17af961 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/place/ApplicationPlaces.java @@ -113,6 +113,9 @@ public static final String storageSnapshotSubTabPlace = storageMainTabPlace + SUB_TAB_PREFIX + "snapshots"; //$NON-NLS-1$ + public static final String storageDiskProfileSubTabPlace = storageMainTabPlace + SUB_TAB_PREFIX + + "disk_profiles"; //$NON-NLS-1$ + public static final String storagePermissionSubTabPlace = storageMainTabPlace + SUB_TAB_PREFIX + "permissions"; //$NON-NLS-1$ diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/profile/DiskProfilePopupPresenterWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/profile/DiskProfilePopupPresenterWidget.java new file mode 100644 index 0000000..79c679f --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/profile/DiskProfilePopupPresenterWidget.java @@ -0,0 +1,19 @@ +package org.ovirt.engine.ui.webadmin.section.main.presenter.popup.profile; + +import org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget; +import org.ovirt.engine.ui.uicommonweb.models.profiles.DiskProfileBaseModel; + +import com.google.gwt.event.shared.EventBus; +import com.google.inject.Inject; + +public class DiskProfilePopupPresenterWidget extends AbstractModelBoundPopupPresenterWidget<DiskProfileBaseModel, DiskProfilePopupPresenterWidget.ViewDef> { + + public interface ViewDef extends AbstractModelBoundPopupPresenterWidget.ViewDef<DiskProfileBaseModel> { + } + + @Inject + public DiskProfilePopupPresenterWidget(EventBus eventBus, ViewDef view) { + super(eventBus, view); + } + +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/storage/SubTabStorageDiskProfilePresenter.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/storage/SubTabStorageDiskProfilePresenter.java new file mode 100644 index 0000000..7ba0c31 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/storage/SubTabStorageDiskProfilePresenter.java @@ -0,0 +1,61 @@ +package org.ovirt.engine.ui.webadmin.section.main.presenter.tab.storage; + +import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; +import org.ovirt.engine.ui.common.place.PlaceRequestFactory; +import org.ovirt.engine.ui.common.presenter.AbstractSubTabPresenter; +import org.ovirt.engine.ui.common.uicommon.model.SearchableDetailModelProvider; +import org.ovirt.engine.ui.common.widget.tab.ModelBoundTabData; +import org.ovirt.engine.ui.uicommonweb.models.profiles.DiskProfileListModel; +import org.ovirt.engine.ui.uicommonweb.models.storage.StorageListModel; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.place.ApplicationPlaces; +import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.StorageSelectionChangeEvent; + +import com.google.gwt.event.shared.EventBus; +import com.google.inject.Inject; +import com.gwtplatform.mvp.client.TabData; +import com.gwtplatform.mvp.client.annotations.NameToken; +import com.gwtplatform.mvp.client.annotations.ProxyCodeSplit; +import com.gwtplatform.mvp.client.annotations.ProxyEvent; +import com.gwtplatform.mvp.client.annotations.TabInfo; +import com.gwtplatform.mvp.client.proxy.PlaceManager; +import com.gwtplatform.mvp.client.proxy.PlaceRequest; +import com.gwtplatform.mvp.client.proxy.TabContentProxyPlace; + +public class SubTabStorageDiskProfilePresenter extends + AbstractSubTabPresenter<StorageDomain, StorageListModel, DiskProfileListModel, SubTabStorageDiskProfilePresenter.ViewDef, SubTabStorageDiskProfilePresenter.ProxyDef> { + + @ProxyCodeSplit + @NameToken(ApplicationPlaces.storageDiskProfileSubTabPlace) + public interface ProxyDef extends TabContentProxyPlace<SubTabStorageDiskProfilePresenter> { + } + + public interface ViewDef extends AbstractSubTabPresenter.ViewDef<StorageDomain> { + } + + @TabInfo(container = StorageSubTabPanelPresenter.class) + static TabData getTabData(ApplicationConstants applicationConstants, + SearchableDetailModelProvider<DiskProfile, StorageListModel, DiskProfileListModel> modelProvider) { + return new ModelBoundTabData(applicationConstants.diskProfilesSubTabLabel(), 9, + modelProvider); + } + + @Inject + public SubTabStorageDiskProfilePresenter(EventBus eventBus, ViewDef view, ProxyDef proxy, + PlaceManager placeManager, + SearchableDetailModelProvider<DiskProfile, StorageListModel, DiskProfileListModel> modelProvider) { + super(eventBus, view, proxy, placeManager, modelProvider, StorageSubTabPanelPresenter.TYPE_SetTabContent); + } + + @Override + protected PlaceRequest getMainTabRequest() { + return PlaceRequestFactory.get(ApplicationPlaces.storageMainTabPlace); + } + + @ProxyEvent + public void onStorageSelectionChange(StorageSelectionChangeEvent event) { + updateMainTabSelection(event.getSelectedItems()); + } + +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/storage/SubTabStoragePermissionPresenter.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/storage/SubTabStoragePermissionPresenter.java index 118c736..92252ed 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/storage/SubTabStoragePermissionPresenter.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/tab/storage/SubTabStoragePermissionPresenter.java @@ -36,7 +36,7 @@ @TabInfo(container = StorageSubTabPanelPresenter.class) static TabData getTabData(ApplicationConstants applicationConstants, SearchableDetailModelProvider<Permissions, StorageListModel, PermissionListModel> modelProvider) { - return new ModelBoundTabData(applicationConstants.storagePermissionSubTabLabel(), 9, modelProvider); + return new ModelBoundTabData(applicationConstants.storagePermissionSubTabLabel(), 10, modelProvider); } @Inject diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/DiskProfilePopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/DiskProfilePopupView.java new file mode 100644 index 0000000..bda370a --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/DiskProfilePopupView.java @@ -0,0 +1,110 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.popup.profile; + +import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.qos.StorageQos; +import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; +import org.ovirt.engine.ui.common.idhandler.WithElementId; +import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView; +import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel; +import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; +import org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor; +import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer; +import org.ovirt.engine.ui.uicommonweb.models.profiles.DiskProfileBaseModel; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.ApplicationResources; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.profile.DiskProfilePopupPresenterWidget; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.editor.client.SimpleBeanEditorDriver; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.inject.Inject; + +public class DiskProfilePopupView extends AbstractModelBoundPopupView<DiskProfileBaseModel> implements DiskProfilePopupPresenterWidget.ViewDef { + + interface Driver extends SimpleBeanEditorDriver<DiskProfileBaseModel, DiskProfilePopupView> { + } + + interface ViewUiBinder extends UiBinder<SimpleDialogPanel, DiskProfilePopupView> { + ViewUiBinder uiBinder = GWT.create(ViewUiBinder.class); + } + + interface ViewIdHandler extends ElementIdHandler<DiskProfilePopupView> { + ViewIdHandler idHandler = GWT.create(ViewIdHandler.class); + } + + @UiField + @Path("name.entity") + @WithElementId("name") + StringEntityModelTextBoxEditor nameEditor; + + @UiField + @Path("description.entity") + @WithElementId("description") + StringEntityModelTextBoxEditor descriptionEditor; + + @UiField(provided = true) + @Path(value = "qos.selectedItem") + @WithElementId("qos") + public ListModelListBoxEditor<StorageQos> qosEditor; + + @UiField(provided = true) + @Path("storageDomains.selectedItem") + ListModelListBoxEditor<StorageDomain> storageDomainEditor; + + private final Driver driver = GWT.create(Driver.class); + + @Inject + public DiskProfilePopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants) { + super(eventBus, resources); + storageDomainEditor = new ListModelListBoxEditor<StorageDomain>(new NullSafeRenderer<StorageDomain>() { + @Override + public String renderNullSafe(StorageDomain storageDomain) { + return storageDomain.getName(); + } + }); + qosEditor = new ListModelListBoxEditor<StorageQos>(new NullSafeRenderer<StorageQos>() { + @Override + public String renderNullSafe(StorageQos storageQos) { + return storageQos.getName(); + } + }); + initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); + localize(constants); + ViewIdHandler.idHandler.generateAndSetIds(this); + driver.initialize(this); + } + + private void localize(ApplicationConstants constants) { + nameEditor.setLabel(constants.diskProfileNameLabel()); + descriptionEditor.setLabel(constants.diskProfileDescriptionLabel()); + storageDomainEditor.setLabel(constants.diskProfileStorageDomainLabel()); + qosEditor.setLabel(constants.diskProfileQosLabel()); + } + + @Override + public void focusInput() { + nameEditor.setFocus(true); + } + + @Override + public void edit(DiskProfileBaseModel object) { + driver.edit(object); + } + + @Override + public DiskProfileBaseModel flush() { + return driver.flush(); + } + + @Override + public int setTabIndexes(int nextTabIndex) { + storageDomainEditor.setTabIndex(nextTabIndex++); + nameEditor.setTabIndex(nextTabIndex++); + descriptionEditor.setTabIndex(nextTabIndex++); + qosEditor.setTabIndex(nextTabIndex++); + + return nextTabIndex; + } +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/DiskProfilePopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/DiskProfilePopupView.ui.xml new file mode 100644 index 0000000..f84b8d9 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/profile/DiskProfilePopupView.ui.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> +<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" + xmlns:g="urn:import:com.google.gwt.user.client.ui" + xmlns:d="urn:import:org.ovirt.engine.ui.common.widget.dialog" + xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor" + xmlns:ge="urn:import:org.ovirt.engine.ui.common.widget.editor.generic" > + + <ui:with field='constants' type='org.ovirt.engine.ui.webadmin.ApplicationConstants' /> + + <d:SimpleDialogPanel width="470px" height="220px"> + <d:content> + <g:FlowPanel> + <e:ListModelListBoxEditor ui:field="storageDomainEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="nameEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="descriptionEditor" /> + <e:ListModelListBoxEditor ui:field="qosEditor"/> + </g:FlowPanel> + </d:content> + </d:SimpleDialogPanel> + +</ui:UiBinder> + diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageDiskProfileView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageDiskProfileView.java new file mode 100644 index 0000000..77b4baf --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/storage/SubTabStorageDiskProfileView.java @@ -0,0 +1,88 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.tab.storage; + +import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.profiles.DiskProfile; +import org.ovirt.engine.core.common.businessentities.qos.StorageQos; +import org.ovirt.engine.ui.common.uicommon.model.SearchableDetailModelProvider; +import org.ovirt.engine.ui.common.widget.table.column.TextColumnWithTooltip; +import org.ovirt.engine.ui.uicommonweb.UICommand; +import org.ovirt.engine.ui.uicommonweb.models.profiles.DiskProfileListModel; +import org.ovirt.engine.ui.uicommonweb.models.storage.StorageListModel; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.storage.SubTabStorageDiskProfilePresenter; +import org.ovirt.engine.ui.webadmin.section.main.view.AbstractSubTabTableView; +import org.ovirt.engine.ui.webadmin.widget.action.WebAdminButtonDefinition; + +import com.google.inject.Inject; + +public class SubTabStorageDiskProfileView extends AbstractSubTabTableView<StorageDomain, DiskProfile, StorageListModel, DiskProfileListModel> + implements SubTabStorageDiskProfilePresenter.ViewDef { + + @Inject + public SubTabStorageDiskProfileView(SearchableDetailModelProvider<DiskProfile, StorageListModel, DiskProfileListModel> modelProvider, + ApplicationConstants constants) { + super(modelProvider); + initTable(constants); + initWidget(getTable()); + } + + void initTable(final ApplicationConstants constants) { + getTable().enableColumnResizing(); + + TextColumnWithTooltip<DiskProfile> nameColumn = + new TextColumnWithTooltip<DiskProfile>() { + @Override + public String getValue(DiskProfile object) { + return object.getName(); + } + }; + nameColumn.makeSortable(); + getTable().addColumn(nameColumn, constants.diskProfileNameLabel(), "200px"); //$NON-NLS-1$ + + TextColumnWithTooltip<DiskProfile> descriptionColumn = + new TextColumnWithTooltip<DiskProfile>() { + @Override + public String getValue(DiskProfile object) { + return object.getDescription(); + } + }; + descriptionColumn.makeSortable(); + getTable().addColumn(descriptionColumn, constants.diskProfileDescriptionLabel(), "200px"); //$NON-NLS-1$ + + TextColumnWithTooltip<DiskProfile> qosColumn = new TextColumnWithTooltip<DiskProfile>() { + @Override + public String getValue(DiskProfile object) { + String name = constants.UnlimitedStorageQos(); + if (object.getQosId() != null) { + StorageQos storageQos = getDetailModel().getStorageQos(object.getQosId()); + if (storageQos != null) { + name = storageQos.getName(); + } + } + return name; + } + }; + qosColumn.makeSortable(); + getTable().addColumn(qosColumn, constants.storageQosName(), "200px"); //$NON-NLS-1$ + + getTable().addActionButton(new WebAdminButtonDefinition<DiskProfile>(constants.newDiskProfile()) { + @Override + protected UICommand resolveCommand() { + return getDetailModel().getNewCommand(); + } + }); + getTable().addActionButton(new WebAdminButtonDefinition<DiskProfile>(constants.editDiskProfile()) { + @Override + protected UICommand resolveCommand() { + return getDetailModel().getEditCommand(); + } + }); + getTable().addActionButton(new WebAdminButtonDefinition<DiskProfile>(constants.removeDiskProfile()) { + @Override + protected UICommand resolveCommand() { + return getDetailModel().getRemoveCommand(); + } + }); + } + +} -- To view, visit http://gerrit.ovirt.org/31832 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibe5cea3c563cf68efca0468749338a532894f709 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches